function get_config_by_network($ip, &$config_list) { if (!is_array($config_list)) { return array(); } foreach ($config_list as $network => $config) { if (Net_IPv4::ipInNetwork($ip, $network)) { return $config; } } return array(); }
public function isMobileIPAddress() { $ipList = (array) (include sfContext::getInstance()->getConfigCache()->checkConfig('config/mobile_ip_address.yml')); require_once 'Net/IPv4.php'; $result = false; foreach ($ipList as $mobileIp) { if (Net_IPv4::ipInNetwork($_SERVER['REMOTE_ADDR'], $mobileIp)) { $result = true; break; } } return $result; }
public function isMobileIPAddress() { require_once 'Net/IPv4.php'; $ipList = (array) (include sfContext::getInstance()->getConfigCache()->checkConfig('config/mobile_ip_address.yml')); $carrier = strtolower($this->getMobile()->getCarrierLongName()); $list = array(); if (isset($ipList[$carrier])) { $list = $ipList[$carrier]; } $result = false; foreach ($list as $mobileIp) { if (Net_IPv4::ipInNetwork($_SERVER['REMOTE_ADDR'], $mobileIp)) { $result = true; break; } } return $result; }
/** * Check IPv4 class type */ function checkIpv4AddressType($ipStart, $ipStop) { /* define classes */ $classes['private A'] = '10.0.0.0/8'; $classes['private B'] = '172.16.0.0/12'; $classes['private C'] = '192.168.0.0/16'; $classes['Loopback'] = '127.0.0.0/8'; $classes['Link-local'] = '169.254.0.0/16'; $classes['Reserved (IANA)'] = '192.0.0.0/24'; $classes['TEST-NET-1'] = '192.0.2.0/24'; $classes['IPv6 to IPv4 relay'] = '192.88.99.0/24'; $classes['Network benchmark'] = '198.18.0.0/15'; $classes['TEST-NET-2'] = '198.51.100.0/24'; $classes['TEST-NET-3'] = '203.0.113.0/24'; $classes['Multicast'] = '224.0.0.0/4'; //Multicast $classes['Reserved'] = '240.0.0.0/4'; //Reserved - research /* check if it is in array */ foreach ($classes as $key => $class) { if (Net_IPv4::ipInNetwork($ipStart, $class)) { if (Net_IPv4::ipInNetwork($ipStop, $class)) { return $key; } } } /* no match */ return false; }
function match_network($ip, $nets, $first = FALSE) { $return = FALSE; $ip_version = get_ip_version($ip); if ($ip_version) { if (!is_array($nets)) { $nets = array($nets); } foreach ($nets as $net) { $ip_in_net = FALSE; $revert = preg_match("/^\\!/", $net) ? TRUE : FALSE; // NOT match network $net = preg_replace("/^\\!/", "", $net); if ($ip_version == 4) { if (strpos($net, '.') === FALSE) { continue; } // NOT IPv4 net, skip if (strpos($net, '/') === FALSE) { $net .= '/32'; } // NET without mask as single IP $ip_in_net = Net_IPv4::ipInNetwork($ip, $net); } else { if (strpos($net, ':') === FALSE) { continue; } if (strpos($net, '/') === FALSE) { $net .= '/128'; } // NET without mask as single IP $ip_in_net = Net_IPv6::isInNetmask($ip, $net); } if ($revert && $ip_in_net) { return FALSE; } // Return FALSE if IP founded in network where should NOT match if ($first && $ip_in_net) { return TRUE; } // Return TRUE if IP founded in first match $return = $return || $ip_in_net; } } return $return; }
function MAX_remotehostPrivateAddress($ip) { setupIncludePath(); require_once 'Net/IPv4.php'; // Define the private address networks, see // http://rfc.net/rfc1918.html $aPrivateNetworks = array('10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.0/24'); foreach ($aPrivateNetworks as $privateNetwork) { if (Net_IPv4::ipInNetwork($ip, $privateNetwork)) { return true; } } return false; }
include $config['install_dir'] . "/includes/rewrites.inc.php"; include $config['install_dir'] . "/includes/rrdtool.inc.php"; include $config['install_dir'] . "/includes/entities.inc.php"; include $config['html_dir'] . "/includes/functions.inc.php"; if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs']) { $auth = TRUE; // hardcode auth for all with config function print_debug('认证旁路 $config[\'allow_unauth_graphs\'].'); } elseif (isset($config['allow_unauth_graphs_cidr']) && count($config['allow_unauth_graphs_cidr'])) { foreach ($config['allow_unauth_graphs_cidr'] as $range) { list($net, $mask) = explode('/', trim($range)); if (Net_IPv4::validateIP($net)) { // IPv4 $mask = $mask != NULL ? $mask : '32'; $range = $net . '/' . $mask; if ($mask >= 0 && $mask <= 32 && Net_IPv4::ipInNetwork($_SERVER['REMOTE_ADDR'], $range)) { $auth = TRUE; // hardcode authenticated for matched subnet print_debug("认证的CIDR匹配IPv4 {$range}."); break; } } elseif (Net_IPv6::checkIPv6($net)) { // IPv6 $mask = $mask != NULL ? $mask : '128'; $range = $net . '/' . $mask; if ($mask >= 0 && $mask <= 128 && Net_IPv6::isInNetmask($_SERVER['REMOTE_ADDR'], $range)) { $auth = TRUE; // hardcode authenticated for matched subnet print_debug("认证的CIDR匹配IPv6 {$range}"); break; }
/** * verify ip address from edit / add * noStrict ignores NW and Broadcast checks */ function VerifyIpAddress($ip, $subnet, $noStrict = false) { /* First identify it */ $type = IdentifyAddress($ip); $type = IdentifyAddress($subnet); /* get mask */ $mask = explode("/", $subnet); /* IPv4 verification */ if ($type == 'IPv4') { require_once 'PEAR/Net/IPv4.php'; $Net_IPv4 = new Net_IPv4(); // is it valid? if (!$Net_IPv4->validateIP($ip)) { $error = _("IP address not valid") . "! ({$ip})"; } elseif (!$Net_IPv4->ipInNetwork($ip, $subnet)) { $error = _("IP address not in selected subnet") . "! ({$ip})"; } elseif ($mask[1] == "31" || $mask[1] == "32" || $noStrict == true) { } else { $net = $Net_IPv4->parseAddress($subnet); if ($net->network == $ip) { $error = _("Cannot add subnet as IP address!"); } elseif ($net->broadcast == $ip) { $error = _("Cannot add broadcast as IP address!"); } } } else { require_once 'PEAR/Net/IPv6.php'; $Net_IPv6 = new Net_IPv6(); //remove /xx from subnet $subnet_short = $Net_IPv6->removeNetmaskSpec($subnet); // is it valid? if (!$Net_IPv6->checkIPv6($ip)) { $error = _("IP address not valid") . "! ({$ip})"; } elseif (!$Net_IPv6->isInNetmask($ip, $subnet)) { $error = _("IP address not in selected subnet") . "! ({$ip})"; } } /* return results */ if (isset($error)) { return $error; } else { return false; } }
private function check_ips($validate, $settings, $which) { $ip = $validate['ip']; $ips = $settings['extra_ips'][$which ? 'black_list' : 'white_list']; if (FALSE === strpos($ips, '/')) { if (FALSE !== strpos($ips, $ip)) { $validate += array('result' => $which ? 'extra' : 'passed'); } // can't overwrite existing result } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { require_once IP_GEO_BLOCK_PATH . 'includes/Net/IPv4.php'; foreach (explode(',', $ips) as $i) { $j = explode('/', $i = trim($i)); if (filter_var($j[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && Net_IPv4::ipInNetwork($ip, !empty($j[1]) ? $i : "{$i}/32")) { $validate += array('result' => $which ? 'extra' : 'passed'); // can't overwrite existing result break; } } } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { require_once IP_GEO_BLOCK_PATH . 'includes/Net/IPv6.php'; foreach (explode(',', $ips) as $i) { $j = explode('/', $i = trim($i)); if (filter_var($j[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && Net_IPv6::isInNetmask($ip, !empty($j[1]) ? $i : "{$i}/128")) { $validate += array('result' => $which ? 'extra' : 'passed'); // can't overwrite existing result break; } } } return $validate; }
/** * Display IPv4/IPv6 addresses. * * Display pages with IP addresses from device Interfaces. * * @param array $vars * @return none * */ function print_addresses($vars) { // With pagination? (display page numbers in header) $pagination = isset($vars['pagination']) && $vars['pagination']; pagination($vars, 0, TRUE); // Get default pagesize/pageno $pageno = $vars['pageno']; $pagesize = $vars['pagesize']; $start = $pagesize * $pageno - $pagesize; if (in_array($vars['search'], array('6', 'v6', 'ipv6')) || in_array($vars['view'], array('6', 'v6', 'ipv6'))) { $address_type = 'ipv6'; } else { $address_type = 'ipv4'; } $ip_array = array(); $param = array(); $where = ' WHERE 1 '; $param_netscaler = array(); $where_netscaler = " WHERE `vsvr_ip` != '0.0.0.0' AND `vsvr_ip` != '' "; foreach ($vars as $var => $value) { if ($value != '') { switch ($var) { case 'device': case 'device_id': $where .= generate_query_values($value, 'I.device_id'); $where_netscaler .= generate_query_values($value, 'N.device_id'); break; case 'interface': $where .= generate_query_values($value, 'I.ifDescr', 'LIKE%'); break; case 'network': list($net, $mask) = explode('/', $value); if (is_numeric(stripos($net, ':abcdef'))) { $address_type = 'ipv6'; } $where .= generate_query_values($value, 'N.ip_network', 'LIKE%'); break; case 'address': list($addr, $mask) = explode('/', $value); if (is_numeric(stripos($addr, ':abcdef'))) { $address_type = 'ipv6'; } switch ($address_type) { case 'ipv6': $ip_valid = Net_IPv6::checkIPv6($addr); break; case 'ipv4': $ip_valid = Net_IPv4::validateIP($addr); break; } if ($ip_valid) { // If address valid -> seek occurrence in network if (!$mask) { $mask = $address_type === 'ipv4' ? '32' : '128'; } $where_netscaler .= generate_query_values($addr, 'N.vsvr_ip'); } else { // If address not valid -> seek LIKE $where .= generate_query_values($addr, 'A.ip_address', '%LIKE%'); $where_netscaler .= generate_query_values($addr, 'N.vsvr_ip', '%LIKE%'); } break; } } } $query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D')); $query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I')); // Also search netscaler Vserver IPs $query_netscaler = 'FROM `netscaler_vservers` AS N '; $query_netscaler .= 'LEFT JOIN `devices` AS D ON N.`device_id` = D.`device_id` '; $query_netscaler .= $where_netscaler . $query_device_permitted; //$query_netscaler_count = 'SELECT COUNT(`vsvr_id`) ' . $query_netscaler; $query_netscaler = 'SELECT * ' . $query_netscaler; $query_netscaler .= ' ORDER BY N.`vsvr_ip`'; // Override by address type if ($address_type == 'ipv6') { $query_netscaler = str_replace(array('vsvr_ip', '0.0.0.0'), array('vsvr_ipv6', '0:0:0:0:0:0:0:0'), $query_netscaler); //$query_netscaler_count = str_replace(array('vsvr_ip', '0.0.0.0'), array('vsvr_ipv6', '0:0:0:0:0:0:0:0'), $query_netscaler_count); } $entries = dbFetchRows($query_netscaler, $param_netscaler); // Rewrite netscaler addresses foreach ($entries as $entry) { $ip_address = $address_type == 'ipv4' ? $entry['vsvr_ip'] : $entry['vsvr_' . $address_type]; $ip_network = $address_type == 'ipv4' ? $entry['vsvr_ip'] . '/32' : $entry['vsvr_' . $address_type] . '/128'; $ip_array[] = array('type' => 'netscaler_vsvr', 'device_id' => $entry['device_id'], 'hostname' => $entry['hostname'], 'vsvr_id' => $entry['vsvr_id'], 'vsvr_label' => $entry['vsvr_label'], 'ifAlias' => 'Netscaler: ' . $entry['vsvr_type'] . '/' . $entry['vsvr_entitytype'], $address_type . '_address' => $ip_address, $address_type . '_network' => $ip_network); } //print_message($query_netscaler_count); $query = 'FROM `ip_addresses` AS A '; $query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = A.`port_id` '; $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` '; $query .= 'LEFT JOIN `ip_networks` AS N ON N.`ip_network_id` = A.`ip_network_id` '; $query .= $where . $query_port_permitted; //$query_count = 'SELECT COUNT(`ip_address_id`) ' . $query; $query = 'SELECT * ' . $query; $query .= ' ORDER BY A.`ip_address`'; if ($ip_valid) { $pagination = FALSE; } // Override by address type $query = str_replace(array('ip_address', 'ip_network'), array($address_type . '_address', $address_type . '_network'), $query); //$query_count = str_replace(array('ip_address', 'ip_network'), array($address_type.'_address', $address_type.'_network'), $query_count); // Query addresses $entries = dbFetchRows($query, $param); $ip_array = array_merge($ip_array, $entries); $ip_array = array_sort($ip_array, $address_type . '_address'); // Query address count //if ($pagination) { $count = dbFetchCell($query_count, $param); } if ($pagination) { $count = count($ip_array); $ip_array = array_slice($ip_array, $start, $pagesize); } $list = array('device' => FALSE); if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') { $list['device'] = TRUE; } $string = generate_box_open($vars['header']); $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED . '">' . PHP_EOL; if (!$short) { $string .= ' <thead>' . PHP_EOL; $string .= ' <tr>' . PHP_EOL; if ($list['device']) { $string .= ' <th>Device</th>' . PHP_EOL; } $string .= ' <th>Interface</th>' . PHP_EOL; $string .= ' <th>Address</th>' . PHP_EOL; $string .= ' <th>Description</th>' . PHP_EOL; $string .= ' </tr>' . PHP_EOL; $string .= ' </thead>' . PHP_EOL; } $string .= ' <tbody>' . PHP_EOL; foreach ($ip_array as $entry) { $address_show = TRUE; if ($ip_valid) { // If address not in specified network, don't show entry. if ($address_type === 'ipv4') { $address_show = Net_IPv4::ipInNetwork($entry[$address_type . '_address'], $addr . '/' . $mask); } else { $address_show = Net_IPv6::isInNetmask($entry[$address_type . '_address'], $addr, $mask); } } if ($address_show) { list($prefix, $length) = explode('/', $entry[$address_type . '_network']); if (port_permitted($entry['port_id']) || $entry['type'] == 'netscaler_vsvr') { if ($entry['type'] == 'netscaler_vsvr') { $entity_link = generate_entity_link($entry['type'], $entry); } else { humanize_port($entry); if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) { $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors'); } $entity_link = generate_port_link($entry, $entry['port_label_short']) . ' ' . $port_error; } $device_link = generate_device_link($entry); $string .= ' <tr>' . PHP_EOL; if ($list['device']) { $string .= ' <td class="entity" style="white-space: nowrap">' . $device_link . '</td>' . PHP_EOL; } $string .= ' <td class="entity">' . $entity_link . '</td>' . PHP_EOL; if ($address_type === 'ipv6') { $entry[$address_type . '_address'] = Net_IPv6::compress($entry[$address_type . '_address']); } $string .= ' <td>' . generate_popup_link('ip', $entry[$address_type . '_address'] . '/' . $length) . '</td>' . PHP_EOL; $string .= ' <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL; $string .= ' </tr>' . PHP_EOL; } } } $string .= ' </tbody>' . PHP_EOL; $string .= '</table>'; $string .= generate_box_close(); // Print pagination header if ($pagination) { $string = pagination($vars, $count) . $string . pagination($vars, $count); } // Print addresses echo $string; }
function checkSource($source, $current_station_id) { $source = trim($source); if (isset($_SERVER['REMOTE_ADDR'])) { $remote_addr = $_SERVER['REMOTE_ADDR']; } else { $remote_addr = NULL; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $x_forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $x_forwarded_for = NULL; } //IGNORE x_forwarded_for for now, because anyone could spoof this. //Add a switch that will enable/disable this feature. //$remote_addr = '192.168.2.10'; //$remote_addr = '192.168.1.10'; //$remote_addr = '127.0.0.1'; if (in_array($this->getType(), array(10, 25)) and preg_match('/[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(\\/[0-9]{1,2})*/', $source)) { Debug::text('Source is an IP address!', __FILE__, __LINE__, __METHOD__, 10); } elseif (in_array($this->getType(), array(10, 25, 100)) and !in_array(strtolower($this->getStation()), $this->getOptions('station_reserved_word'))) { //Do hostname lookups for TTA8 timeclocks as well. Debug::text('Source is NOT an IP address, do hostname lookup: ' . $source, __FILE__, __LINE__, __METHOD__, 10); $hostname_lookup = $this->getCache($remote_addr . $source); if ($hostname_lookup === FALSE) { $hostname_lookup = gethostbyname($source); $this->saveCache($hostname_lookup, $remote_addr . $source); } if ($hostname_lookup == $source) { Debug::text('Hostname lookup failed!', __FILE__, __LINE__, __METHOD__, 10); } else { Debug::text('Hostname lookup succeeded: ' . $hostname_lookup, __FILE__, __LINE__, __METHOD__, 10); $source = $hostname_lookup; } unset($hostname_lookup); } else { Debug::text('Source is not internet related', __FILE__, __LINE__, __METHOD__, 10); } Debug::text('Source: ' . $source . ' Remote IP: ' . $remote_addr . ' Behind Proxy IP: ' . $x_forwarded_for, __FILE__, __LINE__, __METHOD__, 10); if (($current_station_id == $this->getStation() or in_array(strtolower($this->getStation()), $this->getOptions('station_reserved_word'))) and (in_array(strtolower($this->getSource()), $this->getOptions('source_reserved_word')) or $source == $remote_addr or $current_station_id == $this->getSource() or Net_IPv4::ipInNetwork($remote_addr, $source) or in_array($this->getType(), array(100, 110, 120, 200)))) { Debug::text('Returning TRUE', __FILE__, __LINE__, __METHOD__, 10); return TRUE; } Debug::text('Returning FALSE', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
if ($from < 0) { $from = $to + $from; } $period = $to - $from; $prev_from = $from - $period; $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; $type = $graphtype['type']; $subtype = $graphtype['subtype']; if (is_file($config['install_dir'] . "/html/includes/graphs/{$type}/{$subtype}.inc.php")) { if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs']) { $auth = "1"; // hardcode auth for all with config function } if (isset($config['allow_unauth_graphs_cidr']) && count($config['allow_unauth_graphs_cidr']) > 0) { foreach ($config['allow_unauth_graphs_cidr'] as $range) { if (Net_IPv4::ipInNetwork($_SERVER['REMOTE_ADDR'], $range)) { $auth = "1"; if ($debug) { echo "matched {$range}"; } break; } } } include $config['install_dir'] . "/html/includes/graphs/{$type}/auth.inc.php"; if (isset($auth) && $auth) { include $config['install_dir'] . "/html/includes/graphs/{$type}/{$subtype}.inc.php"; } } else { graph_error("{$type}*{$subtype} "); //Graph Template Missing");
/** * 携帯端末からのアクセスかどうかを IPアドレスから判別する * * @return bool */ function is_ktai_ip() { require_once 'Net/IPv4.php'; require_once 'ktaiIP.php'; if (empty($GLOBALS['__Framework']['carrier'])) { return false; } $carrier = $GLOBALS['__Framework']['carrier']; $is_valid_ip = false; $list = array(); if (isset($GLOBALS['_OPENPNE_KTAI_IP_LIST'][$carrier])) { $list = $GLOBALS['_OPENPNE_KTAI_IP_LIST'][$carrier]; } foreach ($list as $ktai_ip) { if (Net_IPv4::ipInNetwork($_SERVER[SERVER_IP_KEY], $ktai_ip)) { $is_valid_ip = true; break; } } return $is_valid_ip; }
/** * Display IPv4/IPv6 addresses. * * Display pages with IP addresses from device Interfaces. * * @param array $vars * @return none * */ function print_addresses($vars) { // With pagination? (display page numbers in header) $pagination = isset($vars['pagination']) && $vars['pagination']; $pageno = isset($vars['pageno']) && !empty($vars['pageno']) ? $vars['pageno'] : 1; $pagesize = isset($vars['pagesize']) && !empty($vars['pagesize']) ? $vars['pagesize'] : 10; $start = $pagesize * $pageno - $pagesize; switch ($vars['search']) { case '6': case 'ipv6': case 'v6': $address_type = 'ipv6'; break; default: $address_type = 'ipv4'; } $param = array(); $where = ' WHERE 1 '; foreach ($vars as $var => $value) { if ($value != '') { switch ($var) { case 'device': case 'device_id': $where .= ' AND I.device_id = ?'; $param[] = $value; break; case 'interface': $where .= ' AND I.ifDescr LIKE ?'; $param[] = $value; break; case 'network': $where .= ' AND N.ip_network_id = ?'; $param[] = $value; break; case 'address': list($addr, $mask) = explode('/', $value); if (is_numeric(stripos($addr, ':abcdef'))) { $address_type = 'ipv6'; } switch ($address_type) { case 'ipv6': $ip_valid = Net_IPv6::checkIPv6($addr); break; case 'ipv4': $ip_valid = Net_IPv4::validateIP($addr); break; } if ($ip_valid) { // If address valid -> seek occurrence in network if (!$mask) { $mask = $address_type === 'ipv4' ? '32' : '128'; } } else { // If address not valid -> seek LIKE $where .= ' AND A.ip_address LIKE ?'; $param[] = '%' . $addr . '%'; } break; } } } if ($_SESSION['userlevel'] >= 5) { $query_perms = ''; $query_user = ''; } else { $query_perms = 'LEFT JOIN devices_perms AS P ON D.device_id = P.device_id '; $query_user = '******'; $param[] = $_SESSION['user_id']; } // Don't show ignored and disabled devices $query_device = ' AND D.ignore = 0 '; if (!$config['web_show_disabled']) { $query_device .= 'AND D.disabled = 0 '; } $query = 'FROM `ip_addresses` AS A '; $query .= 'LEFT JOIN `ports` AS I ON I.port_id = A.port_id '; $query .= 'LEFT JOIN `devices` AS D ON I.device_id = D.device_id '; $query .= 'LEFT JOIN `ip_networks` AS N ON N.ip_network_id = A.ip_network_id '; $query .= $query_perms; $query .= $where . $query_device . $query_user; $query_count = 'SELECT COUNT(ip_address_id) ' . $query; $query = 'SELECT * ' . $query; $query .= ' ORDER BY A.ip_address'; if ($ip_valid) { $pagination = FALSE; } else { $query .= " LIMIT {$start},{$pagesize}"; } // Override by address type $query = str_replace(array('ip_address', 'ip_network'), array($address_type . '_address', $address_type . '_network'), $query); $query_count = str_replace(array('ip_address', 'ip_network'), array($address_type . '_address', $address_type . '_network'), $query_count); // Query addresses $entries = dbFetchRows($query, $param); // Query address count if ($pagination) { $count = dbFetchCell($query_count, $param); } $list = array('device' => FALSE); if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') { $list['device'] = TRUE; } $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL; if (!$short) { $string .= ' <thead>' . PHP_EOL; $string .= ' <tr>' . PHP_EOL; if ($list['device']) { $string .= ' <th>Device</th>' . PHP_EOL; } $string .= ' <th>Interface</th>' . PHP_EOL; $string .= ' <th>Address</th>' . PHP_EOL; $string .= ' <th>Description</th>' . PHP_EOL; $string .= ' </tr>' . PHP_EOL; $string .= ' </thead>' . PHP_EOL; } $string .= ' <tbody>' . PHP_EOL; foreach ($entries as $entry) { $address_show = TRUE; if ($ip_valid) { // If address not in specified network, don't show entry. if ($address_type === 'ipv4') { $address_show = Net_IPv4::ipInNetwork($entry[$address_type . '_address'], $addr . '/' . $mask); } else { $address_show = Net_IPv6::isInNetmask($entry[$address_type . '_address'], $addr, $mask); } } if ($address_show) { list($prefix, $length) = explode('/', $entry[$address_type . '_network']); if (port_permitted($entry['port_id'])) { humanize_port($entry); if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) { $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors'); } $string .= ' <tr>' . PHP_EOL; if ($list['device']) { $string .= ' <td class="entity" nowrap>' . generate_device_link($entry) . '</td>' . PHP_EOL; } $string .= ' <td class="entity">' . generate_port_link($entry, makeshortif($entry['label'])) . ' ' . $port_error . '</td>' . PHP_EOL; if ($address_type === 'ipv6') { $entry[$address_type . '_address'] = Net_IPv6::compress($entry[$address_type . '_address']); } $string .= ' <td>' . $entry[$address_type . '_address'] . '/' . $length . '</td>' . PHP_EOL; $string .= ' <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL; $string .= ' </tr>' . PHP_EOL; } } } $string .= ' </tbody>' . PHP_EOL; $string .= '</table>'; // Print pagination header if ($pagination) { echo pagination($vars, $count); } // Print addresses echo $string; }
function is_client_authorized($clientip) { global $config; if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs']) { d_echo("Unauthorized graphs allowed\n"); return true; } if (isset($config['allow_unauth_graphs_cidr'])) { foreach ($config['allow_unauth_graphs_cidr'] as $range) { if (Net_IPv4::ipInNetwork($clientip, $range)) { d_echo("Unauthorized graphs allowed from {$range}\n"); return true; } } } return false; }
function MAX_remotehostPrivateAddress($ip) { setupIncludePath(); require_once 'Net/IPv4.php'; $aPrivateNetworks = array('10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.0/24'); foreach ($aPrivateNetworks as $privateNetwork) { if (Net_IPv4::ipInNetwork($ip, $privateNetwork)) { return true; } } return false; }
/** * ユーザーエージェントチェック * * @access private */ function _checkAgent() { if (!$this->isMobile()) { return; } static $userAgent; if ($userAgent === NULL) { $userAgent = Net_UserAgent_Mobile::factory(); } $container =& DIContainerFactory::getContainer(); $getdata =& $container->getComponent("GetData"); $config =& $getdata->getParameter("config"); //$configView =& $container->getComponent("configView"); //$config = $configView->getConfigByCatid(_SYS_CONF_MODID, _GENERAL_CONF_CATID); $session =& $container->getComponent("Session"); $tel_id = $userAgent->getSerialNumber() . $userAgent->getUID(); $tel_id = !empty($tel_id) ? $userAgent->getUserAgent() . " " . $tel_id : ""; if (empty($tel_id)) { $tel_id = $session->getParameter("_mobile_tel_id"); } $this->_mobile_info = array("currier" => $userAgent->getCarrierLongName(), "user_agent" => $userAgent->getUserAgent(), "tel_id" => $tel_id, "utn" => $userAgent->isDoCoMo() ? " utn" : "", "model" => $userAgent->getModel(), "autologin" => $config[0]['autologin_use']['conf_value'] == _AUTOLOGIN_OK ? _AUTOLOGIN_OK : _OFF); $session->setParameter("_mobile_tel_id", $tel_id); if ($userAgent->isDoCoMo()) { if (empty($_SERVER["HTTP_REFERER"])) { $_SERVER["HTTP_REFERER"] = BASE_URL; } } /* * IPチェック(調査日 2010.09.01) */ $mobile_ip["DoCoMo"] = array("210.153.84.0/24", "210.136.161.0/24", "210.153.86.0/24", "124.146.174.0/24", "124.146.175.0/24", "202.229.176.0/24", "202.229.177.0/24", "202.229.178.0/24", "202.229.179.0/24", "111.89.188.0/24", "111.89.189.0/24", "111.89.190.0/24", "111.89.191.0/24", "210.153.87.0/24", "203.138.180.0/24", "203.138.181.0/24", "203.138.203.0/24"); $mobile_ip["EZWeb"] = array("210.230.128.224/28", "121.111.227.160/27", "61.117.1.0/28", "219.108.158.0/27", "219.125.146.0/28", "61.117.2.32/29", "61.117.2.40/29", "219.108.158.40/29", "219.125.148.0/25", "222.5.63.0/25", "222.5.63.128/25", "222.5.62.128/25", "59.135.38.128/25", "219.108.157.0/25", "219.125.145.0/25", "121.111.231.0/25", "121.111.227.0/25", "118.152.214.192/26", "118.159.131.0/25", "118.159.133.0/25", "118.159.132.160/27", "111.86.142.0/26", "111.86.141.64/26", "111.86.141.128/26", "111.86.141.192/26", "118.159.133.192/26", "111.86.143.192/27", "111.86.143.224/27", "111.86.147.0/27", "111.86.142.128/26", "111.86.142.192/26", "111.86.143.0/26", "61.117.0.128/25", "61.117.1.128/25", "218.222.1.0/25", "218.222.1.128/28", "218.222.1.160/28", "61.202.3.64/28", "219.125.148.160/27", "121.111.231.160/27", "219.125.148.192/27", "222.7.56.0/27", "222.7.56.32/27", "222.7.56.96/27", "222.7.56.128/27", "222.7.56.192/27", "222.7.56.224/27", "222.7.57.64/27", "222.7.57.96/27", "222.7.57.128/27", "222.7.57.160/27", "222.7.57.192/27", "222.7.57.224/27", "219.125.151.128/27", "219.125.151.160/27", "219.125.151.192/27", "222.7.57.32/27", "222.15.68.192/26", "59.135.39.128/27", "118.152.214.160/27", "118.152.214.128/27", "222.1.136.96/27", "222.1.136.64/27", "59.128.128.0/20", "210.169.40.0/24", "211.5.2.128/25", "222.7.57.0/24", "210.196.3.192/26", "211.5.7.0/24", "59.135.38.128/25", "210.196.5.192/26", "218.222.1.0/24", "61.117.0.0/24", "210.230.128.0/24", "61.117.1.0/24", "219.125.148.0/24", "210.230.141.192/26", "219.108.158.0/26", "61.117.2.0/26", "210.234.105.32/29", "210.251.1.192/26", "219.125.151.128/25", "210.234.108.64/26", "61.202.3.0/24", "210.251.2.0/27", "222.5.63.0/24", "211.5.1.0/24", "222.7.56.0/24"); $mobile_ip["Softbank"] = array("123.108.237.0/27", "202.253.96.224/27", "210.146.7.192/26", "210.175.1.128/25", "123.108.237.224/27", "202.253.96.0/27", "123.108.236.0/24", "202.179.203.0/24", "202.179.203.0/24", "210.146.60.128/25", "210.169.171.0/24", "210.169.176.0/24", "210.175.1.128/25", "210.169.130.112/28", "210.228.189.0/24", "123.108.236.0/24", "202.179.204.0/24", "210.146.60.192/26", "210.151.9.128/26", "210.228.189.0/24", "211.8.159.128/25", "123.108.237.240/28", "202.253.96.0/28", "123.108.237.240/28", "202.253.96.0/28", "219.73.128.0/17", "117.46.128.0/17"); $mobile_ip["WILLCOM"] = array("61.198.128.0/24", "61.198.129.0/24", "61.198.130.0/24", "61.198.131.0/24", "61.198.132.0/24", "61.198.133.0/24", "61.198.134.0/24", "61.198.135.0/24", "61.198.136.0/24", "61.198.137.0/24", "61.198.138.100/32", "61.198.138.101/32", "61.198.138.102/32", "61.198.138.103/32", "61.198.139.0/29", "61.198.139.128/27", "61.198.139.160/28", "61.198.140.0/24", "61.198.141.0/24", "61.198.142.0/24", "61.198.143.0/24", "61.198.160.0/24", "61.198.161.0/24", "61.198.162.0/24", "61.198.163.0/24", "61.198.164.0/24", "61.198.165.0/24", "61.198.166.0/24", "61.198.168.0/24", "61.198.169.0/24", "61.198.170.0/24", "61.198.171.0/24", "61.198.172.0/24", "61.198.173.0/24", "61.198.174.0/24", "61.198.175.0/24", "61.198.248.0/24", "61.198.249.0/24", "61.198.250.0/24", "61.198.251.0/24", "61.198.252.0/24", "61.198.253.0/24", "61.198.254.0/24", "61.198.255.0/24", "61.204.0.0/24", "61.204.2.0/24", "61.204.3.0/25", "61.204.3.128/25", "61.204.4.0/24", "61.204.5.0/24", "61.204.6.0/25", "61.204.6.128/25", "61.204.7.0/25", "61.204.92.0/24", "61.204.93.0/24", "61.204.94.0/24", "61.204.95.0/24", "125.28.0.0/24", "125.28.1.0/24", "125.28.15.0/24", "125.28.16.0/24", "125.28.17.0/24", "125.28.2.0/24", "125.28.3.0/24", "125.28.4.0/24", "125.28.5.0/24", "125.28.8.0/24", "210.168.246.0/24", "210.168.247.0/24", "210.169.92.0/24", "210.169.93.0/24", "210.169.94.0/24", "210.169.95.0/24", "210.169.96.0/24", "210.169.97.0/24", "210.169.98.0/24", "210.169.99.0/24", "211.126.192.128/25", "211.18.232.0/24", "211.18.233.0/24", "211.18.234.0/24", "211.18.235.0/24", "211.18.236.0/24", "211.18.237.0/24", "219.108.10.0/24", "219.108.11.0/24", "219.108.12.0/24", "219.108.13.0/24", "219.108.14.0/24", "219.108.15.0/24", "219.108.7.0/24", "219.108.8.0/24", "219.108.9.0/24", "221.119.0.0/24", "221.119.1.0/24", "221.119.2.0/24", "221.119.3.0/24", "221.119.4.0/24", "221.119.6.0/24", "221.119.7.0/24", "221.119.8.0/24", "221.119.9.0/24", "114.20.49.0/24", "114.20.50.0/24", "114.20.51.0/24", "114.20.52.0/24", "114.20.53.0/24", "114.20.54.0/24", "114.20.55.0/24", "114.20.56.0/24", "114.20.57.0/24", "114.20.58.0/24", "114.20.59.0/24", "114.20.60.0/24", "114.20.61.0/24", "114.20.62.0/24", "114.20.63.0/24", "114.20.64.0/24", "114.20.65.0/24", "114.20.66.0/24", "114.20.67.0/24", "114.21.255.0/27", "219.108.2.0/24", "219.108.3.0/24", "125.28.6.0/24", "125.28.7.0/24", "125.28.11.0/24", "125.28.12.0/24", "125.28.13.0/24", "125.28.14.0/24", "211.18.238.0/24", "211.18.239.0/24", "219.108.4.0/24", "219.108.5.0/24", "219.108.6.0/24", "221.119.5.0/24", "124.211.23.0/26"); $this->_mobile_info["ip_address"] = $_SERVER['REMOTE_ADDR']; $this->_mobile_info["ip_addr_zone"] = ""; $this->_mobile_info["proper_route"] = _OFF; foreach ($mobile_ip as $key => $ip_list) { foreach ($ip_list as $zone) { $valid = Net_IPv4::ipInNetwork($this->_mobile_info["ip_address"], $zone); if ($valid) { $this->_mobile_info["ip_addr_zone"] = $zone; $this->_mobile_info["proper_route"] = _ON; break; } } if ($valid) { break; } } if (empty($this->_mobile_info['proper_route'])) { $this->_mobile_info['autologin'] = _OFF; } }