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:
parent
76dd5c2562
commit
adbca5d4fc
|
@ -113,7 +113,7 @@ if ($user_level <= 3) {
|
||||||
User must fill out name and email </label>
|
User must fill out name and email </label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</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>
|
<p>
|
||||||
<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%;"><?php echo get_settings('moderation_keys'); ?></textarea>
|
<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%;"><?php echo get_settings('moderation_keys'); ?></textarea>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -75,24 +75,19 @@ if (!empty($lasttime)) {
|
||||||
|
|
||||||
|
|
||||||
if ($ok) { // if there was no comment from this IP in the last 10 seconds
|
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');
|
$moderation_notify = get_settings('moderation_notify');
|
||||||
$comments_notify = get_settings('comments_notify');
|
$comments_notify = get_settings('comments_notify');
|
||||||
|
|
||||||
// o42: this place could be the hook for further comment spam checking
|
if(check_comment($author, $email, $url, $comment, $user_ip)) {
|
||||||
// $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
|
|
||||||
$approved = 1;
|
$approved = 1;
|
||||||
|
} else {
|
||||||
|
$approved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$wpdb->query("INSERT INTO $tablecomments
|
$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
|
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()');
|
$comment_ID = $wpdb->get_var('SELECT last_insert_id()');
|
||||||
|
|
|
@ -71,16 +71,6 @@
|
||||||
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
|
<textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
|
||||||
</p>
|
</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’s no need to resubmit your comment.
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
} // comment_moderation != 'none'
|
|
||||||
?>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<input name="submit" type="submit" tabindex="5" value="Say it!" />
|
<input name="submit" type="submit" tabindex="5" value="Say it!" />
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1564,4 +1564,18 @@ function get_posts($args) {
|
||||||
return $posts;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -66,12 +66,10 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u
|
||||||
$comment_moderation = get_settings('comment_moderation');
|
$comment_moderation = get_settings('comment_moderation');
|
||||||
$moderation_notify = get_settings('moderation_notify');
|
$moderation_notify = get_settings('moderation_notify');
|
||||||
|
|
||||||
if ('manual' == $comment_moderation) {
|
if(check_comment($author, $email, $url, $comment, $user_ip)) {
|
||||||
$approved = 0;
|
|
||||||
} else if ('auto' == $comment_moderation) {
|
|
||||||
$approved = 0;
|
|
||||||
} else { // none
|
|
||||||
$approved = 1;
|
$approved = 1;
|
||||||
|
} else {
|
||||||
|
$approved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $wpdb->query("INSERT INTO $tablecomments
|
$result = $wpdb->query("INSERT INTO $tablecomments
|
||||||
|
|
Loading…
Reference in New Issue