1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 09:20:58 +01:00

less_ip is now per board, not site-wide

This commit is contained in:
8chan 2015-03-06 02:00:03 -08:00
parent 9ae160d1ba
commit 83cbe5977b
8 changed files with 21 additions and 17 deletions

View File

@ -166,7 +166,7 @@ class Bans {
}
if ($board_access !== FALSE) {
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']);
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;
}
@ -260,8 +260,11 @@ class Bans {
return false;
}
if ($boards !== false && !in_array($ban['board'], $boards))
if ($boards !== false && !in_array($ban['board'], $boards))
error($config['error']['noaccess']);
if ($ban['board'])
openBoard($ban['board']);
$mask = self::range_to_string(array($ban['ipstart'], $ban['ipend']));

View File

@ -2471,7 +2471,7 @@ function diceRoller($post) {
}
}
function less_ip($ip) {
function less_ip($ip, $board = '') {
global $config;
$ipv6 = (strstr($ip, ':') !== false);
@ -2496,7 +2496,7 @@ function less_ip($ip) {
$masked = str_replace(array(':0', '.0'), array(':x', '.x'), $final);
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 : '');

View File

@ -132,6 +132,6 @@ function twig_secure_link_confirm($text, $title, $confirm_message, $href) {
function twig_secure_link($href) {
return $href . '/' . make_secure_link_token($href);
}
function twig_less_ip($ip) {
return less_ip($ip);
function twig_less_ip($ip, $board = '') {
return less_ip($ip, $board);
}

View File

@ -692,7 +692,8 @@ function mod_board_log($board, $page_no = 1, $hide_names = false, $public = fals
// Supports ipv4 only!
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) {
return less_ip($matches[1]);
global $board;
return less_ip($matches[1], $board['uri']);
}, $log['text']);
}
}
@ -861,6 +862,9 @@ function mod_page_ip($ip) {
function mod_page_ip_less($b, $id) {
global $config, $mod;
if (!openBoard($b))
error('No board.');
$query = prepare(sprintf('SELECT `ip` FROM ``posts_%s`` WHERE `id` = :id', $b));
$query->bindValue(':id', $id);
$query->execute() or error(db_error($query));
@ -912,8 +916,6 @@ function mod_page_ip_less($b, $id) {
if ($config['mod']['dns_lookup'])
$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->bindValue(':ip', $ip);
$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);
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() {

View File

@ -21,7 +21,7 @@
{% elseif mod|hasPermission(config.mod.show_ip_less, board.uri) %}
<tr>
<th>{% trans 'IP' %}</th>
<td>{{ ban.mask|less_ip }}</td>
<td>{{ ban.mask|less_ip(ban.board) }}</td>
</tr>
{% endif %}
<tr>

View File

@ -26,7 +26,7 @@
{% if not hide_ip %}
<input type="text" name="ip" id="ip" size="30" maxlength="40" value="{{ ip }}">
{% else %}
{{ ip|less_ip }}&nbsp;
{{ ip|less_ip(board) }}&nbsp;
<select name="range">
<option value="">no range ban</option>
{% for i in range(29, 12) %}

View File

@ -83,8 +83,7 @@
{% if bans|count > 0 and mod|hasPermission(config.mod.view_ban) %}
<fieldset id="bans">
{% set bans_on_record = 'ban' ~ (bans|count != 1 ? 's' : '') ~ ' on record' %}
<legend>{{ bans|count }} {% trans bans_on_record %}</legend>
<legend>Bans</legend>
{% for ban in bans %}
{% if ban.board in mod.boards or mod.boards.0 == '*' %}
@ -103,7 +102,7 @@
</tr>
<tr>
<th>{% trans 'IP' %}</th>
<td>{{ ban.mask|less_ip }}</td>
<td>{{ ban.mask|less_ip(ban.board) }}</td>
</tr>
<tr>
<th>{% trans 'Reason' %}</th>

View File

@ -1,5 +1,5 @@
{% 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>]
{% 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 %}