mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-28 17:31:00 +01:00
less_ip is now per board, not site-wide
This commit is contained in:
parent
9ae160d1ba
commit
83cbe5977b
@ -166,7 +166,7 @@ class Bans {
|
|||||||
}
|
}
|
||||||
if ($board_access !== FALSE) {
|
if ($board_access !== FALSE) {
|
||||||
if (!$query_addition) {
|
if (!$query_addition) {
|
||||||
$query_addition .= " WHERE (`public_bans` IS TRUE)";
|
$query_addition .= " WHERE (`public_bans` IS TRUE) OR ``bans``.`board` IS NULL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ class Bans {
|
|||||||
}
|
}
|
||||||
unset($ban['type']);
|
unset($ban['type']);
|
||||||
if ($filter_ips || ($board_access !== false && !in_array($ban['board'], $board_access))) {
|
if ($filter_ips || ($board_access !== false && !in_array($ban['board'], $board_access))) {
|
||||||
$ban['mask'] = @less_ip($ban['mask']);
|
$ban['mask'] = @less_ip($ban['mask'], $ban['board']);
|
||||||
|
|
||||||
$ban['masked'] = true;
|
$ban['masked'] = true;
|
||||||
}
|
}
|
||||||
@ -260,8 +260,11 @@ class Bans {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($boards !== false && !in_array($ban['board'], $boards))
|
if ($boards !== false && !in_array($ban['board'], $boards))
|
||||||
error($config['error']['noaccess']);
|
error($config['error']['noaccess']);
|
||||||
|
|
||||||
|
if ($ban['board'])
|
||||||
|
openBoard($ban['board']);
|
||||||
|
|
||||||
$mask = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
$mask = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
||||||
|
|
||||||
|
@ -2471,7 +2471,7 @@ function diceRoller($post) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function less_ip($ip) {
|
function less_ip($ip, $board = '') {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$ipv6 = (strstr($ip, ':') !== false);
|
$ipv6 = (strstr($ip, ':') !== false);
|
||||||
@ -2496,7 +2496,7 @@ function less_ip($ip) {
|
|||||||
$masked = str_replace(array(':0', '.0'), array(':x', '.x'), $final);
|
$masked = str_replace(array(':0', '.0'), array(':x', '.x'), $final);
|
||||||
|
|
||||||
if ($config['hash_masked_ip']) {
|
if ($config['hash_masked_ip']) {
|
||||||
$masked = substr(sha1(sha1($masked) . $config['secure_trip_salt']), 0, 10);
|
$masked = substr(sha1(sha1($masked . $board) . $config['secure_trip_salt']), 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
$masked .= (isset($range) ? '/'.$range : '');
|
$masked .= (isset($range) ? '/'.$range : '');
|
||||||
|
@ -132,6 +132,6 @@ function twig_secure_link_confirm($text, $title, $confirm_message, $href) {
|
|||||||
function twig_secure_link($href) {
|
function twig_secure_link($href) {
|
||||||
return $href . '/' . make_secure_link_token($href);
|
return $href . '/' . make_secure_link_token($href);
|
||||||
}
|
}
|
||||||
function twig_less_ip($ip) {
|
function twig_less_ip($ip, $board = '') {
|
||||||
return less_ip($ip);
|
return less_ip($ip, $board);
|
||||||
}
|
}
|
||||||
|
@ -692,7 +692,8 @@ function mod_board_log($board, $page_no = 1, $hide_names = false, $public = fals
|
|||||||
// Supports ipv4 only!
|
// Supports ipv4 only!
|
||||||
foreach ($logs as $i => &$log) {
|
foreach ($logs as $i => &$log) {
|
||||||
$log['text'] = preg_replace_callback('/(?:<a href="\?\/IP\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}">)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:<\/a>)?/', function($matches) {
|
$log['text'] = preg_replace_callback('/(?:<a href="\?\/IP\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}">)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:<\/a>)?/', function($matches) {
|
||||||
return less_ip($matches[1]);
|
global $board;
|
||||||
|
return less_ip($matches[1], $board['uri']);
|
||||||
}, $log['text']);
|
}, $log['text']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -861,6 +862,9 @@ function mod_page_ip($ip) {
|
|||||||
function mod_page_ip_less($b, $id) {
|
function mod_page_ip_less($b, $id) {
|
||||||
global $config, $mod;
|
global $config, $mod;
|
||||||
|
|
||||||
|
if (!openBoard($b))
|
||||||
|
error('No board.');
|
||||||
|
|
||||||
$query = prepare(sprintf('SELECT `ip` FROM ``posts_%s`` WHERE `id` = :id', $b));
|
$query = prepare(sprintf('SELECT `ip` FROM ``posts_%s`` WHERE `id` = :id', $b));
|
||||||
$query->bindValue(':id', $id);
|
$query->bindValue(':id', $id);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
@ -912,8 +916,6 @@ function mod_page_ip_less($b, $id) {
|
|||||||
if ($config['mod']['dns_lookup'])
|
if ($config['mod']['dns_lookup'])
|
||||||
$args['hostname'] = rDNS($ip);
|
$args['hostname'] = rDNS($ip);
|
||||||
|
|
||||||
openBoard($b);
|
|
||||||
|
|
||||||
$query = prepare(sprintf('SELECT * FROM ``posts_%s`` WHERE `ip` = :ip ORDER BY `sticky` DESC, `id` DESC LIMIT :limit', $b));
|
$query = prepare(sprintf('SELECT * FROM ``posts_%s`` WHERE `ip` = :ip ORDER BY `sticky` DESC, `id` DESC LIMIT :limit', $b));
|
||||||
$query->bindValue(':ip', $ip);
|
$query->bindValue(':ip', $ip);
|
||||||
$query->bindValue(':limit', $config['mod']['ip_less_recentposts'], PDO::PARAM_INT);
|
$query->bindValue(':limit', $config['mod']['ip_less_recentposts'], PDO::PARAM_INT);
|
||||||
@ -956,7 +958,7 @@ function mod_page_ip_less($b, $id) {
|
|||||||
|
|
||||||
$args['security_token'] = make_secure_link_token('IP_less/' . $b . '/' . $id);
|
$args['security_token'] = make_secure_link_token('IP_less/' . $b . '/' . $id);
|
||||||
|
|
||||||
mod_page(sprintf('%s: %s', _('IP'), less_ip($ip)), 'mod/view_ip_less.html', $args);
|
mod_page(sprintf('%s: %s', _('IP'), less_ip($ip, $b)), 'mod/view_ip_less.html', $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mod_ban() {
|
function mod_ban() {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
{% elseif mod|hasPermission(config.mod.show_ip_less, board.uri) %}
|
{% elseif mod|hasPermission(config.mod.show_ip_less, board.uri) %}
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans 'IP' %}</th>
|
<th>{% trans 'IP' %}</th>
|
||||||
<td>{{ ban.mask|less_ip }}</td>
|
<td>{{ ban.mask|less_ip(ban.board) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
{% if not hide_ip %}
|
{% if not hide_ip %}
|
||||||
<input type="text" name="ip" id="ip" size="30" maxlength="40" value="{{ ip }}">
|
<input type="text" name="ip" id="ip" size="30" maxlength="40" value="{{ ip }}">
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ ip|less_ip }}
|
{{ ip|less_ip(board) }}
|
||||||
<select name="range">
|
<select name="range">
|
||||||
<option value="">no range ban</option>
|
<option value="">no range ban</option>
|
||||||
{% for i in range(29, 12) %}
|
{% for i in range(29, 12) %}
|
||||||
|
@ -83,8 +83,7 @@
|
|||||||
|
|
||||||
{% if bans|count > 0 and mod|hasPermission(config.mod.view_ban) %}
|
{% if bans|count > 0 and mod|hasPermission(config.mod.view_ban) %}
|
||||||
<fieldset id="bans">
|
<fieldset id="bans">
|
||||||
{% set bans_on_record = 'ban' ~ (bans|count != 1 ? 's' : '') ~ ' on record' %}
|
<legend>Bans</legend>
|
||||||
<legend>{{ bans|count }} {% trans bans_on_record %}</legend>
|
|
||||||
|
|
||||||
{% for ban in bans %}
|
{% for ban in bans %}
|
||||||
{% if ban.board in mod.boards or mod.boards.0 == '*' %}
|
{% if ban.board in mod.boards or mod.boards.0 == '*' %}
|
||||||
@ -103,7 +102,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans 'IP' %}</th>
|
<th>{% trans 'IP' %}</th>
|
||||||
<td>{{ ban.mask|less_ip }}</td>
|
<td>{{ ban.mask|less_ip(ban.board) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans 'Reason' %}</th>
|
<th>{% trans 'Reason' %}</th>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% if post.mod and post.mod|hasPermission(config.mod.show_ip, board.uri) %}
|
{% if post.mod and post.mod|hasPermission(config.mod.show_ip, board.uri) %}
|
||||||
[<a class="ip-link" style="margin:0;" href="?/IP_less/{{ board.dir }}{{ post.id }}">{{ post.ip }}</a>]
|
[<a class="ip-link" style="margin:0;" href="?/IP_less/{{ board.dir }}{{ post.id }}">{{ post.ip }}</a>]
|
||||||
{% elseif post.mod and post.mod|hasPermission(config.mod.show_ip_less, board.uri) %}
|
{% elseif post.mod and post.mod|hasPermission(config.mod.show_ip_less, board.uri) %}
|
||||||
[<a class="ip-link" style="margin:0;" href="?/IP_less/{{ board.dir }}{{ post.id }}">{{ post.ip|less_ip }}</a>]
|
[<a class="ip-link" style="margin:0;" href="?/IP_less/{{ board.dir }}{{ post.id }}">{{ post.ip|less_ip(board.uri) }}</a>]
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user