forked from mattiasgeniar/MoZBX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_img.php
36 lines (29 loc) · 1023 Bytes
/
graph_img.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
<?php
require_once("config.inc.php");
require_once("functions.php");
require_once("class_zabbix.php");
require_once("cookies.php");
$arrSettings["zabbixApiUrl"] = str_replace("api_jsonrpc.php", "", $zabbixApi);
$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();
}
$graphid = (string) $_GET['graphid'];
$graphperiod = (string) $_GET['period'];
// Set correct header
header("Content-Type: image/jpg");
// Read the file & output
print $zabbix->getGraphImageById($graphid, $graphperiod);
?>