Files
librenms-librenms/html/pages/delhost.inc.php
Tony Murray 32a7c50189 Use Laravel authentication (#8702)
* Use Laravel for authentication
Support legacy auth methods
Always create DB entry for users (segregate by auth method)

Port api auth to Laravel

restrict poller errors to devices the user has access to

Run checks on every page load.  But set a 5 minute (configurable) timer.
Only run some checks if the user is an admin

Move toastr down a few pixels so it isn't as annoying.

Fix menu not loaded on laravel pages when twofactor is enabled for the system, but disabled for the user.
Add two missing menu entries in the laravel menu

Rewrite 2FA code
Simplify some and verify code before applying

Get http-auth working
Handle legacy $_SESSION differently.  Allows Auth::once(), etc to work.

* Fix tests and mysqli extension check

* remove duplicate Toastr messages

* Fix new items

* Rename 266.sql to 267.sql
2018-09-11 07:51:35 -05:00

85 lines
3.0 KiB
PHP

<?php
use LibreNMS\Authentication\LegacyAuth;
if (!LegacyAuth::user()->hasGlobalAdmin()) {
require 'includes/error-no-perm.inc.php';
exit;
}
$pagetitle[] = "Delete device";
if (LegacyAuth::user()->isDemoUser()) {
demo_account();
} else {
if (is_numeric($_REQUEST['id'])) {
echo('
<div class="row">
<div class="col-sm-offset-2 col-sm-7">
');
if ($_REQUEST['confirm']) {
print_message(nl2br(delete_device(mres($_REQUEST['id'])))."\n");
} else {
$device = device_by_id_cache($_REQUEST['id']);
print_error("Are you sure you want to delete device " . $device['hostname'] . "?");
?>
<br />
<center>
<font color="red"></font><i class="fa fa-exclamation-triangle fa-3x"></i></font>
<br>
<form name="form1" method="post" action="" class="form-horizontal" role="form">
<div class="form-group">
<input type="hidden" name="id" value="<?php echo $_REQUEST['id'] ?>" />
<input type="hidden" name="confirm" value="1" />
<!--<input type="hidden" name="remove_rrd" value="<?php echo $_POST['remove_rrd']; ?>">-->
<button type="submit" class="btn btn-danger">Confirm device deletion</button>
</div>
</form>
</center>
<?php
}
echo('
</div>
</div>');
} else {
?>
<form name="form1" method="post" action="" class="form-horizontal" role="form">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-7">
<div><h2>Delete Device</h2></div>
<div class="alert alert-danger" role="alert">
<center>
<p>Warning, this will remove the device from being monitered!</p>
<p>It will also remove historical data about this device such as <mark>Syslog</mark>, <mark>Eventlog</mark> and <mark>Alert log</mark> data.</p>
</center>
</div>
<div class="well">
<div class="form-group">
<label for="id" class="col-sm-2 control-label">Device:</label>
<div class="col-sm-10">
<select name="id" class="form-control" id="id">
<option disabled="disabled" selected="selected">Please select</option>
<?php
foreach (dbFetchRows("SELECT `device_id`, `hostname` FROM `devices` ORDER BY `hostname`") as $data) {
echo("<option value='".$data['device_id']."'>".$data['hostname']."</option>");
}
?>
</select>
</div>
</div>
<hr>
<input id="confirm" type="hidden" name="confirm" value="0" />
<center><button id="confirm_delete" type="submit" class="btn btn-default">Delete Device</button></center>
</div>
<div class="form-group">
<!-- <tr>
<td>Remove RRDs (Data files): </td>
<td><input type="checkbox" name="remove_rrd" value="yes"></td>
</tr>-->
</form>
<?php
}
}