Exemplo n.º 1
0
<?php

/**
 * Script to print devices
 ***************************/
# verify that user is logged in
$User->check_user_session();
# rack object
$Racks = new phpipam_rack($Database);
# fetch all Devices
$devices = $Admin->fetch_all_objects("devices", "hostname");
# fetch all Device types and reindex
$device_types = $Admin->fetch_all_objects("deviceTypes", "tid");
if ($device_types !== false) {
    foreach ($device_types as $dt) {
        $device_types_i[$dt->tid] = $dt;
    }
}
# fetch custom fields
$custom = $Tools->fetch_custom_fields('devices');
# get hidden fields
$hidden_custom_fields = json_decode($User->settings->hiddenCustomFields, true);
$hidden_custom_fields = is_array(@$hidden_custom_fields['devices']) ? $hidden_custom_fields['devices'] : array();
?>

<h4><?php 
print _('Device management');
?>
</h4>
<hr>
<div class="btn-group">
Exemplo n.º 2
0
 ***************************/
# verify that user is logged in
$User->check_user_session();
# set admin
$admin = $User->is_admin(false);
# check that rack support isenabled
if ($User->settings->enableRACK != "1") {
    $Result->show("danger", _("RACK management disabled."), false);
} else {
    # validate integer
    if (!is_numeric($_GET['subnetId'])) {
        header("Location: " . create_link($_GET['page'], "racks"));
        $error = _("Invalid rack Id");
    }
    # init racks object
    $Racks = new phpipam_rack($Database);
    # fetch all racks
    $rack = $Racks->fetch_rack_details($_GET['subnetId']);
    $rack_devices = $Racks->fetch_rack_devices($_GET['subnetId']);
    // rack check
    if ($rack === false) {
        header("Location: " . create_link($_GET['page'], "racks"));
        $error = _("Invalid rack Id");
    }
    // get custom fields
    $cfields = $Tools->fetch_custom_fields('racks');
}
# if error set print it, otherwise print rack
if (isset($error)) {
    ?>
<h4><?php 
Exemplo n.º 3
0
<?php

/**
 *	Edit rack devices script
 ************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Racks = new phpipam_rack($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# strip input tags
$_POST = $Admin->strip_input_tags($_POST);
# ID must be numeric
if ($_POST['action'] != "add" && !is_numeric($_POST['rackid'])) {
    $Result->show("danger", _("Invalid ID"), true, true);
}
# remove or add ?
if ($_POST['action'] == "remove") {
    # validate csrf cookie
    $User->csrf_cookie("validate", "rack_devices", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true, true) : "";
    # set values
    $values = array("id" => $_POST['deviceid'], "rack" => "", "rack_start" => "", "rack_size" => "");
    # update
    if (!$Admin->object_modify("devices", "edit", "id", $values)) {
        $Result->show("success", _("Failed to remove device from rack") . '!', true, true);
Exemplo n.º 4
0
	<?php 
    }
    ?>
</div>
<br>
<?php 
}
?>

<?php 
# check that rack support isenabled
if ($User->settings->enableRACK != "1") {
    $Result->show("danger", _("RACK management disabled."), false);
} else {
    # init racks object
    $Racks = new phpipam_rack($Database);
    # fetch all racks
    $Racks->fetch_all_racks();
    // table
    print "<table class='table sorted table-striped table-top table-td-top'>";
    // headers
    print "<thead>";
    print "<tr>";
    print " <th style='width:80px'></th>";
    print " <th>" . _('Name') . "</th>";
    print " <th>" . _('Size') . "</th>";
    print " <th>" . _('Description') . "</th>";
    print " <th>" . _('Devices') . "</th>";
    if (sizeof($custom) > 0) {
        foreach ($custom as $field) {
            if (!in_array($field['name'], $hidden_custom_fields)) {
Exemplo n.º 5
0
		</td>
	</tr>
	<?php 
}
?>

    <!-- Rack -->
    <?php 
if ($User->settings->enableRACK == "1") {
    ?>
	<tr>
	   	<td colspan="2"><hr></td>
    </tr>
    <tr>
        <?php 
    $Racks = new phpipam_rack($Database);
    $Racks->fetch_all_racks();
    ?>
        <td><?php 
    print _('Rack');
    ?>
</td>
        <td>
            <select name="rack" class="form-control">
                <option value=""><?php 
    print _("None");
    ?>
</option>
                <?php 
    foreach ($Racks->all_racks as $r) {
        if ($device['rack'] == $r->id) {
Exemplo n.º 6
0
<?php

/**
 * Script to draw rack
 ***************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# init racks object
$Racks = new phpipam_rack($Database);
# deviceId not set or empty - set to 0
if (empty($_GET['deviceId'])) {
    $_GET['deviceId'] = 0;
}
# validate rackId
if (!is_numeric($_GET['rackId'])) {
    die;
}
if (!is_numeric($_GET['deviceId'])) {
    die;
}
# draw
$Racks->draw_rack($_GET['rackId'], $_GET['deviceId']);
Exemplo n.º 7
0
<?php

/**
 * Edit rack result
 ***************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Racks = new phpipam_rack($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# validate csrf cookie
$User->csrf_cookie("validate", "rack", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
# get modified details
$rack = $Tools->strip_input_tags($_POST);
# ID must be numeric
if ($_POST['action'] != "add" && !is_numeric($_POST['rackid'])) {
    $Result->show("danger", _("Invalid ID"), true);
}
# Hostname must be present
if ($rack['name'] == "") {
    $Result->show("danger", _('Name is mandatory') . '!', true);
}
# rack checks
# validate position and size
if (!is_numeric($rack['size'])) {
Exemplo n.º 8
0
$User = new User($Database);
$Tools = new Tools($Database);
$Racks = new phpipam_rack($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# check that rack support isenabled
if ($User->settings->enableRACK != "1") {
    $Result->show("danger", _("RACK management disabled."), true, true, false, true);
} else {
    # validate integer
    if (!is_numeric($_POST['rackid'])) {
        $error = _("Invalid rack Id");
    }
    # init racks object
    $Racks = new phpipam_rack($Database);
    # fetch all racks
    $rack = $Racks->fetch_rack_details($_POST['rackid']);
    $rack_devices = $Racks->fetch_rack_devices($_POST['rackid']);
    // rack check
    if ($rack === false) {
        $error = _("Invalid rack Id");
    }
}
?>


<div class="pHeader"><?php 
print _("Rack details");
?>
</div>