Browse Source

Clean up duplicate code for IPv6

main
discomrade 3 years ago
parent
commit
bd120bbda7
  1. 20
      inc/functions.php

20
inc/functions.php

@ -12,6 +12,8 @@ if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
$microtime_start = microtime(true);
use Lifo\IP\IP; // for expanding IPv6 address in DNSBL()
// the user is not currently logged in as a moderator
$mod = false;
@ -2271,23 +2273,7 @@ function ReverseIPv4Octets($ip) {
}
function ReverseIPv6Octets($ip) {
return strrev(implode(".", str_split(str_replace(':', '', 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;
return strrev(implode(".", str_split(str_replace(':', '', IP::inet_expand($ip)))));
}
function wordfilters(&$body) {

Loading…
Cancel
Save