-
Notifications
You must be signed in to change notification settings - Fork 0
/
bantool.php
65 lines (52 loc) · 1.46 KB
/
bantool.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
// This script implements a mass banning tool for phpbb
// It bans by both username and ip it reads it's input from a file
define('IN_PHPBB', true);
define('IN_CRON', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH'))
? PHPBB_ROOT_PATH
: '/home/mgrubb/public_html/verusvia.org/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
$user->session_begin(false);
$auth->acl($user->data);
// Get user list
$banFile = $phpbb_root_path . 'bantool/banlist.txt';
$fh = fopen($banFile, 'r');
$banList = array();
if ( $fh )
{
while (!feof($fh))
{
$line = trim(fgets($fh));
if ( $line == "" )
continue;
$banList[strtolower($line)] = 1;
}
fclose($fh);
}
$sql = 'SELECT user_id id, user_ip ip, user_email email FROM ' . USERS_TABLE .
' WHERE username_clean = \'%s\'';
foreach ($banList as $banUser => &$userInfos )
{
// printf("$sql\n", $banUser);
$result = $db->sql_query(sprintf($sql, $banUser));
$userInfos = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// printf("User: '%s', IP: '%s', EMAIL: '%s'\n", $banUser, $userInfos['ip'], $userInfos['email']);
}
unset($userInfos);
foreach ($banList as $user => $info)
{
if ( defined($info['ip']) )
{
user_ban('ip', $info['ip'], 0, 0, false, "Spam User");
}
if ( defined($info['email']) )
{
user_ban('email', $info['email'], 0, 0, false, "Spam User");
}
user_delete('remove', $info['id']);
}
?>