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


PHP Subnets::get_network_boundaries方法代码示例

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


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

示例1: Addresses

    $Addresses = new Addresses($Database);
    # verify that user is logged in
    $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);
开发者ID:rtd,项目名称:phpipam,代码行数:31,代码来源:print-address-table.php

示例2: get_all_possible_subnet_addresses

 /**
  * Fetches all possible subnet addresses
  *
  * @access private
  * @param $subnet		//subnet in decimal format
  * @param int $mask		//subnet mask
  * @return void			//array of ip addresses in decimal format
  */
 private function get_all_possible_subnet_addresses($subnet, $mask)
 {
     # initialize classes
     $Subnets = new Subnets($this->Database);
     # make sure we have proper subnet format
     $subnet = $Subnets->transform_address($subnet, "decimal");
     //fetch start and stop addresses
     $boundaries = (object) $Subnets->get_network_boundaries($subnet, $mask);
     //create array
     if ($mask == 32) {
         $ip[] = $Subnets->transform_to_decimal($boundaries->network);
     } elseif ($mask == 31) {
         $ip[] = $Subnets->transform_to_decimal($boundaries->network);
         $ip[] = $Subnets->transform_to_decimal($boundaries->broadcast);
     } else {
         //set loop limits
         $start = gmp_strval(gmp_add($Subnets->transform_to_decimal($boundaries->network), 1));
         $stop = gmp_strval($Subnets->transform_to_decimal($boundaries->broadcast));
         //loop
         for ($m = $start; $m < $stop; $m++) {
             $ip[] = $m;
         }
     }
     //return
     return $ip;
 }
开发者ID:routenull0,项目名称:phpipam,代码行数:34,代码来源:class.Scan.php

示例3:

         if (!empty($cdata['vlan']) && strtolower($cdata['vlan']) != "na") {
             if (!isset($vlan_data[$cdom][$cdata['vlan']])) {
                 $msg .= "VLAN not found in provided domain.";
                 $action = "error";
             } else {
                 $cdata['vlanId'] = $vlan_data[$cdom][$cdata['vlan']]['vlanId'];
             }
         } else {
             # no VLAN provided
             $cdata['vlanId'] = 0;
         }
     }
 }
 # check data format
 if ($action != "error") {
     if ($net = $Subnets->get_network_boundaries($cdata['subnet'], $cdata['mask'])) {
         $cdata['mask'] = $net['bitmask'];
         $cidr_check = $Subnets->verify_cidr_address($cdata['subnet'] . "/" . $cdata['mask']);
         if (strlen($cidr_check) > 5) {
             $msg .= $cidr_check;
             $action = "error";
         }
     } else {
         $msg .= $net['message'];
         $action = "error";
     }
     if (preg_match("/[;'\"]/", $cdata['description'])) {
         $msg .= "Invalid characters in description.";
         $action = "error";
     }
     if (!empty($cdata['vrf']) && !preg_match("/^[a-zA-Z0-9-:]+\$/", $cdata['vrf'])) {
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:import-subnets-check.php

示例4: Result

$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# validate csrf cookie
$_POST['csrf_cookie'] == $_SESSION['csrf_cookie'] ?: $Result->show("danger", _("Invalid CSRF cookie"), true);
# ID must be numeric
if (!is_numeric($_POST['subnetId'])) {
    $Result->show("danger", _("Invalid ID"), true);
}
# verify that user has write permissions for subnet
if ($Subnets->check_permission($User->user, $_POST['subnetId']) < 3) {
    $Result->show("danger", _('You do not have permissions to resize subnet') . '!', true);
}
# fetch old subnet details and set new
$subnet_old = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
# verify resizing
$Subnets->verify_subnet_resize($subnet_old['subnet'], $_POST['newMask'], $subnet_old['id'], $subnet_old['vrfId'], $subnet_old['masterSubnetId'], $subnet_old['mask'], $subnet_old['sectionId']);
# we need to recalculate subnet address if needed
if ($subnet_old['mask'] < $_POST['newMask']) {
    $subnet_new['subnet'] = $subnet_old['subnet'];
} else {
    $new_boundaries = $Subnets->get_network_boundaries($Subnets->transform_address($subnet_old['subnet'], "dotted"), $_POST['newMask']);
    $subnet_new['subnet'] = $Subnets->transform_address($new_boundaries['network'], "decimal");
}
# set update values
$values = array("id" => $_POST['subnetId'], "subnet" => $subnet_new['subnet'], "mask" => $_POST['newMask']);
if (!$Subnets->modify_subnet("resize", $values)) {
    $Result->show("danger", _("Error resizing subnet") . "!", true);
} else {
    $Result->show("success", _("Subnet resized successfully") . "!", true);
}
开发者ID:mwodz,项目名称:phpipam,代码行数:31,代码来源:resize-save.php


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