PHP checking XenForo user's account data

Status
Not open for further replies.

revolveextra34

New member
I am authenticating XenForo user via php.

My code:
PHP:
public function Auth($username, $password)
{
    $userIDA = $this->getarray("SELECT * FROM xf_user WHERE username='".$username."'");

    if($userIDA)
    {
        define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed
        require_once('library/XenForo/Autoloader.php');

        $AutoLoader = XenForo_Autoloader::getInstance();
        $AutoLoader->setupAutoloader('library');
        XenForo_Application::initialize('library', '');
        XenForo_Application::set('page_start_time', microtime(true));
        XenForo_Application::disablePhpErrorHandler(); //
        XenForo_Session::startPublicSession(); //
        error_reporting(E_ALL & ~E_NOTICE); // Turn off the strict error reporting.

        $db = XenForo_Application::get('db');
        $result = $db->fetchCol('SELECT user_id FROM xf_user WHERE username='.$db->quote($username));
        $user_id = $result[0];
        $result = $db->fetchCol('SELECT data FROM xf_user_authenticate WHERE user_id='.$db->quote($user_id));
        $data = $result[0];

        $auth = NULL;

        if(class_exists('XenForo_Authentication_Core12'))
            $auth = new XenForo_Authentication_Core12;
        else if(class_exists('XenForo_Authentication_Core'))
            $auth = new XenForo_Authentication_Core;

        $auth->setData($data);

        if ($auth->authenticate($user_id, $password))
        {
            switch (intval($user_id))
            {
                default:
                    return 1;
                break;
                case 1:
                    return -1;
                case 3:
                    return -1;
                break;
            }
        }
        return 2;
    }
    else return 3;
}
error log:

[12-Aug-2017 20:08:45 UTC] PHP Fatal error: Cannot redeclare class XenForo_Autoloader in /home/*******/*******/library/XenForo/Autoloader.php on line 16

So, please help me, what is wrong
 
Upvote 0
We can only provide support to licensed customers. If you are licensed, please add your forum username to the Forum users page in your Account area and then post in the correct forum.
 
Status
Not open for further replies.
Top Bottom