diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php index 0f1ba02dea..e45ff4bd99 100644 --- a/wp-admin/options-discussion.php +++ b/wp-admin/options-discussion.php @@ -40,6 +40,17 @@ for ($i=0; $ifind_spam(); + echo $retrospaminator->display_edit_form( $result ); + include('./admin-footer.php'); + exit; +} ?>
@@ -101,10 +112,13 @@ include('options-head.php');

' ) ?>

-

Common spam words.') ?>

+

Common spam words.') ?>

+

+ Check past comments against current word list +

diff --git a/wp-includes/classes.php b/wp-includes/classes.php index c2fa9da317..a5a3117882 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -560,4 +560,73 @@ if (! isset($wp_query)) { $wp_query = new WP_Query(); } -?> +class retrospam_mgr { + var $spam_words; + var $comments_list; + var $found_comments; + + function retrospam_mgr() { + global $wpdb; + + $list = explode("\n", get_settings('moderation_keys') ); + $list = array_unique( $list ); + $this->spam_words = $list; + + $this->comment_list = $wpdb->get_results("SELECT comment_ID AS ID, comment_content AS text, comment_approved AS approved, comment_author_url AS url, comment_author_ip AS ip, comment_author_email AS email FROM $wpdb->comments ORDER BY comment_ID ASC"); + } // End of class constructor + + function move_spam( $id_list ) { + global $wpdb; + $cnt = 0; + $id_list = explode( ',', $id_list ); + + foreach ( $id_list as $comment ) { + if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) { + $cnt++; + } + } + echo "

$cnt comment"; + if ($cnt != 1 ) echo "s"; + echo " moved to the moderation queue.

\n"; + } // End function move_spam + + function find_spam() { + $in_queue = 0; + + foreach( $this->comment_list as $comment ) { + if( $comment->approved == 1 ) { + foreach( $this->spam_words as $word ) { + $fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text); + if( strpos( $fulltext, strtolower(trim($word)) ) != FALSE ) { + $this->found_comments[] = $comment->ID; + break; + } + } + } else { + $in_queue++; + } + } + return array( 'found' => $this->found_comments, 'in_queue' => $in_queue ); + } // End function find_spam + + function display_edit_form( $counters ) { + $numfound = count($counters[found]); + $numqueue = $counters[in_queue]; + + $body = '

' . sprintf(__('Suspected spam comments: %s'), $numfound) . '

'; + + if ( count($counters[found]) > 0 ) { + $id_list = implode( ',', $counters[found] ); + $body .= '

'. __('Move suspect comments to moderation queue »') . '

'; + + } + $head = '

' . __('Check Comments Results:') . '

'; + + $foot .= '

' . __('« Return to Discussion Options page.') . '

'; + + return $head . $body . $foot; + } // End function display_edit_form + +} + +?> \ No newline at end of file