Advertisement
fabis_sparks

xen_auth

Jul 8th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. header("Content-Type: text/plain; charset=UTF-8");
  3. // Verify login and password
  4. $login = $_GET['login'];
  5. $password = $_GET['password'];
  6. if(empty($login) || empty($password)) {
  7. exit('Empty login or password');
  8. }
  9. // Load XenForo core
  10. $dir = dirname(__FILE__);
  11. $libraryDir = $dir . '/library';
  12. require_once($dir . '/library/XenForo/Autoloader.php');
  13. XenForo_Autoloader::getInstance()->setupAutoloader($libraryDir);
  14. XenForo_Application::initialize($libraryDir, $dir);
  15. XenForo_Application::set('page_start_time', microtime(true));
  16. $db = XenForo_Application::get('db');
  17. // Resolve user_id by login
  18. $result = $db->fetchRow('SELECT user_id, username FROM xf_user WHERE username=' . $db->quote($login) . ' OR email=' . $db->quote($login));
  19. if(!count($result)) {
  20. exit('Incorrect login');
  21. }
  22. $user_id = $result['user_id'];
  23. $username = $result['username'];
  24. // Get user data
  25. $result = $db->fetchCol('SELECT data FROM xf_user_authenticate WHERE user_id=' . $db->quote($user_id));
  26. if(!count($result)) {
  27. exit('Unable to get user data: ' . $user_id);
  28. }
  29. $data = $result[0];
  30. // Select authentication core
  31. $auth = NULL;
  32. if(class_exists('XenForo_Authentication_Core12')) {
  33. $auth = new XenForo_Authentication_Core12;
  34. } else if(class_exists('XenForo_Authentication_Core')) {
  35. $auth = new XenForo_Authentication_Core;
  36. } else exit('Unable to select authentication core');
  37. // Try authenticate
  38. $auth->setData($data);
  39. $success = $auth->authenticate($user_id, $password);
  40. echo($success ? 'OK:' . $username : 'Incorrect login or password');
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement