Hello, i would like some help with writing a piece of code that keeps bots/spammers off my forums.
The code is meant to be added somewhere to the registry page:
case 'register':
if ($user->data['is_registered'] || isset($_REQUEST['not_agreed']))
{
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}
$module->load('ucp', 'register'); //thinking of adding the anti-spam before this line, as this loads the actual page.
$module->display($user->lang['REGISTER']);
break;
What it should do:
1) get the ip of the user currently viewing the page (if he's using a proxy, the ip of the proxy is fine too).
2) use that ip to check this url: http://www.stopforumspam.com/api?ip=xxx.xxx.xxx.xxx
If the ip has been reported there before, it will return something like:
<response success="true">
<type>ip</type>
<appears>yes</appears>
<lastseen>2011-09-04 11:14:44</lastseen>
<frequency>89</frequency>
</response>
If not, it will return
<response success="true">
<type>ip</type>
<appears>no</appears>
<frequency>0</frequency>
</response>
3) If the url returns nothing, 404 error, <response success="false"> or <appears>no</appears> the code should stop (and just continue loading the page if it's not loaded).
4) if the response contains <appears>yes</appears> it should check the <frequency>89</frequency> part, if that number is higher then 5 (or 10, haven't decided on that yet), it should not load the page but show a small message instead. (pop-up, plaintext, anything will do)
Thanks for reading 🙂