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");
|
|
|
|
include("../includes/graphing.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
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
# 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']) {
|
2007-04-08 14:34:19 +00:00
|
|
|
$device_id = $_GET['device'];
|
|
|
|
} elseif($_GET['if']) {
|
|
|
|
$device_id = getifhost($_GET['if']);
|
2007-04-03 14:10:23 +00:00
|
|
|
$ifIndex = getifindexbyid($_GET['if']);
|
2009-10-13 20:07:31 +00:00
|
|
|
} elseif($_GET['port']) {
|
|
|
|
$device_id = getifhost($_GET['port']);
|
|
|
|
$ifIndex = getifindexbyid($_GET['port']);
|
2008-03-15 17:58:15 +00:00
|
|
|
} elseif($_GET['peer']) {
|
|
|
|
$device_id = getpeerhost($_GET['peer']);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
2008-03-15 17:58:15 +00:00
|
|
|
|
2009-03-30 11:20:18 +00:00
|
|
|
if($device_id) { $hostname = gethostbyid($device_id); }
|
2007-04-04 22:05:52 +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']);
|
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);
|
2009-11-07 02:30:38 +00:00
|
|
|
$os_lower = strtolower($os);
|
|
|
|
if($os_groups[$os_lower]) {$os_group = $os_groups[$os_lower];}
|
|
|
|
|
|
|
|
if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".inc.php")) {
|
|
|
|
/// Type + OS Specific
|
|
|
|
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".inc.php");
|
|
|
|
}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) {
|
2009-11-11 11:56:14 +00:00
|
|
|
if($_GET['debug']) { echo("<pre>".$config['rrdtool'] . " graph $graphfile $rrd_options"); }
|
2009-10-28 13:49:37 +00:00
|
|
|
$thing = shell_exec($config['rrdtool'] . " graph $graphfile $rrd_options");
|
|
|
|
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);
|
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
|
|
|
|
|
|
|
if($graph) {
|
2010-02-24 02:16:56 +00:00
|
|
|
# header('Content-type: image/png');
|
|
|
|
# $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd);
|
2007-04-03 14:10:23 +00:00
|
|
|
} else {
|
2007-11-21 14:26:24 +00:00
|
|
|
header('Content-type: image/png');
|
2009-03-30 11:20:18 +00:00
|
|
|
$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);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
|
2010-02-07 22:26:13 +00:00
|
|
|
unlink($graphfile);
|
2009-10-28 13:49:37 +00:00
|
|
|
|
2009-11-28 09:48:23 +00:00
|
|
|
# } // End IF
|
2009-10-28 13:49:37 +00:00
|
|
|
|
2007-04-03 14:10:23 +00:00
|
|
|
|
|
|
|
?>
|