detecting spam keywords with stripos

From: Date: Fri, 29 May 2009 09:36:13 +0000
Subject: detecting spam keywords with stripos
Groups: php.general 
Request: Send a blank email to php-general+get-293340@lists.php.net to get a copy of this message
Hi there, I am matching text against an array of keywords to detect spam. Unfortunatelly there are some false positives due to the fact that stripos also finds the keyword inside a word. E.G. "Bewerbung" -> "Werbung" First thought: use strpos, but this does not help in all cases Second thought: split text into words and use in_array, but this does not find things like "zu Hause" or "flexible/Arbeit" Does somebody have an idea on how to make my function better in terms of not detecting the string inside a word? Here is the code: while ($row = db_get_row($result)){ $keyword[] = $row->keyword; $weight[] = $row->weight; }; $num_results = db_numrows($result); for ($i=0;$i<$num_results;$i++){ $findme = $keyword[$i]; $pos = stripos($data[txt], $findme); $pos2 = stripos($data[title], $findme); if ($pos !== false OR $pos2 !== false){ // spam! $spam_level += $weight[$i]; $triggered_keywords .= $keyword[$i].', '; } } $spam[score] += $spam_level; Thank you for any help! Merlin

« previous php.general (#293340) next »