Last active
December 21, 2015 04:39
-
-
Save punkeel/6250663 to your computer and use it in GitHub Desktop.
Mybb bot removal - detection using http://www.stopforumspam.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$confidence = 75; | |
$db_prefix = 'forum'; | |
function check_user($u) { | |
$details = array('username' => urlencode($u['username']), 'email' => urlencode($u['email']), 'ip' => $u['lastip']); | |
$url = "http://www.stopforumspam.com/api?ip={$details['ip']}&email={$details['email']}&username={$details['username']}&f=json"; | |
$data = @file_get_contents($url); | |
$data = json_decode($data); | |
$from = max(1, $data->ip->appears + $data->email->appears + $data->username->appears); | |
$total = $data->username->confidence + $data->email->confidence + $data->ip->confidence; | |
return $total/$from; | |
} | |
define('IN_MYBB', NULL); | |
require_once 'global.php'; | |
// SELECT username, email, lastip FROM mybb_users; | |
$query=$db->query("SELECT uid, username, email, lastip FROM '.$db_prefix.'_users ORDER BY uid DESC"); | |
while ($r=$db->fetch_array($query)) { | |
$l = check_user($r); | |
if ($l > $confidence) { | |
echo PHP_EOL . '- ' . $r['email'] . ' #'.$l; | |
// Uncomment to enable :3 [security] | |
// $db->query('DELETE FROM '.$db_prefix.'_users WHERE uid = ' . $r['uid']); | |
} | |
flush(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment