This function will tell you if any of the user information you give it appears in the
stopforumspam.com database, could be useful for registration forms, guestbooks etc.
function known_spammer($username = null, $email = null, $ip = null){
if ($username !== null){
$query['username'] = $username;
}
if ($email !== null){
$query['email'] = $email;
}
if ($ip !== null){
$query['ip'] = $ip;
}
if (empty($query)){
return false;
}
$data = file_get_contents('http://www.stopforumspam.com/api?' . http_build_query($query) . '&f=serial');
$data = unserialize($data);
if ($data['success'] !== 1){
return false;
}
unset($data['success']);
foreach ($data as $check){
if ($check['appears'] == '1'){
return true;
}
}
return false;
}
Each parameter is optional and should be replaced with null if you want to skip it. for example to check if an IP is in the database.
var_dump(known_spammer(null, null, '1.2.3.4'));
Or to check all three things,
var_dump(known_spammer('jacek', 'test1@betterphp.co.uk', '1.2.3.4'));
There is a limit to how many times you can use this form the same IP, that limit is 20,000 so I doubt it will cause many problems