-
Notifications
You must be signed in to change notification settings - Fork 0
/
hlcmd.php
executable file
·76 lines (61 loc) · 1.39 KB
/
hlcmd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/php
<?php
/**
* PDX-License-Identifier: GPL-2.0-or-later
*
* @author Stephan Leemburg <stephan@it-functions.nl>
* @copyright Copyright (c) 2020, IT Functions
*/
require_once __DIR__.'/classes/hlcmd.php';
$options = getopt("c:r:m:dh");
if (!is_array($options) || count($options) < 1)
{
echo 'Usage: hlcmd -c cmd'.PHP_EOL;
exit;
}
if (!array_key_exists('c', $options))
{
echo "Required option -c not present\n";
exit;
}
$hlcmd = new Hlcmd();
switch (strtolower(trim($options['c'])))
{
case 'sms':
$ok = true;
foreach (['r', 'm'] as $key)
if (($options[$key] ?? FALSE) === FALSE)
{
echo "Required option -{$key} not present\n";
$ok = false;
}
if (!$ok)
exit;
return $hlcmd->sendSMS($options['r'], $options['m']);
case 'monitor':
break;
case 'connect':
return $hlcmd->connect();
case 'disconnect':
return $hlcmd->disconnect();
case 'month':
return $hlcmd->monthstatistics();
case 'information':
return $hlcmd->information();
case 'wanipv4':
if (($ipv4 = $hlcmd->wanipv4()) === NULL)
{
echo "Not connected\n";
exit(1);
}
else if ($ipv4 === FALSE)
{
echo "Error retrieving information from device\n";
exit(2);
}
echo "{$ipv4}\n";
exit(0);
default:
echo "Unexpected value for option -c ({$options['c']})\n";
exit;
}