~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002110857

« back to all changes in this revision

Viewing changes to frontends/php/chart2.php

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2007-07-02 09:06:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070702090651-8l6fl3fjw9rh6l2u
Tags: 1:1.4.1-2
Add patch from SVN in order to fix Incorrect processing of character '%'
in user parameters and remote commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
**/
20
20
?>
21
21
<?php
22
 
        include "include/config.inc.php";
23
 
        include "include/classes/graph.inc.php";
24
 
 
25
 
        check_authorisation();
26
 
 
27
 
        if(!check_right("Graph","R",$_REQUEST["graphid"]))
28
 
        {
29
 
                exit;
30
 
        }
31
 
        
32
 
        $graph=new Graph();
33
 
        if(isset($_REQUEST["period"]))
34
 
        {
35
 
                $graph->setPeriod($_REQUEST["period"]);
36
 
        }
37
 
        if(isset($_REQUEST["from"]))
38
 
        {
39
 
                $graph->setFrom($_REQUEST["from"]);
40
 
        }
41
 
        if(isset($_REQUEST["stime"]))
42
 
        {
43
 
                $graph->setSTime($_REQUEST["stime"]);
44
 
        }
45
 
        if(isset($_REQUEST["border"]))
46
 
        {
47
 
                $graph->setBorder(0);
48
 
        }
49
 
 
50
 
        $result=DBselect("select * from graphs where graphid=".$_REQUEST["graphid"]);
51
 
        $row=DBfetch($result);
52
 
        $db_hosts = get_hosts_by_graphid($_REQUEST["graphid"]);
53
 
        $name=$row["name"];
54
 
 
55
 
        $db_host = DBfetch($db_hosts);
56
 
        if($db_host)
57
 
        {
58
 
                $name = $db_host["host"].":".$name;
59
 
        }
60
 
        if(isset($_REQUEST["width"])&&$_REQUEST["width"]>0)
61
 
        {
62
 
                $width=$_REQUEST["width"];
63
 
        }
64
 
        else
65
 
        {
66
 
                $width=$row["width"];
67
 
        }
68
 
        if(isset($_REQUEST["height"])&&$_REQUEST["height"]>0)
69
 
        {
70
 
                $height=$_REQUEST["height"];
71
 
        }
72
 
        else
73
 
        {
74
 
                $height=$row["height"];
75
 
        }
76
 
 
77
 
        $graph->ShowWorkPeriod($row["show_work_period"]);
78
 
        $graph->ShowTriggers($row["show_triggers"]);
79
 
 
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"]);
86
 
 
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");
88
 
 
89
 
        while($row=DBfetch($result))
90
 
        {
91
 
                $graph->addItem(
92
 
                        $row["itemid"],
93
 
                        $row["yaxisside"],
94
 
                        $row["calc_fnc"],
95
 
                        $row["color"],
96
 
                        $row["drawtype"],
97
 
                        $row["type"],
98
 
                        $row["periods_cnt"]
 
22
        require_once "include/config.inc.php";
 
23
        require_once "include/graphs.inc.php";
 
24
        require_once "include/classes/graph.inc.php";
 
25
        
 
26
        $page["file"]   = "chart2.php";
 
27
        $page["title"]  = "S_CHART";
 
28
        $page["type"]   = PAGE_TYPE_IMAGE;
 
29
 
 
30
include_once "include/page_header.php";
 
31
 
 
32
?>
 
33
<?php
 
34
//              VAR                     TYPE    OPTIONAL FLAGS  VALIDATION      EXCEPTION
 
35
        $fields=array(
 
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),
 
43
        );
 
44
 
 
45
        check_fields($fields);
 
46
?>
 
47
<?php
 
48
        $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_MODE_LT);
 
49
        
 
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) "))))
 
55
        {
 
56
                access_deny();
 
57
        }
 
58
 
 
59
        $graph = new Graph($db_data["graphtype"]);
 
60
 
 
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);
 
65
 
 
66
        $width = get_request("width", 0);
 
67
 
 
68
        if($width <= 0) $width = $db_data["width"];
 
69
 
 
70
        $height = get_request("height", 0);
 
71
        if($height <= 0) $height = $db_data["height"];
 
72
 
 
73
        $graph->ShowWorkPeriod($db_data["show_work_period"]);
 
74
        $graph->ShowTriggers($db_data["show_triggers"]);
 
75
 
 
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"]);
 
82
 
 
83
        $result = DBselect("select gi.* from graphs_items gi ".
 
84
                " where gi.graphid=".$db_data["graphid"].
 
85
                " order by gi.sortorder, gi.itemid desc");
 
86
 
 
87
        while($db_data=DBfetch($result))
 
88
        {
 
89
                $graph->AddItem(
 
90
                        $db_data["itemid"],
 
91
                        $db_data["yaxisside"],
 
92
                        $db_data["calc_fnc"],
 
93
                        $db_data["color"],
 
94
                        $db_data["drawtype"],
 
95
                        $db_data["type"],
 
96
                        $db_data["periods_cnt"]
99
97
                        );
100
98
        }
101
99
        $graph->Draw();
102
100
?>
 
101
<?php
 
102
 
 
103
include_once "include/page_footer.php";
 
104
 
 
105
?>