File: graph.php

package info (click to toggle)
cacti 0.6.7-2.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,000 kB
  • ctags: 1,120
  • sloc: php: 5,059; sql: 922; sh: 302; perl: 81; makefile: 56
file content (74 lines) | stat: -rw-r--r-- 3,722 bytes parent folder | download
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
<?/* 
+-------------------------------------------------------------------------+
| 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 ('auth/include/auth.php');
	include ("include/database.php");
	include_once ("include/rrd_functions.php");
	include_once ("include/functions.php");
	include ('include/config.php');
	include ("include/top_graph_header.php");

switch ($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") {
	$sql_id = mysql_query("select userid from auth_graph where graphid=$graphid and userid=" . GetCurrentUserID($HTTP_COOKIE_VARS["cactilogin"],$config["guest_user"]["value"]),$cnn_id);
	
	if ($config["graph_policy"]["auth"] == "1") {
		if (mysql_num_rows($sql_id) > 0) { $access_denied = true; }
	}elseif ($config["graph_policy"]["auth"] == "2") {
		if (mysql_num_rows($sql_id) == 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) */
$sql_id = mysql_query("select id from rrd_graph where id=$graphid",$cnn_id);

if (mysql_num_rows($sql_id) == 0) {
	print "<strong><font size=\"+1\" color=\"FF0000\">GRAPH DOES NOT EXIST</font></strong>"; exit;
}

$sql_id_rra = mysql_query("select id,name from rrd_rra $sql_where order by steps",$cnn_id);
$rows_rra = mysql_num_rows($sql_id_rra); $i_rra = 0;

while ($i_rra < $rows_rra) {?>
	<div align="center"><img src="graph_image.php?graphid=<?print $graphid;?>&rraid=<?print mysql_result($sql_id_rra, $i_rra, "id");?>" border="0" alt="cacti/rrdtool graph"></div>
	<div align="center"><strong><?print mysql_result($sql_id_rra, $i_rra, "name");?></strong> [<a href="graph.php?graphid=<?print $graphid;?>&rraid=<?print mysql_result($sql_id_rra, $i_rra, "id");?>&showinfo=true">source</a>]</div><br>
	<?$i_rra++;
}

include_once ("include/bottom_footer.php");

?>