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


PHP Net_IPv4::ip2double方法代码示例

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


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

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

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

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


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