Clean up duplicate code for IPv6
This commit is contained in:
parent
d606deba0e
commit
bd120bbda7
|
@ -12,6 +12,8 @@ if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
|
||||||
|
|
||||||
$microtime_start = microtime(true);
|
$microtime_start = microtime(true);
|
||||||
|
|
||||||
|
use Lifo\IP\IP; // for expanding IPv6 address in DNSBL()
|
||||||
|
|
||||||
// the user is not currently logged in as a moderator
|
// the user is not currently logged in as a moderator
|
||||||
$mod = false;
|
$mod = false;
|
||||||
|
|
||||||
|
@ -2271,23 +2273,7 @@ function ReverseIPv4Octets($ip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ReverseIPv6Octets($ip) {
|
function ReverseIPv6Octets($ip) {
|
||||||
return strrev(implode(".", str_split(str_replace(':', '', inet_expand($ip)))));
|
return strrev(implode(".", str_split(str_replace(':', '', IP::inet_expand($ip)))));
|
||||||
}
|
|
||||||
|
|
||||||
// copypastad from lib/IP/Lifo/IP.php, TODO replace this with a proper include
|
|
||||||
function inet_expand($ip)
|
|
||||||
{
|
|
||||||
// strip possible cidr notation off
|
|
||||||
if (($pos = strpos($ip, '/')) !== false) {
|
|
||||||
$ip = substr($ip, 0, $pos);
|
|
||||||
}
|
|
||||||
$bytes = unpack('n*', inet_pton($ip));
|
|
||||||
if (count($bytes) > 2) {
|
|
||||||
return implode(':', array_map(function ($b) {
|
|
||||||
return sprintf("%04x", $b);
|
|
||||||
}, $bytes));
|
|
||||||
}
|
|
||||||
return $ip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wordfilters(&$body) {
|
function wordfilters(&$body) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user