Hi,
if you want also control the content of the comment, here is simpe solution to check bad or spam words from comment text... or other fields. I use it also for guestbook validiation.
This code is based in your own word list... yes - you must update it time to time if new spam messages apperas to your site
To Do:
1. Make a list of words that indicates spam or bad language. Every word in own row. Save it as spam_word_list.txt in your template directory ea. /templates/default/
NOTE! You can edit the file via admin panel
2. Find in details.php or guestbook.php (if you are using guestbook mod);
if ($comment_text == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
$error = 1;
}
Insert after it;
//========== SPAM CHECK ==============================
// words to filter - from file - editable in admin panel
$spam_word_list = file('templates/default/spam_word_list.txt');
foreach($spam_word_list as $spam_word) {
$spam_word =trim($spam_word, " \n\t\r\0\x0B");
$spam_search = stristr($comment_text, $spam_word);
If ($spam_search != ""){
$msg .= "***** write here your custom message or use default spam message *****";
$error = 1;
break;
}
}
//============================================
That's it.
The default spam message is; (($msg != "") ? "" : "").$lang['spamming'];
But if you want to inform the reason why comment was rejected, make your own info text
I use break; to cut the search loop, this stops the cheking in first found word. By little extra coding you can also create a counter for ex. if some words can appear in text once or twice... or set max value for a word to appear in text before it's "banned"... and so on....
Here is some spam words to begin with;
levitra
fioricet
ultram
phentermine
didrex
butalbital
tramadol
cialis
adipex
hydrocodone
butalbital
acetaminophen
caffeine
prescription
alprazolam
meridia
carisoprodol
paxil
propecia