2018-09-17 10:07:32 +03:00
|
|
|
<?php
|
|
|
|
header("Content-Type: text/plain; charset=UTF-8");
|
|
|
|
|
|
|
|
// Verify login and password
|
|
|
|
$login = $_GET['login'];
|
|
|
|
$password = $_GET['password'];
|
|
|
|
if(empty($login) || empty($password)) {
|
2018-11-05 12:50:46 +03:00
|
|
|
exit('Введены неверные данные');
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load XenForo core
|
|
|
|
$dir = dirname(__FILE__);
|
|
|
|
$libraryDir = $dir . '/library';
|
|
|
|
require_once($dir . '/library/XenForo/Autoloader.php');
|
|
|
|
XenForo_Autoloader::getInstance()->setupAutoloader($libraryDir);
|
|
|
|
XenForo_Application::initialize($libraryDir, $dir);
|
|
|
|
XenForo_Application::set('page_start_time', microtime(true));
|
|
|
|
$db = XenForo_Application::get('db');
|
|
|
|
|
|
|
|
// Resolve user_id by login
|
|
|
|
$result = $db->fetchRow('SELECT user_id, username FROM xf_user WHERE username=' . $db->quote($login) . ' OR email=' . $db->quote($login));
|
|
|
|
if(!count($result)) {
|
2018-11-05 12:50:46 +03:00
|
|
|
exit('Введены неверные данные');
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
$user_id = $result['user_id'];
|
|
|
|
$username = $result['username'];
|
|
|
|
|
|
|
|
// Get user data
|
|
|
|
$result = $db->fetchCol('SELECT data FROM xf_user_authenticate WHERE user_id=' . $db->quote($user_id));
|
|
|
|
if(!count($result)) {
|
2018-11-05 12:50:46 +03:00
|
|
|
exit('Внутренняя ошибка'); // rare!
|
2018-09-17 10:07:32 +03:00
|
|
|
}
|
|
|
|
$data = $result[0];
|
|
|
|
|
|
|
|
// Select authentication core
|
|
|
|
$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;
|
2018-11-05 12:50:46 +03:00
|
|
|
} else exit('Внутренняя ошибка'); // rare!
|
2018-09-17 10:07:32 +03:00
|
|
|
|
|
|
|
// Try authenticate
|
|
|
|
$auth->setData($data);
|
|
|
|
$success = $auth->authenticate($user_id, $password);
|
2018-11-05 12:50:46 +03:00
|
|
|
echo($success ? 'OK:' . $username : 'Ошибка при авторизации');
|
2018-09-17 10:07:32 +03:00
|
|
|
?>
|