本文整理汇总了PHP中Subnets::has_slaves方法的典型用法代码示例。如果您正苦于以下问题:PHP Subnets::has_slaves方法的具体用法?PHP Subnets::has_slaves怎么用?PHP Subnets::has_slaves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subnets
的用法示例。
在下文中一共展示了Subnets::has_slaves方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
print "</span>";
# hidden
print "<input type='hidden' name='subnetId' value='{$_POST['subnetId']}'>";
print "\t</td>";
print "</tr>";
}
} else {
print "<tr>";
print "\t<td colspan='2'><span class='alert alert-info'>" . _('No groups available') . "</span></td>";
print "</tr>";
}
?>
<!-- set parameters to slave subnets -->
<?php
if ($Subnets->has_slaves($_POST['subnetId'])) {
?>
<tr>
<td colspan="2" class="hr"><hr></td>
</tr>
<tr>
<td><?php
print _('Propagate changes');
?>
</td>
<td>
<input type="checkbox" name="set_inheritance" class="input-switch" value="Yes" checked="checked">
</td>
</tr>
<tr class="warning2">
<td colspan="2">
示例2: explode
$User->check_user_session();
# set sorting
$tmp = explode("|", $_POST['direction']);
$sort['field'] = $tmp[0];
$sort['direction'] = $tmp[1];
if ($sort['direction'] == "asc") {
$sort['directionNext'] = "desc";
} else {
$sort['directionNext'] = "asc";
}
# subnet-related variables
$subnet = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
//subnet details
$subnet_detailed = $Subnets->get_network_boundaries($subnet['subnet'], $subnet['mask']);
//set network boundaries
$slaves = $Subnets->has_slaves($subnet['id']) ? true : false;
//check if subnet has slaves and set slaves flag true/false
# fetch all addresses - sorted
if ($slaves) {
$addresses = $Addresses->fetch_subnet_addresses_recursive($subnet['id'], false, $sort['field'], $sort['direction']);
$slave_subnets = (array) $Subnets->fetch_subnet_slaves($subnet['id']);
} else {
$addresses = $Addresses->fetch_subnet_addresses($subnet['id'], $sort['field'], $sort['direction']);
}
# set permissions
$subnet_permission = $Subnets->check_permission($User->user, $subnet['id']);
}
# We need DNS object
$DNS = new DNS($Database, $User->settings);
/* verifications */
# checks
示例3: die
// verify fping path
if ($Scan->icmp_type == "fping") {
if (!file_exists($Scan->settings->scanFPingPath)) {
die("Invalid fping path!");
}
}
//first fetch all subnets to be scanned
$scan_subnets = $Subnets->fetch_all_subnets_for_discoveryCheck(1);
//set addresses
if ($scan_subnets !== false) {
// initial array
$addresses_tmp = array();
// loop
foreach ($scan_subnets as $s) {
// if subnet has slaves dont check it
if ($Subnets->has_slaves($s->id) === false) {
$addresses_tmp[$s->id] = $Scan->prepare_addresses_to_scan("discovery", $s->id, false);
}
}
//reindex
if (sizeof($addresses_tmp) > 0) {
foreach ($addresses_tmp as $s_id => $a) {
foreach ($a as $ip) {
$addresses[] = array("subnetId" => $s_id, "ip_addr" => $ip);
}
}
}
}
if ($Scan->debugging) {
print_r($scan_subnets);
}
示例4:
// same default vlan for nested
$subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId'];
// same default vrf for nested
}
# set master if it came from free space!
if (isset($_POST['freespaceMSID'])) {
$subnet_old_details['masterSubnetId'] = $_POST['freespaceMSID'];
// dumb name, but it will do :)
}
}
# fetch custom fields
$custom_fields = $Tools->fetch_custom_fields('subnets');
# fetch vrfs
$vrfs = $Tools->fetch_all_objects("vrf", "name");
# check if it has slaves - if yes it cannot be splitted!
$slaves = $Subnets->has_slaves($_POST['subnetId']);
# fetch all sections
$sections = $Sections->fetch_all_sections();
# for vlan result on the fly
if (isset($_POST['vlanId'])) {
$subnet_old_details['vlanId'] = $_POST['vlanId'];
}
# set readonly flag
$readonly = $_POST['action'] == "edit" || $_POST['action'] == "delete" ? true : false;
?>
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-switch.min.css">
<script type="text/javascript" src="js/bootstrap-switch.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
示例5: Subnets
$limit = 80;
// 80 percent threshold
# initialize objects
$Database = new Database_PDO();
$Subnets = new Subnets($Database);
$Addresses = new Addresses($Database);
$Tools = new Tools($Database);
$Result = new Result();
# fetch all subnets
$all_subnets = $Tools->fetch_all_objects("subnets");
# loop and check usage for each, make sure it does not have any parent
foreach ($all_subnets as $k => $s) {
// marked as full should not be checked
if ($s->isFull != 1) {
// parent check
if (!$Subnets->has_slaves($s->id)) {
// count number of addresses
$cnt = $Addresses->count_subnet_addresses($s->id);
// calculate usage
$usage = $Subnets->calculate_subnet_usage($cnt, $s->mask, $s->subnet, $s->isFull);
// if more than $threshold report
if ($usage['freehosts_percent'] < 100 - $limit) {
// this subnet has high usage, save it to array
$out[$k]['subnet'] = $Subnets->transform_address($s->subnet, "dotted") . "/" . $s->mask;
$out[$k]['description'] = $s->description;
$out[$k]['usage'] = $usage;
}
}
}
}
# any fount
示例6:
$User->check_user_session();
# create csrf token
$csrf = $User->csrf_cookie("create", "split");
# ID must be numeric
if (!is_numeric($_POST['subnetId'])) {
$Result->show("danger", _("Invalid ID"), true, true);
}
# get subnet details
$subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']);
# verify that user has write permissions for subnet
$subnetPerm = $Subnets->check_permission($User->user, $subnet->id);
if ($subnetPerm < 3) {
$Result->show("danger", _('You do not have permissions to resize subnet') . '!', true, true);
}
# check if it has slaves - if yes it cannot be splitted!
if ($Subnets->has_slaves($subnet->id)) {
$Result->show("danger", _('Only subnets that have no nested subnets can be splitted') . "!", true, true);
}
# calculate max mask
$max_new_mask = $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)) == "IPv4" ? 32 : 128;
# die if too small
if ($max_new_mask < $subnet->mask) {
$Result->show("danger", _("Subnet too small to be splitted"), true, true);
}
$n = 2;
# step
$m = 0;
# array id
//set mask options
for ($mask = $subnet->mask + 1; $mask <= $max_new_mask; $mask++) {
# set vars
示例7: elseif
print "<blockquote style='margin-top:20px;margin-left:20px;'>";
print "<p>" . _("No subnet is selected for threshold check") . "</p>";
print "<small>" . _("You can set threshold for subnets under subnet settings") . "</small>";
print "</blockquote>";
} elseif (!isset($out)) {
print "<hr>";
print "<blockquote style='margin-top:20px;margin-left:20px;'>";
print "<p>" . _("No subnet selected for threshold check available") . "</p>";
print "<small>" . _("No subnet with threshold check available") . "</small>";
print "</blockquote>";
} else {
print "<div class='hContent' style='padding:10px;'>";
// count usage
foreach ($out as $k => $s) {
//check if subnet has slaves and set slaves flag true/false
$slaves = $Subnets->has_slaves($s->id) ? true : false;
# fetch all addresses and calculate usage
if ($slaves) {
$addresses = $Addresses->fetch_subnet_addresses_recursive($s->id, false);
$slave_subnets = (array) $Subnets->fetch_subnet_slaves($s->id);
// save count
$addresses_cnt = gmp_strval(sizeof($addresses));
# full ?
if (sizeof($slave_subnets) > 0) {
foreach ($slave_subnets as $ss) {
if ($ss->isFull == 1) {
# calculate max
$max_hosts = $Subnets->get_max_hosts($ss->mask, $Subnets->identify_address($ss->subnet), true);
# count
$count_hosts = $Addresses->count_subnet_addresses($ss->id);
# add
示例8: foreach
print "\t<th>" . _('Description') . "</th>";
print "\t<th>" . _('Section') . "</th>";
print "\t<th>" . _('VLAN') . "</th>";
print "\t<th></th>";
print "</tr>";
# subnets
foreach ($fsubnets as $f) {
# must be either subnet or folder
if (sizeof($f) > 0) {
print "<tr class='favSubnet-{$f['subnetId']}'>";
if ($f['isFolder'] == 1) {
$master = true;
print "\t<td><a href='" . create_link("folder", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-folder'></i> {$f['description']}</a></td>";
} else {
//master?
if ($Subnets->has_slaves($f['subnetId'])) {
$master = true;
print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-folder-o'></i>" . $Subnets->transform_to_dotted($f['subnet']) . "/{$f['mask']}</a></td>";
} else {
$master = false;
print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-sitemap' ></i>" . $Subnets->transform_to_dotted($f['subnet']) . "/{$f['mask']}</a></td>";
}
}
print "\t<td>{$f['description']}</td>";
print "\t<td><a href='" . create_link("subnets", $f['sectionId']) . "'>{$f['section']}</a></td>";
# get vlan info
if (strlen($f['vlanId']) > 0 && $f['vlanId'] != 0) {
$vlan = $Tools->fetch_object("vlans", "vlanId", $f['vlanId']);
print "\t<td>{$vlan->number}</td>";
} else {
print "\t<td>/</td>";