Hi there,
I got some complaints that people were contacting my site users via the site email to try and pull them onto rivals sites, so I did this little bit of code in contact.php to catch these fishing emails.
PHP Code:
$textContent = str_replace("##comments##", $comments, $textContent);
//Search for .com / .co.uk / .net /.tv etc in comments and if present
//redirect contact to webaccount if found, to avoid spammers
//(if find wblink)
//{$to = spam account}
//(end if)
#
$filter = array('.tv','.TV','.net','.co.uk','com','www.','www','WWW','WWW.');
//$filter = ('COM');
function straipos($haystack, $filter, $offset=0)
{
$occ= Array();
for ($i = 0;$i<sizeof($filter);$i++)
{
$pos = strpos($haystack,$filter[$i],$offset);
if (is_bool($pos)) continue;
$occ[$pos] = $i;
}
if (sizeof($occ)<1) return false;
ksort($occ);
reset($occ);
list($key,$value) = each($occ);
return array($key,$value);
}
//Redirect unwanted mails
if (straipos($comments, $filter, 0)==true)
{
$to = "[email protected]";
}
$mail = new Mailer();
Simply make a new email account for your site spammer@... then add any words you want filered out to the list and they get redirected to your spam account. Could be neat to also tie this into the bad words table so you filter those emails aswell not sure if this already happens.
Working great for me but be sure to test in dev first !