Files
cacti/graph.php
T
Ian Berry eb59dd520f Initial revision
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@2 860744bd-22fc-0310-8c96-e9fe5004b5ca
2002-05-18 20:29:57 +00:00

81 lines
3.5 KiB
PHP

<?/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 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: the rrdtool frontend [php-auth, php-tree, php-form] |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Ian Berry, any |
| questions or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/?>
<?
$section = "View Graphs";
$guest_account = true;
include ('include/auth.php');
include_once ("include/rrd_functions.php");
include_once ("include/functions.php");
include ("include/top_graph_header.php");
if (isset($form[action])) { $action = $form[action]; } else { $action = $args[action]; }
if (isset($form[ID])) { $id = $form[ID]; } else { $id = $args[id]; }
switch ($args[rraid]) {
case 'all':
$sql_where = " where id is not null";
break;
default:
$sql_where = " where id=$rraid";
break;
}
/* take graph permissions into account here, if the user does not have permission
give an "access denied" message */
if ($config["global_auth"]["value"] == "on") {
$user = db_fetch_row("select userid from auth_graph where graphid=$graphid and userid=" . GetCurrentUserID($HTTP_COOKIE_VARS["cactilogin"],$config["guest_user"]["value"]));
if ($config["graph_policy"]["auth"] == "1") {
if (sizeof($user) > 0) { $access_denied = true; }
} elseif ($config["graph_policy"]["auth"] == "2") {
if (! sizeof($user) > 0) { $access_denied = true; }
}
if ($access_denied == true) {
print "<strong><font size=\"+1\" color=\"FF0000\">ACCESS DENIED</font></strong>"; exit;
}
}
/* make sure the graph requested exists (sanity) */
$gid = db_fetch_cell("select ID from rrd_graph where id=$graphid");
if (! $gid > 0) {
print "<strong><font size=\"+1\" color=\"FF0000\">GRAPH DOES NOT EXIST</font></strong>"; exit;
}
$rra_list = db_fetch_assoc("select ID,Name from rrd_rra $sql_where order by steps");
if (sizeof($rra_list) > 0) {
foreach ($rra_list as $rra) {
?>
<div align="center"><img src="graph_image.php?graphid=<?print $graphid;?>&rraid=<?print $rra[ID];?>" border="0" alt="cacti/rrdtool graph"></div>
<div align="center"><strong><?print $rra[Name];?></strong> [<a href="graph.php?graphid=<?print $graphid;?>&rraid=<?print $rra[ID];?>&showinfo=true">source</a>]</div><br>
<?
}
}
include_once ("include/bottom_footer.php");
?>