function ip_addr_in_network_list($ip, $network_list) { $networks = explode(',', $network_list); foreach ($networks as $net) { if (ip_addr_in_network($ip, trim(normalizeIPs($net)))) { return true; } } return false; }
require_once dirName(__FILE__) . '/../../../inc/conf.php'; include_once GS_DIR . 'inc/gettext.php'; require_once GS_DIR . 'inc/netmask.php'; require_once GS_DIR . 'inc/db_connect.php'; //set_error_handler('err_handler_die_on_err'); require_once GS_DIR . 'inc/string.php'; header('Pragma: no-cache'); header('Cache-Control: private, no-cache, must-revalidate'); header('Expires: 0'); header('Vary: *'); header('Content-Type: text/html; charset=utf-8'); $remote_ip = @$_SERVER['REMOTE_ADDR']; $allowed = false; $networks = explode(',', gs_get_conf('GS_MONITOR_FROM_NET')); foreach ($networks as $net) { if (ip_addr_in_network($remote_ip, trim($net))) { $allowed = true; break; } } if (!$allowed) { @header('HTTP/1.0 403 Forbidden', true, 403); @header('Status: 403 Forbidden', true, 403); @header('Content-Type: text/plain; charset=utf-8'); echo "Not allowed for {$remote_ip}.\nSee config.\n"; die; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="de-DE" xml:lang="de-DE">
function get_urlallowed($url) { $remote_ip = @$_SERVER['REMOTE_ADDR']; $networks = preg_split('/,| /', $url); $allowed = false; global $debug; $debug[] = array(level => 'd', status => 'info', file => __FILE__ . ":" . __LINE__, log => '(' . __FUNCTION__ . ') ' . "-+{$net}+-+{$url}+-+{$networks}+-"); if (function_exists('ip_addr_in_network')) { foreach ($networks as $net) { if (preg_match("/[a-zA-Z]/", $net)) { $dnsrec = dns_get_record($net); if ($dnsrec['0']['ip'] != false) { $net = $dnsrec['0']['ip']; } } if (ip_addr_in_network($remote_ip, trim($net))) { $allowed = true; $net = trim($net); break; } } } return $allowed; }
ini_set('implicit_flush', 1); ob_implicit_flush(1); error_reporting(0); require_once dirName(__FILE__) . '/../../inc/conf.php'; require_once GS_DIR . 'inc/util.php'; set_error_handler('err_handler_quiet'); include_once GS_DIR . 'inc/gs-lib.php'; include_once GS_DIR . 'inc/get-listen-to-ips.php'; include_once GS_DIR . 'inc/netmask.php'; $our_ips = @gs_get_listen_to_ips(); if (!is_array($our_ips)) { $our_ips = array(); } //echo 'Our IPs: ', implode(', ', $our_ips), "\n"; # If at least one of our IP addresses (Gemeinschaft node) is # a public IP address then assume NAT for the phones. $nat = 'no'; # use NAT mode only according to RFC 3581 (";rport") foreach ($our_ips as $ip_addr) { //echo '; ', $ip_addr; if (ip_addr_in_network($ip_addr, '0.0.0.0/8') || ip_addr_in_network($ip_addr, '10.0.0.0/8') || ip_addr_in_network($ip_addr, '127.0.0.0/8') || ip_addr_in_network($ip_addr, '169.254.0.0/16') || ip_addr_in_network($ip_addr, '172.16.0.0/12') || ip_addr_in_network($ip_addr, '192.168.0.0/16')) { //echo ' - private' ,"\n"; } else { //echo ' - public' ,"\n"; $nat = 'yes'; # assume NAT (ignore ";rport") break; } } echo 'nat = ', $nat, "\n"; echo "\n";