It’s been a while since I posted anything on DirectorySpy. I have been busy working on some ideas for directory mods, but they are not quite finished. However, I do have something useful for you to help combat directory spam.
For the last month, I’ve seen a growth in directory spam for my directories using phpLinkDirectory. The spam contains the usual rubbish about drugs, etc. They seem to be using discussion forum tags to get the links such as:
[url=http://www.somewebsite.com]buy these drugs[/url]
[url=http://www.somewebsite.com]and these[/url]
[url=http://www.somewebsite.com]and these too[/url]
I started banning ip addresses, but quickly found that the ip address changed for every submission, and there was no pattern to them either. Because I didn’t want to ban the whole of the internet, I started looking at filtering content. I started looking at the Smarty Form Validation code, and realised that my code would quickly become very complex due to requiring some very involved regular expressions. So I thought about a simpler solution… and I found it.
What we want to do is identify spam, and then prevent the spammer from submitting any data. Because its likely to be a spam bot behind this, a quick and dirty solution is absolutely fine. My solution? Check for typical spam data, then send a 403 Forbidden header if detected.
So, in submit.php, I added the following code after the code that uses strip_tags:
// Check Description for SPAM
if (preg_match("/\[url=/i", $data['DESCRIPTION']))
{
Header("HTTP/1.1 403 Forbidden");
return;
}
After this code:
$data['DESCRIPTION'] = strip_tags($data['DESCRIPTION']);
$data['TITLE'] = strip_tags($data['TITLE']);
$data['OWNER_NAME'] = strip_tags($data['OWNER_NAME']);
So if the “[url=” text is detected in the description field, we basically send the bot a 403 Forbidden message and a blank page (caused by the return statement).
If you have a sense of humour, you might want to replace the Header() statement with the one below, which will send the user to the spam page on WikiPedia.
Header("Location: http://en.wikipedia.org/wiki/Spam_(electronic)");
I am now using this code on all of my directories. Rest assured, there will be a fuller mod at some stage in the future! If you find this tip useful, please leave a comment! I really want to know!