1 | <?php |
||
2 | |||
3 | /* |
||
4 | * LibreNMS |
||
5 | * |
||
6 | * Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk> |
||
7 | * Copyright (c) 2018 TheGreatDoc <https://github.com/TheGreatDoc> |
||
8 | * |
||
9 | * This program is free software: you can redistribute it and/or modify it |
||
10 | * under the terms of the GNU General Public License as published by the |
||
11 | * Free Software Foundation, either version 3 of the License, or (at your |
||
12 | * option) any later version. Please see LICENSE.txt at the top level of |
||
13 | * the source code distribution for details. |
||
14 | */ |
||
15 | |||
16 | header('Content-type: application/json'); |
||
17 | |||
18 | if (! Auth::user()->hasGlobalAdmin()) { |
||
19 | $response = [ |
||
20 | 'status' => 'error', |
||
21 | 'message' => 'Need to be admin', |
||
22 | ]; |
||
23 | echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
||
24 | exit; |
||
25 | } |
||
26 | |||
27 | $status = 'error'; |
||
28 | $message = 'Error updating sensor limit'; |
||
29 | $device_id = $_POST['device_id']; |
||
30 | $sensor_id = $_POST['sensor_id']; |
||
31 | $value_type = $_POST['value_type']; |
||
32 | $data = $_POST['data']; |
||
33 | |||
34 | if (! is_numeric($device_id)) { |
||
35 | $message = 'Missing device id'; |
||
36 | } elseif (! is_numeric($sensor_id)) { |
||
37 | $message = 'Missing sensor id'; |
||
38 | } elseif (! isset($data)) { |
||
39 | $message = 'Missing data'; |
||
40 | } else { |
||
41 | if (dbUpdate([$value_type => set_null($data, ['NULL']), 'sensor_custom' => 'Yes'], 'sensors', '`sensor_id` = ? AND `device_id` = ?', [$sensor_id, $device_id]) >= 0) { |
||
0 ignored issues
–
show
|
|||
42 | $message = 'Sensor value updated'; |
||
43 | $status = 'ok'; |
||
44 | } else { |
||
45 | $message = 'Could not update sensor value'; |
||
46 | } |
||
47 | } |
||
48 | |||
49 | $response = [ |
||
50 | 'status' => $status, |
||
51 | 'message' => $message, |
||
52 | ]; |
||
53 | echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
||
54 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.