forked from jdarwood007/smfmod_ipv6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_remove.php
executable file
·56 lines (48 loc) · 1.47 KB
/
database_remove.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
<?php
error_reporting(E_ALL);
// Hopefully we have the goodies.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
{
$using_ssi = true;
require_once(dirname(__FILE__) . '/SSI.php');
}
elseif (!defined('SMF'))
exit('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
global $db_prefix, $modSettings, $func, $smcFunc;
// Find any IPv6 bans.
$result = $smcFunc['db_query']('', '
SELECT bi.id_ban_group, bi.is_ipv6, bg.expire_time
FROM {db_prefix}ban_items AS bi
INNER JOIN {db_prefix}ban_groups AS bg ON (bi.id_ban_group = bg.id_ban_group)
WHERE bi.is_ipv6 = {int:is_ipv6}',
array(
'is_ipv6' => '1'
));
$ipv6_bans = array();
while($row = $smcFunc['db_fetch_assoc']($request))
{
if ($row['expire_time'] != 'NULL')
$smcFunc['db_query']('', '
UPDATE {db_prefix}ban_items
SET is_ipv6 = {raw:expire_time}
WHERE id_ban_group = {int:ban_group}',
array(
'expire_time' => $row['expire_time'],
'ban_group' => $row['id_ban_group'],
));
$ipv6_bans[] = $row['id_ban_group'];
}
// Do a mass update to disable these bans.
$smcFunc['db_query']('', '
UPDATE {db_prefix}ban_groups
SET expire_time = {int:expired_time}
WHERE id_ban_group IN ({array_int:bans})',
array(
'expired_time' => time() - 60, // 1 minute ago should do.
'bans' => $ipv6_bans
));
// Update our ban time, forcing rechecks to occur.
updateSettings(array('banLastUpdated' => time()));
if(!empty($using_ssi))
echo 'If no errors, Success!';
?>