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


PHP obj::fetch_subnet方法代码示例

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


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

示例1: get_first_available_address

 /**
  * Returns first available subnet address, false if none
  *
  * @access public
  * @param int $subnetId
  * @param obj $Subnets
  * @return int / false
  */
 public function get_first_available_address($subnetId, $Subnets)
 {
     # fetch all addresses in subnet and subnet
     $addresses = $this->fetch_subnet_addresses($subnetId, "ip_addr", "asc");
     $subnet = (array) $Subnets->fetch_subnet(null, $subnetId);
     # get max hosts
     $max_hosts = $Subnets->get_max_hosts($subnet['mask'], $this->identify_address($subnet['subnet']));
     # full subnet?
     if (sizeof($addresses) >= $max_hosts) {
         return false;
     }
     //full subnet
     # set type
     $ip_version = $this->identify_address($subnet['subnet']);
     # get first diff > 1
     if (sizeof($addresses) > 0) {
         foreach ($addresses as $k => $ipaddress) {
             # check subnet and first IP
             if ($k == 0) {
                 # /31 fix
                 if ($subnet['mask'] == 31) {
                     if (gmp_strval(gmp_sub($addresses[$k]->ip_addr, $subnet['subnet'])) > 0) {
                         return gmp_strval($subnet['subnet']);
                     }
                 } else {
                     if (gmp_strval(gmp_sub($addresses[$k]->ip_addr, $subnet['subnet'])) > 1) {
                         return gmp_strval(gmp_add($subnet['subnet'], 1));
                     } elseif ($ip_version == "IPv6") {
                         if (sizeof($addresses) == 1) {
                             if (gmp_strval(gmp_sub($addresses[$k]->ip_addr, $subnet['subnet'])) == 0) {
                                 return gmp_strval(gmp_add($subnet['subnet'], 1));
                             }
                         }
                     }
                 }
             } else {
                 if (gmp_strval(gmp_sub($addresses[$k]->ip_addr, $addresses[$k - 1]->ip_addr)) > 1) {
                     return gmp_strval(gmp_add($addresses[$k - 1]->ip_addr, 1));
                 }
             }
         }
         return gmp_strval(gmp_add($addresses[$k]->ip_addr, 1));
     } else {
         # /32, /31
         if ($subnet['mask'] == 32 || $subnet['mask'] == 31 || $ip_version == "IPv6") {
             return $subnet['subnet'];
         } else {
             return gmp_strval(gmp_add($subnet['subnet'], 1));
         }
     }
 }
开发者ID:seisen,项目名称:phpipam,代码行数:59,代码来源:class.Addresses.php

示例2: print_folder_breadcrumbs

 /**
  * Print folder breadcrumbs
  *
  * @access private
  * @param obj $Section
  * @param obj $Subnet
  * @param mixed $req
  * @return void
  */
 private function print_folder_breadcrumbs($Section, $Subnet, $req)
 {
     if (isset($req['subnetId'])) {
         # get all parents
         $parents = $Subnet->fetch_parents_recursive($req['subnetId']);
         print "<ul class='breadcrumb'>";
         # remove root - 0
         array_shift($parents);
         # section details
         $section = (array) $Section->fetch_section(null, $req['section']);
         # section name
         print "\t<li><a href='" . create_link("subnets", $section['id']) . "'>{$section['name']}</a> <span class='divider'></span></li>";
         # all parents
         foreach ($parents as $parent) {
             $parent = (array) $parent;
             $subnet = (array) $Subnet->fetch_subnet(null, $parent[0]);
             if ($subnet['isFolder'] == "1") {
                 print "\t<li><a href='" . create_link("folder", $section['id'], $parent[0]) . "'><i class='icon-folder-open icon-gray'></i> {$subnet['description']}</a> <span class='divider'></span></li>";
             } else {
                 print "\t<li><a href='" . create_link("subnets", $section['id'], $parent[0]) . "'><i class='icon-folder-open icon-gray'></i> {$subnet['description']}</a> <span class='divider'></span></li>";
             }
         }
         # parent subnet
         $subnet = (array) $Subnet->fetch_subnet(null, $req['subnetId']);
         print "\t<li>{$subnet['description']}</li>";
         # active subnet
         print "</ul>";
     }
 }
开发者ID:korhaldragonir,项目名称:phpipam,代码行数:38,代码来源:class.Common.php


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