2
我通過php驗證XenForo用戶。PHP檢查XenForo用戶帳戶數據
我的代碼:
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;
}
錯誤日誌:
[12月 - 2017年20點08分45秒UTC] PHP致命錯誤:在/ home不能重新聲明類XenForo_Autoloader/****在線***/******* /庫/ XenForo/Autoloader.php 16
所以,請幫助我,什麼是錯的