Changeset 39125
- Timestamp:
- 04/08/08 04:46:12 (3 months ago)
- Files:
-
- worst-offenders/trunk/classes/all_litmus.php (modified) (1 diff)
- worst-offenders/trunk/classes/domain_litmus.php (modified) (1 diff)
- worst-offenders/trunk/classes/email_litmus.php (modified) (1 diff)
- worst-offenders/trunk/classes/ip_litmus.php (modified) (1 diff)
- worst-offenders/trunk/classes/litmus.php (modified) (3 diffs)
- worst-offenders/trunk/classes/md5_litmus.php (modified) (2 diffs)
- worst-offenders/trunk/classes/multilink_litmus.php (modified) (1 diff)
- worst-offenders/trunk/classes/obvious_name_litmus.php (modified) (2 diffs)
- worst-offenders/trunk/functions.php (modified) (5 diffs)
- worst-offenders/trunk/plugin.php (modified) (1 diff)
- worst-offenders/trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
worst-offenders/trunk/classes/all_litmus.php
r35685 r39125 15 15 add_action('wo3_tabs', array('AllLitmus', 'tab')); 16 16 add_action('wo3_content', array('AllLitmus', 'content')); 17 add_action('wo3_rollcall', array('AllLitmus', 'rollCall'));18 17 19 18 class AllLitmus extends Litmus { worst-offenders/trunk/classes/domain_litmus.php
r35682 r39125 43 43 function addIndex() { 44 44 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);"); 51 47 } 52 48 worst-offenders/trunk/classes/email_litmus.php
r35682 r39125 42 42 43 43 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);"); 47 45 } 48 46 worst-offenders/trunk/classes/ip_litmus.php
r35682 r39125 41 41 } 42 42 43 43 44 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 );"); 48 46 } 49 47 worst-offenders/trunk/classes/litmus.php
r35824 r39125 28 28 self::updateCount($name, $result); 29 29 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 } 30 40 } 31 41 … … 70 80 echo("<td>$num</td>"); 71 81 echo("<td>$reason_or_offender</td><td>"); 72 Litmus::link_to_comments($ids);82 self::link_to_comments($ids); 73 83 echo("</td></tr>"); 74 84 } … … 78 88 foreach( explode( ",", $comma_separated_list ) as $id ) { 79 89 $id = trim($id); 80 $link[] = "<a href='comment.php?action=editcomment&c=$id'>$id</a>";90 $link[] = self::link_to($id); 81 91 } 82 92 echo implode(", ",$link); 93 } 94 95 function link_to($id) { 96 return "<span class='spam' id='c$id' >$id</span>"; 83 97 } 84 98 } worst-offenders/trunk/classes/md5_litmus.php
r35682 r39125 24 24 global $keys; 25 25 $lower_limit = get_option( $keys['ui_vis'] ); 26 echo "\n<!-- ".self::getName().".getMatches() -->\n";27 26 return self::runCachedMatchesQuery( 28 27 self::getName(), … … 46 45 47 46 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 );"); 59 49 } 60 50 worst-offenders/trunk/classes/multilink_litmus.php
r35682 r39125 41 41 42 42 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) ) 48 47 RETURNS INTEGER 49 48 CONTAINS SQL DETERMINISTIC 50 49 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 "); 54 51 } 52 55 53 56 54 //============================================ worst-offenders/trunk/classes/obvious_name_litmus.php
r35825 r39125 18 18 19 19 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 );"); 23 21 } 24 22 … … 30 28 return self::runCachedMatchesQuery( 31 29 self::getName(), 32 "SELECT comment_author, comment_id FROM wp_comments where comment_approved='spam' and MATCH (comment_author) AGAINST ('xxx download debit c redit 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);" 33 31 ); 34 32 } worst-offenders/trunk/functions.php
r35823 r39125 83 83 function wo3_conf() { 84 84 if ( isset($_POST['submit']) ) { 85 $thing = preg_replace('/[^a-h0-9]/i', '', $_POST['thing']);86 // update_option('thing', $thing);87 85 echo '<div class="wrap">'; 88 86 do_action( "wo3_add_index" ); 89 echo '<p>Indexes added.</p>'; 90 echo '</div>'; 87 echo '<p>OK</p></div>'; 91 88 } 92 89 ?><title></title> … … 95 92 <div class="wrap"> 96 93 <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 »'); ?>" /></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 »'); ?>" /></p> 104 98 </form> 105 <h2><?php _e('Modules'); ?></h2>106 <?php do_action( "wo3_rollcall" ); ?>107 108 99 109 100 … … 118 109 global $wpdb, $wo3_title, $submenu; 119 110 $count = get_current_count(); 120 111 112 wp_enqueue_script('jquery'); 113 121 114 wo3_check_user_input(); 122 115 … … 163 156 } 164 157 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 165 188 </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 166 213 <?php 167 214 } … … 222 269 223 270 224 <form method="post" action=" <?php echo $submit_url; ?>">271 <form method="post" action=""> 225 272 <?php do_action( "wo3_content" ); ?> 226 273 <input type="hidden" name="act" value="delete" /> worst-offenders/trunk/plugin.php
r35837 r39125 10 10 11 11 $wo3_title="WorstOffenders"; 12 $submit_url = __FILE__;13 12 14 13 include("functions.php"); worst-offenders/trunk/readme.txt
r35838 r39125 51 51 == Screenshots == 52 52 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. 53 1. 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. 54 1. 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). 55 55 56 56 == To do ==
