• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Net_IPv4类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

 public function execute($params = array())
 {
     $ip = filter_input(INPUT_POST, 'ip');
     $netmask = filter_input(INPUT_POST, 'netmask');
     $validateIP = new Net_IPv4();
     $net = $validateIP->getNetLength($netmask);
     $subnet = $validateIP->getSubnet($ip, $netmask);
     $ipValid = $subnet . '/' . $net;
     $geo_model = new Geo();
     $geos = $geo_model->getGeoList($ipValid);
     require 'app/Views/Geo_View.php';
 }
开发者ID:MontseArchPWeb,项目名称:sessions,代码行数:12,代码来源:GeoController.php


示例2: _get_ranges

 function _get_ranges(&$config)
 {
     // get all ip ranges
     $ranges = array();
     foreach ($config as $carrier => $carrier_ips) {
         foreach ($carrier_ips as $cidr) {
             $cidr = @Net_IPv4::parseAddress($cidr);
             $ranges[] = array('broadcast' => $this->ip2double($cidr->broadcast), 'carrier' => $carrier, 'network' => $this->ip2double($cidr->network));
         }
     }
     // sort
     usort($ranges, array($this, 'compareByNetwork'));
     // unite sequent ip range
     $l = count($ranges);
     $cur =& $ranges[0];
     for ($i = 1; $i < $l; $i++) {
         $next =& $ranges[$i];
         $condition = $cur['broadcast'] + 1 === $next['network'] && $cur['carrier'] === $next['carrier'];
         if ($condition) {
             $cur['broadcast'] = $next['broadcast'];
             unset($ranges[$i]);
         } else {
             $cur =& $ranges[$i];
         }
     }
     $ranges = array_values($ranges);
     // compile data
     $retval = "<?php\n" . "// auto-generated by %s\n" . "// date: %s\n" . "return %s;\n";
     $retval = sprintf($retval, __CLASS__, date('Y/m/d H:i:s'), var_export($ranges, true));
     return $retval;
 }
开发者ID:kaz29,项目名称:mobileip,代码行数:31,代码来源:mobile_ip.php


示例3: 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


示例4: 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


示例5: testWillcom

 function testWillcom()
 {
     $this->mobile_ip->initialize($this->controller);
     $ranges = $this->ranges['willcom'];
     foreach ($ranges as $cidr) {
         $cidr = @Net_IPv4::parseAddress($cidr);
         $network = explode('.', $cidr->network);
         $broadcast = explode('.', $cidr->broadcast);
         $ip = "{$network[0]}.{$network[1]}.{$network[2]}";
         for ($i = $network[3]; $i <= $broadcast[3]; $i++) {
             $this->assertEqual($this->mobile_ip->carrier("{$ip}.{$i}"), 'willcom');
         }
     }
 }
开发者ID:kaz29,项目名称:mobileip,代码行数:14,代码来源:mobile_ip.test.php


示例6: 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


示例7: MAX_remotehostPrivateAddress

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;
}
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:12,代码来源:dxmlrpc.php


示例8: 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


示例9: reformatIPv4forSearch

/**	
 * Reformat incomplete IPv4 address to decimal for search!
 */
function reformatIPv4forSearch($ip)
{
    //remove % sign if present
    $ip = str_replace("%", "", $ip);
    //remove last .
    $size = count($ip);
    $lastChar = substr($ip, -1);
    if ($lastChar == ".") {
        $ip = substr($ip, 0, -1);
    }
    /* check if subnet provided, then we have all we need */
    if (strpos($ip, "/") > 0) {
        require_once 'PEAR/Net/IPv4.php';
        $net = Net_IPv4::parseAddress($ip);
        $result['low'] = transform2decimal($net->network);
        $result['high'] = transform2decimal($net->broadcast);
    } else {
        /* if subnet is not provided maye wildcard is, so explode it to array */
        $ip = explode(".", $ip);
        //4 is ok
        if (sizeof($ip) == 4) {
            $temp = implode(".", $ip);
            $result['low'] = $result['high'] = transform2decimal($temp);
        } else {
            if (sizeof($ip) == 3) {
                $ip[3] = 0;
                $result['low'] = transform2decimal(implode(".", $ip));
                $ip[3] = 255;
                $result['high'] = transform2decimal(implode(".", $ip));
            } else {
                if (sizeof($ip) == 2) {
                    $ip[2] = 0;
                    $ip[3] = 0;
                    $result['low'] = transform2decimal(implode(".", $ip));
                    $ip[2] = 255;
                    $ip[3] = 255;
                    $result['high'] = transform2decimal(implode(".", $ip));
                } else {
                    if (sizeof($ip) == 1) {
                        $ip[1] = 0;
                        $ip[2] = 0;
                        $ip[3] = 0;
                        $result['low'] = transform2decimal(implode(".", $ip));
                        $ip[1] = 255;
                        $ip[2] = 255;
                        $ip[3] = 255;
                        $result['high'] = transform2decimal(implode(".", $ip));
                    } else {
                        $result['low'] = implode(".", $ip);
                        $result['high'] = implode(".", $ip);
                    }
                }
            }
        }
    }
    //return result!
    return $result;
}
开发者ID:retexica,项目名称:phpipam,代码行数:61,代码来源:functions-tools.php


示例10: ipInNetwork

 /**
  * Determines whether or not the supplied IP is within the supplied network.
  *
  * This function determines whether an IP address is within a network.
  * The IP address ($ip) must be supplied in dot-quad format, and the
  * network ($network) may be either a string containing a CIDR
  * formatted network definition, or a Net_IPv4 object.
  *
  * @param  string  $ip      A dot quad representation of an IP address
  * @param  string  $network A string representing the network in CIDR format or a Net_IPv4 object.
  * @return bool             true if the IP address exists within the network
  */
 function ipInNetwork($ip, $network)
 {
     if (!is_object($network) || strcasecmp(get_class($network), 'net_ipv4') != 0) {
         $network = Net_IPv4::parseAddress($network);
     }
     if (strcasecmp(get_class($network), 'pear_error') === 0) {
         return false;
     }
     $net = Net_IPv4::ip2double($network->network);
     $bcast = Net_IPv4::ip2double($network->broadcast);
     $ip = Net_IPv4::ip2double($ip);
     unset($network);
     if ($ip >= $net && $ip <= $bcast) {
         return true;
     }
     return false;
 }
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:29,代码来源:IPv4.php


示例11: list

         </dl>';
     }
     echo "</a></li>";
 }
 /// SEARCH IP ADDRESSES
 list($addr, $mask) = explode('/', $queryString);
 $address_type = "ipv4";
 if (is_numeric(stripos($queryString, ':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.`ipv4_address` LIKE ?';
 $param[] = '%' . $addr . '%';
 #    }
 // FIXME no v6 yet.
 $query = 'SELECT * ';
 $query .= 'FROM `ipv4_addresses` AS A ';
 $query .= 'LEFT JOIN `ports` ON `A`.`port_id` = `ports`.`port_id` ';
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:ajax_search.php


示例12: array

    $old_table[$entry['ifIndex']][$entry['ipv4_address']] = $entry;
}
// Process founded IPv4 addresses
$valid[$ip_version] = array();
$check_networks = array();
if (count($ip_data)) {
    foreach ($ip_data as $ifIndex => $addresses) {
        if (!isset($cache['port_index'][$device_id][$ifIndex])) {
            continue;
        }
        // continue if ifIndex not found
        $port_id = $cache['port_index'][$device_id][$ifIndex];
        foreach ($addresses as $ipv4_address => $entry) {
            $update_array = array();
            $ipv4_mask = $entry['ipAdEntNetMask'];
            $addr = Net_IPv4::parseAddress($ipv4_address . '/' . $ipv4_mask);
            $ipv4_prefixlen = $addr->bitmask;
            $ipv4_network = $addr->network . '/' . $ipv4_prefixlen;
            $full_address = $ipv4_address . '/' . $ipv4_prefixlen;
            // First check networks
            $ipv4_network_id = dbFetchCell('SELECT `ipv4_network_id` FROM `ipv4_networks` WHERE `ipv4_network` = ?', array($ipv4_network));
            if (empty($ipv4_network_id)) {
                $ipv4_network_id = dbInsert(array('ipv4_network' => $ipv4_network), 'ipv4_networks');
                echo 'N';
            }
            // Check IPs in DB
            if (isset($old_table[$ifIndex][$ipv4_address])) {
                foreach (array('ipv4_prefixlen', 'ipv4_network_id', 'port_id') as $param) {
                    if ($old_table[$ifIndex][$ipv4_address][$param] != ${$param}) {
                        $update_array[$param] = ${$param};
                    }
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:ipv4-addresses.inc.php


示例13: getFirstAvailableIPAddress

/**
 * Get first available IP address
 */
function getFirstAvailableIPAddress($subnetId)
{
    global $database;
    /* get all ip addresses in subnet */
    $query = 'SELECT `ip_addr` from `ipaddresses` where `subnetId` = "' . $subnetId . '" order by `ip_addr` ASC;';
    /* execute */
    try {
        $ipAddresses = $database->getArray($query);
    } catch (Exception $e) {
        $error = $e->getMessage();
        print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>";
        return false;
    }
    /* get subnet */
    $query = 'SELECT `subnet`,`mask` from `subnets` where `id` = "' . $subnetId . '";';
    $subnet2 = $database->getArray($query);
    $subnet = $subnet2[0]['subnet'];
    $mask = $subnet2[0]['mask'];
    /* create array of IP addresses */
    $ipaddressArray[] = $subnet;
    foreach ($ipAddresses as $ipaddress) {
        $ipaddressArray[] = $ipaddress['ip_addr'];
    }
    //get array size
    $size = sizeof($ipaddressArray);
    $curr = 0;
    //get type
    $type = IdentifyAddress($subnet);
    // IPv4
    if ($type == "IPv4") {
        //if subnet is /32
        if ($mask == "32") {
            if ($size == 1) {
                $firstAvailable = $ipaddressArray[0];
            } else {
                $firstAvailable = false;
            }
        } elseif ($mask == "31") {
            if ($size == 1) {
                $firstAvailable = $ipaddressArray[0];
            } elseif ($size == 2) {
                $delta = $ipaddressArray[1] - $ipaddressArray[0];
                if ($delta == 1) {
                    $firstAvailable = $ipaddressArray[0];
                } else {
                    $firstAvailable = gmp_strval(gmp_add($ipaddressArray[0], 1));
                }
            } else {
                $firstAvailable = false;
            }
        } elseif ($size == 1) {
            $firstAvailable = gmp_strval(gmp_add($ipaddressArray[0], 1));
        } else {
            //get first change -> delta > 1
            for ($m = 1; $m <= $size - 1; $m++) {
                $delta = gmp_strval(gmp_sub($ipaddressArray[$m], $ipaddressArray[$m - 1]));
                //compare with previous
                if ($delta != 1) {
                    $firstAvailable = gmp_strval(gmp_add($ipaddressArray[$m - 1], 1));
                    $m = $size;
                } else {
                    $firstAvailable = gmp_strval(gmp_add($ipaddressArray[$m], 1));
                }
            }
            //if bcast ignore!
            require_once 'PEAR/Net/IPv4.php';
            $Net_IPv4 = new Net_IPv4();
            $net = $Net_IPv4->parseAddress(transform2long($subnet) . "/" . $mask);
            if ($net->broadcast == transform2long($firstAvailable)) {
                $firstAvailable = false;
            }
        }
    } else {
        //if subnet is /128
        if ($mask == "128" && $type == "IPv6") {
            if ($size == 1) {
                $firstAvailable = $ipaddressArray[0];
            } else {
                $firstAvailable = false;
            }
        } elseif ($mask == "127" && $type == "IPv6") {
            if ($size == 1) {
                $firstAvailable = $ipaddressArray[0];
            } elseif ($size == 2) {
                $delta = $ipaddressArray[1] - $ipaddressArray[0];
                if ($delta == 1) {
                    $firstAvailable = $ipaddressArray[0];
                } else {
                    $firstAvailable = gmp_strval(gmp_add($ipaddressArray[0], 1));
                }
            } else {
                $firstAvailable = false;
            }
        } elseif ($size == 1) {
            $firstAvailable = gmp_strval($ipaddressArray[0]);
        } elseif ($subnet == $ipaddressArray[0]) {
            $firstAvailable = gmp_strval($subnet);
//.........这里部分代码省略.........
开发者ID:retexica,项目名称:phpipam,代码行数:101,代码来源:functions-network.php


示例14: _checkAgent

 /**
  * ユーザーエージェントチェック
  *
  * @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;
     }
 }
开发者ID:RikaFujiwara,项目名称:NetCommons2,代码行数:59,代码来源:MobileCheck.class.php


示例15: perform_snmp_scan

}
if (isset($opts['n'])) {
    $force_network = true;
}
if (isset($opts['b'])) {
    $force_broadcast = true;
}
if (isset($opts['r'])) {
    $net = Net_IPv4::parseAddress($opts['r']);
    if (ip2long($net->network) !== false) {
        perform_snmp_scan($net, $force_network, $force_broadcast);
        echo 'Scanned ' . $stats['count'] . ' IPs, Already known ' . $stats['known'] . ' Devices, Added ' . $stats['added'] . ' Devices, Failed to add ' . $stats['failed'] . ' Devices.' . PHP_EOL;
        echo 'Runtime: ' . (microtime(true) - $ts) . ' secs' . PHP_EOL;
    } else {
        echo 'Could not interpret supplied CIDR noted IP-Range: ' . $opts['r'] . PHP_EOL;
        exit(2);
    }
} elseif (isset($config['nets']) && !empty($config['nets'])) {
    if (!is_array($config['nets'])) {
        $config['nets'] = array($config['nets']);
    }
    foreach ($config['nets'] as $subnet) {
        $net = Net_IPv4::parseAddress($subnet);
        perform_snmp_scan($net, $force_network, $force_broadcast);
    }
    echo 'Scanned ' . $stats['count'] . ' IPs, Already know ' . $stats['known'] . ' Devices, Added ' . $stats['added'] . ' Devices, Failed to add ' . $stats['failed'] . ' Devices.' . PHP_EOL;
    echo 'Runtime: ' . (microtime(true) - $ts) . ' secs' . PHP_EOL;
} else {
    echo 'Please either add a range argument with \'-r <CIDR_RANGE>\' or define $config[\'nets\'] in your config.php' . PHP_EOL;
    exit(2);
}
开发者ID:vitalisator,项目名称:librenms,代码行数:31,代码来源:snmp-scan.php


示例16: 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


示例17: ini_set

    ini_set('error_reporting', E_ALL);
}
require '../includes/defaults.inc.php';
require '../config.php';
require_once '../includes/definitions.inc.php';
require 'includes/functions.inc.php';
require '../includes/functions.php';
require 'includes/authenticate.inc.php';
if (!$_SESSION['authenticated']) {
    echo 'unauthenticated';
    exit;
}
$output = '';
if ($_GET['query'] && $_GET['cmd']) {
    $host = $_GET['query'];
    if (Net_IPv6::checkIPv6($host) || Net_IPv4::validateip($host) || preg_match('/^[a-zA-Z0-9.-]*$/', $host)) {
        switch ($_GET['cmd']) {
            case 'whois':
                $cmd = $config['whois'] . " {$host} | grep -v \\%";
                break;
            case 'ping':
                $cmd = $config['ping'] . " -c 5 {$host}";
                break;
            case 'tracert':
                $cmd = $config['mtr'] . " -r -c 5 {$host}";
                break;
            case 'nmap':
                if ($_SESSION['userlevel'] != '10') {
                    echo 'insufficient privileges';
                } else {
                    $cmd = $config['nmap'] . " {$host}";
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:netcmd.php


示例18: drawPool

function drawPool($id)
{
    $pools = fullIPUsage();
    $mypool = $pools[$id];
    $out = "";
    $out .= "<h2>" . $mypool["location"] . ": " . $mypool["ip_addr"] . "/" . $mypool["netmask"] . "</h2>";
    $out .= _("IP pool size:") . " " . $mypool["pool_size"] . "<br>";
    $out .= _("Number of SSL IP(s):") . " " . $mypool["nbr_ssl"] . "<br>";
    $out .= _("Number of dom0 IP(s):") . " " . $mypool["nbr_dom0"] . "<br>";
    $out .= _("Number of VPS IP(s):") . " " . $mypool["nbr_vps"] . "<br>";
    $out .= _("Number of dedicated IP(s):") . " " . $mypool["nbr_dedicated"] . "<br>";
    $out .= _("Total number of used IPs:") . " " . $mypool["nbr_total_used"] . "<br>";
    $out .= _("Number of IPs remaining in the pool:") . " " . $mypool["ip_remaining"] . "<br>";
    $ip_calc = new Net_IPv4();
    $ip_long = $ip_calc->ip2double($mypool["ip_addr"]);
    $out .= "<table class=\"dtcDatagrid_table_props\" border=\"1\"><tr><td class=\"dtcDatagrid_table_titles\">" . _("IP address") . "</td><td class=\"dtcDatagrid_table_titles\">" . _("Type") . "</td><td class=\"dtcDatagrid_table_titles\">" . _("Name") . "</td><td class=\"dtcDatagrid_table_titles\">" . _("Provision") . "</td></tr>";
    for ($i = 0; $i < $mypool["pool_size"]; $i++) {
        $ip = long2ip($ip_long);
        if ($i % 2) {
            $class = "dtcDatagrid_table_flds_alt";
        } else {
            $class = "dtcDatagrid_table_flds";
        }
        $out .= "<tr><td class=\"{$class}\" style=\"text-align:right;\">" . $ip . "</td>";
        if (isset($mypool["all_ips"][$ip])) {
            $all_ips = $mypool["all_ips"];
            $out .= "<td class=\"{$class}\" style=\"text-align:center;\">" . $mypool["all_ips"][$ip]["type"] . "</td>";
            if (isset($all_ips[$ip]["available"])) {
                if ($all_ips[$ip]["available"] == "yes") {
                    $av = "<b>" . _("FREE") . "</b>";
                } else {
                    $av = _("no");
                }
            } else {
                $av = "-";
            }
            switch ($all_ips[$ip]["type"]) {
                case "vps":
                    $out .= "<td class=\"{$class}\" style=\"text-align:center;\">" . $all_ips[$ip]["vps_xen_name"] . ":" . $all_ips[$ip]["vps_server_hostname"] . "</td><td class=\"{$class}\" style=\"text-align:center;\">" . $av . "</td>";
                    break;
                case "ssl":
                    $out .= "<td class=\"{$class}\" style=\"text-align:center;\">-</td><td class=\"{$class}\" style=\"text-align:center;\">" . $av . "</td>";
                    break;
                case "dedicated":
                    $out .= "<td class=\"{$class}\">" . $all_ips[$ip]["dedicated_server_hostname"] . "</td><td class=\"{$class}\" style=\"text-align:center;\">-</td>";
                    break;
                case "dom0":
                    $out .= "<td class=\"{$class}\">" . $all_ips[$ip]["hostname"] . "</td><td class=\"{$class}\" style=\"text-align:center;\">-</td>";
                    break;
                default:
                    $out .= "<td class=\"{$class}\" style=\"text-align:center;\">-</td><td class=\"{$class}\" style=\"text-align:center;\">-</td>";
                    break;
            }
            $out .= "</tr>";
        } else {
            $out .= "<td class=\"{$class}\" colspan=\"3\" style=\"text-align:center;\"><b>" . _("FREE") . "</b></td></tr>";
        }
        $ip_long++;
    }
    $out .= "</table>";
    return $out;
}
开发者ID:jeremy-cayrasso,项目名称:dtc,代码行数:62,代码来源:ip_usage_report.php


示例19: is_ipv4_valid

function is_ipv4_valid($ipv4_address, $ipv4_prefixlen = NULL)
{
    if (strpos($ipv4_address, '/') !== FALSE) {
        list($ipv4_address, $ipv4_prefixlen) = explode('/', $ipv4_address);
    }
    // False if prefix less or equal 0 and more 32
    if (is_numeric($ipv4_prefixlen) && ($ipv4_prefixlen < '1' || $ipv4_prefixlen > '32')) {
        return FALSE;
    }
    // False if invalid IPv4 syntax
    if (!Net_IPv4::validateIP($ipv4_address)) {
        return FALSE;
    }
    // False if 0.0.0.0
    if ($ipv4_address == '0.0.0.0') {
        return FALSE;
    }
    return TRUE;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:19,代码来源:functions.php


示例20: ipInNetwork

 /**
  * Determines whether or not the supplied IP is within the supplied network.
  *
  * This function determines whether an IP address is within a network.
  * The IP address ($ip) must be supplied in dot-quad format, and the
  * network ($network) may be either a string containing a CIDR
  * formatted network definition, or a Net_IPv4 object.
  *
  * @param  string $ip A quad-dot representation of an IP address 
  * @param  string $network A string representing the network in CIDR format or a Net_IPv4 object.
  * @return boolean  true if the IP address exists within the network
  */
 function ipInNetwork($ip, $network)
 {
     if (!is_object($network) || get_class($network) != 'net_ipv4') {
         $network = Net_IPv4::parseAddress($network);
     }
     if (!is_object($network) || get_class($network) != 'net_ipv4') {
         return $network;
     }
     $net = Net_IPv4::ip2double($network->network);
     $bcast = Net_IPv4::ip2double($network->broadcast);
     $ip = Net_IPv4::ip2double($ip);
     unset($network);
     if ($ip >= $net && $ip <= $bcast) {
         return TRUE;
     }
     return FALSE;
     return (double) sprintf("%u", ip2long($ip));
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:30,代码来源:IPv4.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Net_IPv6类代码示例发布时间:2022-05-23
下一篇:
PHP Net_IDNA2类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap