lundi 29 mars 2021

Php Issue - ERR_TOO_MANY_REDIRECTS

Up until recently my web application was working fine. Then when I try visiting the site im getting a ERR_TOO_MANY_REDIRECTS error. Nothing has changed with the site and this has been working for several years without issue. I have checked with the hosting company to confirm nothing has automatically updated such as the PHP version etc. When I look at the error logs this states an issue with line 161 below.

if( ! $session->contains('waste_uuid') or ! $session->contains('waste_pwd') )

Why all of a sudden would the site just stop working? Im perplexed as nothing has changed. The code has remained the same. Any help with this would be much appreciated.

I have tried clearing down all the logs, clearing the caches etc thinking this may be causing the issue however no luck.

Full Code block I believe is affected

static protected function installCredentials()
    {
        $session    = &self::$registry->session();
        $request    = &self::$registry->request();
        $output     = &self::$registry->output();
        $db         =  self::$registry->db();
                        
        do
        {
            if( ! $session->contains('waste_uuid') or ! $session->contains('waste_pwd') )
            {               
                //if( ! strcasecmp($request['app'], 'account') and ! strcasecmp//($request['module'], 'login') )
                    //return ;
                                
                break;
            }
                        
            $session_uuid = $session['waste_uuid'];
            $session_pass = $session['waste_pwd'];
            
            $credentials = $db->scalar(array (
                'select'    => '*',
                'from'      => 'users',
                'where'     => '`id` = ? and `password` = ?',
                'params'    => array( $session_uuid, $session_pass )
            ));
                        
            if( ! $credentials || $credentials['disabled'] == '1' )
            {
                $session->removeSession('waste_uuid');
                $session->removeSession('waste_pwd');
                
                if( ! strcasecmp($request['app'], 'account') and ! strcasecmp($request['module'], 'login') )
                    return ;
                
                break;
            }
            
            $kick = $db->scalar(array (
                'select'    => 'kick',
                'from'      => 'users_online',
                'where'     => 'user_id = ?',
                'params'    => array( $credentials['id'] )
            ));
            
            if( $kick && $kick['kick'] == '1' )
            {
                $session->removeSession('waste_uuid');
                $session->removeSession('waste_pwd');
                
                $statement = $db->prepare('UPDATE `users_online` SET `kick` = ? WHERE `user_id` = ?');
                $statement->execute(array( '0', $credentials['id'] ));
                
                if( ! strcasecmp($request['app'], 'account') && ! strcasecmp($request['module'], 'login') )
                    return ;
                
                break;
            }
            
            $credentials['group'] = $db->scalar(array (
                'select'    => '*',
                'from'      => 'groups',
                'where'     => 'id = ?',
                'params'    => array( $credentials['group'] )
            ));
            
            $credentials['sites'] = $db->all(array (
                'select'    => 'site_id',
                'from'      => 'sites_users',
                'where'     => 'user_id = ? and disabled = ?',
                'params'    => array( $credentials['id'], '0' )
            ));
            
            $user = registry::getClass('user', array( self::$registry ));           
            $user->merge($credentials);
                        
            self::$registry->resolveUser($user);
            self::$registry->output()->atomize(array (
                'menu'          => array (),
                'breadcrumb'    => array (),
                'title'         => array ()
            ));
            
            $user->detect_notifications();
            
            if( $user['opt_messages'] == '1' )
                $user->detect_chats();
            
            $logger = registry::getClass('logger', array( self::$registry ));
            self::$registry->resolveLogger($logger);
            
            self::registerActivity();
            
            return ;
        }
        while (false);
                
        $output->redirect('login'); 
    }



Aucun commentaire:

Enregistrer un commentaire