From dd1c160d35e778aff154e059183d262f7d4c9b89 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 3 Dec 2014 00:15:24 -0800 Subject: [PATCH] Hash masked IPs option, use less_ip in inc/bans --- inc/bans.php | 10 ++-------- inc/config.php | 1 - inc/functions.php | 12 +++++++++++- inc/instance-config.php | 1 + 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/inc/bans.php b/inc/bans.php index 14b7f939..215ff279 100644 --- a/inc/bans.php +++ b/inc/bans.php @@ -218,14 +218,8 @@ class Bans { } unset($ban['type']); if ($filter_ips || ($board_access !== false && !in_array($ban['board'], $board_access))) { - @list($ban['mask'], $subnet) = explode("/", $ban['mask']); - $ban['mask'] = preg_split("/[\.:]/", $ban['mask']); - $ban['mask'] = array_slice($ban['mask'], 0, 2); - $ban['mask'] = implode(".", $ban['mask']); - $ban['mask'] .= ".x.x"; - if (isset ($subnet)) { - $ban['mask'] .= "/$subnet"; - } + $ban['mask'] = @less_ip($ban['mask']); + $ban['masked'] = true; } diff --git a/inc/config.php b/inc/config.php index 89eaac69..056ec77c 100644 --- a/inc/config.php +++ b/inc/config.php @@ -753,7 +753,6 @@ // Allowed image file extensions. $config['allowed_ext'][] = 'jpg'; $config['allowed_ext'][] = 'jpeg'; - $config['allowed_ext'][] = 'bmp'; $config['allowed_ext'][] = 'gif'; $config['allowed_ext'][] = 'png'; // $config['allowed_ext'][] = 'svg'; diff --git a/inc/functions.php b/inc/functions.php index 2ffdc222..0ff32e37 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2427,6 +2427,8 @@ function diceRoller($post) { } function less_ip($ip) { + global $config; + $ipv6 = (strstr($ip, ':') !== false); $has_range = (strstr($ip, '/') !== false); @@ -2446,7 +2448,15 @@ function less_ip($ip) { } $final = inet_ntop($in_addr & $mask); - return str_replace(array(':0', '.0'), array(':x', '.x'), $final) . (isset($range) ? '/'.$range : ''); + $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 .= (isset($range) ? '/'.$range : ''); + + return $masked; } function less_hostmask($hostmask) { diff --git a/inc/instance-config.php b/inc/instance-config.php index 9c442fef..bd51e227 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -192,6 +192,7 @@ ); $config['gzip_static'] = false; +$config['hash_masked_ip'] = true; // 8chan specific mod pages require '8chan-mod-pages.php';