/
action.php
118 lines (107 loc) · 2.86 KB
/
action.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
$conf = parse_ini_file("/var/share/html/easyMonitor/lib/Conf.ini",true);
require("./lib/Db.php");
require("./lib/Alert.php");
require("./lib/Host.php");
require("./lib/Monitor.php");
$act = htmlspecialchars($_GET["act"]);
switch ($act) {
case "alertChecked":
$alert_id = htmlspecialchars($_GET["alert_id"]);
$checked = htmlspecialchars($_GET["checked"]);
$res = _alert([
'action' =>'update'
,'conf' =>$conf
,'con' =>$con
,'alert_id'=>$alert_id
,'checked'=>$checked
]);
break;
case "alertListGetJson":
$offset = htmlspecialchars($_GET["offset"]);
$count = htmlspecialchars($_GET["count"]);
$res = _alert([
'action' =>'select'
,'conf' =>$conf
,'con' =>$con
,'offset' =>$offset
,'count' =>$count
]);
echo $res['list'];
break;
case "hostListGetJson":
$offset = htmlspecialchars($_GET["offset"]);
$count = htmlspecialchars($_GET["count"]);
$res = _host([
'action'=>'hostselect'
,'conf' =>$conf
,'con' =>$con
,'offset'=>$offset
,'count' =>$count
]);
echo $res['list'];
break;
case "monitorListGetJson":
$offset = htmlspecialchars($_GET["offset"]);
$count = htmlspecialchars($_GET["count"]);
$res = _monitor([
'action'=>'monitorselect'
,'conf'=>$conf
,'con' =>$con
,'offset'=>$offset
,'count'=>$count
]);
echo $res['list'];
break;
case "hostCreate":
$hostname = htmlspecialchars($_GET["hostname"]);
$ipaddress = htmlspecialchars($_GET["ipaddress"]);
$res = _host([
'action'=>'hostinsert'
,'conf'=>$conf
,'con'=>$con
,'hostname'=>$hostname
,'ipaddress'=>$ipaddress
]);
echo $res['list'];
break;
case "monitorCreate":
$monitorname = htmlspecialchars($_GET["monitorname"]);
$monitortype = htmlspecialchars($_GET["monitortype"]);
$monitortimeout = htmlspecialchars($_GET["monitortimeout"]);
$monitorretry = htmlspecialchars($_GET["monitorretry"]);
$monitorargument = htmlspecialchars($_GET["monitorargument"]);
$res = _monitor([
'action'=>'monitorinsert'
,'conf'=>$conf
,'con'=>$con
,'monitorname'=>$monitorname
,'monitortype'=>$monitortype
,'timeout' =>$monitortimeout
,'retry' =>$monitorretry
,'argument' =>$monitorargument
]);
echo $res['list'];
break;
case "hostDelete":
$host_id = htmlspecialchars($_GET["host_id"]);
$res = _host([
'action'=>'hostdelete'
,'conf'=>$conf
,'con'=>$con
,'host_id'=>$host_id
]);
echo $res['list'];
break;
case "monitorDelete":
$monitor_id = htmlspecialchars($_GET["monitor_id"]);
$res = _monitor([
'action'=>'monitordelete'
,'conf'=>$conf
,'con'=>$con
,'monitor_id'=>$monitor_id
]);
echo $res['list'];
break;
}
?>