本文整理汇总了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));
}
}
}
示例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>";
}
}