Ticket #7001: admin_ssl-1.diff
| File admin_ssl-1.diff, 8.1 KB (added by , 18 years ago) |
|---|
-
wp-includes/functions.php
1765 1765 return 0; 1766 1766 } 1767 1767 1768 function is_ssl() { 1769 return ( 'on' == $_SERVER['HTTPS'] ) ? true : false; 1770 } 1768 1771 ?> -
wp-includes/link-template.php
774 774 775 775 return apply_filters('shortcut_link', $link); 776 776 } 777 778 // return the site_url option, using https if is_ssl() is true 779 // if $scheme is 'http' or 'https' it will override is_ssl() 780 function site_url($scheme = null) { 781 // should the list of allowed schemes be maintained elsewhere? 782 if ( !in_array($scheme, array('http', 'https')) ) 783 $scheme = ( is_ssl() ? 'https' : 'http' ); 784 785 return str_replace( 'http://', "{$scheme}://", get_option('siteurl') ); 786 } 787 788 function admin_url($path = '') { 789 global $_wp_admin_url; 790 791 $url = site_url() . '/wp-admin/'; 792 793 if ( !empty($path) ) 794 $url .= ltrim($path, '/'); 795 796 return $url; 797 } 798 799 function includes_url($path = '') { 800 global $_wp_includes_url; 801 802 $url = site_url() . '/' . WPINC . '/'; 803 804 if ( !empty($path) ) 805 $url .= ltrim($path, '/'); 806 807 return $url; 808 } 809 777 810 ?> -
wp-includes/general-template.php
1136 1136 $_file = $color->url; 1137 1137 $_file = ('css/colors-rtl' == $file) ? str_replace('.css','-rtl.css',$_file) : $_file; 1138 1138 } else { 1139 $_file = get_option( 'siteurl' ) . "/wp-admin/$file.css";1139 $_file = admin_url("$file.css"); 1140 1140 } 1141 1141 } 1142 1142 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); -
wp-includes/pluggable.php
469 469 */ 470 470 function wp_validate_auth_cookie($cookie = '') { 471 471 if ( empty($cookie) ) { 472 if ( empty($_COOKIE[AUTH_COOKIE]) ) 472 if ( is_ssl() ) 473 $cookie_name = SECURE_AUTH_COOKIE; 474 else 475 $cookie_name = AUTH_COOKIE; 476 477 if ( empty($_COOKIE[$cookie_name]) ) 473 478 return false; 474 $cookie = $_COOKIE[ AUTH_COOKIE];479 $cookie = $_COOKIE[$cookie_name]; 475 480 } 476 481 477 482 $cookie_elements = explode('|', $cookie); … … 514 519 * 515 520 * @param int $user_id User ID 516 521 * @param int $expiration Cookie expiration in seconds 522 * @param bool $secure Whether the cookie is for https delivery only or not. Not used by default. For plugin use. 517 523 * @return string Authentication cookie contents 518 524 */ 519 function wp_generate_auth_cookie($user_id, $expiration ) {525 function wp_generate_auth_cookie($user_id, $expiration, $secure = false) { 520 526 $user = get_userdata($user_id); 521 527 522 528 $key = wp_hash($user->user_login . '|' . $expiration); … … 524 530 525 531 $cookie = $user->user_login . '|' . $expiration . '|' . $hash; 526 532 527 return apply_filters('auth_cookie', $cookie, $user_id, $expiration );533 return apply_filters('auth_cookie', $cookie, $user_id, $expiration, $secure); 528 534 } 529 535 endif; 530 536 … … 550 556 $expire = 0; 551 557 } 552 558 553 $cookie = wp_generate_auth_cookie($user_id, $expiration); 559 if ( is_ssl() ) { 560 $secure = true; 561 $cookie_name = SECURE_AUTH_COOKIE; 562 } else { 563 $secure = false; 564 $cookie_name = AUTH_COOKIE; 565 } 554 566 555 do_action('set_auth_cookie', $cookie, $expire);567 $cookie = wp_generate_auth_cookie($user_id, $expiration, $secure); 556 568 557 setcookie(AUTH_COOKIE, $cookie, $expire, COOKIEPATH, COOKIE_DOMAIN); 569 do_action('set_auth_cookie', $cookie, $expire, $secure); 570 571 setcookie($cookie_name, $cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure); 558 572 if ( COOKIEPATH != SITECOOKIEPATH ) 559 setcookie( AUTH_COOKIE, $cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN);573 setcookie($cookie_name, $cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure); 560 574 } 561 575 endif; 562 576 … … 569 583 function wp_clear_auth_cookie() { 570 584 setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); 571 585 setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); 586 setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); 587 setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); 572 588 573 589 // Old cookies 574 590 setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); … … 604 620 */ 605 621 function auth_redirect() { 606 622 // Checks if a user is logged in, if not redirects them to the login page 607 if ( (!empty($_COOKIE[AUTH_COOKIE]) &&608 !wp_validate_auth_cookie($_COOKIE[AUTH_COOKIE])) ||609 (empty($_COOKIE[AUTH_COOKIE])) ) {610 nocache_headers();611 623 612 wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); 613 exit(); 624 if ( is_ssl() || (defined('FORCE_HTTPS_LOGIN') && FORCE_HTTPS_LOGIN) ) 625 $secure = true; 626 else 627 $secure = false; 628 629 // If https is required and request is http, redirect 630 if ( $secure && !is_ssl() ) { 631 if ( false !== strpos($_SERVER['REQUEST_URI'], 'http') ) { 632 wp_redirect(str_replace('http://', 'https://', $_SERVER['REQUEST_URI'])); 633 exit(); 634 } else { 635 wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 636 exit(); 637 } 614 638 } 639 640 if ( wp_validate_auth_cookie() ) 641 return; // The cookie is good so we're done 642 643 // The cookie is no good so force login 644 nocache_headers(); 645 646 $login_url = get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']); 647 648 // Redirect to https if connection is secure 649 if ( $secure ) 650 $login_url = str_replace('http://', 'https://', $login_url); 651 wp_redirect($login_url); 652 exit(); 615 653 } 616 654 endif; 617 655 -
wp-includes/script-loader.php
137 137 $this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' ); 138 138 $this->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080128' ); 139 139 $this->localize( 'postbox', 'postboxL10n', array( 140 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',140 'requestFile' => admin_url('admin-ajax.php'), 141 141 ) ); 142 142 $this->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20080208' ); 143 143 $this->localize( 'slug', 'slugL10n', array( 144 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',144 'requestFile' => admin_url('admin-ajax.php'), 145 145 'save' => __('Save'), 146 146 'cancel' => __('Cancel'), 147 147 ) ); -
wp-settings.php
307 307 308 308 /** 309 309 * It is possible to define this in wp-config.php 310 * @since 2.6 311 */ 312 if ( !defined('SECURE_AUTH_COOKIE') ) 313 define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH); 314 315 /** 316 * It is possible to define this in wp-config.php 310 317 * @since 2.3.0 311 318 */ 312 319 if ( !defined('TEST_COOKIE') ) -
wp-admin/admin.php
26 26 27 27 wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback')); 28 28 29 wp_admin_css_color('classic', __('Classic'), get_option( 'siteurl' ) . "/wp-admin/css/colors-classic.css", array('#07273E', '#14568A', '#D54E21', '#2683AE'));30 wp_admin_css_color('fresh', __('Fresh'), get_option( 'siteurl' ) . "/wp-admin/css/colors-fresh.css", array('#464646', '#CEE1EF', '#D54E21', '#2683AE'));29 wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"), array('#07273E', '#14568A', '#D54E21', '#2683AE')); 30 wp_admin_css_color('fresh', __('Fresh'), admin_url("css/colors-fresh.css"), array('#464646', '#CEE1EF', '#D54E21', '#2683AE')); 31 31 32 32 wp_enqueue_script( 'common' ); 33 33 wp_enqueue_script( 'jquery-color' );