Issues (2963)

includes/html/forms/alert-details.inc.php (1 issue)

1
<?php
2
3
header('Content-type: application/json');
4
5
$alert_log_id = $vars['alert_log_id'];
6
$sub_type = $vars['sub_type'];
7
$status = 'error';
8
$details = 'No Details found';
9
$message = 'No Details found';
10
11
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

11
if (! Auth::user()->/** @scrutinizer ignore-call */ hasGlobalAdmin()) {
Loading history...
12
    $message = 'Wrong permissions';
13
    $details = 'You need to have admin permissions.';
14
    exit(json_encode([
15
        'status'  => $status,
16
        'message' => $message,
17
        'details' => $details,
18
    ]));
19
}
20
21
if (is_numeric($alert_log_id)) {
22
    foreach (dbFetchRows('SELECT device_id, id, time_logged, details as detail FROM alert_log WHERE state != 2 && state != 0  && id =  ?', [$alert_log_id])  as $alertlog) {
23
        $details = json_decode(gzuncompress($alertlog['detail']), true)['rule'];
24
        if (! empty($details)) {
25
            $message = 'Found alert details';
26
            $status = 'ok';
27
        } else {
28
            $details = 'No Details found';
29
        }
30
    }
31
} else {
32
    $message = 'Invalid alert id';
33
    $details = 'Invalid alert id';
34
}
35
36
exit(json_encode([
37
    'status'  => $status,
38
    'message' => $message,
39
    'details' => $details,
40
]));
41