本文整理汇总了PHP中Subnets::fetch_all_subnets_search方法的典型用法代码示例。如果您正苦于以下问题:PHP Subnets::fetch_all_subnets_search方法的具体用法?PHP Subnets::fetch_all_subnets_search怎么用?PHP Subnets::fetch_all_subnets_search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subnets
的用法示例。
在下文中一共展示了Subnets::fetch_all_subnets_search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Sections = new Sections($Database);
$Subnets = new Subnets($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# create csrf token
$csrf = $User->csrf_cookie("create", "linkedsubnet");
# ID must be numeric
if (!is_numeric($_POST['subnetId'])) {
$Result->show("danger", _("Invalid ID"), true, true);
}
# get all IPv6 subnets
$ipv6_subnets = $Subnets->fetch_all_subnets_search("IPv6");
# get subnet details
$subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']);
?>
<!-- header -->
<div class="pHeader"><?php
print _('Link IPv4 subnet to IPv6 subnet');
?>
</div>
<!-- content -->
<div class="pContent">
<span class='muted'><?php
示例2: search_subnets_inside_v6
/**
* Search inside subnets if host address is provided! ipv6
*
* @access private
* @param mixed $search_term
* @param number $high
* @param number $low
* @return array
*/
private function search_subnets_inside_v6($high, $low, $search_req)
{
// same
if ($low == $high) {
# Initialize PEAR NET object
$this->initialize_pear_net_IPv6();
// validate
if ($this->Net_IPv6->checkIPv6($search_req)) {
# ifmask remove it
if (strpos($search_req, "/") > 0) {
$search_req = $this->Net_IPv6->removeNetmaskSpec($search_req);
}
# subnets class
$Subnets = new Subnets($this->Database);
# fetch all subnets
$subnets = $Subnets->fetch_all_subnets_search("IPv6");
# loop and search
foreach ($subnets as $s) {
# cast
$s = (array) $s;
# parse address
$net = $this->Net_IPv6->parseAddress($this->transform_address($s['subnet'], "dotted") . '/' . $s['mask']);
if (gmp_cmp($low, $this->transform_address(@$net['start'], "decimal")) == 1 && gmp_cmp($low, $this->transform_address($net['end'], "decimal")) == -1) {
$ids[] = $s['id'];
}
}
# filter
$ids = sizeof(@$ids) > 0 ? array_filter($ids) : array();
# search
if (sizeof($ids) > 0) {
foreach ($ids as $id) {
$result[] = $Subnets->fetch_subnet(null, $id);
}
}
# return
return sizeof(@$result) > 0 ? array_filter($result) : array();
} else {
return array();
}
} else {
return array();
}
}
示例3: search_subnets_inside
/**
* Search inside subnets if host address is provided!
*
* @access private
* @param mixed $search_term
* @param number $high
* @param number $low
* @return array
*/
private function search_subnets_inside($high, $low)
{
if ($low == $high) {
# subnets class
$Subnets = new Subnets($this->Database);
# fetch all subnets
$subnets = $Subnets->fetch_all_subnets_search();
# loop and search
foreach ($subnets as $s) {
# cast
$s = (array) $s;
//first verify address type
$type = $Subnets->identify_address($s['subnet']);
if ($type == "IPv4") {
# Initialize PEAR NET object
$this->initialize_pear_net_IPv4();
# parse address
$net = $this->Net_IPv4->parseAddress($Subnets->transform_to_decimal($s['subnet']) . '/' . $s['mask']);
if ($low > $Subnets->transform_to_decimal(@$net->network) && $low < $Subnets->transform_to_decimal($net->broadcast)) {
$ids[] = $s['id'];
}
}
}
# filter
$ids = sizeof(@$ids) > 0 ? array_filter($ids) : array();
# search
if (sizeof($ids) > 0) {
foreach ($ids as $id) {
$result[] = $Subnets->fetch_subnet(null, $id);
}
}
# return
return sizeof(@$result) > 0 ? array_filter($result) : array();
} else {
return array();
}
}