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


PHP Addresses::fetch_subnet_addresses方法代码示例

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


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

示例1: die

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_pingCheck();
if ($Scan->debugging) {
    print_r($scan_subnets);
}
if ($scan_subnets === false) {
    die("No subnets are marked for checking status updates");
}
//fetch all addresses that need to be checked
foreach ($scan_subnets as $s) {
    $subnet_addresses = $Addresses->fetch_subnet_addresses($s->id);
    //set array for fping
    if ($Scan->icmp_type == "fping") {
        $subnets[] = array("id" => $s->id, "cidr" => $Subnets->transform_to_dotted($s->subnet) . "/" . $s->mask);
    }
    //save addresses
    if (sizeof($subnet_addresses) > 1) {
        foreach ($subnet_addresses as $a) {
            //ignore excludePing
            if ($a->excludePing != 1) {
                //create old status
                $tDiff = time() - strtotime($a->lastSeen);
                $oldStatus = $tDiff <= $statuses[1] ? 0 : 2;
                //create different array for fping
                if ($Scan->icmp_type == "fping") {
                    $addresses2[$s->id][$a->id] = array("id" => $a->id, "ip_addr" => $a->ip_addr, "description" => $a->description, "subnetId" => $a->subnetId, "lastSeen" => $a->lastSeen, "oldStatus" => $oldStatus);
开发者ID:rtd,项目名称:phpipam,代码行数:31,代码来源:pingCheck.php

示例2: elseif

     print " <form name='domainEdit' id='domainEdit'><input type='hidden' name='action' value='delete'><input type='hidden' name='id' value='{$domain->id}'></form>";
     print "\t<div class='domain-edit-result'></div>";
     print "</div>";
 } elseif (isset($_POST['DNSrecursive']) && $domain === false) {
     // use default values
     $values = json_decode($User->settings->powerDNS, true);
     $values['name'] = $zone;
     // create domain
     $PowerDNS->domain_edit("add", array("name" => $zone, "type" => "NATIVE"));
     // save id
     $domain_id = $PowerDNS->get_last_db_id();
     // create default records
     $PowerDNS->create_default_records($values);
     // create PTR records
     $Addresses->pdns_validate_connection();
     $hosts = $Addresses->fetch_subnet_addresses($subnet_old_details['id'], "ip_addr", "asc");
     // loop
     if (sizeof($hosts) > 0) {
         $cnt = 0;
         $err = 0;
         $ski = 0;
         // loop
         foreach ($hosts as $h) {
             if ($h->PTRignore == "1") {
                 $ski++;
             } elseif ($Addresses->ptr_add($h, false, $h->id) !== false) {
                 $cnt++;
             } else {
                 $err++;
             }
         }
开发者ID:jselan,项目名称:phpipam,代码行数:31,代码来源:edit-result.php

示例3: DNS

    } 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
if (sizeof($subnet) == 0) {
    $Result->show("danger", _('Subnet does not exist'), true);
}
//subnet doesnt exist
if ($subnet_permission == 0) {
    $Result->show("danger", _('You do not have permission to access this network'), true);
}
开发者ID:rtd,项目名称:phpipam,代码行数:31,代码来源:print-address-table.php

示例4: dirname

require dirname(__FILE__) . '/../../../functions/PEAR/Spreadsheet/Excel/Writer.php';
# initialize required objects
$Database = new Database_PDO();
$Result = new Result();
$User = new User($Database);
$Subnets = new Subnets($Database);
$Tools = new Tools($Database);
$Addresses = new Addresses($Database);
# verify that user is logged in
$User->check_user_session();
# we dont need any errors!
//ini_set('display_errors', 0);
# fetch subnet details
$subnet = (array) $Subnets->fetch_subnet(null, $_GET['subnetId']);
# fetch all IP addresses in subnet
$addresses = $Addresses->fetch_subnet_addresses($_GET['subnetId'], "ip_addr", "asc");
# get all custom fields
$custom_fields = $Tools->fetch_custom_fields('ipaddresses');
# Create a workbook
$filename = "phpipam_subnet_export.xls";
$workbook = new Spreadsheet_Excel_Writer();
//formatting headers
$format_header =& $workbook->addFormat();
$format_header->setBold();
$format_header->setColor('black');
$format_header->setSize(12);
//format vlan
$format_vlan =& $workbook->addFormat();
$format_vlan->setColor('black');
$format_vlan->setSize(11);
//formatting titles
开发者ID:netbuild,项目名称:phpipam,代码行数:31,代码来源:export-subnet.php

示例5: verify_subnet_split

 /**
  * Checks if it ok to split subnet
  *
  * @access private
  * @param mixed $subnet_old
  * @param mixed $number
  * @param string $group
  * @param string $strict
  * @return void
  */
 private function verify_subnet_split($subnet_old, $number, $group, $strict)
 {
     # addresses class
     $Addresses = new Addresses($this->Database);
     # get new mask - how much we need to add to old mask?
     switch ($number) {
         case "2":
             $mask_diff = 1;
             break;
         case "4":
             $mask_diff = 2;
             break;
         case "8":
             $mask_diff = 3;
             break;
         case "16":
             $mask_diff = 4;
             break;
         case "32":
             $mask_diff = 5;
             break;
         case "64":
             $mask_diff = 6;
             break;
         case "128":
             $mask_diff = 7;
             break;
         case "256":
             $mask_diff = 8;
             break;
             //otherwise die
         //otherwise die
         default:
             $Result->show("danger", _("Invalid number of subnets"), true);
     }
     //set new mask
     $mask = $subnet_old->mask + $mask_diff;
     //set number of subnets
     $number_of_subnets = pow(2, $mask_diff);
     //set max hosts per new subnet
     $max_hosts = $this->get_max_hosts($mask, $this->identify_address($this->transform_to_dotted($subnet_old->subnet)), false);
     # create array of new subnets based on number of subnets (number)
     for ($m = 0; $m < $number_of_subnets; $m++) {
         $newsubnets[$m] = (array) $subnet_old;
         $newsubnets[$m]['id'] = $m;
         $newsubnets[$m]['mask'] = $mask;
         // if group is selected rewrite the masterSubnetId!
         if ($group == "yes") {
             $newsubnets[$m]['masterSubnetId'] = $subnet_old->id;
         }
         // recalculate subnet
         if ($m > 0) {
             $newsubnets[$m]['subnet'] = gmp_strval(gmp_add($newsubnets[$m - 1]['subnet'], $max_hosts));
         }
     }
     // recalculate old hosts to put it to right subnet
     $addresses = $Addresses->fetch_subnet_addresses($subnet_old->id, "ip_addr", "asc");
     # get all IP addresses
     $subSize = sizeof($newsubnets);
     # how many times to check
     $n = 0;
     # ip address count
     // loop
     foreach ($addresses as $ip) {
         //cast
         $ip = (array) $ip;
         # check to which it belongs
         for ($m = 0; $m < $subSize; $m++) {
             # check if between this and next - strict
             if ($strict == "yes") {
                 # check if last
                 if ($m + 1 == $subSize) {
                     if ($ip['ip_addr'] > $newsubnets[$m]['subnet']) {
                         $addresses[$n]->subnetId = $newsubnets[$m]['id'];
                     }
                 } elseif ($ip['ip_addr'] > $newsubnets[$m]['subnet'] && $ip['ip_addr'] < @$newsubnets[$m + 1]['subnet']) {
                     $addresses[$n]->subnetId = $newsubnets[$m]['id'];
                 }
             } else {
                 # check if last
                 if ($m + 1 == $subSize) {
                     if ($ip['ip_addr'] >= $newsubnets[$m]['subnet']) {
                         $addresses[$n]->subnetId = $newsubnets[$m]['id'];
                     }
                 } elseif ($ip['ip_addr'] >= $newsubnets[$m]['subnet'] && $ip['ip_addr'] < $newsubnets[$m + 1]['subnet']) {
                     $addresses[$n]->subnetId = $newsubnets[$m]['id'];
                 }
             }
         }
         # if subnetId is still the same save to error
//.........这里部分代码省略.........
开发者ID:seisen,项目名称:phpipam,代码行数:101,代码来源:class.Subnets.php

示例6: foreach

 $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']);
 if (strlen($vlan['number']) > 0) {
     $vlanText = " (vlan: " . $vlan['number'];
     if (strlen($vlan['name']) > 0) {
         $vlanText .= ' - ' . $vlan['name'] . ')';
     } else {
         $vlanText .= ")";
     }
 } else {
     $vlanText = "";
 }
 $worksheet->write($lineCount, 0, $Subnets->transform_to_dotted($subnet['subnet']) . "/" . $subnet['mask'] . " - " . $subnet['description'] . $vlanText, $format_header);
 $worksheet->mergeCells($lineCount, 0, $lineCount, $colSize);
 $lineCount++;
 //IP addresses in subnet
 $ipaddresses = $Addresses->fetch_subnet_addresses($subnet['id']);
 //write headers
 $worksheet->write($lineCount, 0, _('ip address'), $format_title);
 $worksheet->write($lineCount, 1, _('ip state'), $format_title);
 $worksheet->write($lineCount, 2, _('description'), $format_title);
 $worksheet->write($lineCount, 3, _('hostname'), $format_title);
 $worksheet->write($lineCount, 4, _('mac'), $format_title);
 $worksheet->write($lineCount, 5, _('owner'), $format_title);
 $worksheet->write($lineCount, 6, _('device'), $format_title);
 $worksheet->write($lineCount, 7, _('port'), $format_title);
 $worksheet->write($lineCount, 8, _('note'), $format_title);
 $m = 9;
 //custom
 if (sizeof($myFields) > 0) {
     foreach ($myFields as $myField) {
         $worksheet->write($lineCount, $m, $myField['name'], $format_title);
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:generate-xls.php

示例7: array

$domain = $PowerDNS->fetch_domain_by_name($zone);
// default values
$values = json_decode($User->settings->powerDNS, true);
$values['name'] = $zone;
// domain missing, create it and default records
if ($domain === false) {
    // create domain
    $PowerDNS->domain_edit("add", array("name" => $zone, "type" => "NATIVE"));
    // create default records
    $PowerDNS->create_default_records($values);
}
// remove existing records and links
$PowerDNS->remove_all_ptr_records($domain->id);
$Addresses->ptr_unlink_subnet_addresses($subnet->id);
// fetch all hosts
$hosts = $Addresses->fetch_subnet_addresses($subnet->id, "ip_addr", "asc");
// create PTR records
if (sizeof($hosts) > 0) {
    foreach ($hosts as $h) {
        // ignore PTR
        if ($h->PTRignore == "1") {
            $ignored[] = $h;
        } elseif ($Result->validate_hostname($h->dns_name) !== false) {
            // formulate new record
            $record = $PowerDNS->formulate_new_record($domain->id, $PowerDNS->get_ip_ptr_name($h->ip), "PTR", $h->dns_name, $values['ttl']);
            // insert record
            $PowerDNS->add_domain_record($record, false);
            // link
            $Addresses->ptr_link($h->id, $PowerDNS->lastId);
            // ok
            $success[] = $h;
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:refresh-ptr-records-submit.php

示例8: prepare_addresses_to_update

 /**
  * Returns array of all addresses to be scanned
  *
  * @access public
  * @param mixed $subnetId
  * @return void
  */
 public function prepare_addresses_to_update($subnetId)
 {
     # first fetch all addresses
     $Addresses = new Addresses($this->Database);
     // get all existing IP addresses in subnet
     $subnet_addresses = $Addresses->fetch_subnet_addresses($subnetId);
     //create array
     if (sizeof($subnet_addresses) > 0) {
         foreach ($subnet_addresses as $a) {
             $scan_addresses[$a->id] = $a->ip_addr;
         }
         //reindex
         $scan_addresses = array_values(@$scan_addresses);
         //return
         return $scan_addresses;
     } else {
         return array();
     }
 }
开发者ID:routenull0,项目名称:phpipam,代码行数:26,代码来源:class.Scan.php


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