Issues (2963)

includes/html/forms/routing-update.inc.php (1 issue)

1
<?php
2
3
/*
4
 * LibreNMS
5
 *
6
 * Copyright (c) 2018 TheGreatDoc
7
 *
8
 * This program is free software: you can redistribute it and/or modify it
9
 * under the terms of the GNU General Public License as published by the
10
 * Free Software Foundation, either version 3 of the License, or (at your
11
 * option) any later version.  Please see LICENSE.txt at the top level of
12
 * the source code distribution for details.
13
 */
14
15
header('Content-type: application/json');
16
17
if (! Auth::user()->hasGlobalAdmin()) {
0 ignored issues
show
The method hasGlobalAdmin() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
if (! Auth::user()->/** @scrutinizer ignore-call */ hasGlobalAdmin()) {
Loading history...
18
    $response = [
19
        'status'  => 'error',
20
        'message' => 'Need to be admin',
21
    ];
22
    echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
23
    exit;
24
}
25
26
$status = 'error';
27
$message = 'Error updating routing information';
28
29
$device_id = $_POST['device_id'];
30
$routing_id = $_POST['routing_id'];
31
$data = $_POST['data'];
32
33
if (! is_numeric($device_id)) {
34
    $message = 'Missing device id';
35
} elseif (! is_numeric($routing_id)) {
36
    $message = 'Missing routing id';
37
} else {
38
    if (dbUpdate(['bgpPeerDescr'=>$data], 'bgpPeers', '`bgpPeer_id`=? AND `device_id`=?', [$routing_id, $device_id]) >= 0) {
39
        $message = 'Routing information updated';
40
        $status = 'ok';
41
    } else {
42
        $message = 'Could not update Routing information';
43
    }
44
}
45
46
$response = [
47
    'status'        => $status,
48
    'message'       => $message,
49
    'extra'         => $extra,
50
];
51
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
52