Make WordPress Core


Ignore:
Timestamp:
09/19/2006 06:11:42 AM (18 years ago)
Author:
matt
Message:

Options cleanup and some styling changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r4195 r4196  
    11<?php
    2 
    3 class retrospam_mgr {
    4     var $spam_words;
    5     var $comments_list;
    6     var $found_comments;
    7 
    8     function retrospam_mgr() {
    9         global $wpdb;
    10 
    11         $list = explode("\n", get_option('moderation_keys') );
    12         $list = array_unique( $list );
    13         $this->spam_words = $list;
    14 
    15         $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");
    16     }   // End of class constructor
    17 
    18     function move_spam( $id_list ) {
    19         global $wpdb;
    20         $cnt = 0;
    21         $id_list = explode( ',', $id_list );
    22 
    23         foreach ( $id_list as $comment ) {
    24             if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) {
    25                 $cnt++;
    26             }
    27         }
    28         echo "<div class='updated'><p> ";
    29         printf(__('%d comment(s) moved to the moderation queue.'), $cnt);
    30         echo "</p></div>\n";
    31     }   // End function move_spam
    32 
    33     function find_spam() {
    34         $in_queue = 0;
    35 
    36         foreach( $this->comment_list as $comment ) {
    37             if( $comment->approved == 1 ) {
    38                 foreach( $this->spam_words as $word ) {
    39                     $word = trim($word);
    40                     if ( empty( $word ) )
    41                         continue;
    42                     $fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text);
    43                     if( false !== strpos( $fulltext, strtolower($word) ) ) {
    44                         $this->found_comments[] = $comment->ID;
    45                         break;
    46                     }
    47                 }
    48             } else {
    49                 $in_queue++;
    50             }
    51         }
    52         return array( 'found' => $this->found_comments, 'in_queue' => $in_queue );
    53     }   // End function find_spam
    54 
    55     function display_edit_form( $counters ) {
    56         $numfound = count($counters[found]);
    57         $numqueue = $counters[in_queue];
    58 
    59         $body = '<p>' . sprintf(__('Suspected spam comments: %s'), "<strong>$numfound</strong>") . '</p>';
    60 
    61         if ( count($counters[found]) > 0 ) {
    62             $id_list = implode( ',', $counters[found] );
    63             $body .= '<p><a href="options-discussion.php?action=retrospam&amp;move=true&amp;ids='.$id_list.'">'. __('Move suspect comments to moderation queue &raquo;') . '</a></p>';
    64 
    65         }
    66         $head = '<div class="wrap"><h2>' . __('Check Comments Results:') . '</h2>';
    67 
    68         $foot .= '<p><a href="options-discussion.php">' . __('&laquo; Return to Discussion Options page.') . '</a></p></div>';
    69 
    70         return $head . $body . $foot;
    71     }   // End function display_edit_form
    72 
    73 }
    742
    753class WP {
Note: See TracChangeset for help on using the changeset viewer.