CodeIgniter Forums
An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! (/showthread.php?tid=17212)

Pages: 1 2


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]Rubiz'[/eluser]
Hello all

Well I'm working with DX Auth, last version of CI, and I don't know why I'm getting the:

An Error Was Encountered

Unable to load the requested class: dx_auth


message when I try launch the web site. It's very weird problem, just because my local app copy is working fine!!

Any suggestion of how to fix it?


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]TheFuzzy0ne[/eluser]
The file either doesn't exist, or has the permissions set incorrectly.


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]Rubiz'[/eluser]
Well, I have made FTP copy with the same files and folders I have in local copy, that works fine...
I Could give some permissions, but in which folders?


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]TheFuzzy0ne[/eluser]
Well, in theory, all of your files should have the permissions of 755. Do they? The best way to check is to compare the permissions of the file that's not working to a file you know does work (like index.php). If you're still getting no love, you can override the loader method with your own:

./system/application/libraries/MY_Loader.php
Code:
class MY_Loader extends CI_Loader {

    function _ci_load_class($class, $params = NULL, $object_name = NULL)
    {    
        // Get the class name, and while we're at it trim any slashes.  
        // The directory path can be included as part of the class name,
        // but we don't want a leading slash
        $class = str_replace(EXT, '', trim($class, '/'));
    
        // Was the path included with the class name?
        // We look for a slash to determine this
        $subdir = '';
        if (strpos($class, '/') !== FALSE)
        {
            // explode the path so we can separate the filename from the path
            $x = explode('/', $class);    
            
            // Reset the $class variable now that we know the actual filename
            $class = end($x);
            
            // Kill the filename from the array
            unset($x[count($x)-1]);
            
            // Glue the path back together, sans filename
            $subdir = implode($x, '/').'/';
        }

        // We'll test for both lowercase and capitalized versions of the file name
        foreach (array(ucfirst($class), strtolower($class)) as $class)
        {
            $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.EXT;

            // Is this a class extension request?            
            if (file_exists($subclass))
            {
                $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT;
                
                if ( ! file_exists($baseclass))
                {
                    log_message('error', "Unable to load the requested class: ".$class);
                    show_error("Unable to load the requested class: ".$class);
                }

                // Safety:  Was the class already loaded by a previous call?
                if (in_array($subclass, $this->_ci_loaded_files))
                {
                    // Before we deem this to be a duplicate request, let's see
                    // if a custom object name is being supplied.  If so, we'll
                    // return a new instance of the object
                    if ( ! is_null($object_name))
                    {
                        $CI =& get_instance();
                        if ( ! isset($CI->$object_name))
                        {
                            return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);            
                        }
                    }
                    
                    $is_duplicate = TRUE;
                    log_message('debug', $class." class already loaded. Second attempt ignored.");
                    return;
                }
    
                include_once($baseclass);                
                include_once($subclass);
                $this->_ci_loaded_files[] = $subclass;
    
                return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);            
            }
        
            // Lets search for the requested library file and load it.
            $is_duplicate = FALSE;        
            for ($i = 1; $i < 3; $i++)
            {
                $path = ($i % 2) ? APPPATH : BASEPATH;    
                $filepath = $path.'libraries/'.$subdir.$class.EXT;
                
                // Does the file exist?  No?  Bummer...
                if ( ! file_exists($filepath))
                {
                    continue;
                }
                
                // Safety:  Was the class already loaded by a previous call?
                if (in_array($filepath, $this->_ci_loaded_files))
                {
                    // Before we deem this to be a duplicate request, let's see
                    // if a custom object name is being supplied.  If so, we'll
                    // return a new instance of the object
                    if ( ! is_null($object_name))
                    {
                        $CI =& get_instance();
                        if ( ! isset($CI->$object_name))
                        {
                            return $this->_ci_init_class($class, '', $params, $object_name);
                        }
                    }
                
                    $is_duplicate = TRUE;
                    log_message('debug', $class." class already loaded. Second attempt ignored.");
                    return;
                }
                
                include_once($filepath);
                $this->_ci_loaded_files[] = $filepath;
                return $this->_ci_init_class($class, '', $params, $object_name);
            }
        } // END FOREACH

        // One last attempt.  Maybe the library is in a subdirectory, but it wasn't specified?
        if ($subdir == '')
        {
            $path = strtolower($class).'/'.$class;
            return $this->_ci_load_class($path, $params);
        }
        
        // If we got this far we were unable to find the requested class.
        // We do not issue errors if the load call failed due to a duplicate request
        if ($is_duplicate == FALSE)
        {
            log_message('error', "Unable to load the requested class: ".$class);
            show_error("Unable to load the requested class: ".$class);
        }
    }
}

This will be loaded automatically, and then you can add log_message()s, die()s or anything else you want to that will help you to see where the method is failing.

Hope this helps.


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]Rubiz'[/eluser]
well.. I think DXAuth should work without all that things... this code is advanced for me, I'll try other solution... in last instance, I'll be taking off DXAuth of my app...


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]tomcode[/eluser]
Maybe it's a upper / lower case problem, try with all lower case : filename, class name, constructor function name, load call.


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]TheFuzzy0ne[/eluser]
If you'd like to zip up your app and put it somewhere that I can download it, I'll happily have a look at it for you.


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]Rubiz'[/eluser]
I find very kind FuzzyOne u to see my code, but now I installed CI and DXAuth all again, without my app pages, and got 2 unexpected T_OBJECT_OPERATOR errors:


Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /nfs/c01/h04/mnt/45239/domains/webresolv.com.br/html/alkindar/system/application/libraries/DX_Auth.php on line 803

1. On this line (803):
Code:
return ($this->ci->login_attempts->check_attempts($this->ci->input->ip_address())->num_rows() >= $this->ci->config->item('DX_max_login_attempts'));

2. On this line (1092)
Code:
$user_id = $query->row()->id;

This is breaking my load for dx_auth, I'm sure...
But how could I solve this?!?!?!


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]TheFuzzy0ne[/eluser]
Sounds like you're running PHP 4 and DXAuth doesn't seem to like it.


An Error Was Encountered. Unable to load the requested class: dx_auth - But local copy works fine! - El Forum - 03-29-2009

[eluser]Rubiz'[/eluser]
Wow... the host is media temple, but uses PHP 4.4.8 !!
I feel bad with this... they are not a bad host!!

:-(