Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.22 KB | None | 0 0
  1. <?php
  2. /*======================================================================*\
  3. || #################################################################### ||
  4. || # vBulletin 3.8.7 Patch Level 1
  5. || # ---------------------------------------------------------------- # ||
  6. || # Copyright ©2000-2011 vBulletin Solutions, Inc. All Rights Reserved. ||
  7. || # This file may not be redistributed in whole or significant part. # ||
  8. || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
  9. || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
  10. || #################################################################### ||
  11. \*======================================================================*/
  12.  
  13. // ####################### SET PHP ENVIRONMENT ###########################
  14. error_reporting(E_ALL & ~E_NOTICE & ~8192);
  15.  
  16. // #################### DEFINE IMPORTANT CONSTANTS #######################
  17. define('THIS_SCRIPT', 'login');
  18. define('CSRF_PROTECTION', true);
  19. define('CSRF_SKIP_LIST', 'login');
  20.  
  21. // ################### PRE-CACHE TEMPLATES AND DATA ######################
  22. // get special phrase groups
  23. $phrasegroups = array();
  24.  
  25. // get special data templates from the datastore
  26. $specialtemplates = array();
  27.  
  28. // pre-cache templates used by all actions
  29. $globaltemplates = array();
  30.  
  31. // pre-cache templates used by specific actions
  32. $actiontemplates = array(
  33.     'lostpw' => array(
  34.         'lostpw',
  35.         'humanverify'
  36.     )
  37. );
  38.  
  39. // ######################### REQUIRE BACK-END ############################
  40. require_once('./global.php');
  41. require_once(DIR . '/includes/functions_login.php');
  42.  
  43. // #######################################################################
  44. // ######################## START MAIN SCRIPT ############################
  45. // #######################################################################
  46.  
  47. $vbulletin->input->clean_gpc('r', 'a', TYPE_STR);
  48.  
  49. if (empty($_REQUEST['do']) AND empty($vbulletin->GPC['a']))
  50. {
  51.     exec_header_redirect($vbulletin->options['forumhome'] . '.php');
  52. }
  53.  
  54. // ############################### start logout ###############################
  55. if ($_REQUEST['do'] == 'logout')
  56. {
  57.     define('NOPMPOPUP', true);
  58.  
  59.     $vbulletin->input->clean_gpc('r', 'logouthash', TYPE_STR);
  60.  
  61.     if ($vbulletin->userinfo['userid'] != 0 AND !verify_security_token($vbulletin->GPC['logouthash'], $vbulletin->userinfo['securitytoken_raw']))
  62.     {
  63.         eval(standard_error(fetch_error('logout_error', $vbulletin->session->vars['sessionurl'], $vbulletin->userinfo['securitytoken'])));
  64.     }
  65.  
  66.     process_logout();
  67.  
  68.     $vbulletin->url = fetch_replaced_session_url($vbulletin->url);
  69.     if (strpos($vbulletin->url, 'do=logout') !== false)
  70.     {
  71.         $vbulletin->url = $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'];
  72.     }
  73.     $show['member'] = false;
  74.     eval(standard_error(fetch_error('cookieclear', create_full_url($vbulletin->url), $vbulletin->options['forumhome'], $vbulletin->session->vars['sessionurl_q']), '', false));
  75.  
  76. }
  77.  
  78. // ############################### start do login ###############################
  79. // this was a _REQUEST action but where do we all login via request?
  80. if ($_POST['do'] == 'login')
  81. {
  82.     $vbulletin->input->clean_array_gpc('p', array(
  83.         'vb_login_username'        => TYPE_STR,
  84.         'vb_login_password'        => TYPE_STR,
  85.         'vb_login_md5password'     => TYPE_STR,
  86.         'vb_login_md5password_utf' => TYPE_STR,
  87.         'postvars'                 => TYPE_BINARY,
  88.         'cookieuser'               => TYPE_BOOL,
  89.         'logintype'                => TYPE_STR,
  90.         'cssprefs'                 => TYPE_STR,
  91.     ));
  92.  
  93.     // can the user login?
  94.     $strikes = verify_strike_status($vbulletin->GPC['vb_login_username']);
  95.  
  96.     if ($vbulletin->GPC['vb_login_username'] == '')
  97.     {
  98.         eval(standard_error(fetch_error('badlogin', $vbulletin->options['bburl'], $vbulletin->session->vars['sessionurl'], $strikes)));
  99.     }
  100.  
  101.     // make sure our user info stays as whoever we were (for example, we might be logged in via cookies already)
  102.     $original_userinfo = $vbulletin->userinfo;
  103.  
  104.     if (!verify_authentication($vbulletin->GPC['vb_login_username'], $vbulletin->GPC['vb_login_password'], $vbulletin->GPC['vb_login_md5password'], $vbulletin->GPC['vb_login_md5password_utf'], $vbulletin->GPC['cookieuser'], true))
  105.     {
  106.         ($hook = vBulletinHook::fetch_hook('login_failure')) ? eval($hook) : false;
  107.  
  108.         // check password
  109.         exec_strike_user($vbulletin->userinfo['username']);
  110.  
  111.         if ($vbulletin->GPC['logintype'] === 'cplogin' OR $vbulletin->GPC['logintype'] === 'modcplogin')
  112.         {
  113.             // log this error if attempting to access the control panel
  114.             require_once(DIR . '/includes/functions_log_error.php');
  115.             log_vbulletin_error($vbulletin->GPC['vb_login_username'], 'security');
  116.         }
  117.         $vbulletin->userinfo = $original_userinfo;
  118.  
  119.         if ($vbulletin->options['usestrikesystem'])
  120.         {
  121.             eval(standard_error(fetch_error('badlogin_strikes', $vbulletin->options['bburl'], $vbulletin->session->vars['sessionurl'], $strikes)));
  122.         }
  123.         else
  124.         {
  125.             eval(standard_error(fetch_error('badlogin', $vbulletin->options['bburl'], $vbulletin->session->vars['sessionurl'])));
  126.         }
  127.     }
  128.  
  129.     exec_unstrike_user($vbulletin->GPC['vb_login_username']);
  130.  
  131.     // create new session
  132.     process_new_login($vbulletin->GPC['logintype'], $vbulletin->GPC['cookieuser'], $vbulletin->GPC['cssprefs']);
  133.  
  134.     // do redirect
  135.     do_login_redirect();
  136.  
  137. }
  138. else if ($_GET['do'] == 'login')
  139. {
  140.     // add consistency with previous behavior
  141.     exec_header_redirect($vbulletin->options['forumhome'] . '.php');
  142. }
  143.  
  144. // ############################### start lost password ###############################
  145. if ($_REQUEST['do'] == 'lostpw')
  146. {
  147.     $vbulletin->input->clean_gpc('r', 'email', TYPE_NOHTML);
  148.     $email = $vbulletin->GPC['email'];
  149.  
  150.     if ($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview'])
  151.     {
  152.         $navbits = construct_navbits(array('' => $vbphrase['lost_password_recovery_form']));
  153.         eval('$navbar = "' . fetch_template('navbar') . '";');
  154.     }
  155.     else
  156.     {
  157.         $navbar = '';
  158.     }
  159.  
  160.     // human verification
  161.     if (fetch_require_hvcheck('lostpw'))
  162.     {
  163.         require_once(DIR . '/includes/class_humanverify.php');
  164.         $verification =& vB_HumanVerify::fetch_library($vbulletin);
  165.         $human_verify = $verification->output_token();
  166.     }
  167.     else
  168.     {
  169.         $human_verify = '';
  170.     }
  171.  
  172.     $url =& $vbulletin->url;
  173.     eval('print_output("' . fetch_template('lostpw') . '");');
  174. }
  175.  
  176. // ############################### start email password ###############################
  177. if ($_POST['do'] == 'emailpassword')
  178. {
  179.  
  180.     $vbulletin->input->clean_array_gpc('p', array(
  181.         'email' => TYPE_STR,
  182.         'userid' => TYPE_UINT,
  183.         'humanverify'  => TYPE_ARRAY,
  184.     ));
  185.  
  186.     if ($vbulletin->GPC['email'] == '')
  187.     {
  188.         eval(standard_error(fetch_error('invalidemail', $vbulletin->options['contactuslink'])));
  189.     }
  190.  
  191.     if (fetch_require_hvcheck('lostpw'))
  192.     {
  193.         require_once(DIR . '/includes/class_humanverify.php');
  194.         $verify =& vB_HumanVerify::fetch_library($vbulletin);
  195.         if (!$verify->verify_token($vbulletin->GPC['humanverify']))
  196.         {
  197.             standard_error(fetch_error($verify->fetch_error()));
  198.         }
  199.     }
  200.  
  201.     require_once(DIR . '/includes/functions_user.php');
  202.  
  203.     $users = $db->query_read_slave("
  204.         SELECT userid, username, email, languageid
  205.         FROM " . TABLE_PREFIX . "user
  206.         WHERE email = '" . $db->escape_string($vbulletin->GPC['email']) . "'
  207.     ");
  208.     if ($db->num_rows($users))
  209.     {
  210.         while ($user = $db->fetch_array($users))
  211.         {
  212.             if ($vbulletin->GPC['userid'] AND $vbulletin->GPC['userid'] != $user['userid'])
  213.             {
  214.                 continue;
  215.             }
  216.             $user['username'] = unhtmlspecialchars($user['username']);
  217.  
  218.             $user['activationid'] = build_user_activation_id($user['userid'], 2, 1);
  219.  
  220.             eval(fetch_email_phrases('lostpw', $user['languageid']));
  221.             vbmail($user['email'], $subject, $message, true);
  222.         }
  223.  
  224.         $vbulletin->url = str_replace('"', '', $vbulletin->url);
  225.         eval(print_standard_redirect('redirect_lostpw', true, true));
  226.     }
  227.     else
  228.     {
  229.         eval(standard_error(fetch_error('invalidemail', $vbulletin->options['contactuslink'])));
  230.     }
  231. }
  232.  
  233. // ############################### start reset password ###############################
  234. if ($vbulletin->GPC['a'] == 'pwd' OR $_REQUEST['do'] == 'resetpassword')
  235. {
  236.  
  237.     $vbulletin->input->clean_array_gpc('r', array(
  238.         'userid'       => TYPE_UINT,
  239.         'u'            => TYPE_UINT,
  240.         'activationid' => TYPE_STR,
  241.         'i'            => TYPE_STR
  242.     ));
  243.  
  244.     if (!$vbulletin->GPC['userid'])
  245.     {
  246.         $vbulletin->GPC['userid'] = $vbulletin->GPC['u'];
  247.     }
  248.  
  249.     if (!$vbulletin->GPC['activationid'])
  250.     {
  251.         $vbulletin->GPC['activationid'] = $vbulletin->GPC['i'];
  252.     }
  253.  
  254.     $userinfo = verify_id('user', $vbulletin->GPC['userid'], 1, 1);
  255.  
  256.     $user = $db->query_first("
  257.         SELECT activationid, dateline
  258.         FROM " . TABLE_PREFIX . "useractivation
  259.         WHERE type = 1
  260.             AND userid = $userinfo[userid]
  261.     ");
  262.  
  263.     if (!$user)
  264.     {
  265.         // no activation record, probably got back here after a successful request, back to home
  266.         exec_header_redirect($vbulletin->options['forumhome'] . '.php');
  267.     }
  268.  
  269.     if ($user['dateline'] < (TIMENOW - 24 * 60 * 60))
  270.     {  // is it older than 24 hours?
  271.         eval(standard_error(fetch_error('resetexpired', $vbulletin->session->vars['sessionurl'])));
  272.     }
  273.  
  274.     if ($user['activationid'] != $vbulletin->GPC['activationid'])
  275.     { //wrong act id
  276.         eval(standard_error(fetch_error('resetbadid', $vbulletin->session->vars['sessionurl'])));
  277.     }
  278.  
  279.     // delete old activation id
  280.     $db->query_write("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid = $userinfo[userid] AND type = 1");
  281.  
  282.     $newpassword = fetch_random_password(8);
  283.  
  284.     // init user data manager
  285.     $userdata =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
  286.     $userdata->set_existing($userinfo);
  287.     $userdata->set('password', $newpassword);
  288.     $userdata->save();
  289.  
  290.     ($hook = vBulletinHook::fetch_hook('reset_password')) ? eval($hook) : false;
  291.  
  292.     eval(fetch_email_phrases('resetpw', $userinfo['languageid']));
  293.     vbmail($userinfo['email'], $subject, $message, true);
  294.  
  295.     eval(standard_error(fetch_error('resetpw', $vbulletin->session->vars['sessionurl'])));
  296.  
  297. }
  298.  
  299. /*======================================================================*\
  300. || ####################################################################
  301. || #
  302. || # CVS: $RCSfile$ - $Revision: 39862 $
  303. || ####################################################################
  304. \*======================================================================*/
  305. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement