2007-04-03 14:10:23 +00:00
|
|
|
<?php
|
|
|
|
|
2009-04-23 21:13:56 +00:00
|
|
|
if($_GET['debug']) {
|
2009-04-13 19:16:22 +00:00
|
|
|
ini_set('display_errors', 1);
|
2008-03-22 16:55:27 +00:00
|
|
|
ini_set('display_startup_errors', 0);
|
|
|
|
ini_set('log_errors', 0);
|
2007-04-03 14:10:23 +00:00
|
|
|
ini_set('allow_url_fopen', 0);
|
2009-04-23 21:13:56 +00:00
|
|
|
ini_set('error_reporting', E_ALL);
|
|
|
|
}
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2010-02-27 14:44:38 +00:00
|
|
|
include("../includes/defaults.inc.php");
|
2007-04-03 14:10:23 +00:00
|
|
|
include("../config.php");
|
2009-05-07 13:47:51 +00:00
|
|
|
include("../includes/common.php");
|
2009-11-11 18:20:32 +00:00
|
|
|
include("../includes/rewrites.php");
|
2010-02-20 17:37:42 +00:00
|
|
|
include("includes/authenticate.inc.php");
|
2009-05-07 13:47:51 +00:00
|
|
|
|
2010-05-28 15:21:27 +00:00
|
|
|
if(!$config['allow_unauth_graphs']) {
|
|
|
|
if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
|
|
|
|
}
|
2009-03-11 14:46:55 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
if($_GET['device']) {
|
2010-05-02 19:47:09 +00:00
|
|
|
$_GET['id'] = $_GET['device'];
|
2010-06-12 18:14:59 +00:00
|
|
|
$device_id = $_GET['device'];
|
2007-04-08 14:34:19 +00:00
|
|
|
} elseif($_GET['if']) {
|
2010-05-02 19:47:09 +00:00
|
|
|
$_GET['id'] = $_GET['if'];
|
2009-10-13 20:07:31 +00:00
|
|
|
} elseif($_GET['port']) {
|
2010-05-02 19:47:09 +00:00
|
|
|
$_GET['id'] = $_GET['port'];
|
2008-03-15 17:58:15 +00:00
|
|
|
} elseif($_GET['peer']) {
|
2010-05-02 19:47:09 +00:00
|
|
|
$_GET['id'] = $_GET['peer'];
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
2008-03-15 17:58:15 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
$from = mres($_GET['from']);
|
|
|
|
$to = mres($_GET['to']);
|
|
|
|
$width = mres($_GET['width']);
|
|
|
|
$height = mres($_GET['height']);
|
|
|
|
$title = mres($_GET['title']);
|
|
|
|
$vertical = mres($_GET['vertical']);
|
|
|
|
$type = mres($_GET['type']);
|
2010-05-02 19:47:09 +00:00
|
|
|
$legend = mres($_GET['legend']);
|
|
|
|
$id = mres($_GET['id']);
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2007-04-08 14:34:19 +00:00
|
|
|
$os = gethostosbyid($device_id);
|
2010-06-25 12:18:00 +00:00
|
|
|
if($config['os'][$os]['group']) {$os_group = $config['os'][$os]['group'];}
|
2009-11-07 02:30:38 +00:00
|
|
|
|
2010-06-25 12:18:00 +00:00
|
|
|
if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".inc.php")) {
|
2009-11-07 02:30:38 +00:00
|
|
|
/// Type + OS Specific
|
2010-06-25 12:18:00 +00:00
|
|
|
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".inc.php");
|
2009-11-07 02:30:38 +00:00
|
|
|
}elseif($os_group && is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php")) {
|
|
|
|
/// Type + OS Group Specific
|
|
|
|
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php");
|
2009-10-28 13:49:37 +00:00
|
|
|
} elseif(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) {
|
2009-11-07 02:30:38 +00:00
|
|
|
/// Type Specific
|
2009-10-28 13:49:37 +00:00
|
|
|
include($config['install_dir'] . "/html/includes/graphs/$type.inc.php");
|
|
|
|
}
|
|
|
|
|
|
|
|
if($rrd_options) {
|
2010-07-04 21:09:22 +00:00
|
|
|
|
|
|
|
if($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; }
|
|
|
|
$rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches;
|
|
|
|
$woo = shell_exec($rrd_cmd);
|
|
|
|
if($_GET['debug']) { echo("<pre>".$rrd_cmd."</pre>"); }
|
2010-06-10 14:52:46 +00:00
|
|
|
# $thing = popen($config['rrdtool'] . " -",'w');
|
|
|
|
# fputs($thing, "graph $graphfile $rrd_options");
|
|
|
|
# pclose($thing);
|
2009-10-28 13:49:37 +00:00
|
|
|
if(is_file($graphfile)) {
|
|
|
|
header('Content-type: image/png');
|
2010-02-05 23:11:47 +00:00
|
|
|
$fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd);
|
2010-05-02 19:47:09 +00:00
|
|
|
unlink($graphfile);
|
2009-10-28 13:49:37 +00:00
|
|
|
} else {
|
|
|
|
header('Content-type: image/png');
|
|
|
|
$string = "Graph Generation Error";
|
|
|
|
$im = imagecreate($width, $height);
|
|
|
|
$orange = imagecolorallocate($im, 255, 255, 255);
|
|
|
|
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
|
|
|
|
imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
|
|
|
|
imagepng($im);
|
|
|
|
imagedestroy($im);
|
|
|
|
}
|
2009-11-28 09:48:23 +00:00
|
|
|
}
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
|
2007-04-03 14:10:23 +00:00
|
|
|
|
|
|
|
?>
|