当前位置: 首页>>代码示例>>PHP>>正文


PHP Net_IPv4::ipInNetwork方法代码示例

本文整理汇总了PHP中Net_IPv4::ipInNetwork方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_IPv4::ipInNetwork方法的具体用法?PHP Net_IPv4::ipInNetwork怎么用?PHP Net_IPv4::ipInNetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_IPv4的用法示例。


在下文中一共展示了Net_IPv4::ipInNetwork方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_config_by_network

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();
}
开发者ID:udomsak,项目名称:rahunas,代码行数:12,代码来源:networkchk.php

示例2: isMobileIPAddress

 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;
 }
开发者ID:phenom,项目名称:OpenPNE3,代码行数:13,代码来源:sfOpenPNEWebRequest.class.php

示例3: isMobileIPAddress

 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;
 }
开发者ID:TadahiroKudo,项目名称:OpenPNE3,代码行数:18,代码来源:opWebRequest.class.php

示例4: checkIpv4AddressType

/**
 * 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;
}
开发者ID:retexica,项目名称:phpipam,代码行数:32,代码来源:functions-tools.php

示例5: match_network

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;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:46,代码来源:functions.inc.php

示例6: MAX_remotehostPrivateAddress

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;
}
开发者ID:villos,项目名称:tree_admin,代码行数:14,代码来源:ag.php

示例7: print_debug

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;
            }
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:graph.php

示例8: VerifyIpAddress

/**
 * 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;
    }
}
开发者ID:retexica,项目名称:phpipam,代码行数:48,代码来源:functions-network.php

示例9: check_ips

 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;
 }
开发者ID:pemiu01,项目名称:WordPress-IP-Geo-Block,代码行数:32,代码来源:class-ip-geo-block.php

示例10: print_addresses


//.........这里部分代码省略.........
        //$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;
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:addresses.inc.php

示例11: checkSource

 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;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:46,代码来源:StationFactory.class.php

示例12: strgen

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");
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:31,代码来源:graph.inc.php

示例13: is_ktai_ip

/**
 * 携帯端末からのアクセスかどうかを 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;
}
开发者ID:KimuraYoichi,项目名称:PukiWiki,代码行数:26,代码来源:ktai.php

示例14: print_addresses


//.........这里部分代码省略.........
                        $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 = ' AND P.user_id = ? ';
        $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;
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:101,代码来源:functions-print.inc.php

示例15: is_client_authorized

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;
}
开发者ID:BillTheBest,项目名称:librenms,代码行数:17,代码来源:common.php


注:本文中的Net_IPv4::ipInNetwork方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。