Make WordPress Core

Changeset 3902


Ignore:
Timestamp:
06/22/2006 08:52:12 PM (20 years ago)
Author:
ryan
Message:

wp_get_current_commenter()

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/classic/comments-popup.php

    r3517 r3902  
    3030<?php
    3131// this line is WordPress' motor, do not delete it.
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
     32$commenter = wp_get_current_commenter();
     33extract($commenter);
    3534$comments = get_approved_comments($id);
    3635$commentstatus = get_post($id);
  • trunk/wp-content/themes/default/comments-popup.php

    r3517 r3902  
    3030<?php
    3131// this line is WordPress' motor, do not delete it.
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
     32$commenter = wp_get_current_commenter();
     33extract($commenter);
    3534$comments = get_approved_comments($id);
    3635$post = get_post($id);
  • trunk/wp-includes/comment-template.php

    r3874 r3902  
    274274        global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
    275275
    276         if ( is_single() || is_page() || $withcomments ) :
    277                 $req = get_settings('require_name_email');
    278                 $comment_author = '';
    279                 if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
    280                         $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
    281                         $comment_author = stripslashes($comment_author);
    282                         $comment_author = wp_specialchars($comment_author, true);
    283                 }
    284                 $comment_author_email = '';
    285                 if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
    286                         $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
    287                         $comment_author_email = stripslashes($comment_author_email);
    288                         $comment_author_email = wp_specialchars($comment_author_email, true);           
    289                 }
    290                 $comment_author_url = '';
    291                 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
    292                         $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
    293                         $comment_author_url = stripslashes($comment_author_url);
    294                         $comment_author_url = wp_specialchars($comment_author_url, true);               
    295                 }
     276        if ( ! (is_single() || is_page() || $withcomments) )
     277                return;
     278
     279        $req = get_settings('require_name_email');
     280        $commenter = wp_get_current_commenter();
     281        extract($commenter);
    296282
    297283        // TODO: Use API instead of SELECTs.
     
    310296        else
    311297                require( ABSPATH . 'wp-content/themes/default/comments.php');
    312 
    313         endif;
    314298}
    315299
  • trunk/wp-includes/comment.php

    r3900 r3902  
    147147}
    148148
     149function sanitize_comment_cookies() {
     150        if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
     151                $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
     152                $comment_author = stripslashes($comment_author);
     153                $comment_author = wp_specialchars($comment_author, true);
     154                $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
     155        }
     156
     157        if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
     158                $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
     159                $comment_author_email = stripslashes($comment_author_email);
     160                $comment_author_email = wp_specialchars($comment_author_email, true);   
     161                $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
     162        }
     163
     164        if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
     165                $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
     166                $comment_author_url = stripslashes($comment_author_url);
     167                $comment_author_url = wp_specialchars($comment_author_url, true);
     168                $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
     169        }
     170}
     171
    149172function wp_allow_comment($commentdata) {
    150173        global $wpdb;
     
    274297                return false;
    275298        }
     299}
     300
     301function wp_get_current_commenter() {
     302        // Cookies should already be sanitized.
     303
     304        $comment_author = '';
     305        if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
     306                $comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
     307
     308        $comment_author_email = '';
     309        if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
     310                $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
     311
     312        $comment_author_url = '';
     313        if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
     314                $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
     315
     316        return compact('comment_author', 'comment_author_email', 'comment_author_url');
    276317}
    277318
  • trunk/wp-includes/default-filters.php

    r3831 r3902  
    128128add_action('do_pings', 'do_all_pings', 10, 1);
    129129add_action('do_robots', 'do_robots');
     130add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
    130131?>
  • trunk/wp-settings.php

    r3893 r3902  
    205205$_SERVER = add_magic_quotes($_SERVER);
    206206
     207do_action('sanitize_comment_cookies');
     208
    207209$wp_query   = new WP_Query();
    208210$wp_rewrite = new WP_Rewrite();
Note: See TracChangeset for help on using the changeset viewer.