Changeset 2107
- Timestamp:
- 01/20/05 04:56:24 (4 years ago)
- Files:
-
- trunk/wp-admin/options.php (modified) (4 diffs)
- trunk/wp-admin/profile.php (modified) (1 diff)
- trunk/wp-includes/functions.php (modified) (1 diff)
- trunk/wp-includes/vars.php (modified) (1 diff)
- trunk/wp-login.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/options.php
r2067 r2107 28 28 29 29 case 'update': 30 $any_changed = 0;30 $any_changed = 0; 31 31 32 32 if (!$_POST['page_options']) { … … 40 40 41 41 $options = $wpdb->get_results("SELECT $wpdb->options.option_id, option_name, option_type, option_value, option_admin_level FROM $wpdb->options WHERE option_name IN ($option_names)"); 42 43 // Save for later. 44 $old_siteurl = get_settings('siteurl'); 45 $old_home = get_settings('home'); 42 46 43 47 // HACK … … 57 61 } 58 62 if( in_array($option->option_name, $nonbools) && $new_val == '0' ) $new_val = 'closed'; 59 if ($new_val !== $old_val) 63 if ($new_val !== $old_val) { 60 64 $result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'"); 65 $any_changed++; 66 } 61 67 } 62 68 } … … 66 72 67 73 if ($any_changed) { 68 $message = sprintf(__('%d setting(s) saved... '), $any_changed); 74 // If siteurl or home changed, reset cookies. 75 if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) { 76 // Get currently logged in user and password. 77 get_currentuserinfo(); 78 // Clear cookies for old paths. 79 wp_clearcookie(); 80 // Set cookies for new paths. 81 wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl')); 82 } 83 84 //$message = sprintf(__('%d setting(s) saved... '), $any_changed); 69 85 } 70 86 71 //$referred = str_replace('?updated=true' , '', $_SERVER['HTTP_REFERER']);72 87 $referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']); 73 //$goback = str_replace('?updated=true', '', $_SERVER['HTTP_REFERER']) . '?updated=true';74 88 $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']); 75 $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);89 $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); 76 90 header('Location: ' . $goback); 77 91 break; trunk/wp-admin/profile.php
r1998 r2107 63 63 $newuser_pass = $_POST["pass1"]; 64 64 $updatepassword = "user_pass=MD5('$newuser_pass'), "; 65 setcookie('wordpresspass_' . COOKIEHASH, " ", time() - 31536000, COOKIEPATH);66 setcookie('wordpresspass_' . COOKIEHASH, md5(md5($newuser_pass)), time() + 31536000, COOKIEPATH);65 wp_clearcookie(); 66 wp_setcookie($user_login, $newuser_pass); 67 67 } 68 68 trunk/wp-includes/functions.php
r2104 r2107 1629 1629 } 1630 1630 1631 function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') { 1632 if ( ! $already_md5) 1633 $password = md5(md5($password)); // Double hash the password in the cookie. 1634 1635 if (empty($home)) 1636 $cookiepath = COOKIEPATH; 1637 else 1638 $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' ); 1639 1640 if (empty($siteurl)) { 1641 $sitecookiepath = SITECOOKIEPATH; 1642 $cookiehash = COOKIEHASH; 1643 } else { 1644 $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' ); 1645 $cookiehash = md5($siteurl); 1646 } 1647 1648 setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath); 1649 setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath); 1650 1651 if ( $cookiepath != $sitecookiepath ) { 1652 setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath); 1653 setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath); 1654 } 1655 } 1656 1657 function wp_clearcookie() { 1658 setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); 1659 setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); 1660 setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); 1661 setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH); 1662 } 1663 1631 1664 ?> trunk/wp-includes/vars.php
r2068 r2107 114 114 // Path for cookies 115 115 define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) ); 116 define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) ); 116 117 117 118 // Some default filters trunk/wp-login.php
r2047 r2107 21 21 case 'logout': 22 22 23 setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); 24 setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH); 23 wp_clearcookie(); 25 24 header('Expires: Mon, 11 Jan 1984 05:00:00 GMT'); 26 25 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 27 26 header('Cache-Control: no-cache, must-revalidate, max-age=0'); 28 27 header('Pragma: no-cache'); 29 30 28 header('Location: wp-login.php'); 31 29 exit(); … … 135 133 if ( wp_login($user_login, $user_pass, $using_cookie) ) { 136 134 if (! $using_cookie) { 137 $user_pass = md5(md5($user_pass)); // Double hash the password in the cookie. 138 setcookie('wordpressuser_'. COOKIEHASH, $user_login, time() + 31536000, COOKIEPATH); 139 setcookie('wordpresspass_'. COOKIEHASH, $user_pass, time() + 31536000, COOKIEPATH); 135 wp_setcookie($user_login, $user_pass); 140 136 } 141 137
