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


PHP Subnets类代码示例

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


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

示例1: dirname

<?php

/*
 * Scan subnet for new hosts
 ***************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$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
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:subnet-scan.php

示例2: fetch_subnet_slaves_changlog_entries_recursive

 /**
  * Fetches changelog entries for all slave subnets recursive
  *
  * @access public
  * @param mixed $subnetId
  * @param int $limit (default: 50)
  * @return void
  */
 public function fetch_subnet_slaves_changlog_entries_recursive($subnetId, $limit = 50)
 {
     # limit check
     if (!is_numeric($limit)) {
         $this->Result->show("danger", "Invalid limit", true);
         return false;
     }
     # $subnetId check
     if (!is_numeric($subnetId)) {
         $this->Result->show("danger", "Invalid subnet Id", true);
         return false;
     }
     # fetch all slave subnet ids
     $Subnets = new Subnets($this->Database);
     $Subnets->reset_subnet_slaves_recursive();
     $Subnets->fetch_subnet_slaves_recursive($subnetId);
     # remove master subnet ID
     $key = array_search($subnetId, $Subnets->slaves);
     unset($Subnets->slaves[$key]);
     $Subnets->slaves = array_unique($Subnets->slaves);
     # if some slaves are present get changelog
     if (sizeof($Subnets->slaves) > 0) {
         # set query
         $query = "select\n\t\t\t\t\t\t`u`.`real_name`,`o`.`sectionId`,`o`.`subnet`,`o`.`mask`,`o`.`isFolder`,`o`.`description`,`o`.`id`,`c`.`caction`,`c`.`cresult`,`c`.`cdate`,`c`.`cdiff`  from `changelog` as `c`, `users` as `u`, `subnets` as `o`\n\t\t\t\t\t\twhere `c`.`cuser` = `u`.`id` and `c`.`coid`=`o`.`id`\n\t\t\t\t\t\tand (";
         foreach ($Subnets->slaves as $slaveId) {
             if (!isset($args)) {
                 $args = array();
             }
             $query .= "`c`.`coid` = ? or ";
             $args[] = $slaveId;
             //set keys
         }
         $query = substr($query, 0, -3);
         $query .= ") and `c`.`ctype` = 'subnet' order by `c`.`cid` desc limit {$limit};";
         # fetch
         try {
             $logs = $this->Database->getObjectsQuery($query, $args);
         } catch (Exception $e) {
             $this->Result->show("danger", $e->getMessage(), false);
             return false;
         }
         # return result
         return $logs;
     } else {
         return false;
     }
 }
开发者ID:routenull0,项目名称:phpipam,代码行数:55,代码来源:class.Log.php

示例3: dirname

<?php

/*
 * Print truncate subnet
 *********************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$Addresses = new Addresses($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# create csrf token
$csrf = $User->create_csrf_cookie();
# id must be numeric
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);
}
?>
开发者ID:mwodz,项目名称:phpipam,代码行数:30,代码来源:truncate.php

示例4: foreach

    foreach ($scan_subnets as $sk => $s) {
        if (isset($add_tmp[$s->id])) {
            $scan_subnets[$sk]->discovered = $add_tmp[$s->id];
        }
    }
}
# print change
if ($Scan->debugging) {
    "\nDiscovered addresses:\n----------\n";
    print_r($scan_subnets);
}
# reinitialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$Addresses = new Addresses($Database);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Scan = new Scan($Database);
$Result = new Result();
# insert to database
$discovered = 0;
//for mailing
foreach ($scan_subnets as $s) {
    if (sizeof(@$s->discovered) > 0) {
        foreach ($s->discovered as $ip) {
            // fetch subnet
            $subnet = $Subnets->fetch_subnet("id", $s->id);
            $nsid = $subnet === false ? false : $subnet->nameserverId;
            // try to resolve hostname
            $hostname = $DNS->resolve_address($ip, false, true, $nsid);
            //set update query
开发者ID:mwodz,项目名称:phpipam,代码行数:31,代码来源:discoveryCheck.php

示例5: dirname

<?php

/*
 * Print edit folder
 *********************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Sections = new Sections($Database);
$Subnets = new Subnets($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# create csrf token
$csrf = $User->csrf_cookie("create", "folder");
# strip tags - XSS
$_POST = $User->strip_input_tags($_POST);
# validate action
$Admin->validate_action($_POST['action'], true);
# ID must be numeric
if ($_POST['action'] != "add") {
    if (!is_numeric($_POST['subnetId'])) {
        $Result->show("danger", _("Invalid ID"), true, true);
    }
}
# verify that user has permissions to add subnet
if ($_POST['action'] == "add") {
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:edit-folder.php

示例6: dirname

<?php

/**
 * Script to check edited / deleted / new IP addresses
 * If all is ok write to database
 *************************************************/
# include required scripts
require dirname(__FILE__) . '/../../../functions/functions.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);
$Log = new Logging($Database, $User->settings);
$Zones = new FirewallZones($Database);
$Ping = new Scan($Database);
# verify that user is logged in
$User->check_user_session();
# validate csrf cookie
$User->csrf_cookie("validate", "address", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
# validate action
$Tools->validate_action($_POST['action']);
$action = $_POST['action'];
//reset delete action form visual visual
if (isset($_POST['action-visual'])) {
    if (@$_POST['action-visual'] == "delete") {
        $action = "delete";
    }
}
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:address-modify-submit.php

示例7: dirname

<?php

/**
 * Function to add / edit / delete subnet
 ********************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$Sections = new Sections($Database);
$Addresses = new Addresses($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# ID must be numeric
if ($_POST['action'] == "add") {
    if (!is_numeric($_POST['sectionId'])) {
        $Result->show("danger", _("Invalid ID"), true);
    }
} else {
    if (!is_numeric($_POST['subnetId'])) {
        $Result->show("danger", _("Invalid ID"), true);
    }
    if (!is_numeric($_POST['sectionId'])) {
        $Result->show("danger", _("Invalid ID"), true);
    }
}
开发者ID:jselan,项目名称:phpipam,代码行数:31,代码来源:edit-result.php

示例8: dirname

<?php

# include required scripts
require dirname(__FILE__) . '/../functions.php';
# limit
$limit = 80;
// 80 percent threshold
# initialize objects
$Database = new Database_PDO();
$Subnets = new Subnets($Database);
$Addresses = new Addresses($Database);
$Tools = new Tools($Database);
$Result = new Result();
# fetch all subnets
$all_subnets = $Tools->fetch_all_objects("subnets");
# loop and check usage for each, make sure it does not have any parent
foreach ($all_subnets as $k => $s) {
    // marked as full should not be checked
    if ($s->isFull != 1) {
        // parent check
        if (!$Subnets->has_slaves($s->id)) {
            // count number of addresses
            $cnt = $Addresses->count_subnet_addresses($s->id);
            // calculate usage
            $usage = $Subnets->calculate_subnet_usage($cnt, $s->mask, $s->subnet, $s->isFull);
            // if more than $threshold report
            if ($usage['freehosts_percent'] < 100 - $limit) {
                // this subnet has high usage, save it to array
                $out[$k]['subnet'] = $Subnets->transform_address($s->subnet, "dotted") . "/" . $s->mask;
                $out[$k]['description'] = $s->description;
                $out[$k]['usage'] = $usage;
开发者ID:korhaldragonir,项目名称:phpipam,代码行数:31,代码来源:find_full_subnets.php

示例9: dirname

<?php

/*
 * CSV import form + guide
 *************************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# classes
$Database = new Database_PDO();
$User = new User($Database);
$Tools = new Tools($Database);
$Addresses = new Addresses($Database);
$Subnets = new Subnets($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# permissions
$permission = $Subnets->check_permission($User->user, $_POST['subnetId']);
# die if write not permitted
if ($permission < 2) {
    $Result->show("danger", _('You cannot write to this subnet'), true);
}
# fetch subnet details
$subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']);
$subnet !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
# full
if ($_POST['type'] != "update-icmp" && $subnet->isFull == 1) {
    $Result->show("warning", _("Cannot scan as subnet is market as used"), true, true);
}
# get custom fields
$custom_address_fields = $Tools->fetch_custom_fields('ipaddresses');
开发者ID:jselan,项目名称:phpipam,代码行数:31,代码来源:index.php

示例10: dirname

<?php

/**
 * Function to add / edit / delete section
 *************************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Sections = new Sections($Database);
$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
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:edit-result.php

示例11: array

$resolve_config['emptyonly'] = true;
# if true it will only update the ones without DNS entry!
$resolve_config['subnets'] = array();
# which subnets to check - by id
# example -> array(1,3,5)	will only update subnets with id 1,3,5
# 	you can get id's and descriptions with following MySQL query:
#	select `id`,`description` from `subnets`;
$resolve_config['verbose'] = true;
# verbose response - prints results, cron will email it to you!
# include required scripts
require dirname(__FILE__) . '/../functions.php';
require dirname(__FILE__) . '/../../functions/classes/class.Thread.php';
# initialize objects
$Database = new Database_PDO();
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Result = new Result();
// set to 1 in case of errors
ini_set('display_errors', 0);
error_reporting(E_ERROR);
# cli required
if ($resolve_config['clionly'] && !defined('STDIN')) {
    $Result->show_cli("cli only\n", true);
} elseif (!$resolve_config['clionly'] && !defined('STDIN')) {
    $User = new User($Database);
    # verify that user is logged in
    $User->check_user_session();
}
#
# If id is provided via STDIN resolve hosts for 1 subnet only,
开发者ID:seisen,项目名称:phpipam,代码行数:31,代码来源:resolveIPaddresses.php

示例12: 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;
 }
开发者ID:martinsv,项目名称:phpipam,代码行数:40,代码来源:class.Sections.php

示例13: dirname

<?php

/**
 * Script to print mail notification form
 ********************************************/
# include required scripts
require dirname(__FILE__) . '/../../functions/functions.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();
# id must be numeric
is_numeric($_POST['id']) || strlen($_POST['id']) == 0 ?: $Result->show("danger", _("Invalid ID"), true);
# get IP address id
$id = $_POST['id'];
# fetch subnet, vlan and nameservers
$subnet = (array) $Subnets->fetch_subnet(null, $_POST['id']);
$vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']);
$vrf = (array) $Tools->fetch_object("vrf", "vrfId", $subnet['vrfId']);
$nameservers = (array) $Tools->fetch_object("nameservers", "id", $subnet['nameserverId']);
# get all custom fields
$custom_fields = $Tools->fetch_custom_fields('subnets');
# checks
sizeof($subnet) > 0 ?: $Result->show("danger", _("Invalid subnet"), true);
# set title
$title = _('Subnet details') . ' :: ' . $Subnets->transform_address($subnet['subnet'], "dotted") . "/" . $subnet['mask'];
开发者ID:routenull0,项目名称:phpipam,代码行数:31,代码来源:mail-notify-subnet.php

示例14: dirname

<?php

/**
 * Function to add / edit / delete section
 ********************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Subnets = new Subnets($Database);
$Sections = new Sections($Database);
$Addresses = new Addresses($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# ID must be numeric
if ($_POST['action'] == "add") {
    if (!is_numeric($_POST['sectionId'])) {
        $Result->show("danger", _("Invalid ID"), true);
    }
} else {
    if (!is_numeric($_POST['subnetId'])) {
        $Result->show("danger", _("Invalid ID"), true);
    }
}
# verify that user has permissions to add subnet
if ($_POST['action'] == "add") {
    if ($Sections->check_permission($User->user, $_POST['sectionId']) != 3) {
开发者ID:martinsv,项目名称:phpipam,代码行数:31,代码来源:edit-folder-result.php

示例15: dirname

<?php

/*
 * Print edit subnet
 *********************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Sections = new Sections($Database);
$Subnets = new Subnets($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# verify that user has permissions to add subnet
if ($_POST['action'] == "add") {
    if ($Sections->check_permission($User->user, $_POST['sectionId']) != 3) {
        $Result->show("danger", _('You do not have permissions to add new subnet in this section') . "!", true, true);
    }
} else {
    if ($Subnets->check_permission($User->user, $_POST['subnetId']) != 3) {
        $Result->show("danger", _('You do not have permissions to add edit/delete this subnet') . "!", true, true);
    }
}
/**
 *	This script can be called from administration, subnet edit in IP details page and from IPCalc!
 *
 *	From IP address list we must also provide delete button!
开发者ID:Ratler,项目名称:phpipam,代码行数:31,代码来源:edit.php


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