Created
January 18, 2012 04:25
-
-
Save MilkZoft/1630967 to your computer and use it in GitHub Desktop.
codejobs - Filter SPAM words - PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isSPAM($string, $max = 2) { | |
$words = array( | |
"http", "www", ".com", ".mx", ".org", ".net", ".co.uk", ".jp", ".ch", ".info", ".me", ".mobi", ".us", ".biz", ".ca", ".ws", ".ag", | |
".com.co", ".net.co", ".com.ag", ".net.ag", ".it", ".fr", ".tv", ".am", ".asia", ".at", ".be", ".cc", ".de", ".es", ".com.es", ".eu", | |
".fm", ".in", ".tk", ".com.mx", ".nl", ".nu", ".tw", ".vg", "sex", "porn", "fuck", "buy", "free", "dating", "viagra", "money", "dollars", | |
"payment", "website", "games", "toys", "poker", "cheap" | |
); | |
$count = 0; | |
$string = strtolower($string); | |
if(is_array($words)) { | |
foreach($words as $word) { | |
$count += substr_count($string, $word); | |
} | |
} | |
return ($count > $max) ? TRUE : FALSE; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment