Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pluggable.php

    r17387 r17385  
    8282
    8383    if ( ! $user = wp_validate_auth_cookie() ) {
    84          if ( is_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
     84         if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
    8585            wp_set_current_user(0);
    8686            return false;
     
    672672        $secure = is_ssl();
    673673
     674    $secure = apply_filters('secure_auth_cookie', $secure, $user_id);
     675    $secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure);
     676
    674677    if ( $secure ) {
    675678        $auth_cookie_name = SECURE_AUTH_COOKIE;
     
    690693        setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
    691694        setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
    692         setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, false, true);
     695        setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
    693696        if ( COOKIEPATH != SITECOOKIEPATH )
    694             setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, false, true);
     697            setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
    695698    } else {
    696699        $cookie_domain = COOKIE_DOMAIN;
     
    699702        setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, $cookie_domain, $secure);
    700703        setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, $cookie_domain, $secure);
    701         setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, $cookie_domain);
     704        setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, $cookie_domain, $secure_logged_in_cookie);
    702705        if ( COOKIEPATH != SITECOOKIEPATH )
    703             setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, $cookie_domain);
     706            setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, $cookie_domain, $secure_logged_in_cookie);
    704707    }
    705708}
     
    764767
    765768    $secure = ( is_ssl() || force_ssl_admin() );
     769
     770    $secure = apply_filters('secure_auth_redirect', $secure);
    766771
    767772    // If https is required and request is http, redirect
     
    776781    }
    777782
    778     if ( $user_id = wp_validate_auth_cookie( '', apply_filters( 'auth_redirect_scheme', '' ) ) ) {
     783    if ( is_user_admin() )
     784        $scheme = 'logged_in';
     785    else
     786        $scheme = apply_filters( 'auth_redirect_scheme', '' );
     787
     788    if ( $user_id = wp_validate_auth_cookie( '',  $scheme) ) {
    779789        do_action('auth_redirect', $user_id);
    780790
     
    862872if ( !function_exists('wp_redirect') ) :
    863873/**
    864  * Redirects to another page, with a workaround for the IIS Set-Cookie bug.
    865  *
    866  * @link http://support.microsoft.com/kb/q176113/
     874 * Redirects to another page.
     875 *
    867876 * @since 1.5.1
    868877 * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
     
    883892    $location = wp_sanitize_redirect($location);
    884893
    885     if ( $is_IIS ) {
    886         header("Refresh: 0;url=$location");
    887     } else {
    888         if ( php_sapi_name() != 'cgi-fcgi' )
    889             status_header($status); // This causes problems on IIS and some FastCGI setups
    890         header("Location: $location", true, $status);
    891     }
     894    if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
     895        status_header($status); // This causes problems on IIS and some FastCGI setups
     896
     897    header("Location: $location", true, $status);
    892898}
    893899endif;
     
    10011007 * @return bool False if user email does not exist. True on completion.
    10021008 */
    1003 function wp_notify_postauthor($comment_id, $comment_type='') {
    1004     $comment = get_comment($comment_id);
    1005     $post    = get_post($comment->comment_post_ID);
    1006     $user    = get_userdata( $post->post_author );
    1007 
    1008     if ( $comment->user_id == $post->post_author ) return false; // The author moderated a comment on his own post
    1009 
    1010     if ('' == $user->user_email) return false; // If there's no email to send the comment to
     1009function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
     1010    $comment = get_comment( $comment_id );
     1011    $post    = get_post( $comment->comment_post_ID );
     1012    $author  = get_userdata( $post->post_author );
     1013
     1014    // The comment was left by the author
     1015    if ( $comment->user_id == $post->post_author )
     1016        return false;
     1017
     1018    // The author moderated a comment on his own post
     1019    if ( $post->post_author == get_current_user_id() )
     1020        return false;
     1021
     1022    // If there's no email to send the comment to
     1023    if ( '' == $author->user_email )
     1024        return false;
    10111025
    10121026    $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
     
    10241038        $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
    10251039        $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
    1026         $notify_message .= sprintf( __('Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
     1040        $notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
    10271041        $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    10281042        $notify_message .= __('You can see all comments on this post here: ') . "\r\n";
     
    10491063    }
    10501064    $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
     1065    $notify_message .= sprintf( __('Permalink: %s'), get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ) . "\r\n";
    10511066    if ( EMPTY_TRASH_DAYS )
    10521067        $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
     
    10771092    $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
    10781093
    1079     @wp_mail($user->user_email, $subject, $notify_message, $message_headers);
     1094    @wp_mail( $author->user_email, $subject, $notify_message, $message_headers );
    10801095
    10811096    return true;
     
    10961111    global $wpdb;
    10971112
    1098     if( get_option( "moderation_notify" ) == 0 )
     1113    if ( 0 == get_option( 'moderation_notify' ) )
    10991114        return true;
    11001115
    1101     $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID=%d LIMIT 1", $comment_id));
    1102     $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID=%d LIMIT 1", $comment->comment_post_ID));
     1116    $comment = get_comment($comment_id);
     1117    $post = get_post($comment->comment_post_ID);
     1118    $user = get_userdata( $post->post_author );
     1119    // Send to the administation and to the post author if the author can modify the comment.
     1120    $email_to = array( get_option('admin_email') );
     1121    if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )
     1122        $email_to[] = $user->user_email;
    11031123
    11041124    $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
     
    11311151            $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
    11321152            $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
    1133             $notify_message .= sprintf( __('Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
     1153            $notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
    11341154            $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    11351155            break;
     
    11481168
    11491169    $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
    1150     $admin_email = get_option('admin_email');
    11511170    $message_headers = '';
    11521171
     
    11551174    $message_headers = apply_filters('comment_moderation_headers', $message_headers);
    11561175
    1157     @wp_mail($admin_email, $subject, $notify_message, $message_headers);
     1176    foreach ( $email_to as $email )
     1177        @wp_mail($email, $subject, $notify_message, $message_headers);
    11581178
    11591179    return true;
     
    16471667    } else {
    16481668        if ( !empty($email) )
    1649             $host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash{0} ) % 2 ) );
     1669            $host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
    16501670        else
    16511671            $host = 'http://0.gravatar.com';
Note: See TracChangeset for help on using the changeset viewer.