1 | #!/usr/bin/env php |
||
2 | <?php |
||
3 | |||
4 | /* |
||
5 | * LibreNMS |
||
6 | * |
||
7 | * This file is part of LibreNMS. |
||
8 | * |
||
9 | * @package LibreNMS |
||
10 | * @subpackage cli |
||
11 | * @copyright (C) 2006 - 2012 Adam Armstrong |
||
12 | * |
||
13 | */ |
||
14 | |||
15 | use LibreNMS\Authentication\LegacyAuth; |
||
16 | |||
17 | $init_modules = []; |
||
18 | if (php_sapi_name() != 'cli') { |
||
19 | $init_modules[] = 'auth'; |
||
20 | } |
||
21 | require __DIR__ . '/includes/init.php'; |
||
22 | |||
23 | if (LegacyAuth::get()->canManageUsers()) { |
||
24 | if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) { |
||
25 | if (! LegacyAuth::get()->userExists($argv[1])) { |
||
26 | if (LegacyAuth::get()->addUser($argv[1], $argv[2], $argv[3], @$argv[4])) { |
||
0 ignored issues
–
show
|
|||
27 | echo 'User ' . $argv[1] . " added successfully\n"; |
||
28 | } |
||
29 | } else { |
||
30 | echo 'User ' . $argv[1] . " already exists!\n"; |
||
31 | } |
||
32 | } else { |
||
33 | echo "Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10> [email]\n"; |
||
34 | } |
||
35 | } else { |
||
36 | echo "Auth module does not allow adding users!\n"; |
||
37 | }//end if |
||
38 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: