forked from mattiasgeniar/MoZBX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trigger_ack.php
60 lines (50 loc) · 1.71 KB
/
trigger_ack.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
<?php
require_once("config.inc.php");
require_once("functions.php");
require_once("class_zabbix.php");
require_once("cookies.php");
$zabbix = new Zabbix($arrSettings);
// Populate our class
$zabbix->setUsername($zabbixUser);
$zabbix->setPassword($zabbixPass);
$zabbix->setZabbixApiUrl($zabbixApi);
// Login
if (isset($zabbixAuthHash) && strlen($zabbixAuthHash) > 0) {
// Try it with the authentication hash we have
$zabbix->setAuthToken($zabbixAuthHash);
} elseif (strlen($zabbix->getUsername()) > 0 && strlen($zabbix->getPassword()) > 0 && strlen($zabbix->getZabbixApiUrl()) > 0) {
$zabbix->login();
}
if (!$zabbix->isLoggedIn()) {
header("Location: index.php");
exit();
}
// Process the AJAX call of the form, if it exists
$ack_ok = false;
if (isset($_POST['type'])) {
$post_type = $_POST['type'];
switch ($post_type) {
case "acknowledge":
$zabbixEventId = array((string) $_POST['eventid']);
$comment = addslashes(htmlspecialchars($_POST["comment"]));
$zabbix->acknowledgeEvent($zabbixEventId, $comment);
/* For now: if we got here, assume the ACK went OK
TODO: check the return value of this call */
$ack_ok = true;
break;
default:
break;
}
}
if ($ack_ok) {
header("Location: trigger_info.php?triggerid=". (string) $_POST['triggerid']);
exit();
} else {
/* Something, somewhere, went terribly wrong */
?>
<ul class="rounded">
<li>Sorry, something went wrong</li>
</ul>
<?php
}
?>