Esempio n. 1
0
<?php

include 'config/db.php';
include 'libraries/events.php';
include 'libraries/general.php';
$device_id = mysqli_real_escape_string($conn, $_GET['device_id']);
if (ctype_digit($device_id) && !empty($device_id)) {
    $sql = "DELETE FROM `devices` WHERE `device_id`='{$device_id}'";
    if ($conn->query($sql) === TRUE) {
        //set success message
        $device_label = get_device_label_from_id($device_id);
        $event_type = "Device Removed";
        $event_message = "Device {$device_label} was removed";
        $event_status = "Complete";
        add_event($event_type, $event_message, $event_status);
        $_SESSION['success'] = "Success, device removed.";
    } else {
        //set error message
        $_SESSION['error'] = "Error, device not removed.";
    }
    //redirect back to where we came from
    $referrer = $_SESSION['referrer'];
    unset($_SESSION['referrer']);
    //clear session var
    header("Location: {$referrer}");
    //redirect!
}
Esempio n. 2
0
<?php

include 'graph_functions.php';
include 'libraries/general.php';
$librenms_api_endpoint = lirenms_api_endpoint();
$librenms_api_key = librenms_api_key();
$device_name = get_device_label_from_id($_GET['device_id']);
$port_name = port_name($_GET['port_number']);
$url = $librenms_api_endpoint . "" . $device_name . "/ports/" . $port_name . "/port_bits";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Auth-Token: {$librenms_api_key}"));
$content = trim(curl_exec($ch));
curl_close($ch);
header("Content-Type: image/png");
print $content;
Esempio n. 3
0
<br>
<form action="update_device_db.php" id="device_parent_form" method="post">
    <input type="hidden" class="form-control" name="device_id" value="<?php 
echo $device_id;
?>
">
    <label>Server</label>
    <small><i>Select the server this disk is currently inserted into - if any</i></small>
    <?php 
include 'config/db.php';
$sql = "SELECT * FROM `devices` WHERE `device_type`='server'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    echo "<select class='form-control' name='device_parent'>";
    // output data of each row
    echo "<option value='{$device_parent}'>" . get_device_label_from_id($device_parent) . "</option>";
    echo "<option value='0'>None</option>";
    while ($row = $result->fetch_assoc()) {
        $device_label = $row["device_label"];
        if ($row["device_id"] != $device_parent) {
            echo "<option value=" . $row["device_id"] . ">{$device_label}</option>";
        }
    }
    echo "</select>";
} else {
    echo "0 results";
}
?>
    <hr>
    <center><input type="submit" form="device_parent_form" value="Update" class="btn btn-primary"></center>
</form>
Esempio n. 4
0
    echo "<th><center>Manage</center></th>";
    echo "</tr>";
    echo "</thead>";
    while ($row = $result->fetch_assoc()) {
        $device_id = $row["device_id"];
        if ($row["device_parent"] != 0 || $row["device_inuse"] == 1) {
            echo "<tr class='info'>";
        } else {
            echo "<tr>";
        }
        echo "<td>" . get_rack_name($row['rackid']) . "</td>";
        echo "<td>" . $row["device_brand"] . "</td>";
        echo "<td>" . $row["device_type"] . "</td>";
        echo "<td>" . $row["device_label"] . "</td>";
        echo "<td>" . $row["device_capacity"] . "</td>";
        echo "<td>" . get_device_label_from_id($row["device_parent"]) . "</td>";
        echo "<td>" . $row["device_serial"] . "</td>";
        echo "<td><center><a href='manage_disk.php?device_id={$device_id}'>Manage</a></center></td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "0 results";
}
$conn->close();
?>
    <div class="pull-right">
      <small><i>Blue indicates the drive in use, Red indicates a failed drive</i></small>
    </div>
  </div>
  <!-- Add HDD Modal -->