Skip to content

Instantly share code, notes, and snippets.

@MilkZoft
Created January 18, 2012 04:25
Show Gist options
  • Save MilkZoft/1630967 to your computer and use it in GitHub Desktop.
Save MilkZoft/1630967 to your computer and use it in GitHub Desktop.
codejobs - Filter SPAM words - PHP
<?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