本文整理汇总了PHP中Subnets::fetch_section_subnets方法的典型用法代码示例。如果您正苦于以下问题:PHP Subnets::fetch_section_subnets方法的具体用法?PHP Subnets::fetch_section_subnets怎么用?PHP Subnets::fetch_section_subnets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subnets
的用法示例。
在下文中一共展示了Subnets::fetch_section_subnets方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
foreach ($all_vrfs as $vrf) {
//cast
$vrf = (array) $vrf;
$vrf_data[$vrf['name']] = $vrf;
$vrf_data[$vrf['rd']] = $vrf;
# add also RD as VRF name, will allow matches against both name and RD
}
# fetch all sections and load all subnets
$all_sections = $Sections->fetch_all_sections();
# get all subnets in all sections
$edata = array();
$section_names = array();
foreach ($all_sections as $section) {
$section = (array) $section;
$section_names[$section['name']] = $section;
$section_subnets = $Subnets->fetch_section_subnets($section['id']);
# skip empty sections
if (sizeof($section_subnets) == 0) {
continue;
}
foreach ($section_subnets as $subnet) {
$subnet = (array) $subnet;
# load whole record in array
$edata[$section['id']][$subnet['vrfId']][$subnet['ip']][$subnet['mask']] = $subnet;
$edata[$section['id']][$subnet['vrfId']][$subnet['ip']][$subnet['mask']]['type'] = $Subnets->identify_address($subnet['ip']);
}
}
#print_r($vlan_data);
$rows = "";
$counters = array();
$ndata = array();
示例2: section_delete
/**
* Delete section, subsections, subnets and ip addresses
*
* @access private
* @param mixed $values
* @return void
*/
private function section_delete($values)
{
# subnets class
$Subnets = new Subnets($this->Database);
# save old values
$old_section = $this->fetch_section("id", $values['id']);
# check for subsections and store all ids
$all_ids = $this->get_all_section_and_subsection_ids($values['id']);
//array of section + all subsections
# truncate and delete all subnets in all sections, than delete sections
foreach ($all_ids as $id) {
$section_subnets = $Subnets->fetch_section_subnets($id);
if (sizeof($section_subnets) > 0) {
foreach ($section_subnets as $ss) {
//delete subnet
$Subnets->modify_subnet("delete", array("id" => $ss->id));
}
}
# delete all sections
try {
$this->Database->deleteRow("sections", "id", $id);
} catch (Exception $e) {
$this->Log->write("Section {$old_section->name} delete", "Failed to delete section {$old_section->name}<hr>" . $e->getMessage() . "<hr>" . $this->array_to_log($this->reformat_empty_array_fields($values, "NULL")), 2);
$this->Result->show("danger", _("Error: ") . $e->getMessage(), false);
return false;
}
}
# write changelog
$this->Log->write_changelog('section', "delete", 'success', $old_section, array());
# log
$this->Log->write("Section {$old_section->name} delete", "Section {$old_section->name} deleted<hr>" . $this->array_to_log($this->reformat_empty_array_fields((array) $old_section)), 0);
return true;
}
示例3: Subnets
$Subnets = new Subnets($Database);
$Addresses = new Addresses($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# If confirm is not set print delete warning
if ($_POST['action'] == "delete" && !isset($_POST['deleteconfirm'])) {
//for ajax to prevent reload
print "<div style='display:none'>alert alert-danger</div>";
//result
print "<div class='alert alert-warning'>";
//fetch all subsections
$subsections = $Sections->fetch_subsections($_POST['id']);
//print what will be deleted
if (sizeof($subsections) > 0) {
$subnets = $Subnets->fetch_section_subnets($_POST['id']);
//fetch all subnets in section
$num_subnets = sizeof($subnets);
//number of subnets to be deleted
if (sizeof($subnets) > 0) {
foreach ($subnets as $s) {
$out[] = $s;
}
}
//fetch subsection subnets
foreach ($subsections as $ss) {
$subsection_subnets = $Subnets->fetch_section_subnets($ss->id);
//fetch all subnets in subsection
if (sizeof($subsection_subnets) > 0) {
foreach ($subsection_subnets as $sss) {
$out[] = $sss;
示例4: array
$vrf = (array) $vrf;
$vrf_name[$vrf['vrfId']] = $vrf['name'];
}
# Precompute masks values, to avoid too much CPU load
$masks = array();
for ($i = 0; $i <= 32; $i++) {
$masks["IPv4"][$i] = 0xffffffff >> 32 - $i << 32 - $i;
}
# IPv4 masks, long
for ($i = 0; $i <= 128; $i++) {
$masks["IPv6"][$i] = str_repeat('1', $i) . str_repeat('0', 128 - $i);
}
# IPv6 masks, bin str
# Read IPs for the sections we need to order
foreach ($rlist as $sect_id => $sect_check) {
$section_subnets = $Subnets->fetch_section_subnets($sect_id);
# skip empty sections
if (sizeof($section_subnets) == 0) {
continue;
}
$isFolder[$sect_id] = array();
foreach ($section_subnets as &$subnet) {
$subnet = (array) $subnet;
$subnet['ip'] = $Subnets->transform_to_dotted($subnet['subnet']);
$subnet['type'] = $Subnets->identify_address($subnet['ip']);
# Precompute subnet in AND format (long for IPv4 and bin str for IPv6)
$subnet['andip'] = $subnet['type'] == "IPv4" ? $subnet['subnet'] : my_ip2Bin($pi6, $subnet['ip']);
# Add to array
$edata[$sect_id][] = $subnet;
$isFolder[$sect_id][$subnet['id']] = $subnet['isFolder'];
}