Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2015-08-03 10:46:40 +00:00
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
2016-04-26 15:06:29 -07:00
header('Content-type: application/json');
2015-08-03 10:46:40 +00:00
if (! Auth::user()->hasGlobalAdmin()) {
$response = [
2024-01-05 05:39:12 +01:00
'status' => 'error',
'message' => 'Need to be admin',
];
2021-03-04 07:55:41 -06:00
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
2015-08-03 10:46:40 +00:00
$status = 'error';
$message = 'Error updating storage information';
2021-03-28 17:25:30 -05:00
$device_id = $_POST['device_id'];
$storage_id = $_POST['storage_id'];
$data = $_POST['data'];
2015-08-03 10:46:40 +00:00
if (! is_numeric($device_id)) {
$message = 'Missing device id';
2016-08-18 20:28:22 -05:00
} elseif (! is_numeric($storage_id)) {
2015-08-03 10:46:40 +00:00
$message = 'Missing storage id';
2016-08-18 20:28:22 -05:00
} elseif (! is_numeric($data)) {
2015-08-03 10:46:40 +00:00
$message = 'Missing value';
2016-08-18 20:28:22 -05:00
} else {
2024-01-05 05:39:12 +01:00
if (dbUpdate(['storage_perc_warn' => $data], 'storage', '`storage_id`=? AND `device_id`=?', [$storage_id, $device_id]) >= 0) {
2015-08-03 10:46:40 +00:00
$message = 'Storage information updated';
$status = 'ok';
2016-08-18 20:28:22 -05:00
} else {
2015-08-03 10:46:40 +00:00
$message = 'Could not update storage information';
}
}
$response = [
2024-01-05 05:39:12 +01:00
'status' => $status,
'message' => $message,
'extra' => $extra,
2015-08-03 10:46:40 +00:00
];
2021-03-04 07:55:41 -06:00
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);