function wp_login($username, $password, $already_md5 = false) { global $wpdb, $error; if(is_object($GLOBALS["xoopsModule"]) && WP_BLOG_DIRNAME == $GLOBALS["xoopsModule"]->getVar("dirname")){ if(!is_object($GLOBALS["xoopsUser"])){ wp_clearcookie(); return false; } } $username = sanitize_user($username); if ( '' == $username ) return false; if ( '' == $password ) { $error = __('<strong>ERROR</strong>: The password field is empty.'); return false; } $login = get_userdatabylogin($username); //$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '******'"); if (!$login) { $error = __('<strong>ERROR</strong>: Invalid username.'); return false; } else { if ($login->user_login == $username) { if ($login->user_pass == $password) return true; if ($login->user_pass == md5($password)) return true; } $error = __('<strong>ERROR</strong>: Incorrect password.'); $pwd = ''; return false; } }
function ProjectTheme_do_login_scr() { /*do_action( 'login_enqueue_scripts' ); do_action( 'login_head' ); do_action('login_footer'); */ global $wpdb, $error, $wp_query, $current_theme_locale_name; if (!is_array($wp_query->query_vars)) { $wp_query->query_vars = array(); } $action = $_REQUEST['action']; $error = ''; nocache_headers(); header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset')); if (defined('RELOCATE')) { // Move flag is set if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) { $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); } $schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl')) { update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); } } do_action('login_init'); do_action('login_form_' . $action); switch ($_REQUEST["action"]) { //logout case "logout": wp_clearcookie(); session_start(); $sessions->destroy_all(); /*session_start(); if(isset($vstrsnln_blog_id)) { unset( $vstrsnln_blog_id); session_destroy(); } */ if (get_option("jk_logout_redirect_to")) { $redirect_to = get_option("jk_logout_redirect_to"); } else { $redirect_to = "wp-login.php"; } do_action('wp_logout'); nocache_headers(); if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; } wp_redirect(get_bloginfo('siteurl')); exit; break; //lost lost password //lost lost password case 'lostpassword': case 'retrievepassword': $http_post = 'POST' == $_SERVER['REQUEST_METHOD']; if ($http_post) { $errors = my_retrieve_password(); if (!is_wp_error($errors)) { $redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; wp_safe_redirect($redirect_to); exit; } } if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) { $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); } $redirect_to = apply_filters('lostpassword_redirect', !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); do_action('lost_password'); $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; get_header(); ?> <div class="page_heading_me"> <div class="page_heading_me_inner"> <div class="mm_inn"><?php printf(__("Retrieve Password - %s", $current_theme_locale_name), get_bloginfo('name')); ?> </div> </div> </div> <!-- ########## --> <div id="main_wrapper"> <div id="main" class="wrapper"><div class="padd10"> <div class="my_box3"> <div class="padd10"> <div class="box_content"> <div class="login-submit-form"> <form name="lostpass" action="<?php echo esc_url(site_url('wp-login.php?action=lostpassword', 'login_post')); ?> " method="post" id="loginform"> <p><?php _e('Please enter your information here. We will send you a new password.', $current_theme_locale_name); ?> </p> <?php if ($errors) { echo "<div class='errrs'>" . $errors->get_error_message() . "</div>"; } ?> <input type="hidden" name="action" value="retrievepassword" /> <p> <label><?php _e('Username or Email:', $current_theme_locale_name); ?> </label> <input type="text" class="do_input" name="user_login" id="user_login" value="" size="30" tabindex="1" /> </p> <?php do_action('lostpassword_form'); ?> <p><label> </label> <input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password', $current_theme_locale_name); ?> " class="submit_bottom" tabindex="3" /> </p> </form> <script type="text/javascript"> $(function() { // gather all inputs of selected types var inputs = $('#user_tp, #user_email, #user_login, #log, #login_password, #rememberme, #submits, .green_btn'), inputTo; // bind on keydown inputs.on('keydown', function(e) { // if we pressed the tab if (e.keyCode == 9 || e.which == 9) { alert('tab'); // prevent default tab action e.preventDefault(); if (e.shiftKey) { // get previous input based on the current input inputTo = inputs.get(inputs.index(this) - 1); } else { // get next input based on the current input inputTo = inputs.get(inputs.index(this) + 1); } // move focus to inputTo, otherwise focus first input if (inputTo) { inputTo.focus(); } else { inputs[0].focus(); } } }); }); </script> </div> <ul id="logins"> <li><a href="<?php bloginfo('home'); ?> /" title="<?php _e('Are you lost?', $current_theme_locale_name); ?> ">« <?php _e('Home', $current_theme_locale_name); ?> </a></li> <?php if (get_settings('users_can_register')) { ?> <li><a href="<?php bloginfo('wpurl'); ?> /wp-login.php?action=register"><?php _e('Register', $current_theme_locale_name); ?> </a></li> <?php } ?> <li><a href="<?php bloginfo('wpurl'); ?> /wp-login.php"><?php _e('Login', $current_theme_locale_name); ?> </a></li> </ul> </div> </div> </div> </div></div></div> <?php get_footer(); die; break; case 'retrievepassword2': get_header(); $user_data = get_userdatabylogin($_POST['user_login']); // redefining user_login ensures we return the right case in the email $user_login = $user_data->user_login; $user_email = $user_data->user_email; if (!$user_email || $user_email != $_POST['email']) { ?> <div class="my_box3"> <div class="padd10"> <div class="box_title"><?php _e("Retrieve Error", $current_theme_locale_name); ?> - <?php echo get_bloginfo('name'); ?> </div> <div class="box_content"> <br/><br/> <?php echo sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? <a href="%s">Try again</a>.', $current_theme_locale_name), 'wp-login.php?action=lostpassword'); ?> <br/><br/> </div></div></div> <?php get_footer(); die; } do_action('retreive_password', $user_login); // Misspelled and deprecated. do_action('retrieve_password', $user_login); // Generate something random for a password... md5'ing current time with a rand salt $key = substr(md5(uniqid(current_time('timestamp', 0))), 0, 50); // now insert the new pass md5'd into the db $wpdb->query("UPDATE {$wpdb->users} SET user_activation_key = '{$key}' WHERE user_login = '******'"); $message = __('Someone has asked to reset the password for the following site and username.', $current_theme_locale_name) . "\r\n\r\n"; $message .= get_option('siteurl') . "\r\n\r\n"; $message .= sprintf(__('Username: %s', $current_theme_locale_name), $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', $current_theme_locale_name) . "\r\n\r\n"; $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key={$key}\r\n"; $m = ProjectTheme_send_email($user_email, sprintf(__('[%s] Password Reset', $current_theme_locale_name), get_settings('blogname')), $message); echo get_option("jk_login_after_head_html"); echo " <div id=\"login\">\n"; if ($m == false) { echo "<h1>" . __("There Was a Problem", $current_theme_locale_name) . "</h1>"; echo '<p>' . __('The e-mail could not be sent.', $current_theme_locale_name) . "<br />\n"; echo __('Possible reason: your host may have disabled the mail() function...', $current_theme_locale_name) . "</p>"; } else { echo "<h1>Success!</h1>"; echo '<p>' . sprintf(__("The e-mail was sent successfully to %s's e-mail address.", $current_theme_locale_name), $user_login) . '<br />'; echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course', $current_theme_locale_name) . "'>" . __('Click here to login!', $current_theme_locale_name) . '</a></p>'; } echo " </div>\n"; echo '</div></div></div>'; get_footer(); die; break; //reset password //reset password case 'rp': get_header(); //_get_whole_menu(); echo '<div class="my_box3"> <div class="padd10">'; echo " <div id=\"login\">\n"; // Generate something random for a password... md5'ing current time with a rand salt $key = preg_replace('/a-z0-9/i', '', $_GET['key']); if (empty($key)) { _e('<h1>Problem</h1>', $current_theme_locale_name); _e('Sorry, that key does not appear to be valid.', $current_theme_locale_name); echo " </div>\n"; echo '</div></td></tr></table></div></div>'; get_footer(); die; } $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_activation_key = '{$key}'"); if (!$user) { _e('<h1>Problem</h1>', $current_theme_locale_name); _e('Sorry, that key does not appear to be valid.', $current_theme_locale_name); echo " </div>\n"; echo '</div></div>'; get_footer(); die; } do_action('password_reset'); $new_pass = substr(md5(uniqid(current_time('timestamp', 0))), 0, 7); $wpdb->query("UPDATE {$wpdb->users} SET user_pass = MD5('{$new_pass}'), user_activation_key = '' WHERE user_login = '******'"); wp_cache_delete($user->ID, 'users'); wp_cache_delete($user->user_login, 'userlogins'); $message = '<img id="logo" alt="BidQA" src="bidqa.com/wp-content/themes/ProjectTheme/images/logo/imgo.jpeg"><br>We have reset the password for the following account. Please find the new temporary password below (we recommend that you change it once you log in).<br>'; $message .= sprintf(__('Username: %s', $current_theme_locale_name), $user->user_login) . "\r\n<br>"; $message .= sprintf(__('Password: %s', $current_theme_locale_name), $new_pass) . "\r\n<br>"; $message .= get_bloginfo('siteurl') . "/wp-login.php\r\n<br>"; $m = wp_mail($user->user_email, sprintf(__('Your new password', $current_theme_locale_name)), $message); //ProjectTheme_send_email($user->user_email, sprintf(__('Your new password',$current_theme_locale_name) ), $message); if ($m == false) { echo __('<h1>Problem</h1>', $current_theme_locale_name); echo '<p>' . __('The e-mail could not be sent.', $current_theme_locale_name) . "<br />\n"; echo __('Possible reason: your host may have disabled the mail() function...', $current_theme_locale_name) . '</p>'; } else { echo __('<h1>Success!</h1>', $current_theme_locale_name); echo '<p>' . sprintf(__('Your new password is in the mail.', $current_theme_locale_name), $user_login) . '<br />'; echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course', $current_theme_locale_name) . "'>" . __('Click here to login!', $current_theme_locale_name) . '</a></p>'; // send a copy of password change notification to the admin $message = sprintf(__('Password Lost and Changed for user: %s', $current_theme_locale_name), $user->user_login) . "\r\n"; ProjectTheme_send_email(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change', $current_theme_locale_name), get_settings('blogname')), $message); } echo " </div>\n"; echo '</div></div></div>'; get_footer(); die; break; //login and default action //login and default action case 'login': default: //check credentials - 99% of this is identical to the normal wordpress login sequence as of 2.0.4 //Any differences will be noted with end of line comments. $user_login = ''; $user_pass = ''; $using_cookie = false; /** * this is what the code was * if ( !isset( $_REQUEST['redirect_to'] ) ) * $redirect_to = 'wp-admin/'; * else * $redirect_to = $_REQUEST['redirect_to']; */ if (!isset($_REQUEST['redirect_to'])) { $redirect_to = get_permalink(get_option('ProjectTheme_my_account_page_id')); } else { $redirect_to = $_REQUEST['redirect_to']; } if (isset($_SESSION['redirect_me_back'])) { $redirect_to = $_SESSION['redirect_me_back']; } if ($_POST) { $user_login = $_POST['log']; $user_login = sanitize_user($user_login); $user_pass = $_POST['pwd']; $rememberme = $_POST['rememberme']; } else { if (function_exists('wp_get_cookie_login')) { $cookie_login = wp_get_cookie_login(); if (!empty($cookie_login)) { $using_cookie = true; $user_login = $cookie_login['login']; $user_pass = $cookie_login['password']; } } elseif (!empty($_COOKIE)) { if (!empty($_COOKIE[USER_COOKIE])) { $user_login = $_COOKIE[USER_COOKIE]; } if (!empty($_COOKIE[PASS_COOKIE])) { $user_pass = $_COOKIE[PASS_COOKIE]; $using_cookie = true; } } } do_action('wp_authenticate', $user_login, $user_pass); if ($user_login && $user_pass) { $user = new WP_User(0, $user_login); // If the user can't edit posts, send them to their profile. //if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) ) // $redirect_to = get_settings('siteurl') . '/' . 'my-account'; if (wp_login($user_login, $user_pass, $using_cookie)) { if (!$using_cookie) { wp_setcookie($user_login, $user_pass, false, '', '', $rememberme); } do_action('wp_login', $user_login); wp_redirect($redirect_to); exit; } else { if ($using_cookie) { $error = __('Your session has expired.', $current_theme_locale_name); } } } else { if ($_POST && !$user_login) { $error = __('<strong>Error</strong>: The Username field is empty.', $current_theme_locale_name); } else { if ($_POST && !$user_pass) { $error = __('<strong>Error</strong>: The password field is empty.', $current_theme_locale_name); } } } get_header(); ?> <div class="page_heading_me"> <div class="page_heading_me_inner"> <div class="mm_inn"><?php printf(__("Login - %s", $current_theme_locale_name), get_bloginfo('name')); ?> </div> </div> </div> <!-- ########## --> <div id="main_wrapper"> <div id="main" class="wrapper"><div class="padd10"> <div class="my_box3"> <div class="padd10"> <div class="box_content"> <?php if (isset($_GET['checkemail']) && $_GET['checkemail'] == "confirm") { ?> <div class="check-email-div"><div class="padd10"> <?php _e('We have sent a confirmation message to your email address.<br/> Please follow the instructions in the email and get back to this page.', $current_theme_locale_name); ?> </div></div> <?php } ?> <?php if (!empty($error)) { ?> <div class="error"><ul> <?php echo "<li>{$error}</li>"; ?> </ul> </div> <?php } ?> <div class="login-submit-form"> <form name="loginform" id="loginform" action="<?php echo esc_url(site_url('wp-login.php', 'login_post')); ?> " method="post"> <p><label><?php _e('Username:'******'Password:'******'Keep me logged in', $current_theme_locale_name); ?> </p> <?php do_action('login_form'); ?> <p><label> </label> <input type="submit" class="submit_bottom" name="submits" id="submits" value="<?php _e('Sign in', $current_theme_locale_name); ?> " tabindex="4" /> <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($redirect_to); ?> " /> </p> </form> <script type="text/javascript"> $(function() { // gather all inputs of selected types var inputs = $('#user_tp, #user_email, #user_login, #log, #login_password, #rememberme, #submits, .green_btn'), inputTo; console.log(inputs); // bind on keydown inputs.on('keydown', function(e) { // if we pressed the tab if (e.keyCode == 9 || e.which == 9) { // prevent default tab action e.preventDefault(); if (e.shiftKey) { // get previous input based on the current input inputTo = inputs.get(inputs.index(this) - 1); } else { // get next input based on the current input inputTo = inputs.get(inputs.index(this) + 1); } // move focus to inputTo, otherwise focus first input if (inputTo) { inputTo.focus(); } else { inputs[0].focus(); } } }); }); </script> <ul id="logins"> <li><a class="green_btn" href="<?php bloginfo('home'); ?> /" title="<?php _e('Are you lost?', $current_theme_locale_name); ?> ">« <?php _e('Home', $current_theme_locale_name); ?> </a></li> <?php if (get_settings('users_can_register')) { ?> <li><a class="green_btn" href="<?php bloginfo('wpurl'); ?> /wp-login.php?action=register"><?php _e('Register', $current_theme_locale_name); ?> </a></li> <?php } ?> <li><a class="green_btn" href="<?php bloginfo('wpurl'); ?> /wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found', $current_theme_locale_name); ?> "><?php _e('Lost your password?', $current_theme_locale_name); ?> </a></li> </ul> </div> </div> </div> </div> </div> </div> </div> <?php get_footer(); die; break; } }
/** * Clears the authentication cookie, logging the user out. * * @since 1.5 * @deprecated Use wp_clear_auth_cookie() * @see wp_clear_auth_cookie() */ function un_set() { wp_clearcookie(); }
function wp_update_user($userdata) { global $wpdb, $current_user; $ID = (int) $userdata['ID']; // First, get all of the original fields $user = get_userdata($ID); // Escape data pulled from DB. $user = add_magic_quotes(get_object_vars($user)); // If password is changing, hash it now. if ( ! empty($userdata['user_pass']) ) { $plaintext_pass = $userdata['user_pass']; $userdata['user_pass'] = md5($userdata['user_pass']); } // Merge old and new fields with new fields overwriting old ones. $userdata = array_merge($user, $userdata); $user_id = wp_insert_user($userdata); // Update the cookies if the password changed. if( $current_user->id == $ID ) { if ( isset($plaintext_pass) ) { wp_clearcookie(); wp_setcookie($userdata['user_login'], $plaintext_pass); } } return $user_id; }
/** * Creates a new user with args passed through an array or string of arguments. * * wp_nonce_field( 'register' ) must be used on the register form * * @param: username [string] - The desired username for the new user * @param: email [string] - The desired email address for the new user * @param: use_password [bool] [default: false] - Whether to specify a password on registration * @param: password [string] - If use_password is true, the desired password for the new user * @param: use_tos [bool] [default: true] - Whether the user needs to accept Terms of Service * @param: tos [string] - If use_tos is true, the value to the accept Terms of Service checkbox * @param: unique_email [bool] [default: false] - Set to true if only one username is allowed per email address * @param: do_redirect [bool] [default: true] Whether to redirect the user after registration is complete * @param: redirect [string] [default: User Profile Page] - The url to redirect the user to after successful login * @param: send_email [bool] [default: true] Whether to send an email containing the username and password of the newly registered user * @param: profile_info [array] [dafault: false] An array containing values to be used in wp_update_user() such as first_name, last_name * @param: validate [bool] [default: true] * @param: require_verify_email [bool] [default: false] Sends the user an email with a Activate Account link to activate their account * @param: override_nonce [bool] [default: false] Bypasses the nonce check, not recommended in most situations * * @return: Int ID, the ID of the newly registered user [on error returns error string] or WP_Error */ function hma_new_user($args) { if (is_user_logged_in()) { hm_error_message('You are already logged in', 'register'); return new WP_Error('already-logged-in'); } $checks = array('use_password' => false, 'tos' => '', 'use_tos' => true, 'unique_email' => false, 'do_redirect' => true, 'do_login' => false, 'redirect' => '', 'send_email' => false, 'override_nonce' => false); $defaults = array('user_login' => '', 'user_email' => '', 'user_pass' => false, 'role' => 'subscriber', 'validate' => true); $original_args = $args; $default_args = array_merge($defaults, $checks); $args = wp_parse_args($args, $default_args); extract($args, EXTR_SKIP); $validation = apply_filters('hma_registration_info', $args); unset($args['user_pass2']); unset($original_args['user_pass2']); unset($user_pass2); if (is_wp_error($validation) && $validate == true) { return $validation; } // Merge arrays overwritting defaults, remove any non-standard keys keys with empty values. $user_vars = array_filter(array('user_login' => $user_login, 'user_pass' => $user_pass, 'user_email' => $user_email, 'display_name' => $display_name)); // Check for require_verify_email, send email and store temp data if ($require_verify_email) { $original_args['require_verify_email'] = false; $unverified_users = (array) get_option('unverified_users'); $unverified_users[time()] = $original_args; update_option('unverified_users', $unverified_users); $message = "Please click the link below to activate your account for " . get_bloginfo() . "\n \n"; $message .= '<a href="' . get_bloginfo('url') . '/login/?verify_email=' . $user_vars['user_email'] . '&key=' . time() . '">' . get_bloginfo('url') . '/login/?verify_email=' . $user_vars['user_email'] . '&key=' . time() . '</a>'; $headers = 'From: ' . get_bloginfo() . ' <noreply@' . get_bloginfo('url') . '>' . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n\r\n"; wp_mail($user_vars['user_email'], 'Please activate your account for ' . get_bloginfo(), $message, $headers); return hm_return_success('sent-email-activation', '<p class="message success">You have been sent an activation email, please follow the link in the email sent to ' . $user_vars['user_email'] . '</p>'); } $user_id = wp_insert_user($user_vars); if (!$user_id || is_wp_error($user_id)) { return $user_id; } // Setup the users role if ($role) { $user = new WP_User($user_id); $user->set_role($role); } // Get any remaining variable that were passed $meta_vars = array_diff_key($original_args, $defaults, $checks, $user_vars); foreach ((array) $meta_vars as $key => $value) { if (hma_is_profile_field($key) || !hma_custom_profile_fields()) { update_user_meta($user_id, $key, $value); } } $user = get_userdata($user_id); // Send Notifcation email if specified if ($send_email) { $email = hma_email_registration_success($user, $user_pass); } // If they chose a password, login them in if (($use_password == 'true' || $do_login == true) && !empty($user->ID)) { wp_login($user->user_login, $user_pass); wp_clearcookie(); wp_setcookie($user->user_login, $user_pass, false); do_action('wp_login', $user->user_login); wp_set_current_user($user->ID); } // Redirect the user if is set if ($redirect !== '' && !empty($user->ID) && $do_redirect == true) { wp_redirect($redirect); exit; } do_action('hma_registered_user', $user); return $user_id; }
function shipme_do_login_scr() { /*do_action( 'login_enqueue_scripts' ); do_action( 'login_head' ); do_action('login_footer'); */ global $wpdb, $error, $wp_query; if (!is_array($wp_query->query_vars)) { $wp_query->query_vars = array(); } $action = $_REQUEST['action']; $error = ''; nocache_headers(); header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset')); if (defined('RELOCATE')) { // Move flag is set if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) { $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); } $schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl')) { update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); } } do_action('login_init'); do_action('login_form_' . $action); switch ($_REQUEST["action"]) { //logout case "logout": wp_clearcookie(); if (get_option("jk_logout_redirect_to")) { $redirect_to = get_option("jk_logout_redirect_to"); } else { $redirect_to = "wp-login.php"; } do_action('wp_logout'); nocache_headers(); if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; } wp_redirect(get_bloginfo('siteurl')); exit; break; //lost lost password //lost lost password case 'lostpassword': case 'retrievepassword': $http_post = 'POST' == $_SERVER['REQUEST_METHOD']; if ($http_post) { $errors = my_retrieve_password(); if (!is_wp_error($errors)) { $redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; wp_safe_redirect($redirect_to); exit; } } if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) { $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'shipme')); } $redirect_to = apply_filters('lostpassword_redirect', !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); do_action('lost_password'); $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; global $real_ttl; $real_ttl = __("Retrieve Password", 'shipme'); add_filter('wp_title', 'shipme_sitemile_filter_ttl', 10, 3); get_header(); ?> <div class="container_ship_no_bk margin_top_40"> <ul class="virtual_sidebar"> <li class="widget-container widget_text"><h3 class="widget-title"><?php _e("Retrieve Password", 'shipme'); ?> - <?php echo get_bloginfo('name'); ?> </h3> <div class="my-only-widget-content "> <?php if (isset($errors) && isset($_POST['action'])) { ?> <div class="bam_bam"> <div class="error"> <ul> <?php $me = $errors->get_error_messages(); foreach ($me as $mm) { echo "<li>" . $mm . "</li>"; } ?> </ul> </div> </div> <?php } ?> <div class="login-submit-form"> <form name="lostpass" action="<?php echo esc_url(site_url('wp-login.php?action=lostpassword', 'login_post')); ?> " method="post" id="lostpass"> <p><?php _e('Please enter your information here. We will send you a new password.', 'shipme'); ?> </p> <?php if ($error) { echo "<div id='login_error'>{$error}</div>"; } ?> <input type="hidden" name="action" value="retrievepassword" /> <p> <label><?php _e('Mobile Number or Email:', 'shipme'); ?> </label> <input type="text" class="do_input" name="user_login" id="user_login" value="" size="30" tabindex="1" /> </p> <?php do_action('lostpassword_form'); ?> <p><label> </label> <a href="" class="submit_bottom2" onClick="document.getElementById('lostpass').submit(); return false;"><i class="fa fa-check-circle"></i> <?php _e('Retrieve Password', 'shipme'); ?> </a> </p> </form> </div> <ul id="logins"> <li><a class="green_btn" href="<?php echo esc_url(home_url()); ?> /" title="<?php _e('Are you lost?', 'shipme'); ?> ">« <?php _e('Home', 'shipme'); ?> </a></li> <?php if (get_settings('users_can_register')) { ?> <li><a class="green_btn" href="<?php echo esc_url(site_url()); ?> /wp-login.php?action=register"><?php _e('Register', 'shipme'); ?> </a></li> <?php } ?> <li><a class="green_btn" href="<?php echo esc_url(site_url()); ?> /wp-login.php"><?php _e('Login', 'shipme'); ?> </a></li> </ul> </div> </li> </ul> </div> <?php get_footer(); die; break; case 'retrievepassword2': global $real_ttl; $real_ttl = __("Retrieve Error", 'shipme'); add_filter('wp_title', 'shipme_sitemile_filter_ttl', 10, 3); get_header(); $user_data = get_userdatabylogin($_POST['user_login']); // redefining user_login ensures we return the right case in the email $user_login = $user_data->user_login; $user_email = $user_data->user_email; if (!$user_email || $user_email != $_POST['email']) { ?> <div class="my_box3 breadcrumb-wrap"> <div class="box_title"><?php _e("Retrieve Error", 'shipme'); ?> - <?php echo get_bloginfo('name'); ?> </div> <div class="box_content"> <br/><br/> <?php echo sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong Mobile Number or e-mail address? <a href="%s">Try again</a>.', 'shipme'), 'wp-login.php?action=lostpassword'); ?> <br/><br/> </div></div> <?php get_footer(); die; } do_action('retreive_password', $user_login); // Misspelled and deprecated. do_action('retrieve_password', $user_login); // Generate something random for a password... md5'ing current time with a rand salt $key = substr(md5(uniqid(current_time('timestamp', 0))), 0, 50); // now insert the new pass md5'd into the db $wpdb->query("UPDATE {$wpdb->users} SET user_activation_key = '{$key}' WHERE user_login = '******'"); $message = __('Someone has asked to reset the password for the following site and username.', 'shipme') . "\r\n\r\n"; $message .= get_option('siteurl') . "\r\n\r\n"; $message .= sprintf(__('Mobile Number: %s', 'shipme'), $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', 'shipme') . "\r\n\r\n"; $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key={$key}\r\n"; $m = wp_mail($user_email, sprintf(__('[%s] Password Reset', 'shipme'), get_settings('blogname')), $message); echo get_option("jk_login_after_head_html"); echo " <div id=\"login\">\n"; if ($m == false) { echo "<h1>" . __("There Was a Problem", 'shipme') . "</h1>"; echo '<p>' . __('The e-mail could not be sent.', 'shipme') . "<br />\n"; echo __('Possible reason: your host may have disabled the mail() function...', 'shipme') . "</p>"; } else { echo "<h1>Success!</h1>"; echo '<p>' . sprintf(__("The e-mail was sent successfully to %s's e-mail address.", 'shipme'), $user_login) . '<br />'; echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course', 'shipme') . "'>" . __('Click here to login!', 'shipme') . '</a></p>'; } echo " </div>\n"; echo '</div></div></div>'; get_footer(); die; break; //reset password //reset password case 'rp': global $real_ttl; $real_ttl = __("Key Not Valid", 'shipme'); add_filter('wp_title', 'shipme_sitemile_filter_ttl', 10, 3); get_header(); //_get_whole_menu(); echo '<div class="my_box3 breadcrumb-wrap"> <div class="padd10">'; echo " <div id=\"login\">\n"; // Generate something random for a password... md5'ing current time with a rand salt $key = preg_replace('/a-z0-9/i', '', $_GET['key']); if (empty($key)) { _e('<h1>Problem</h1>', 'shipme'); _e('Sorry, that key does not appear to be valid.', 'shipme'); echo " </div>\n"; echo '</div></td></tr></table></div></div>'; get_footer(); die; } $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_activation_key = '{$key}'"); if (!$user) { _e('<h1>Problem</h1>', 'shipme'); _e('Sorry, that key does not appear to be valid.', 'shipme'); echo " </div>\n"; echo '</div></div>'; get_footer(); die; } do_action('password_reset'); $new_pass = substr(md5(uniqid(current_time('timestamp', 0))), 0, 7); $wpdb->query("UPDATE {$wpdb->users} SET user_pass = MD5('{$new_pass}'), user_activation_key = '' WHERE user_login = '******'"); wp_cache_delete($user->ID, 'users'); wp_cache_delete($user->user_login, 'userlogins'); $message = sprintf(__('Mobile Number: %s', 'shipme'), $user->user_login) . "\r\n"; $message .= sprintf(__('Password: %s', 'shipme'), $new_pass) . "\r\n"; $message .= get_settings('siteurl') . "/wp-login.php\r\n"; $m = wp_mail($user->user_email, sprintf(__('[%s] Your new password', 'shipme'), get_settings('blogname')), $message); if ($m == false) { echo __('<h1>Problem</h1>', 'shipme'); echo '<p>' . __('The e-mail could not be sent.', 'shipme') . "<br />\n"; echo __('Possible reason: your host may have disabled the mail() function...', 'shipme') . '</p>'; } else { echo __('<h1>Success!</h1>', 'shipme'); echo '<p>' . sprintf(__('Your new password is in the mail.', 'shipme'), $user_login) . '<br />'; echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course', 'shipme') . "'>" . __('Click here to login!', 'shipme') . '</a></p>'; // send a copy of password change notification to the admin $message = sprintf(__('Password Lost and Changed for user: %s', 'shipme'), $user->user_login) . "\r\n"; wp_mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change', 'shipme'), get_settings('blogname')), $message); } echo " </div>\n"; echo '</div></div></div>'; get_footer(); die; break; //login and default action //login and default action case 'login': default: //check credentials - 99% of this is identical to the normal wordpress login sequence as of 2.0.4 //Any differences will be noted with end of line comments. $user_login = ''; $user_pass = ''; $using_cookie = false; /** * this is what the code was * if ( !isset( $_REQUEST['redirect_to'] ) ) * $redirect_to = 'wp-admin/'; * else * $redirect_to = $_REQUEST['redirect_to']; */ if (empty($_REQUEST['redirect_to'])) { $redirect_to = get_permalink(get_option('shipme_account_page_id')); } else { $redirect_to = $_REQUEST['redirect_to']; } if (empty($redirect_to)) { $redirect_to = get_permalink(get_option('shipme_account_page_id')); } //print_r($_REQUEST); // $redirect_to; //exit; if (isset($_SESSION['redirect_me_back'])) { $redirect_to = $_SESSION['redirect_me_back']; } if ($_POST) { $user_login = $_POST['log']; $user_login = sanitize_user($user_login); $user_pass = $_POST['pwd']; $rememberme = $_POST['rememberme']; } else { if (function_exists('wp_get_cookie_login')) { $cookie_login = wp_get_cookie_login(); if (!empty($cookie_login)) { $using_cookie = true; $user_login = $cookie_login['login']; $user_pass = $cookie_login['password']; } } elseif (!empty($_COOKIE)) { if (!empty($_COOKIE[USER_COOKIE])) { $user_login = $_COOKIE[USER_COOKIE]; } if (!empty($_COOKIE[PASS_COOKIE])) { $user_pass = $_COOKIE[PASS_COOKIE]; $using_cookie = true; } } } do_action('wp_authenticate', $user_login, $user_pass); if ($user_login && $user_pass) { $user = new WP_User(0, $user_login); // If the user can't edit posts, send them to their profile. //if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) ) // $redirect_to = get_settings('siteurl') . '/' . 'my-account'; if (wp_login($user_login, $user_pass, $using_cookie)) { if (!$using_cookie) { wp_setcookie($user_login, $user_pass, false, '', '', $rememberme); } do_action('wp_login', $user_login); wp_redirect($redirect_to); exit; } else { if ($using_cookie) { $error = __('Your session has expired.', 'shipme'); } } } else { if ($user_login || $user_pass) { $error = __('<strong>Error</strong>: The password field is empty.', 'shipme'); } } global $real_ttl; $real_ttl = __("Login", 'shipme'); add_filter('wp_title', 'shipme_sitemile_filter_ttl', 10, 3); get_header(); ?> <div class="container_ship_no_bk margin_top_40"> <ul class="virtual_sidebar"> <li class="widget-container widget_text"><h3 class="widget-title"><?php _e("Login", 'shipme'); ?> - <?php echo get_bloginfo('name'); ?> </h3> <div class="my-only-widget-content "> <?php if (isset($_GET['checkemail']) && $_GET['checkemail'] == "confirm") { ?> <div class="check-email-div"><div class="padd10"> <?php _e('We have sent a confirmation message to your email address.<br/> Please follow the instructions in the email and get back to this page.', 'shipme'); ?> </div></div> <?php } ?> <?php if (!empty($error)) { ?> <div class="bam_bam"><div class="error"><ul> <?php echo "<li>{$error}</li>"; ?> </ul> </div></div> <?php } ?> <div class="login-submit-form"> <form name="loginform" id="loginform" action="<?php echo esc_url(site_url('wp-login.php', 'login_post')); ?> " method="post"> <p><label><?php _e('Mobile Number:', 'shipme'); ?> </label> <input class="do_input" type="text" name="log" id="log" value="<?php echo esc_html(stripslashes($user_login), 1); ?> " size="30" /> </p> <p><label><?php _e('Password:'******'shipme'); ?> </label> <input class="do_input" type="password" name="pwd" id="login_password" value="" size="30" /> </p> <p><label> </label> <input class="do_input" name="rememberme" type="checkbox" id="rememberme" value="true" tabindex="3" /> <?php _e('Keep me logged in', 'shipme'); ?> </p> <?php do_action('login_form'); ?> <input type="hidden" name="testcookie" value="1" /> <p><label> </label> <a href="#" class="submit_bottom2" onClick="document.getElementById('loginform').submit();" ><i class="fa fa-check-circle"></i> <?php _e('Sign in', 'shipme'); ?> </a> <input type="hidden" name="redirect_to" value="<?php echo $_GET['redirect_to']; ?> " /> </p> </form> <ul id="logins"> <li><a class="green_btn" href="<?php echo esc_url(home_url()); ?> /" title="<?php _e('Are you lost?', 'shipme'); ?> ">« <?php _e('Home', 'shipme'); ?> </a></li> <?php if (get_settings('users_can_register')) { ?> <li><a class="green_btn" href="<?php echo esc_url(site_url()); ?> /wp-login.php?action=register"><?php _e('Register', 'shipme'); ?> </a></li> <?php } ?> <!-- <li><a class="green_btn" href="<?php //echo esc_url( site_url() ); ?> /wp-login.php?action=lostpassword" title="<?php //_e('Password Lost and Found','shipme') ?> "><?php _e('Lost your password?', 'shipme'); ?> </a></li>--> </ul> </div> </div> </li> </ul> </div> <?php get_footer(); die; break; } }
/** * Logout the user by removing their WRAP cookies * */ public function logout() { foreach (array_keys($_COOKIE) as $name) { if (preg_match('/^WRAP.*/',$name)) { // set the expiration date to one hour ago setcookie($name, "", time() - 3600, "/", "ncsu.edu"); } } wp_clearcookie(); nocache_headers(); header('Location:' . get_option('siteurl')); exit(); }
$error = ''; nocache_headers(); header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset')); if (defined('RELOCATE')) { // Move flag is set if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) { $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); } $schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl')) { update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); } } switch ($action) { case 'logout': wp_clearcookie(); do_action('wp_logout'); nocache_headers(); $redirect_to = 'wp-login.php'; if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; } wp_safe_redirect($redirect_to); exit; break; case 'lostpassword': do_action('lost_password'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
/** * Create a new WordPress user with the specified identity URL and user data. * * @param string $identity_url OpenID to associate with the newly * created account * @param array $user_data array of user data */ function openid_create_new_user($identity_url, &$user_data) { global $wpdb; // Identity URL is new, so create a user @include_once( ABSPATH . 'wp-admin/upgrade-functions.php'); // 2.1 @include_once( ABSPATH . WPINC . '/registration-functions.php'); // 2.0.4 // otherwise, try to use preferred username if ( empty($username) && array_key_exists('nickname', $user_data) ) { $username = openid_generate_new_username($user_data['nickname'], false); } // finally, build username from OpenID URL if (empty($username)) { $username = openid_generate_new_username($identity_url); } $user_data['user_login'] = $username; $user_data['user_pass'] = substr( md5( uniqid( microtime() ) ), 0, 7); $user_id = wp_insert_user( $user_data ); if( $user_id ) { // created ok $user_data['ID'] = $user_id; // XXX this all looks redundant, see openid_set_current_user $user = new WP_User( $user_id ); if( ! wp_login( $user->user_login, $user_data['user_pass'] ) ) { openid_message(__('User was created fine, but wp_login() for the new user failed. This is probably a bug.', 'openid')); openid_status('error'); openid_error(openid_message()); return; } // notify of user creation wp_new_user_notification( $user->user_login ); wp_clearcookie(); wp_setcookie( $user->user_login, md5($user->user_pass), true, '', '', true ); // Bind the provided identity to the just-created user openid_add_user_identity($user_id, $identity_url); openid_status('redirect'); if ( !$user->has_cap('edit_posts') ) $redirect_to = '/wp-admin/profile.php'; } else { // failed to create user for some reason. openid_message(__('OpenID authentication successful, but failed to create WordPress user. This is probably a bug.', 'openid')); openid_status('error'); openid_error(openid_message()); } }
/** * TT New User * Creates a new user with args passed through an array or string of arguments. Passing arguments works the same * as functions such as query_posts(). Params are show as variable names which you must use when passing args * NOTE: wp_nonce_field( 'register' ) must be used on the register form * * @Param: username [string] - The desired username for the new user * @Param: email [string] - The desired email address for the new user * @Param: use_password [bool] [default: false] - Whether to specify a password on registration * @Param: password [string] - If use_password is true, the desired password for the new user * @Param: use_tos [bool] [default: true] - Whether the user needs to accept Terms of Service * @Param: tos [string] - If use_tos is true, the value to the accept Terms of Service checkbox * @Param: unique_email [bool] [default: false] - Set to true if only one username is allowed per email address * @Param: do_redirect [bool] [default: true] Whether to redirect the user after registration is complete * @Param: redirect [string] [default: User Profile Page] - The url to redirect the user to after successful login * @Param: send_email [bool] [default: true] Whether to send an email containing the username and password of the newly registered user * @Param: profile_info [array] [dafault: false] An array containing values to be used in wp_update_user() such as first_name, last_name * @Param: validate [bool] [default: true] * @param: require_verify_email [bool] [default: false] Sends the user an email with a Activate Account link to activate their account * @param: override_nonce [bool] [default: false] Bypasses the nonce check, not recommended in most situations * @return: The ID of the newly registered user [on error returns error string] * @author: Joe Hoyle * @version 1.0 **/ function tja_new_user($args) { //Check the nonce field if ($args['override_nonce'] !== true) { check_admin_referer('register'); } if (is_user_logged_in()) { tj_error_message('You are already logged in', 'register'); return new WP_Error('already-logged-in'); } include_once ABSPATH . '/wp-includes/registration.php'; $checks = array('use_password' => false, 'tos' => '', 'use_tos' => true, 'unique_email' => false, 'do_redirect' => true, 'redirect' => '', 'send_email' => false); $defaults = array('user_login' => '', 'user_email' => '', 'user_pass' => false, 'role' => 'subscriber', 'validate' => true); $original_args = $args; $default_args = array_merge($defaults, $checks); //Strip any tags then may have been put into the array strip_tags((string) $args); $args = wp_parse_args($args, $default_args); extract($args, EXTR_SKIP); $validation = apply_filters('tja_registration_info', $args); unset($args['user_pass2']); unset($user_pass2); if ($validation['status'] === 'error' && $validate == true) { return $validation; } // Merge arrays overwritting defaults, remove any non-standard keys keys with empty values. $user_vars = array_filter(array_intersect_key(array_merge($defaults, $args), $defaults)); //Check for require_verify_email, send email and store temp data if ($require_verify_email) { $original_args['require_verify_email'] = false; $unverified_users = (array) get_option('unverified_users'); $unverified_users[time()] = $original_args; update_option('unverified_users', $unverified_users); $message = "Please click the link below to activate your account for " . get_bloginfo() . "\n \n"; $message .= '<a href="' . get_bloginfo('url') . '/login/?verify_email=' . $user_vars['user_email'] . '&key=' . time() . '">' . get_bloginfo('url') . '/login/?verify_email=' . $user_vars['user_email'] . '&key=' . time() . '</a>'; $headers = 'From: ' . get_bloginfo() . ' <noreply@' . get_bloginfo('url') . '>' . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n\r\n"; wp_mail($user_vars['user_email'], 'Please activate your account for ' . get_bloginfo(), $message, $headers); return tj_return_success('sent-email-activation', '<p class="message success">You have been sent an activation email, please follow the link in the email sent to ' . $user_vars['user_email'] . '</p>'); } $user_id = wp_insert_user($user_vars); if ($role) { $user = new WP_User($user_id); $user->set_role($role); } // Get any remaining variable that were passed $meta_vars = array_diff_key($original_args, $defaults, $checks); foreach ((array) $meta_vars as $key => $value) { update_usermeta($user_id, $key, $value); } $user = get_userdata($user_id); //Send Notifcation email if specified if ($send_email == true) { $email = tja_email_registration_success($user, $user_pass); } //If they chose a password, login them in if ($use_password == 'true' && $user->ID > 0) { wp_login($user->user_login, $user_pass); wp_clearcookie(); wp_setcookie($user->user_login, $user_pass, false); } //Redirect the user if is set if ($redirect !== '' && $user->ID && $do_redirect == true) { wp_redirect($redirect); } return $user_id; }
function ProjectTheme_do_login_scr() { global $wpdb, $error, $wp_query, $current_theme_locale_name; if (!is_array($wp_query->query_vars)) { $wp_query->query_vars = array(); } $action = $_REQUEST['action']; $error = ''; nocache_headers(); header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset')); if (defined('RELOCATE')) { // Move flag is set if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) { $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); } $schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl')) { update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); } } $secure = 'https' === parse_url(site_url(), PHP_URL_SCHEME) && 'https' === parse_url(home_url(), PHP_URL_SCHEME); setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure); if (SITECOOKIEPATH != COOKIEPATH) { setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure); } $http_post = 'POST' == $_SERVER['REQUEST_METHOD']; $interim_login = isset($_REQUEST['interim-login']); do_action('login_init'); do_action('login_form_' . $action); switch ($_REQUEST["action"]) { //logout case "logout": wp_clearcookie(); if (get_option("jk_logout_redirect_to")) { $redirect_to = get_option("jk_logout_redirect_to"); } else { $redirect_to = "wp-login.php"; } do_action('wp_logout'); nocache_headers(); if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; } wp_redirect(get_bloginfo('siteurl')); exit; break; //lost lost password //lost lost password case 'lostpassword': case 'retrievepassword': $http_post = 'POST' == $_SERVER['REQUEST_METHOD']; if ($http_post) { $errors = my_retrieve_password(); if (!is_wp_error($errors)) { $redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; wp_safe_redirect($redirect_to); exit; } } if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) { $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.')); } $redirect_to = apply_filters('lostpassword_redirect', !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); do_action('lost_password'); $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; get_header(); ?> <div class="page_heading_me"> <div class="page_heading_me_inner"> <div class="mm_inn"><?php printf(__("Retrieve Password - %s", $current_theme_locale_name), get_bloginfo('name')); ?> </div> </div> </div> <!-- ########## --> <div id="main_wrapper"> <div id="main" class="wrapper"><div class="padd10"> <div class="my_box3"> <div class="padd10"> <div class="box_content"> <div class="login-submit-form"> <form name="lostpass" action="<?php echo esc_url(site_url('wp-login.php?action=lostpassword', 'login_post')); ?> " method="post" id="loginform"> <p><?php _e('Please enter your information here. We will send you a new password.', $current_theme_locale_name); ?> </p> <?php if ($errors) { echo "<div class='errrs'>" . $errors->get_error_message() . "</div>"; } ?> <input type="hidden" name="action" value="retrievepassword" /> <p> <label><?php _e('Username or Email:', $current_theme_locale_name); ?> </label> <input type="text" class="do_input" name="user_login" id="user_login" value="" size="30" tabindex="1" /> </p> <?php do_action('lostpassword_form'); ?> <p><label> </label> <input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password', $current_theme_locale_name); ?> " class="submit_bottom" tabindex="3" /> </p> </form> </div> <ul id="logins"> <li><a href="<?php bloginfo('home'); ?> /" title="<?php _e('Are you lost?', $current_theme_locale_name); ?> ">« <?php _e('Home', $current_theme_locale_name); ?> </a></li> <?php if (get_settings('users_can_register')) { ?> <li><a href="<?php bloginfo('wpurl'); ?> /wp-login.php?action=register"><?php _e('Register', $current_theme_locale_name); ?> </a></li> <?php } ?> <li><a href="<?php bloginfo('wpurl'); ?> /wp-login.php"><?php _e('Login', $current_theme_locale_name); ?> </a></li> </ul> </div> </div> </div> </div></div></div> <?php get_footer(); die; break; case 'retrievepassword2': get_header(); $user_data = get_userdatabylogin($_POST['user_login']); // redefining user_login ensures we return the right case in the email $user_login = $user_data->user_login; $user_email = $user_data->user_email; if (!$user_email || $user_email != $_POST['email']) { ?> <div class="my_box3"> <div class="padd10"> <div class="box_title"><?php _e("Retrieve Error", $current_theme_locale_name); ?> - <?php echo get_bloginfo('name'); ?> </div> <div class="box_content"> <br/><br/> <?php echo sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? <a href="%s">Try again</a>.', $current_theme_locale_name), 'wp-login.php?action=lostpassword'); ?> <br/><br/> </div></div></div> <?php get_footer(); die; } do_action('retreive_password', $user_login); // Misspelled and deprecated. do_action('retrieve_password', $user_login); // Generate something random for a password... md5'ing current time with a rand salt $key = substr(md5(uniqid(current_time('timestamp', 0))), 0, 50); // now insert the new pass md5'd into the db $wpdb->query("UPDATE {$wpdb->users} SET user_activation_key = '{$key}' WHERE user_login = '******'"); $message = __('Someone has asked to reset the password for the following site and username.', $current_theme_locale_name) . "\r\n\r\n"; $message .= get_option('siteurl') . "\r\n\r\n"; $message .= sprintf(__('Username: %s', $current_theme_locale_name), $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', $current_theme_locale_name) . "\r\n\r\n"; $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key={$key}\r\n"; $m = ProjectTheme_send_email($user_email, sprintf(__('[%s] Password Reset', $current_theme_locale_name), get_settings('blogname')), $message); echo get_option("jk_login_after_head_html"); echo " <div id=\"login\">\n"; if ($m == false) { echo "<h1>" . __("There Was a Problem", $current_theme_locale_name) . "</h1>"; echo '<p>' . __('The e-mail could not be sent.', $current_theme_locale_name) . "<br />\n"; echo __('Possible reason: your host may have disabled the mail() function...', $current_theme_locale_name) . "</p>"; } else { echo "<h1>Success!</h1>"; echo '<p>' . sprintf(__("The e-mail was sent successfully to %s's e-mail address.", $current_theme_locale_name), $user_login) . '<br />'; echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course', $current_theme_locale_name) . "'>" . __('Click here to login!', $current_theme_locale_name) . '</a></p>'; } echo " </div>\n"; echo '</div></div></div>'; get_footer(); die; break; //reset password //reset password case 'rp': get_header(); //_get_whole_menu(); echo '<div class="my_box3"> <div class="padd10">'; echo " <div id=\"login\">\n"; // Generate something random for a password... md5'ing current time with a rand salt $key = preg_replace('/a-z0-9/i', '', $_GET['key']); if (empty($key)) { _e('<h1>Problem</h1>', $current_theme_locale_name); _e('Sorry, that key does not appear to be valid.', $current_theme_locale_name); echo " </div>\n"; echo '</div></td></tr></table></div></div>'; get_footer(); die; } $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_activation_key = '{$key}'"); if (!$user) { _e('<h1>Problem</h1>', $current_theme_locale_name); _e('Sorry, that key does not appear to be valid.', $current_theme_locale_name); echo " </div>\n"; echo '</div></div>'; get_footer(); die; } do_action('password_reset'); $new_pass = substr(md5(uniqid(current_time('timestamp', 0))), 0, 7); $wpdb->query("UPDATE {$wpdb->users} SET user_pass = MD5('{$new_pass}'), user_activation_key = '' WHERE user_login = '******'"); wp_cache_delete($user->ID, 'users'); wp_cache_delete($user->user_login, 'userlogins'); $message = sprintf(__('Username: %s', $current_theme_locale_name), $user->user_login) . "\r\n"; $message .= sprintf(__('Password: %s', $current_theme_locale_name), $new_pass) . "\r\n"; $message .= get_bloginfo('siteurl') . "/wp-login.php\r\n"; $m = wp_mail($user->user_email, sprintf(__('Your new password', $current_theme_locale_name)), $message); //ProjectTheme_send_email($user->user_email, sprintf(__('Your new password',$current_theme_locale_name) ), $message); if ($m == false) { echo __('<h1>Problem</h1>', $current_theme_locale_name); echo '<p>' . __('The e-mail could not be sent.', $current_theme_locale_name) . "<br />\n"; echo __('Possible reason: your host may have disabled the mail() function...', $current_theme_locale_name) . '</p>'; } else { echo __('<h1>Success!</h1>', $current_theme_locale_name); echo '<p>' . sprintf(__('Your new password is in the mail.', $current_theme_locale_name), $user_login) . '<br />'; echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course', $current_theme_locale_name) . "'>" . __('Click here to login!', $current_theme_locale_name) . '</a></p>'; // send a copy of password change notification to the admin $message = sprintf(__('Password Lost and Changed for user: %s', $current_theme_locale_name), $user->user_login) . "\r\n"; ProjectTheme_send_email(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change', $current_theme_locale_name), get_settings('blogname')), $message); } echo " </div>\n"; echo '</div></div></div>'; get_footer(); die; break; //login and default action //login and default action case 'login': default: //check credentials - 99% of this is identical to the normal wordpress login sequence as of 2.0.4 //Any differences will be noted with end of line comments. $user_login = ''; $user_pass = ''; $using_cookie = false; $secure_cookie = ''; if (!empty($_POST['log']) && !force_ssl_admin()) { $user_name = sanitize_user($_POST['log']); if ($user = get_user_by('login', $user_name)) { if (get_user_option('use_ssl', $user->ID)) { $secure_cookie = true; force_ssl_admin(true); } } } //------------------------------ if (empty($_GET['redirect_to'])) { $redirect_to = get_permalink(get_option('ProjectTheme_my_account_page_id')); if (empty($redirect_to)) { $redirect_to = admin_url(); } } else { $redirect_to = $_GET['redirect_to']; } if (isset($_SESSION['redirect_me_back'])) { $redirect_to = $_SESSION['redirect_me_back']; } //------------------------------------------ $reauth = empty($_REQUEST['reauth']) ? false : true; $user = wp_signon('', $secure_cookie); if (empty($_COOKIE[LOGGED_IN_COOKIE])) { if (headers_sent()) { $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>.'), __('https://codex.wordpress.org/Cookies'), __('https://wordpress.org/support/'))); } elseif (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) { // If cookies are disabled we can't log in even with a valid user+pass $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.'), __('https://codex.wordpress.org/Cookies'))); } } //-------------------------------------------- $requested_redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user); if (!is_wp_error($user) && !$reauth) { wp_safe_redirect($redirect_to); } get_header(); ?> <div class="page_heading_me"> <div class="page_heading_me_inner"> <div class="mm_inn"><?php printf(__("Login - %s", $current_theme_locale_name), get_bloginfo('name')); ?> </div> </div> </div> <!-- ########## --> <div id="main_wrapper"> <div id="main" class="wrapper"><div class="padd10"> <div class="my_box3"> <div class="padd10"> <div class="box_content"> <?php if (isset($_GET['checkemail']) && $_GET['checkemail'] == "confirm") { ?> <div class="check-email-div"><div class="padd10"> <?php _e('We have sent a confirmation message to your email address.<br/> Please follow the instructions in the email and get back to this page.', $current_theme_locale_name); ?> </div></div> <?php } $errors = $user; $errors = apply_filters('wp_login_errors', $errors, $redirect_to); if (empty($errors)) { $errors = new WP_Error(); } ?> <?php global $error; $wp_error = $errors; if (!empty($error)) { $wp_error->add('error', $error); unset($error); } if ($wp_error->get_error_code()) { $errors = ''; $messages = ''; foreach ($wp_error->get_error_codes() as $code) { $severity = $wp_error->get_error_data($code); foreach ($wp_error->get_error_messages($code) as $error_message) { if ('message' == $severity) { $messages .= ' ' . $error_message . "<br />\n"; } else { $errors .= ' ' . $error_message . "<br />\n"; } } } if (!empty($errors)) { /** * Filter the error messages displayed above the login form. * * @since 2.1.0 * * @param string $errors Login error message. */ echo '<div class="error">' . apply_filters('login_errors', $errors) . "</div>\n"; } if (!empty($messages)) { /** * Filter instructional messages displayed above the login form. * * @since 2.5.0 * * @param string $messages Login messages. */ echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n"; } } ?> <div class="login-submit-form"> <form name="loginform" id="loginform" action="<?php echo esc_url(site_url('wp-login.php', 'login_post')); ?> " method="post"> <p><label><?php _e('Username:'******'Password:'******'Keep me logged in', $current_theme_locale_name); ?> </p> <?php do_action('login_form'); ?> <p><label> </label> <input type="submit" class="submit_bottom" name="submits" id="submits" value="<?php _e('Sign in', $current_theme_locale_name); ?> " tabindex="4" /> <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($redirect_to); ?> " /> </p> </form> <ul id="logins"> <li><a class="green_btn" href="<?php bloginfo('home'); ?> /" title="<?php _e('Are you lost?', $current_theme_locale_name); ?> ">« <?php _e('Home', $current_theme_locale_name); ?> </a></li> <?php if (get_settings('users_can_register')) { ?> <li><a class="green_btn" href="<?php bloginfo('wpurl'); ?> /wp-login.php?action=register"><?php _e('Register', $current_theme_locale_name); ?> </a></li> <?php } ?> <li><a class="green_btn" href="<?php bloginfo('wpurl'); ?> /wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found', $current_theme_locale_name); ?> "><?php _e('Lost your password?', $current_theme_locale_name); ?> </a></li> </ul> </div> </div> </div> </div> </div> </div> </div> <?php get_footer(); die; break; } }
function do_wp_logout() { // // LOG OUT // ------------------------------ // used by login.php // No need to check for newly-created vars after this one, or use any globals, it's all too simple. if ($this->wpVersion >= 2.5) { wp_logout(); unset($_COOKIE[AUTH_COOKIE]); unset($_COOKIE[SECURE_AUTH_COOKIE]); unset($_COOKIE[LOGGED_IN_COOKIE]); } else { wp_clearcookie(); } do_action('wp_logout'); wp_set_current_user(0, 0); nocache_headers(); unset($_COOKIE[USER_COOKIE]); unset($_COOKIE[PASS_COOKIE]); }
/** * Create a new WordPress user with the specified identity URL and user data. * * @param string $identity_url OpenID to associate with the newly * created account * @param array $user_data array of user data */ function create_new_user($identity_url, &$user_data) { global $wpdb, $openid; // Identity URL is new, so create a user @(include_once ABSPATH . 'wp-admin/upgrade-functions.php'); // 2.1 @(include_once ABSPATH . WPINC . '/registration-functions.php'); // 2.0.4 // use email address for username if URL is from emailtoid.net $username = $identity_url; if (null != $_SESSION['openid_login_email'] and strpos($username, 'http://emailtoid.net/') == 0) { if ($user_data['user_email'] == NULL) { $user_data['user_email'] = $_SESSION['openid_login_email']; } $username = $_SESSION['openid_login_email']; unset($_SESSION['openid_login_email']); } $user_data['user_login'] = $wpdb->escape(WordPressOpenID_Logic::generate_new_username($username)); $user_data['user_pass'] = substr(md5(uniqid(microtime())), 0, 7); $user_id = wp_insert_user($user_data); $openid->log->debug("wp_create_user( {$user_data} ) returned {$user_id} "); if ($user_id) { // created ok $user_data['ID'] = $user_id; // XXX this all looks redundant, see WordPressOpenID_Logic::set_current_user $openid->log->debug("OpenIDConsumer: Created new user {$user_id} : " . $user_data['user_login'] . " and metadata: " . var_export($user_data, true)); $user = new WP_User($user_id); if (!wp_login($user->user_login, $user_data['user_pass'])) { $openid->message = 'User was created fine, but wp_login() for the new user failed. ' . 'This is probably a bug.'; $openid->action = 'error'; $openid->log->err($openid->message); return; } // notify of user creation wp_new_user_notification($user->user_login); wp_clearcookie(); wp_setcookie($user->user_login, md5($user->user_pass), true, '', '', true); // Bind the provided identity to the just-created user global $userdata; $userdata = get_userdata($user_id); $store = WordPressOpenID_Logic::getStore(); $store->insert_identity($user_id, $identity_url); $openid->action = 'redirect'; if (!$user->has_cap('edit_posts')) { $redirect_to = '/wp-admin/profile.php'; } } else { // failed to create user for some reason. $openid->message = 'OpenID authentication successful, but failed to create WordPress user. ' . 'This is probably a bug.'; $openid->action = 'error'; $openid->log->error($openid->message); } }
function update_home_siteurl( $old_value, $value ) { global $wp_rewrite, $user_login, $user_pass_md5; if ( defined( "WP_INSTALLING" ) ) return; // If home changed, write rewrite rules to new location. $wp_rewrite->flush_rules(); // Clear cookies for old paths. wp_clearcookie(); // Set cookies for new paths. wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); }
function single_user_login_uid_check() { global $wpdb; $ID = wp_get_current_user(); $logout_url = wp_logout_url(home_url()); $user_uni_uid = $_COOKIE["user_uni_uid" . $ID->user_login . ""]; $sql = "SELECT uni_hash FROM `wp_users` WHERE uni_hash='" . $user_uni_uid . "'"; $getinfo = $wpdb->get_results($sql); $check_time = $wpdb->get_results("SELECT session_time FROM `wp_users` WHERE user_login='******'"); if (!is_null($check_time)) { $time_result = $check_time[0]->session_time; } else { $time_result = time() - 2000; } if ($getinfo[0]->uni_hash != $user_uni_uid && time() - $time_result < 1800 && is_user_logged_in()) { wp_clearcookie(); myEndSession(); do_action('wp_logout'); nocache_headers(); $redirect_to = home_url(); wp_redirect($redirect_to); exit; } else { myStartSession(); if (!isset($_SESSION["LAST_ACTIVITY"])) { $_SESSION["LAST_ACTIVITY"] = time(); } elseif (time() - $_SESSION["LAST_ACTIVITY"] > 120) { $_SESSION["LAST_ACTIVITY"] = time(); } $new_time = $_SESSION["LAST_ACTIVITY"]; $sql = "UPDATE `wp_users` set `session_time`='" . $new_time . "' WHERE user_login='******'"; $wpdb->get_results($sql); } }
/** * Create a new WordPress user with the specified identity URL and user data. * * @param string $identity_url OpenID to associate with the newly * created account * @param array $user_data array of user data */ function openid_create_new_user($identity_url, &$user_data) { global $wpdb; // Identity URL is new, so create a user @(include_once ABSPATH . 'wp-admin/upgrade-functions.php'); // 2.1 @(include_once ABSPATH . WPINC . '/registration-functions.php'); // 2.0.4 // use email address for username if URL is from emailtoid.net $username = $identity_url; if (null != $_SESSION['openid_login_email'] and strpos($username, 'http://emailtoid.net/') == 0) { if ($user_data['user_email'] == NULL) { $user_data['user_email'] = $_SESSION['openid_login_email']; } $username = $_SESSION['openid_login_email']; unset($_SESSION['openid_login_email']); } $user_data['user_login'] = $wpdb->escape(openid_generate_new_username($username)); $user_data['user_pass'] = substr(md5(uniqid(microtime())), 0, 7); $user_id = wp_insert_user($user_data); if ($user_id) { // created ok $user_data['ID'] = $user_id; // XXX this all looks redundant, see openid_set_current_user $user = new WP_User($user_id); if (!wp_login($user->user_login, $user_data['user_pass'])) { openid_message(__('User was created fine, but wp_login() for the new user failed. This is probably a bug.', 'openid')); openid_action('error'); openid_error(openid_message()); return; } // notify of user creation wp_new_user_notification($user->user_login); wp_clearcookie(); wp_setcookie($user->user_login, md5($user->user_pass), true, '', '', true); // Bind the provided identity to the just-created user openid_add_user_identity($user_id, $identity_url); openid_status('redirect'); if (!$user->has_cap('edit_posts')) { $redirect_to = '/wp-admin/profile.php'; } } else { // failed to create user for some reason. openid_message(__('OpenID authentication successful, but failed to create WordPress user. This is probably a bug.', 'openid')); openid_status('error'); openid_error(openid_message()); } }
function wp_update_user($userdata) { global $wpdb, $wp_version; $ID = (int) $userdata['ID']; // First, get all of the original fields $user = get_userdata($ID); // Escape data pulled from DB. $user = add_magic_quotes(get_object_vars($user)); // If password is changing, hash it now. if (!empty($userdata['user_pass'])) { $plaintext_pass = $userdata['user_pass']; // NOTE BY JOHN WELLS -- IN WINTERMUTE VERSION BELOW IS UNCOMMENTED, BUT PHPBB WILL NOT BE PROVIDING // A PLAINTEXT PASSWORD HERE, SO THIS WILL NOT WORK || TODO: 20: TO CHECK HOW TO RECONCILE PASSWORDS, IF AT ALL //$userdata['user_pass'] = wp_hash_password($userdata['user_pass']); //[WP-UNITED CHANGED] } // Merge old and new fields with new fields overwriting old ones. $userdata = array_merge($user, $userdata); $user_id = wp_insert_user($userdata); // Update the cookies if the password changed. $current_user = wp_get_current_user(); if ($current_user->id == $ID) { if (isset($plaintext_pass)) { if ((double) $wp_version >= 2.5) { //new additions wp_clear_auth_cookie(); wp_set_auth_cookie($ID); } else { //old WP wp_clearcookie(); wp_setcookie($userdata['user_login'], $userdata['user_pass'], true, '', '', false); // wp_setcookie($userdata['user_login'], $plaintext_pass); [WP-UNITED CHANGED] } } } return $user_id; }
function create_new_user($identity_url, &$oid_user_data) { global $wpdb; // Identity URL is new, so create a user with md5()'d password @(include_once ABSPATH . 'wp-admin/upgrade-functions.php'); // 2.1 @(include_once ABSPATH . WPINC . '/registration-functions.php'); // 2.0.4 $oid_user_data['user_login'] = $wpdb->escape($this->generate_new_username($identity_url)); $oid_user_data['user_pass'] = substr(md5(uniqid(microtime())), 0, 7); $user_id = wp_insert_user($oid_user_data); $this->core->log->debug("wp_create_user( {$oid_user_data} ) returned {$user_id} "); if ($user_id) { // created ok $oid_user_data['ID'] = $user_id; $this->core->log->debug("OpenIDConsumer: Created new user {$user_id} : {$username} and metadata: " . var_export($oid_user_data, true)); $user = new WP_User($user_id); if (!wp_login($user->user_login, $oid_user_data['user_pass'])) { $this->error = 'User was created fine, but wp_login() for the new user failed. ' . 'This is probably a bug.'; $this->action = 'error'; $this->core->log->err($this->error); return; } // notify of user creation wp_new_user_notification($user->user_login); wp_clearcookie(); wp_setcookie($user->user_login, md5($user->user_pass), true, '', '', true); // Bind the provided identity to the just-created user global $userdata; $userdata = get_userdata($user_id); $this->store->insert_identity($identity_url); $this->action = 'redirect'; if (!$user->has_cap('edit_posts')) { $redirect_to = '/wp-admin/profile.php'; } } else { // failed to create user for some reason. $this->error = 'OpenID authentication successful, but failed to create WordPress user. ' . 'This is probably a bug.'; $this->action = 'error'; $this->core->log->error($this->error); } }
function ymind_ip_check() { get_currentuserinfo(); global $current_user; $path = ymind_get_filename($_SERVER['HTTP_REFERER']); if ($current_user->ID && $path != 'wp-login.php') { if (ymind_check_lockout()) { $lockout = get_option('ymind_lockout_option'); $send_email = get_option('ymind_email_offender'); if ($lockout == 1) { if ($send_email) { $value = 1; } else { $value = time(); } update_usermeta($current_user->ID, 'ymind_locked_out', $value); } if ($send_email == 1) { ymind_email_user(); } wp_clearcookie(); $url = get_option('ymind_redirect_url'); echo '<script>document.location="' . $url . '";</script>'; } } }