New comment moderation code, for trackbacks and comments.

git-svn-id: http://svn.automattic.com/wordpress/trunk@984 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-03-21 08:31:33 +00:00
parent 76dd5c2562
commit adbca5d4fc
5 changed files with 24 additions and 27 deletions

View File

@ -113,7 +113,7 @@ if ($user_level <= 3) {
User must fill out name and email </label>
</li>
</ul>
<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>
<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>
<p>
<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%;"><?php echo get_settings('moderation_keys'); ?></textarea>
</p>

View File

@ -75,24 +75,19 @@ if (!empty($lasttime)) {
if ($ok) { // if there was no comment from this IP in the last 10 seconds
$comment_moderation = get_settings('comment_moderation');
$moderation_notify = get_settings('moderation_notify');
$comments_notify = get_settings('comments_notify');
// o42: this place could be the hook for further comment spam checking
// $approved should be set according the final approval status
// of the new comment
if ('manual' == $comment_moderation) {
$approved = 0;
} else if ('auto' == $comment_moderation) {
$approved = 0;
} else { // none
if(check_comment($author, $email, $url, $comment, $user_ip)) {
$approved = 1;
} else {
$approved = 0;
}
$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_approved)
(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
VALUES
('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '$approved')
('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '$approved')
");
$comment_ID = $wpdb->get_var('SELECT last_insert_id()');

View File

@ -71,16 +71,6 @@
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
</p>
<?php
if ('none' != get_settings("comment_moderation")) {
?>
<p>
<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.
</p>
<?php
} // comment_moderation != 'none'
?>
<p>
<input name="submit" type="submit" tabindex="5" value="Say it!" />
</p>

View File

@ -1564,4 +1564,18 @@ function get_posts($args) {
return $posts;
}
function check_comment($author, $email, $url, $comment, $user_ip) {
$words = explode("\n", get_settings('moderation_keys') );
foreach ($words as $word) {
$word = trim($word);
$pattern = "#$word#i";
if ( preg_match($pattern, $author) ) return false;
if ( preg_match($pattern, $email) ) return false;
if ( preg_match($pattern, $url) ) return false;
if ( preg_match($pattern, $comment) ) return false;
if ( preg_match($pattern, $user_ip) ) return false;
}
return true;
}
?>

View File

@ -66,12 +66,10 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u
$comment_moderation = get_settings('comment_moderation');
$moderation_notify = get_settings('moderation_notify');
if ('manual' == $comment_moderation) {
$approved = 0;
} else if ('auto' == $comment_moderation) {
$approved = 0;
} else { // none
if(check_comment($author, $email, $url, $comment, $user_ip)) {
$approved = 1;
} else {
$approved = 0;
}
$result = $wpdb->query("INSERT INTO $tablecomments