public static function decode_ip($ip) { global $db; $ip = $db->unescape_binary($ip); $l = strlen($ip); if ($l == 5 || $l == 17) { --$l; $ip = substr($ip, 0, -1); } if ($l == 4 || $l == 16) { return inet_ntop($ip); } else { if ($l == 8) { $ip = explode('.', chunk_split($ip, 2, '.')); return hexdec($ip[0]) . '.' . hexdec($ip[1]) . '.' . hexdec($ip[2]) . '.' . hexdec($ip[3]); } else { if ($tmp = FILTER::ipv4($ip, true)) { return $tmp; } } } return long2ip($ip); }
case -1: cpg_error(sprintf(_ERROR_BAD_FORMAT, 'IPv4')); break; case -2: cpg_error(sprintf(_ERROR_BAD_FORMAT, 'CIDR')); break; default: break; } } else { if (!FILTER::ipv4($_POST['ban_ipv4_s'], true)) { cpg_error(sprintf(_ERROR_BAD_FORMAT, 'IPv4 start')); } else { $ip = inet_pton($_POST['ban_ipv4_s']); if (!empty($_POST['ban_ipv4_e'])) { if (!FILTER::ipv4($_POST['ban_ipv4_e'], true)) { cpg_error(sprintf(_ERROR_BAD_FORMAT, 'IPv4 end')); } $ip2 = inet_pton($_POST['ban_ipv4_e']); } } } } if (!empty($_POST['ban_mac'])) { } if ($ip === false) { cpg_error('Nothing specified'); } $ip_len = strlen($ip); $details = $db->sql_escape_string($_POST['description']); if ($ip_len == 4) {