mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-28 01:10:51 +01:00
IP range bans
This commit is contained in:
parent
6f62e038d4
commit
b4aa39ca2d
@ -462,6 +462,10 @@
|
|||||||
// Characters used to generate a random password (with Javascript)
|
// Characters used to generate a random password (with Javascript)
|
||||||
$config['genpassword_chars'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+';
|
$config['genpassword_chars'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+';
|
||||||
|
|
||||||
|
// Enable IP range bans (eg. "127.*.0.1", "127.0.0.*", and "12*.0.0.1" all match "127.0.0.1").
|
||||||
|
// A little more load on the database
|
||||||
|
$config['ban_range'] = true;
|
||||||
|
|
||||||
// Custom stylesheets available. The prefix for each stylesheet URI is defined below.
|
// Custom stylesheets available. The prefix for each stylesheet URI is defined below.
|
||||||
$config['stylesheets'] = Array(
|
$config['stylesheets'] = Array(
|
||||||
// Stylesheet name => URI
|
// Stylesheet name => URI
|
||||||
|
@ -195,9 +195,14 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = prepare("SELECT * FROM `bans` WHERE `ip` = :ip LIMIT 1");
|
$query = prepare("SELECT * FROM `bans` WHERE `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1");
|
||||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
if($query->rowCount() < 1 && $config['ban_range']) {
|
||||||
|
$query = prepare("SELECT * FROM `bans` WHERE :ip REGEXP CONCAT('^', REPLACE(REPLACE(`ip`, '.', '\\.'), '*', '[0-9]*'), '$') ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1");
|
||||||
|
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
}
|
||||||
|
|
||||||
if($ban = $query->fetch()) {
|
if($ban = $query->fetch()) {
|
||||||
if($ban['expires'] && $ban['expires'] < time()) {
|
if($ban['expires'] && $ban['expires'] < time()) {
|
||||||
|
12
mod.php
12
mod.php
@ -945,7 +945,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($query->rowCount() < 1) {
|
if($query->rowCount() < 1) {
|
||||||
$body = '(There are no active bans.)';
|
$body = '<p style="text-align:center" class="unimportant">(There are no active bans.)</p>';
|
||||||
} else {
|
} else {
|
||||||
$body = '<form action="" method="post">';
|
$body = '<form action="" method="post">';
|
||||||
$body .= '<table><tr><th>IP address</th><th>Reason</th><th>Set</th><th>Expires</th><th>Staff</th></tr>';
|
$body .= '<table><tr><th>IP address</th><th>Reason</th><th>Set</th><th>Expires</th><th>Staff</th></tr>';
|
||||||
@ -964,9 +964,13 @@
|
|||||||
'<input type="checkbox" name="ban_' . $ban['ip'] . '" id="ban_' . $ban['ip'] . '" /> ' .
|
'<input type="checkbox" name="ban_' . $ban['ip'] . '" id="ban_' . $ban['ip'] . '" /> ' .
|
||||||
|
|
||||||
// IP address
|
// IP address
|
||||||
'<a href="?/IP/' .
|
(preg_match('/^(\d+\.\d+\.\d+\.\d+|' . $config['ipv6_regex'] . ')$/', $ban['ip']) ?
|
||||||
$ban['ip'] .
|
'<a href="?/IP/' .
|
||||||
'">'. $ban['ip'] . '</a></td>' .
|
$ban['ip'] .
|
||||||
|
'">'. $ban['ip'] . '</a>'
|
||||||
|
: $ban['ip']) .
|
||||||
|
|
||||||
|
'</td>' .
|
||||||
|
|
||||||
// Reason
|
// Reason
|
||||||
'<td>' . ($ban['reason'] ? $ban['reason'] : '<em>-</em>') . '</td>' .
|
'<td>' . ($ban['reason'] ? $ban['reason'] : '<em>-</em>') . '</td>' .
|
||||||
|
Loading…
Reference in New Issue
Block a user