Make WordPress Core


Ignore:
Timestamp:
11/12/2003 03:22:47 PM (23 years ago)
Author:
emc3
Message:

otaku42's comment moderation patches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2comments.post.php

    r524 r546  
    8383
    8484if ($ok) { // if there was no comment from this IP in the last 10 seconds
     85        $comment_moderation = get_settings("comment_moderation");
     86        $moderation_notify = get_settings("moderation_notify");
     87       
     88        // o42: this place could be the hook for further comment spam checking
     89        // $approved should be set according the final approval status
     90        // of the new comment
     91        if ('manual' == $comment_moderation) {
     92                $approved = 0;
     93        } else if ('auto' == $comment_moderation) {
     94                $approved = 0;
     95        } else { // none
     96                $approved = 1;
     97        }
     98        $wpdb->query("INSERT INTO $tablecomments (comment_ID,comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content,comment_karma,comment_approved) VALUES ('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '0', '$approved')");
    8599
    86         $wpdb->query("INSERT INTO $tablecomments VALUES ('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '0')");
     100        // o42: this should be changed as soon as other sql dbs are supported
     101        // as it's proprietary to mysql
    87102        $comment_ID = $wpdb->get_var("SELECT last_insert_id()");
    88103
    89         if ($comments_notify) {
    90                 $postdata = get_postdata($comment_post_ID);
    91                 $authordata = get_userdata($postdata['Author_ID']);
    92 
    93                 if('' != $authordata->user_email) {
    94                         $notify_message  = "New comment on your post #$comment_post_ID \"".stripslashes($postdata['Title'])."\"\r\n\r\n";
    95                         $notify_message .= "Author : $comment_author (IP: $user_ip , $user_domain)\r\n";
    96                         $notify_message .= "E-mail : $comment_author_email\r\n";
    97                         $notify_message .= "URL    : $comment_author_url\r\n";
    98                         $notify_message .= "Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=$user_ip\r\n";
    99                         $notify_message .= "Delete : $siteurl/wp-admin/wp-post.php?action=deletecomment&p=$comment_post_ID&comment=$comment_ID \r\n";
    100                         $notify_message .= "Comment:\r\n".stripslashes($original_comment)."\r\n\r\n";
    101                         $notify_message .= "You can see all comments on this post here: \r\n";
    102                         $notify_message .= $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$comment_post_ID.$querystring_separator.'c'.$querystring_equal.'1#comments';
    103 
    104                         $subject = '[' . stripslashes($blogname) . '] Comment: "' .stripslashes($postdata['Title']).'"';
    105 
    106                         if ('' != $comment_author_email) {
    107                                 $from = "From: \"$comment_author\" <$comment_author_email>\r\n";
    108                                 } else {
    109                                 $from = 'From: "' . stripslashes($comment_author) . "\" <$authordata->user_email>\r\n";
    110                                 }
    111                         $from .= "X-Mailer: WordPress $b2_version with PHP/" . phpversion();
    112 
    113                         @mail($authordata->user_email, $subject, $notify_message, $from);
    114                 }
     104        $fp = fopen("/tmp/wpdebug.txt", "w+");
     105        fwrite($fp, "comment_moderation: $comment_moderation\n");
     106        fwrite($fp, "moderation_notify : $moderation_notify\n");
     107       
     108        if (($moderation_notify) && (!$approved)) {
     109            wp_notify_moderator($comment_ID);
     110            fwrite($fp, "notify moderator -> $comment_ID\n");
    115111        }
     112       
     113        if (($comment_notify) && ($approved)) {
     114            wp_notify_postauthor($comment_ID);
     115            fwrite($fp, "notify postauthor -> $comment_ID\n");
     116        }
     117       
     118        fclose($fp);
    116119
    117120        if ($email == '')
    … …  
    125128        setcookie('comment_author_url_'.$cookiehash, $url, time()+30000000);
    126129
    127         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    128         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     130        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     131        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    129132        header('Cache-Control: no-cache, must-revalidate');
    130133        header('Pragma: no-cache');
Note: See TracChangeset for help on using the changeset viewer.