22
include "include/config.inc.php";
23
include "include/classes/graph.inc.php";
25
check_authorisation();
27
if(!check_right("Graph","R",$_REQUEST["graphid"]))
33
if(isset($_REQUEST["period"]))
35
$graph->setPeriod($_REQUEST["period"]);
37
if(isset($_REQUEST["from"]))
39
$graph->setFrom($_REQUEST["from"]);
41
if(isset($_REQUEST["stime"]))
43
$graph->setSTime($_REQUEST["stime"]);
45
if(isset($_REQUEST["border"]))
50
$result=DBselect("select * from graphs where graphid=".$_REQUEST["graphid"]);
51
$row=DBfetch($result);
52
$db_hosts = get_hosts_by_graphid($_REQUEST["graphid"]);
55
$db_host = DBfetch($db_hosts);
58
$name = $db_host["host"].":".$name;
60
if(isset($_REQUEST["width"])&&$_REQUEST["width"]>0)
62
$width=$_REQUEST["width"];
68
if(isset($_REQUEST["height"])&&$_REQUEST["height"]>0)
70
$height=$_REQUEST["height"];
74
$height=$row["height"];
77
$graph->ShowWorkPeriod($row["show_work_period"]);
78
$graph->ShowTriggers($row["show_triggers"]);
80
$graph->setWidth($width);
81
$graph->setHeight($height);
82
$graph->setHeader($name);
83
$graph->setYAxisType($row["yaxistype"]);
84
$graph->setYAxisMin($row["yaxismin"]);
85
$graph->setYAxisMax($row["yaxismax"]);
87
$result=DBselect("select gi.*,i.description,h.host,gi.drawtype from graphs_items gi,items i,hosts h where gi.itemid=i.itemid and gi.graphid=".$_REQUEST["graphid"]." and i.hostid=h.hostid order by gi.sortorder");
89
while($row=DBfetch($result))
22
require_once "include/config.inc.php";
23
require_once "include/graphs.inc.php";
24
require_once "include/classes/graph.inc.php";
26
$page["file"] = "chart2.php";
27
$page["title"] = "S_CHART";
28
$page["type"] = PAGE_TYPE_IMAGE;
30
include_once "include/page_header.php";
34
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
36
"graphid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
37
"period"=> array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD,ZBX_MAX_PERIOD), null),
38
"from"=> array(T_ZBX_INT, O_OPT, P_NZERO, null, null),
39
"stime"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
40
"border"=> array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null),
41
"width"=> array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null),
42
"height"=> array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null),
45
check_fields($fields);
48
$denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_MODE_LT);
50
if( !($db_data = DBfetch(DBselect("select g.*,h.host,h.hostid from graphs g left join graphs_items gi on g.graphid=gi.graphid ".
51
" left join items i on gi.itemid=i.itemid left join hosts h on i.hostid=h.hostid ".
52
" where g.graphid=".$_REQUEST["graphid"].
53
/* " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID. */ /* NOTE: the chart can display any accesiable graph! */
54
" and ( h.hostid not in (".$denyed_hosts.") OR h.hostid is NULL) "))))
59
$graph = new Graph($db_data["graphtype"]);
61
if(isset($_REQUEST["period"])) $graph->SetPeriod($_REQUEST["period"]);
62
if(isset($_REQUEST["from"])) $graph->SetFrom($_REQUEST["from"]);
63
if(isset($_REQUEST["stime"])) $graph->SetSTime($_REQUEST["stime"]);
64
if(isset($_REQUEST["border"])) $graph->SetBorder(0);
66
$width = get_request("width", 0);
68
if($width <= 0) $width = $db_data["width"];
70
$height = get_request("height", 0);
71
if($height <= 0) $height = $db_data["height"];
73
$graph->ShowWorkPeriod($db_data["show_work_period"]);
74
$graph->ShowTriggers($db_data["show_triggers"]);
76
$graph->SetWidth($width);
77
$graph->SetHeight($height);
78
$graph->SetHeader($db_data["host"].":".$db_data['name']);
79
$graph->SetYAxisType($db_data["yaxistype"]);
80
$graph->SetYAxisMin($db_data["yaxismin"]);
81
$graph->SetYAxisMax($db_data["yaxismax"]);
83
$result = DBselect("select gi.* from graphs_items gi ".
84
" where gi.graphid=".$db_data["graphid"].
85
" order by gi.sortorder, gi.itemid desc");
87
while($db_data=DBfetch($result))
91
$db_data["yaxisside"],
96
$db_data["periods_cnt"]
103
include_once "include/page_footer.php";