Skip to content

Instantly share code, notes, and snippets.

@punkeel
Last active December 21, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save punkeel/6250663 to your computer and use it in GitHub Desktop.
Save punkeel/6250663 to your computer and use it in GitHub Desktop.
Mybb bot removal - detection using http://www.stopforumspam.com
<?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