Changeset 39125

Show
Ignore:
Timestamp:
04/08/08 04:46:12 (3 months ago)
Author:
ear1grey
Message:

Improved index creation.
Started migration to AJAX / JQuery based comment lookup (so click-to-lookup is now off).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • worst-offenders/trunk/classes/all_litmus.php

    r35685 r39125  
    1515      add_action('wo3_tabs', array('AllLitmus', 'tab')); 
    1616      add_action('wo3_content', array('AllLitmus', 'content')); 
    17       add_action('wo3_rollcall', array('AllLitmus', 'rollCall')); 
    1817 
    1918      class AllLitmus extends Litmus { 
  • worst-offenders/trunk/classes/domain_litmus.php

    r35682 r39125  
    4343            function addIndex() { 
    4444                  global $wpdb; 
    45                   echo("<p>Adding index and fucntion for URL addresses.</p>"); 
    46                   $wpdb->query("drop function if exists address;"); 
    47                   $wpdb->query("create FUNCTION address(url varchar(255)) RETURNS varchar(255) CONTAINS SQL DETERMINISTIC RETURN SUBSTRING_INDEX( TRIM( LEADING 'http://' FROM TRIM(url) ),'?',1);"); 
    48                   $wpdb->query("drop index if exists url_spotter;"); 
    49                   $wpdb->query("ALTER TABLE 'wp_comments' ADD INDEX 'url_spotter'('comment_author_url');"); 
    50                   echo("<p>Adding index to comment_author_url for Domain.</p>"); 
     45                  self::ensureIndex("create function address(url varchar(255)) RETURNS varchar(255) CONTAINS SQL DETERMINISTIC RETURN SUBSTRING_INDEX( TRIM( LEADING 'http://' FROM TRIM(url) ),'?',1);"); 
     46                  self::ensureIndex("alter table wp_comments ADD INDEX url_spotter (comment_author_url);"); 
    5147            } 
    5248 
  • worst-offenders/trunk/classes/email_litmus.php

    r35682 r39125  
    4242 
    4343            function addIndex() { 
    44                   global $wpdb; 
    45                   echo("<p>Adding index and fucntion for URL addresses.</p>"); 
    46                   $wpdb->query("ALTER TABLE 'wp_comments' ADD INDEX email_spotter'('comment_author_email');"); 
     44                  self::ensureIndex( "ALTER TABLE wp_comments ADD INDEX email_spotter (comment_author_email);"); 
    4745            } 
    4846 
  • worst-offenders/trunk/classes/ip_litmus.php

    r35682 r39125  
    4141            } 
    4242 
     43 
    4344            function addIndex() { 
    44                   global $wpdb; 
    45                   $q = "ALTER TABLE 'wp_comments' ADD INDEX 'ip_spotter'('comment_author_IP');"; 
    46                   $x = $wpdb->query($q); 
    47                   echo("<p>Adding index for IP addresses: $x.</p>"); 
     45                  self::ensureIndex("ALTER TABLE wp_comments ADD INDEX ip_spotter ( comment_author_IP );"); 
    4846            } 
    4947 
  • worst-offenders/trunk/classes/litmus.php

    r35824 r39125  
    2828            self::updateCount($name, $result); 
    2929            return $result; 
     30      } 
     31 
     32      function ensureIndex($q) { 
     33            global $wpdb; 
     34            $x = $wpdb->query($q); 
     35            if ( !empty($wpdb->error) ) { 
     36                  echo ("<p>Error (".mysql_errno()." - ".mysql_error()." - ".$wpdb->error->get_error_message().") doing $q</p>"); 
     37            } else { 
     38                  echo("<p>Done: $q</p>"); 
     39            } 
    3040      } 
    3141 
     
    7080                  echo("<td>$num</td>"); 
    7181                  echo("<td>$reason_or_offender</td><td>"); 
    72                   Litmus::link_to_comments($ids); 
     82                  self::link_to_comments($ids); 
    7383                  echo("</td></tr>"); 
    7484            } 
     
    7888            foreach( explode( ",", $comma_separated_list ) as $id ) { 
    7989                  $id = trim($id); 
    80                   $link[] = "<a href='comment.php?action=editcomment&c=$id'>$id</a>"
     90                  $link[] = self::link_to($id)
    8191            } 
    8292            echo implode(", ",$link); 
     93      } 
     94 
     95      function link_to($id) { 
     96            return "<span class='spam' id='c$id' >$id</span>"; 
    8397      } 
    8498} 
  • worst-offenders/trunk/classes/md5_litmus.php

    r35682 r39125  
    2424                  global $keys; 
    2525                  $lower_limit = get_option( $keys['ui_vis'] );  
    26                   echo "\n<!-- ".self::getName().".getMatches() -->\n"; 
    2726                  return self::runCachedMatchesQuery( 
    2827                        self::getName(), 
     
    4645 
    4746            function addIndex() { 
    48                   global $wpdb; 
    49                   $q = " 
    50                         ALTER TABLE 'wp_comments' ENGINE = MyISAM ROW_FORMAT = DYNAMIC; 
    51                         ALTER TABLE 'wp_comments' ADD FULLTEXT INDEX 'content_fulltext'('comment_content'); 
    52                         CREATE FUNCTION wordcount2 ( a text, b VARCHAR(255) ) 
    53                         RETURNS INTEGER 
    54                         CONTAINS SQL DETERMINISTIC 
    55                         RETURN (CHAR_LENGTH(a)-CHAR_LENGTH(REPLACE(a, b, '')))/CHAR_LENGTH(b); 
    56                   "; 
    57                   $wpdb->query($q); 
    58                   echo("<p>Adding index for MD5s.</p>"); 
     47                  self::ensureIndex("ALTER TABLE 'wp_comments' ENGINE = MyISAM ROW_FORMAT = DYNAMIC;"); 
     48                  self::ensureIndex("alter table wp_comments add fulltext index content_fulltext ( comment_content );"); 
    5949            } 
    6050 
  • worst-offenders/trunk/classes/multilink_litmus.php

    r35682 r39125  
    4141 
    4242            function addIndex() { 
    43                   global $wpdb; 
    44                   $q = " 
    45                         ALTER TABLE 'wp_comments' ENGINE = MyISAM ROW_FORMAT = DYNAMIC; 
    46                         ALTER TABLE 'wp_comments' ADD FULLTEXT INDEX 'content_fulltext'('comment_content'); 
    47                         CREATE FUNCTION wordcount2 ( a text, b VARCHAR(255) ) 
     43                  self::ensureIndex("ALTER TABLE 'wp_comments' ENGINE = MyISAM ROW_FORMAT = DYNAMIC;"); 
     44                  self::ensureIndex("ALTER TABLE wp_comments ADD FULLTEXT INDEX content_fulltext ( comment_content );"); 
     45                  self::ensureIndex( 
     46                        "CREATE FUNCTION wordcount2 ( a text, b VARCHAR(255) ) 
    4847                        RETURNS INTEGER 
    4948                        CONTAINS SQL DETERMINISTIC 
    5049                        RETURN (CHAR_LENGTH(a)-CHAR_LENGTH(REPLACE(a, b, '')))/CHAR_LENGTH(b); 
    51                   "; 
    52                   $wpdb->query($q); 
    53                   echo("<p>Adding index for MultiLinks.</p>"); 
     50                  "); 
    5451            } 
     52 
    5553 
    5654            //============================================ 
  • worst-offenders/trunk/classes/obvious_name_litmus.php

    r35825 r39125  
    1818 
    1919            function addIndex() { 
    20                   global $wpdb; 
    21                   echo("<p>Adding 'author_fulltext' index for the comment_author field.</p>"); 
    22                   $wpdb->query("ALTER TABLE wp_comments ADD FULLTEXT INDEX 'author_fulltext' (comment_author);"); 
     20                  self::ensureIndex("ALTER TABLE wp_comments ADD FULLTEXT INDEX author_fulltext ( comment_author );"); 
    2321            } 
    2422                   
     
    3028                  return self::runCachedMatchesQuery( 
    3129                        self::getName(), 
    32                         "SELECT comment_author, comment_id FROM wp_comments where comment_approved='spam' and MATCH (comment_author) AGAINST ('xxx download debit credit ringtone viagra cialis' IN BOOLEAN MODE);" 
     30                        "SELECT comment_author, comment_id FROM wp_comments where comment_approved='spam' and MATCH (comment_author) AGAINST ('xxx download debit casino credit ringtone viagra cialis payment consolidation poker holdem' IN BOOLEAN MODE);" 
    3331                  ); 
    3432            } 
  • worst-offenders/trunk/functions.php

    r35823 r39125  
    8383function wo3_conf()     { 
    8484      if ( isset($_POST['submit']) ) { 
    85             $thing = preg_replace('/[^a-h0-9]/i',     '',   $_POST['thing']); 
    86             // update_option('thing',     $thing); 
    8785            echo '<div class="wrap">'; 
    8886            do_action( "wo3_add_index" ); 
    89             echo '<p>Indexes added.</p>'; 
    90             echo '</div>'; 
     87            echo '<p>OK</p></div>'; 
    9188      } 
    9289?><title></title> 
     
    9592<div class="wrap"> 
    9693<h2><?php   _e($wo3_title.'   Configuration'); ?></h2> 
    97 <p><?php __('WO   Config explanation goes here.'); ?></p> 
    98  
    99 <form action=""   method="post"     id="wo-conf" style="margin:   auto; width: 25em; "> 
    100 <h3><label for="key"><?php _e('Blah'); ?></label></h3> 
    101 <p><input   id="key" name="key"     type="text" size="15"   maxlength="12" value="<?php   echo get_option('wo-thing'); ?>" style="font-family: 'Courier     New', Courier, mono; font-size:     1.5em;"     /> </p> 
    102 <p class="submit"><input class="button" type="submit" name="submit" value="<?php    _e('Update Options &raquo;'); ?>"   /></p> 
    103 <h2><?php   _e('Indexes'); ?></h2> 
     94<form action=""   method="post"     id="wo-conf" > 
     95<h3><label for="key"><?php _e('Indexes'); ?></label></h3> 
     96<!-- <p><input    id="key" name="key"     type="text" size="15"   maxlength="12" value="<?php   echo get_option('wo-thing'); ?>"/> </p> --> 
     97<p><input class="button" type="submit" name="submit" value="<?php _e('Add / Update Indexes &raquo;'); ?>"   /></p> 
    10498</form> 
    105 <h2><?php   _e('Modules'); ?></h2> 
    106 <?php do_action( "wo3_rollcall"     ); ?> 
    107  
    10899 
    109100 
     
    118109      global $wpdb,     $wo3_title, $submenu; 
    119110      $count = get_current_count(); 
    120        
     111 
     112      wp_enqueue_script('jquery'); 
     113 
    121114      wo3_check_user_input(); 
    122115       
     
    163156      } 
    164157 
     158      span.spam{ 
     159    position:relative; 
     160    z-index:24; 
     161    background-color:#fff; 
     162    color:#000; 
     163    text-decoration:none; 
     164    } 
     165 
     166      span.spam:hover{ 
     167            z-index:25; 
     168            background-color:#EEE; 
     169            } 
     170 
     171      span.spam span{ 
     172            display: none; 
     173            } 
     174 
     175      span.spam:hover span{ 
     176    display:block; 
     177    position:absolute; 
     178    top:1em; 
     179    left:1em; 
     180    width:20em; 
     181    border:1px solid #666; 
     182    background-color:#FFF; 
     183    color:#333; 
     184    margin:0em; 
     185    padding:1ex 2ex; 
     186    } 
     187 
    165188      </style> 
     189 
     190      <script type="text/javascript"> 
     191      //<![CDATA[ 
     192            function wibble(id) { 
     193              var elem = document.getElementById(id); 
     194                  while ( elem.hasChildNodes() ) { 
     195                              elem.removeChild(elem.firstChild); 
     196                  } 
     197                  var para = document.createElement('p'); 
     198                  var txt = document.createTextNode('wibble'); 
     199                  para.appendChild(txt); 
     200                  elem.appendChild(para); 
     201            } 
     202             
     203            $j=jQuery.noConflict(); 
     204 
     205            $j(document).ready(function(){ 
     206                  $('.spam').css('opacity', '0.5'); 
     207            }); 
     208 
     209             
     210      //]]> 
     211</script> 
     212 
    166213<?php 
    167214} 
     
    222269 
    223270 
    224 <form method="post"     action="<?php    echo $submit_url; ?>"> 
     271<form method="post"     action=""> 
    225272      <?php do_action( "wo3_content" );   ?> 
    226273      <input type="hidden" name="act"     value="delete" /> 
  • worst-offenders/trunk/plugin.php

    r35837 r39125  
    1010 
    1111$wo3_title="WorstOffenders"; 
    12 $submit_url = __FILE__; 
    1312 
    1413include("functions.php"); 
  • worst-offenders/trunk/readme.txt

    r35838 r39125  
    5151== Screenshots == 
    5252 
    53 1. Worst Offenders adds a tab to the Comments page showing how many of the currently queued spam comments it can delete. 
    54 1. Each separate spam litmus test provides a tab showing which messages have been identified using that test. 
     531. Worst Offenders adds a tab to the Comments page showing how many of the currently queued spam comments it can delete.  Here, Akismet has discovered 11 spam comments and Worst Offenders can delete 10 of them. 
     541. Each separate spam litmus test provides a tab showing which messages have been identified using that test.  Of 13 spam comments detected by Akismet, WorstOffenders can remove 12.  Of these twelve, 6 were identified because they came from a common IP address, 10 contain more than five links.  Note that there is an overlap in what the two tests discover, so the total number of deletions is 12, not 16 (i.e. the total is not 6+10).  
    5555 
    5656== To do ==