-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
functions.php
55 lines (46 loc) · 1.56 KB
/
functions.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
<?php
function arrSortFunctionHostgroupsName ($arrElement1, $arrElement2) {
return strcmp($arrElement1["name"], $arrElement2["name"]);
}
function arrSortFunctionHostsName ($arrElement1, $arrElement2) {
return strcmp($arrElement1["host"], $arrElement2["host"]);
}
function getVisitorIP () {
if (isset($_SERVER['HTTP_X_FORWARD_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
function cleanTriggerDescription ($description) {
$trigger_description = str_replace("{HOSTNAME}", "", $description);
// If what remains is shown as ": trigger", delete the first char
$arrReplaceChars = array(":", "-", " ");
$char_cut = 0;
for ($c = 0; $c < strlen($trigger_description); $c++) {
if (!in_array($trigger_description[$c], $arrReplaceChars)) {
$char_cut = $c;
$c = strlen($trigger_description) + 1; // Exit the loop
}
}
$trigger_description = substr($trigger_description, $char_cut, strlen($trigger_description));
return $trigger_description;
}
function convertEventClock ($clock) {
return date("d/m, H:i:s", $clock);
}
function convertEventValue ($value) {
switch ($value) {
case "1":
return "Problem";
break;
case "0":
return "OK";
break;
case "2":
return "Acknowledged";
break;
}
}
?>