diff --git a/inc/bans.php b/inc/bans.php index b2c001f5..3e9eb9cf 100644 --- a/inc/bans.php +++ b/inc/bans.php @@ -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'])); diff --git a/inc/functions.php b/inc/functions.php index dc28421d..3c53043c 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -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 : ''); diff --git a/inc/lib/Twig/Extensions/Extension/Tinyboard.php b/inc/lib/Twig/Extensions/Extension/Tinyboard.php index 65578582..b7b55de7 100644 --- a/inc/lib/Twig/Extensions/Extension/Tinyboard.php +++ b/inc/lib/Twig/Extensions/Extension/Tinyboard.php @@ -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); } diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 8deddbae..1e7cb32d 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -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('/(?:)?(\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() { diff --git a/templates/mod/ban_appeals.html b/templates/mod/ban_appeals.html index d75a3f35..94360768 100644 --- a/templates/mod/ban_appeals.html +++ b/templates/mod/ban_appeals.html @@ -21,7 +21,7 @@ {% elseif mod|hasPermission(config.mod.show_ip_less, board.uri) %} {% trans 'IP' %} - {{ ban.mask|less_ip }} + {{ ban.mask|less_ip(ban.board) }} {% endif %} diff --git a/templates/mod/ban_form.html b/templates/mod/ban_form.html index 18ec851e..dbcfedae 100644 --- a/templates/mod/ban_form.html +++ b/templates/mod/ban_form.html @@ -26,7 +26,7 @@ {% if not hide_ip %} {% else %} - {{ ip|less_ip }}  + {{ ip|less_ip(board) }}