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


PHP Subnets::identify_address方法代码示例

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


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

示例1: array

# 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();
# store new networks in a similar format with edata for easier processing
# check the fields
foreach ($data as &$cdata) {
    $msg = "";
    $action = "";
    $cfieldtds = "";
    # check if required fields are present and not empty
    foreach ($reqfields as $creq) {
        if (!isset($cdata[$creq]) or $cdata[$creq] == "") {
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:import-subnets-check.php

示例2: array

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'];
    }
}
$rows = "";
$counters = array();
# Recompute master/nested relations for the selected sections and address families
foreach ($rlist as $sect_id => $sect_check) {
    # Skip empty sections
    if (!$edata[$sect_id]) {
        continue;
    }
开发者ID:MrWoodward,项目名称:phpipam,代码行数:31,代码来源:import-recompute-logic.php

示例3: _

$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# ID must be numeric
if (!is_numeric($_POST['subnetId'])) {
    $Result->show("danger", _("Invalid ID"), true, true);
}
# verify that user has write permissionss for subnet
if ($Subnets->check_permission($User->user, $_POST['subnetId']) != 3) {
    $Result->show("danger", _('You do not have permissions to modify hosts in this subnet') . "!", true, true);
}
# fetch subnet details
$subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']);
$subnet !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
# IPv6 scanning is not supported
if ($Subnets->identify_address($subnet->subnet) == "IPv6") {
    $Result->show("danger", _('IPv6 scanning is not supported') . '!', true, true);
}
# fix description
$subnet->description = strlen($subnet->description) > 0 ? "(" . $subnet->description . ")" : "";
?>

<!-- header -->
<div class="pHeader"><?php 
print _('Scan subnet');
?>
</div>


<!-- content -->
<div class="pContent">
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:subnet-scan.php

示例4:

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
    $opts[$m]['mask'] = $mask;
    $opts[$m]['number'] = $n;
    $opts[$m]['max'] = $Subnets->get_max_hosts($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)));
    # next
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:split.php

示例5: foreach

 // 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
                     $addresses_cnt = gmp_strval(gmp_add($addresses_cnt, gmp_sub($max_hosts, $count_hosts)));
                 }
             }
         }
         $subnet_usage = $Subnets->calculate_subnet_usage($addresses_cnt, $s->mask, $s->subnet, $s->isFull);
         //Calculate free/used etc
     } else {
         # fetch addresses in subnet
         $addresses_cnt = $Addresses->count_subnet_addresses($s->id);
         # calculate usage
         $subnet_usage = $Subnets->calculate_subnet_usage($addresses_cnt, $s->mask, $s->subnet, $s->isFull);
     }
开发者ID:korhaldragonir,项目名称:phpipam,代码行数:31,代码来源:threshold.php

示例6: dirname

/**
 * Function to get RIPe info for network
 ********************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Subnets = new Subnets($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
/* http://apps.db.ripe.net/whois/lookup/ripe/inetnum/212.58.224.0-212.58.255.255.html.xml */
/* http://apps.db.ripe.net/whois/lookup/ripe/inet6num/2102:840::/32.xml */
# identify address and set proper url
$type = $Subnets->identify_address($_POST['subnet']);
if ($type == "IPv4") {
    $url = "http://apps.db.ripe.net/whois/lookup/ripe/inetnum/{$_POST['subnet']}.xml";
} else {
    $url = "http://apps.db.ripe.net/whois/lookup/ripe/inet6num/{$_POST['subnet']}.xml";
}
/* querry ripe db and parse result */
$xml = @simplexml_load_file($url);
/* fail */
if (!$xml) {
    /* save to json and return */
    header("Content-type: text/javascript");
    echo json_encode(array("Error" => "Subnet not present in RIPE DB<br>Error opening URL {$url}"));
} else {
    foreach ($xml->objects->object[0]->attributes->children() as $m => $subtag) {
        $a = (string) $subtag->attributes()->name;
开发者ID:netbuild,项目名称:phpipam,代码行数:31,代码来源:ripe-query.php

示例7: Result

$Result = new Result();
$User = new User($Database);
$Subnets = new Subnets($Database);
$Tools = new Tools($Database);
$Addresses = new Addresses($Database);
$Ping = new Scan($Database);
# verify that user is logged in
$User->check_user_session();
# validate post
is_numeric($_POST['subnetId']) ?: $Result->show("danger", _("Invalid ID"), true, true, false, true);
if (is_numeric($_POST['id'])) {
    strlen($_POST['id']) != 0 ?: $Result->show("danger", _("Invalid ID"), true, true, false, true);
    # fetch address
    $address = (array) $Addresses->fetch_address(null, $_POST['id']);
} else {
    $validate = $Subnets->identify_address($_POST['id']) == "IPv4" ? filter_var($_POST['id'], FILTER_VALIDATE_IP) : filter_var($_POST['id'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
    if ($validate === false) {
        $Result->show("danger", _("Invalid IP address"), true, true, false, true);
    } else {
        $address['ip'] = $_POST['id'];
    }
}
# set and check permissions
$subnet_permission = $Subnets->check_permission($User->user, $_POST['subnetId']);
$subnet_permission > 2 ?: $Result->show("danger", _('Cannot edit IP address details') . '! <br>' . _('You do not have write access for this network'), true, true);
# try to ping it
$pingRes = $Ping->ping_address($address['ip']);
# update last seen if success
if ($pingRes == 0 && is_numeric($_POST['id'])) {
    @$Ping->ping_update_lastseen($address['id']);
}
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:ping-address.php

示例8: 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();
     }
 }
开发者ID:jonashauge,项目名称:phpipam,代码行数:46,代码来源:class.Tools.php


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