Changeset 44627

Show
Ignore:
Timestamp:
05/07/08 05:17:09 (2 months ago)
Author:
ear1grey
Message:

Improved obvious word matching. Previous version used strpos which worked on substrings, so it could cause errors (e.g. if the author name contained the word "slots" and the obvious word list contained "lots", then lots would be incorrectly highlighted.

Files:

Legend:

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

    r44533 r44627  
    99*/ 
    1010 
    11 $obvious_words = "baccarat casino casinos cialis consolidation craps credit debit download gambling holdem kasino kredit payday payment poker ringtone ringtones roulette tramadol viagra xxx zocor"; 
     11$obvious_words = "baccarat casino casinos cialis consolidation craps credit debit download gambling holdem kasino kredit payday payment poker ringtone ringtones roulette tramadol slots viagra xxx zocor"; 
     12$obvious_words_array = explode(" ",$obvious_words); 
    1213 
    1314if (class_exists('Litmus')) { 
     
    4950 
    5051            function prepare($comments) { 
    51                   global $obvious_words
     52                  global $obvious_words_array
    5253                  $results = array(); 
    5354                  foreach($comments as $item) { 
    5455                        $new_name_bits = array(); 
    55                         $name_bits = explode(" ",$item->comment_author); 
     56                        $name_bits = explode(" ",strtolower($item->comment_author)); 
    5657                        foreach($name_bits as $name_bit) { 
    57                               if (strpos($obvious_words, $name_bit) !== false) { 
     58                              if (in_array($name_bit,$obvious_words_array)) { 
    5859                                    $name_bit = "<strong>$name_bit</strong>"; 
    5960                              }