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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004 Ian Berry |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| cacti: a php-based graphing solution |
+-------------------------------------------------------------------------+
| Most of this code has been designed, written and is maintained by |
| Ian Berry. See about.php for specific developer credit. Any questions |
| or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/
/* set default action */
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = "view"; }
if (!isset($_REQUEST["view_type"])) { $_REQUEST["view_type"] = ""; }
$guest_account = true;
include("./include/auth.php");
include("./lib/rrd.php");
include("./lib/html_tree.php");
include("./include/top_graph_header.php");
/* ================= input validation ================= */
input_validate_input_regex(get_request_var("rra_id"), "^([0-9]+|all)$");
input_validate_input_number(get_request_var("local_graph_id"));
/* ==================================================== */
if ($_GET["rra_id"] == "all") {
$sql_where = " where id is not null";
}else{
$sql_where = " where id=" . $_GET["rra_id"];
}
/* make sure the graph requested exists (sanity) */
if (!(db_fetch_cell("select local_graph_id from graph_templates_graph where local_graph_id=" . $_GET["local_graph_id"]))) {
print "<strong><font size='+1' color='FF0000'>GRAPH DOES NOT EXIST</font></strong>"; exit;
}
/* take graph permissions into account here, if the user does not have permission
give an "access denied" message */
if (read_config_option("global_auth") == "on") {
$access_denied = !(is_graph_allowed($_GET["local_graph_id"]));
if ($access_denied == true) {
print "<strong><font size='+1' color='FF0000'>ACCESS DENIED</font></strong>"; exit;
}
}
$graph_title = get_graph_title($_GET["local_graph_id"]);
if ($_REQUEST["view_type"] == "tree") {
print "<table width='98%' style='background-color: #ffffff; border: 1px solid #ffffff;' align='center' cellpadding='3'>";
}else{
print "<br><table width='98%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center' cellpadding='3'>";
}
$rras = get_associated_rras($_GET["local_graph_id"]);
switch ($_REQUEST["action"]) {
case 'view':
?>
<tr bgcolor='#<?php print $colors["header_panel"];?>'>
<td colspan='3' class='textHeaderDark'>
<strong>Viewing Graph</strong> '<?php print $graph_title;?>'
</td>
</tr>
<?php
$i = 0;
if (sizeof($rras) > 0) {
foreach ($rras as $rra) {
?>
<tr>
<td align='center'>
<table width='1' cellpadding='0'>
<tr>
<td>
<img src='graph_image.php?local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $rra["id"];?>' border='0' alt='<?php print $graph_title;?>'>
</td>
<td valign='top' style='padding: 3px;' class='noprint'>
<a href='graph.php?action=zoom&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $rra["id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
<a href='graph.php?action=properties&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $rra["id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<strong><?php print $rra["name"];?></strong>
</td>
</tr>
</table>
</td>
</tr>
<?php
$i++;
}
}
break;
case 'zoom':
/* find the maximum time span a graph can show */
$max_timespan=1;
if (sizeof($rras) > 0) {
foreach ($rras as $rra) {
if ($rra["steps"] * $rra["rows"] * $rra["rrd_step"] > $max_timespan) {
$max_timespan = $rra["steps"] * $rra["rows"] * $rra["rrd_step"];
}
}
}
/* fetch information for the current RRA */
$rra = db_fetch_row("select timespan,steps,name from rra where id=" . $_GET["rra_id"]);
/* define the time span, which decides which rra to use */
$timespan = -($rra["timespan"]);
/* find the step and how often this graph is updated with new data */
$ds_step = db_fetch_cell("SELECT
data_template_data.rrd_step
FROM (data_template_data,data_template_rrd,graph_templates_item)
WHERE graph_templates_item.task_item_id=data_template_rrd.id
AND data_template_rrd.local_data_id=data_template_data.local_data_id
AND graph_templates_item.local_graph_id=" . $_GET["local_graph_id"] .
" LIMIT 0,1");
$ds_step = empty($ds_step) ? 300 : $ds_step;
$seconds_between_graph_updates = ($ds_step * $rra["steps"]);
$now = time();
if (isset($_GET["graph_end"]) && ($_GET["graph_end"] <= $now - $seconds_between_graph_updates)) {
$graph_end = $_GET["graph_end"];
}else{
$graph_end = $now - $seconds_between_graph_updates;
}
if (isset($_GET["graph_start"])) {
if (($graph_end - $_GET["graph_start"])>$max_timespan) {
$graph_start = $now - $max_timespan;
}else {
$graph_start = $_GET["graph_start"];
}
}else{
$graph_start = $now + $timespan;
}
/* required for zoom out function */
if ($graph_start == $graph_end) {
$graph_start--;
}
$graph = db_fetch_row("select
graph_templates_graph.height,
graph_templates_graph.width
from graph_templates_graph
where graph_templates_graph.local_graph_id=" . $_GET["local_graph_id"]);
$graph_height = $graph["height"];
$graph_width = $graph["width"];
if ((read_config_option("rrdtool_version")) == "rrd-1.2.x") {
if (read_graph_config_option("title_font") == "") {
if (read_config_option("title_font") == "") {
$title_font_size = 10;
}else {
$title_font_size = read_config_option("title_size");
}
}else {
$title_font_size = read_graph_config_option("title_size");
}
}else {
$title_font_size = 0;
}
?>
<tr bgcolor='#<?php print $colors["header_panel"];?>'>
<td colspan='3' class='textHeaderDark'>
<strong>Zooming Graph</strong> '<?php print $graph_title;?>'
</td>
</tr>
<div id='zoomBox' style='position:absolute; overflow:none; left:0px; top:0px; width:0px; height:0px; visibility:visible; background:red; filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity:0.5; opacity:0.5'></div>
<div id='zoomSensitiveZone' style='position:absolute; overflow:none; left:0px; top:0px; width:0px; height:0px; visibility:visible; cursor:crosshair; background:blue; filter:alpha(opacity=0); -moz-opacity:0; -khtml-opacity:0; opacity:0' oncontextmenu='return false'></div>
<STYLE MEDIA="print">
/*Turn off the zoomBox*/
div#zoomBox, div#zoomSensitiveZone {display: none}
/*This keeps IE from cutting things off*/
#why {position: static; width: auto}
</STYLE>
<tr>
<td align='center'>
<table width='1' cellpadding='0'>
<tr>
<td>
<img id='zoomGraphImage' src='graph_image.php?local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $_GET["rra_id"];?>&view_type=<?php print $_REQUEST["view_type"];?>&graph_start=<?php print $graph_start;?>&graph_end=<?php print $graph_end;?>&graph_height=<?php print $graph_height;?>&graph_width=<?php print $graph_width;?>&title_font_size=<?php print $title_font_size ?>' border='0' alt='<?php print $graph_title;?>'>
</td>
<td valign='top' style='padding: 3px;' class='noprint'>
<a href='graph.php?action=properties&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $_GET["rra_id"];?>&view_type=<?php print $_REQUEST["view_type"];?>&graph_start=<?php print $graph_start;?>&graph_end=<?php print $graph_end;?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<strong><?php print $rra["name"];?></strong>
</td>
</tr>
</table>
</td>
</tr>
<?php
include("./include/zoom.js");
break;
case 'properties':
?>
<tr bgcolor='#<?php print $colors["header_panel"];?>'>
<td colspan='3' class='textHeaderDark'>
<strong>Viewing Graph Properties </strong> '<?php print $graph_title;?>'
</td>
</tr>
<tr>
<td align='center'>
<table width='1' cellpadding='0'>
<tr>
<td>
<img src='graph_image.php?local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $_GET["rra_id"];?>&graph_start=<?php print (isset($_GET["graph_start"]) ? $_GET["graph_start"] : 0);?>&graph_end=<?php print (isset($_GET["graph_end"]) ? $_GET["graph_end"] : 0);?>' border='0' alt='<?php print $graph_title;?>'>
</td>
<td valign='top' style='padding: 3px;'>
<a href='graph.php?action=zoom&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $_GET["rra_id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<strong><?php print db_fetch_cell("select name from rra where id=" . $_GET["rra_id"]);?></strong>
</td>
</tr>
</table>
</td>
</tr>
<?php
break;
}
print "</table>";
print "<br><br>";
include_once("./include/bottom_footer.php");
?>
|