Issues (2963)

includes/html/pages/addsrv.inc.php (1 issue)

1
<?php
2
3
$no_refresh = true;
4
5
if (! Auth::user()->hasGlobalAdmin()) {
6
    include 'includes/html/error-no-perm.inc.php';
7
} else {
8
    if ($vars['addsrv']) {
9
        if (Auth::user()->hasGlobalAdmin()) {
10
            $updated = '1';
11
12
            $service_id = add_service($vars['device'], $vars['type'], $vars['descr'], $vars['ip'], $vars['params'], $vars['ignore'], $vars['disabled'], 0, $vars['name']);
13
            if ($service_id) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $service_id of type integer|null is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
14
                $message .= $message_break . 'Service added (' . $service_id . ')!';
15
                $message_break .= '<br />';
16
            }
17
        }
18
    }
19
    foreach (list_available_services() as $current_service) {
20
        $servicesform .= "<option value='$current_service'>$current_service</option>";
21
    }
22
23
    foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) {
24
        $devicesform .= "<option value='" . $device['device_id'] . "'>" . format_hostname($device) . '</option>';
25
    }
26
27
    if ($updated) {
28
        print_message('Device Settings Saved');
29
    }
30
31
    $pagetitle[] = 'Add service';
32
33
    echo "<div class='row'>
34
        <div class='col-sm-3'>
35
        </div>
36
        <div class='col-sm-6'>";
37
38
    include_once 'includes/html/print-service-add.inc.php';
39
40
    echo '</div>
41
        </div>';
42
}//end if
43