My 500 Internal server error puzzle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    My 500 Internal server error puzzle

    PHP Code:
    <?php defined'COREPATH' ) or
    die( 
    'Direct access to this file is
    forbidden.' 
    );
    /// These values should be left
    for ScriptID
    define
    (
    'IC_VERSION' '1.0' );
    define'IC_CODE_NAME' 'app
    debuti' 
    );
    /**
    * IoniCore class
    *
    * Main class that handles most
    of IoniCore's processes
    *
    * @package IoniCore PHP
    * @author Neo Ighodaro
    * @copyright CreativityKills
    * @license http://removed
    */
    class ionicore{
    protected static 
    $cache;
    protected static 
    $lang_dir;
    protected static 
    $force_locale;
    protected static 
    $config_dir;
    /**
    * Class constructor
    *
    * @return void
    */
    private function __construct(){
    if( ! 
    is_array($this-
    cache))$
    this->cache = array();
    $this->lang_dir =
    'lang' ;
    $this->force_locale false;
    $this->config_dir =
    'config' ;
    }

    public static function
    autoloader($class){
    /// capitalize the first letter in
    classname
    $class 
    ucfirst($class);
    /// set classes array in cache
    self::write_cache(
    'classes' );
    /// if class already exists
    if(class_exists($class)){
    self::write_cache(
    'classes' , $
    class, array());
    return;
    }
    /// get path to file
    $file COREPATH.
    'classes/' .$
    class. 
    '.php' ;
    /// Find file in directory
    if(file_exists($file)){
    include_once(
    $file);
    self::write_cache(
    'classes' , $
    class, array( 
    'file' => $file));
    return;
    }
    }

    public static function 
    load($
    key){
    /// prepare the key
    if(strpos(
    '.' ,$key) === TRUE){
    list(
    $dir,$file) = explode'.' trim
    ($key), 2);
    $_dir $dir;
    }else{
    throw new 
    ionicore_Exception
    (sprintf(self::lang
    (
    'syserror.invalid_key' ),$key));
    return 
    FALSE;
    }
    die(
    'ha' );
    /// Set load array in cache
    self::write_cache(
    'load' );
    /// check if key is cached
    if(array_key_exists($keyself::$
    cache[
    'load' ]))return TRUE;
    /// get the file path
    $dir self::$lang_dir;
    $locale = (self::$force_locale) ?
    self::$force_locale self::config
    (
    'core.default_locale' );
    $loadfile $dir'/' .$locale'/' .$
    file'.php' ;
    }else{
    $loadfile $dir.
    '/' .$file'.php' ;
    }
    /// Include the file
    if( ! file_exists($loadfile)){
    throw new 
    ionicore_Exception
    (sprintf(ionicore::lang
    (
    'syserror.file_not_found' ),$
    loadfile));
    return 
    FALSE;
    }else{
    /// include file and cache data
    if(include_once($loadfile)){
    $file_var = (isset($$_dir)) ? $$_
    dir 
    : array();
    $cache = array($$_dir => $file_
    var);
    ionicore::write_cache(
    'load' , $
    key$cache);
    return 
    TRUE;
    }
    }
    /// Script will probably never
    get here
    throw new ionicore_Exception
    (self::lang(
    'syserror.unknown_
    error' 
    ));
    return 
    FALSE;
    }

    /**
    * Loads a value or values
    (array) from a config file
    *
    * @param string file_
    name.array_key
    * @return string/array
    */
    public static function config($
    key){
    /// Prepare key for use
    if(strpos(
    '.' ,$key) === TRUE){
    list(
    $file,$val) = explode'.' trim
    ($key), 2);
    }else{
    /// Load entire file array
    $file $key;
    $val false;
    }
    /// Load config file
    $loadkey self::$config_dir.'.'.$
    file;
    try{
    self::load($loadkey);
    }catch(
    ionicore_Exception $e){
    echo 
    $e->errorMessage();
    }
    /// check if load updated cache
    $cache self::$cache[
    'load' ][$
    loadkey][self::$config_dir];
    if(isset(
    $cache) AND ! empty($
    cache)){
    return (
    $val) ? $cache[$val] : $
    cache;
    }else{
    return 
    null;
    }
    }

    public static function 
    lang($key,
    $force_locale false){
    /// force another locale
    if($force_locale)self::$force_
    locale 
    $force_locale;
    /// Prepare key for use
    if(strpos(
    '.' ,$key) === TRUE){
    list(
    $file,$val) = explode'.' trim
    ($key), 2);
    }else{
    /// Load entire file array
    $file $key;
    $val false;
    }
    /// Load lang file
    $loadkey =
    'lang.' .$file;
    try{
    self::load($loadkey);
    }catch(
    ionicore_Exception $e){
    echo 
    $e->errorMessage();
    }
    /// check if load updated cache
    $cache self::$cache'load' ][$
    loadkey][ 'lang' ];
    if(isset(
    $cache) AND ! empty($
    cache)){
    return (
    $val) ? $cache[$val] :
    (array) 
    $cache;
    }else{
    return 
    null;
    }
    }
    /**
    * Writes value to class cache
    *
    * @param string
    * @param string
    * @param array
    * @return boolean
    */
    private static function write_
    cache
    ($key$subkey=null, $
    val=array()){
    try{
    if( ! 
    $key || ! is_array($val))
    throw new 
    ionicore_Exception
    (self::lang(
    'syserror.invalid_
    param' 
    ));
    return 
    false;
    }catch(
    ionicore_Exception $e){
    echo 
    $e->errorMessage();
    }
    if( ! 
    array_key_exists($key,self::
    $cache)){
    $key = array($key => array());
    self::$cache array_merge($
    key,self::$cache);
    }
    if(
    $subkey AND ! array_key_
    exists
    ($subkey,self::$cache[$
    key])){
    $key = array($subkey => $val);
    self::$cache[$key] = array_
    merge
    ($subkey,self::$cache[$
    key]);
    }
    return 
    true;
    }
    /**
    * Resets class cache
    *
    * @return void
    */
    public static function reset_
    cache
    (){
    self::$cache = array();
    }
    /**
    * Generates a backtrace for
    debugging
    *
    * @return string
    */
    public static function backtrace
    (){
    return
    '@todo' ;
    }
    /// End of class:
    'ionicore'

    #2
    Anytime i use the config, lang or load method, apache freaks out and throws a 500 at me. Maybe im overlooking something? What ure lookin at tho is the core file of my new community script to replace the mobileGiGS Script. This is the supposed mg2 script bt its no longer under that name.

    Comment


      #3
      this line looks wrong to me:

      for ScriptID

      Added after 12 minutes:

      oh its listing many errors as of end of lines not being carried over ..
      Last edited by something else; 14.08.10, 19:13.

      Comment


        #4
        @something else...The syntax is right. When i call the backtrace method statically, it outputs '@todo'
        e.g when i do dis:
        echo ionicore::backtrace();
        its okay, bt when i do:
        echo ionicore::config('core.site_name');
        it throws the 500. Same with, lang. The problem myt be the load method so pls focus ur attention primarily on that and secordarily on the config and lang methods.

        Comment


          #5
          script path (_dir_)

          define script_path(_core_);

          just a sample
          Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
          Visit: WapMasterz Coming Back Soon!
          _______
          SCRIPTS FOR SALE BY SUBZERO
          Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
          FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
          _______
          Info & Tips
          php.net
          w3schools.com

          Comment


            #6
            yeah i cant really read your coding without a lot of work of modifying it myself as commented out lines such as
            PHP Code:
            /// These values should be left 
            for ScriptID


            and


            /// capitalize the first letter in 
            classname 
            are not being commented out

            Added after 20 minutes:

            heres another error:
            PHP Code:
            }else{ 
            $loadfile $dir
            '/' .$file'.php' 

            no if($something){ before it
            Last edited by something else; 14.08.10, 19:39.

            Comment


              #7
              Okay like i sed b4, this is just one file. Its nt to be called directly. Its require()d by a Bootstrap file. All the necessary paths are set there. The ONLY PROBLEM is the three methods i gave u.

              @something else... Just forget abt those commentin or nt. If they r nt commented php wud giv me a syntax error. The code is fine, so is the classname, just the 3 methods.
              PHP Code:
              if($dir == 'lang'){ 
              Added after 6 minutes:

              Ok what the 3 method does is:
              when u call the ionicore::config() method with a parameter, it goes to a config file and loads the var associated with it. Eg
              PHP Code:
              echo ionicore::config('core.site_name'); 
              outputs:
              IoniCore
              PHP Code:
              // ./config/core.php
              $config['site_name'] = 'IoniCore'
              Last edited by CreativityKills; 15.08.10, 04:00.

              Comment


                #8
                so where is ionicore_Exception ?

                Comment


                  #9
                  The exception class? Didnt fink it was useful to add it. Anyway i fixed it a bit.

                  Comment


                    #10
                    .htaccess

                    If there is a .htaccess file, remove it and try

                    Comment


                      #11
                      Originally posted by athora View Post
                      If there is a .htaccess file, remove it and try
                      Duh! Have fixed the script long time. And no it was not the htaccess

                      Comment

                      Working...
                      X