home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress / wp-login.php < prev    next >
Encoding:
PHP Script  |  2017-10-12  |  35.7 KB  |  1,089 lines

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