Example #1
0
        // same master subnet ID for nested
        $subnet_old_details['vlanId'] = @$subnet_old_temp['vlanId'];
        // same default vlan for nested
        $subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId'];
        // same default vrf for nested
    }
    # set master if it came from free space!
    if (isset($_POST['freespaceMSID'])) {
        $subnet_old_details['masterSubnetId'] = $_POST['freespaceMSID'];
        // dumb name, but it will do :)
    }
}
# fetch custom fields
$custom_fields = $Tools->fetch_custom_fields('subnets');
# fetch vrfs
$vrfs = $Tools->fetch_all_objects("vrf", "name");
# check if it has slaves - if yes it cannot be splitted!
$slaves = $Subnets->has_slaves($_POST['subnetId']);
# fetch all sections
$sections = $Sections->fetch_all_sections();
# for vlan result on the fly
if (isset($_POST['vlanId'])) {
    $subnet_old_details['vlanId'] = $_POST['vlanId'];
}
# set readonly flag
$readonly = $_POST['action'] == "edit" || $_POST['action'] == "delete" ? true : false;
?>


<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-switch.min.css">
<script type="text/javascript" src="js/bootstrap-switch.min.js"></script>
Example #2
0
# verify that user is logged in
$User->check_user_session();
# fake error
print "<div class='alert-danger hidden'></div>";
# scan disabled
if ($User->settings->enableSNMP != "1") {
    $Result->show("danger", _("SNMP module disbled"), true);
}
# admin check
if ($User->is_admin() !== true) {
    $Result->show("danger", _('Admin privileges required'), true);
}
# set class
$Snmp = new phpipamSNMP();
# get existing vrfs
$existing_vrfs = $Tools->fetch_all_objects("vrf", "vrfId");
if ($existing_vrfs !== false) {
    foreach ($existing_vrfs as $v) {
        $ex_vrfs[$v->name] = $v->rd;
    }
}
// no errors
error_reporting(E_ERROR);
# set devices
foreach ($_POST as $k => $p) {
    if (strpos($k, "device-") !== false) {
        # fetch device
        $device = $Tools->fetch_object("devices", "id", str_replace("device-", "", $k));
        if ($device !== false) {
            $scan_devices[] = $device;
        }
<?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;
Example #4
0
 (<?php 
print implode(", ", $nat_types);
?>
)</span>
        	</td>
        </tr>

    	<!-- Device -->
    	<tr>
        	<th><?php 
print _('Device');
?>
</th>
        	<td>
            	<?php 
$devices = $Tools->fetch_all_objects("devices", "hostname");
?>
            	<select name="device" class="form-control input-sm input-w-auto" <?php 
print $readonly;
?>
>
        	    <option value="0"><?php 
print _('None');
?>
</option>
                <?php 
if ($devices !== false) {
    foreach ($devices as $d) {
        $selected = $nat->device == $d->id ? "selected" : "";
        print "<option value='{$d->id}' {$selected}>{$d->hostname}</option>";
    }
Example #5
0
# fetch custom fields
$custom = $Tools->fetch_custom_fields('racks');
# ID must be numeric
if ($_POST['action'] != "add" && !is_numeric($_POST['rackid'])) {
    $Result->show("danger", _("Invalid ID"), true, true);
}
# fetch device details
if ($_POST['action'] == "edit" || $_POST['action'] == "delete") {
    $rack = $Admin->fetch_object("racks", "id", $_POST['rackid']);
} else {
    $rack = new StdClass();
    $rack->size = 42;
}
# all locations
if ($User->settings->enableLocations == "1") {
    $locations = $Tools->fetch_all_objects("locations");
}
# set readonly flag
$readonly = $_POST['action'] == "delete" ? "readonly" : "";
?>

<script type="text/javascript">
$(document).ready(function(){
     if ($("[rel=tooltip]").length) { $("[rel=tooltip]").tooltip(); }
});
</script>


<!-- header -->
<div class="pHeader"><?php 
print ucwords(_("{$_POST['action']}"));
Example #6
0
    $_POST['fval'] = null;
} else {
    //format posted values!
    $tmp = explode("|", $_POST['direction']);
    $sort['field'] = $tmp[0];
    $sort['direction'] = $tmp[1];
    if ($sort['direction'] == "asc") {
        $sort['directionNext'] = "desc";
    } else {
        $sort['directionNext'] = "asc";
    }
}
# filter devices or fetch print all?
$filter = isset($_POST['ffield']) ? true : false;
$devices = $Tools->fetch_devices($_POST['ffield'], $_POST['fval'], $sort['field'], $sort['direction']);
$device_types = $Tools->fetch_all_objects("deviceTypes", "tid");
# get custom fields
$custom_fields = $Tools->fetch_custom_fields('devices');
# get hidden fields */
$hidden_fields = json_decode($User->settings->hiddenCustomFields, true);
$hidden_fields = is_array(@$hidden_fields['devices']) ? $hidden_fields['devices'] : array();
# sort icons
if ($sort['direction'] == 'asc') {
    $icon = "<i class='fa fa-angle-down'></i> ";
} else {
    $icon = "<i class='fa fa-angle-up'></i> ";
}
# title
print "<h4>" . _('List of network devices') . "</h4>";
print "<hr>";
//filter
Example #7
0
        if ($User->settings->enableLocations == "1") {
            $subnet_old_details['location'] = @$subnet_old_temp['location'];
        }
        // inherit location
    }
    # set master if it came from free space!
    if (isset($_POST['freespaceMSID'])) {
        $subnet_old_details['masterSubnetId'] = $_POST['freespaceMSID'];
        // dumb name, but it will do :)
    }
}
# fetch custom fields
$custom_fields = $Tools->fetch_custom_fields('subnets');
# fetch vrfs
if ($User->settings->enableVRF == 1) {
    $vrfs = $Tools->fetch_all_objects("vrf", "name");
}
# check if it has slaves - if yes it cannot be splitted!
$slaves = $Subnets->has_slaves($_POST['subnetId']);
# fetch all sections
$sections = $Sections->fetch_all_sections();
# for vlan result on the fly
if (isset($_POST['vlanId'])) {
    $subnet_old_details['vlanId'] = $_POST['vlanId'];
}
# all locations
if ($User->settings->enableLocations == "1") {
    $locations = $Tools->fetch_all_objects("locations", "name");
}
# set readonly flag
$readonly = $_POST['action'] == "edit" || $_POST['action'] == "delete" ? true : false;
Example #8
0
    if ($Subnets->is_multicast($address['ip_addr'])) {
        // propose mac
        $address['mac'] = $Subnets->create_multicast_mac($address['ip_addr']);
        // if add validate
        if ($act == "add") {
            $mcast_err_check = $Subnets->validate_multicast_mac($address['mac'], $subnet['sectionId'], $subnet['vlanId'], MCUNIQUE, 0);
            // check if proposed already exists
            if ($mcast_err_check !== true) {
                $mcast_err = $mcast_err_check;
            }
        }
    }
}
# all locations
if ($User->settings->enableLocations == "1") {
    $locations = $Tools->fetch_all_objects("locations", "name");
}
?>

<script type="text/javascript">
$(document).ready(function() {
/* bootstrap switch */
var switch_options = {
	onText: "Yes",
	offText: "No",
    onColor: 'default',
    offColor: 'default',
    size: "mini"
};
var switch_options_danger = {
	onText: "Yes",
Example #9
0
            $Result->show("danger", _("Prefix cannot be same as master"), true);
        }
        if ($_POST['prefix_raw_start'] < $master_prefix->prefix_raw_start || $_POST['prefix_raw_stop'] > $master_prefix->prefix_raw_stop) {
            $Result->show("danger", _("Prefix not inside its master"), true);
        }
    }
}
// root check
if ($_POST['action'] == "add" && $_POST['master'] == 0) {
    // set raw values
    $_POST['prefix_raw'] = $Tools->prefix_normalize($_POST['prefix']);
    $_POST['prefix_raw_start'] = $Tools->prefix_normalize($_POST['prefix'] . $_POST['start']);
    $_POST['prefix_raw_stop'] = $Tools->prefix_normalize($_POST['prefix'] . $_POST['stop']);
    $_POST['prefix_size'] = $_POST['prefix_raw_stop'] - $_POST['prefix_raw_start'];
    # fetch all
    $all_prefixes = $Tools->fetch_all_objects("pstnPrefixes", "master", 0);
    if ($all_prefixes !== false) {
        foreach ($all_prefixes as $master_prefix) {
            $overlap_text = _("Prefix overlapps with prefix " . $master_prefix->name . " (" . $master_prefix->prefix . ")");
            // ranges
            $master_prefix->prefix_raw = $Tools->prefix_normalize($master_prefix->prefix);
            $master_prefix->prefix_raw_start = $Tools->prefix_normalize($master_prefix->prefix . $master_prefix->start);
            $master_prefix->prefix_raw_stop = $Tools->prefix_normalize($master_prefix->prefix . $master_prefix->stop);
            $master_prefix->prefix_size = $master_prefix->prefix_raw_stop - $master_prefix->prefix_raw_start;
            // if it begins before
            if ($_POST['prefix_raw_start'] < $master_prefix->prefix_raw_start) {
                if ($_POST['prefix_raw_stop'] >= $master_prefix->prefix_raw_start) {
                    $Result->show("danger", $overlap_text, true);
                }
            } elseif ($_POST['prefix_raw_start'] > $master_prefix->prefix_raw_start) {
                if ($_POST['prefix_raw_start'] <= $master_prefix->prefix_raw_stop) {