Make WordPress Core

Changeset 984


Ignore:
Timestamp:
03/21/2004 08:31:33 AM (22 years ago)
Author:
saxmatt
Message:

New comment moderation code, for trackbacks and comments.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-discussion.php

    r970 r984  
    114114                        </li>
    115115                </ul>
    116                 <p>When a comment contains any of these words in its content, name, URI, or email, hold it in the moderation queue: (Seperate multiple words with new lines.)</p>
     116                <p>When a comment contains any of these words in its content, name, URI,  email, or IP, hold it in the moderation queue: (Seperate multiple words with new lines.) <a href="http://wiki.wordpress.org/index.php/SpamWords">Common spam words</a>.</p>
    117117                <p>
    118118                        <textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%;"><?php echo get_settings('moderation_keys'); ?></textarea>
  • trunk/wp-comments-post.php

    r956 r984  
    7676
    7777if ($ok) { // if there was no comment from this IP in the last 10 seconds
    78         $comment_moderation = get_settings('comment_moderation');
    7978        $moderation_notify = get_settings('moderation_notify');
    8079        $comments_notify = get_settings('comments_notify');
    8180
    82         // o42: this place could be the hook for further comment spam checking
    83         // $approved should be set according the final approval status
    84         // of the new comment
    85         if ('manual' == $comment_moderation) {
     81        if(check_comment($author, $email, $url, $comment, $user_ip)) {
     82                $approved = 1;
     83        } else {
    8684                $approved = 0;
    87         } else if ('auto' == $comment_moderation) {
    88                 $approved = 0;
    89         } else { // none
    90                 $approved = 1;
    9185        }
     86
    9287        $wpdb->query("INSERT INTO $tablecomments
    93         (comment_ID, comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
     88        (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
    9489        VALUES
    95         ('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '$approved')
     90        ('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '$approved')
    9691        ");
    9792
  • trunk/wp-comments.php

    r945 r984  
    7272        </p>
    7373
    74 <?php
    75 if ('none' != get_settings("comment_moderation")) {
    76 ?>
    77         <p>
    78         <strong>Please note:</strong> Comment moderation is currently enabled so there may be a delay between when you post your comment and when it shows up. Patience is a virtue; there&#8217;s no need to resubmit your comment.
    79         </p>
    80 <?php
    81 } // comment_moderation != 'none'
    82 ?>
    83 
    8474        <p>
    8575          <input name="submit" type="submit" tabindex="5" value="Say it!" />
  • trunk/wp-includes/functions.php

    r982 r984  
    15651565}
    15661566
     1567function check_comment($author, $email, $url, $comment, $user_ip) {
     1568        $words = explode("\n", get_settings('moderation_keys') );
     1569        foreach ($words as $word) {
     1570        $word = trim($word);
     1571        $pattern = "#$word#i";
     1572                if ( preg_match($pattern, $author) ) return false;
     1573                if ( preg_match($pattern, $email) ) return false;
     1574                if ( preg_match($pattern, $url) ) return false;
     1575                if ( preg_match($pattern, $comment) ) return false;
     1576                if ( preg_match($pattern, $user_ip) ) return false;
     1577        }
     1578return true;
     1579}
     1580
    15671581?>
  • trunk/wp-trackback.php

    r957 r984  
    6767        $moderation_notify = get_settings('moderation_notify');
    6868
    69         if ('manual' == $comment_moderation) {
     69        if(check_comment($author, $email, $url, $comment, $user_ip)) {
     70                $approved = 1;
     71        } else {
    7072                $approved = 0;
    71         } else if ('auto' == $comment_moderation) {
    72                 $approved = 0;
    73         } else { // none
    74                 $approved = 1;
    7573        }
    7674
Note: See TracChangeset for help on using the changeset viewer.