2010-07-24 19:14:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if($_GET['debug']) {
|
2010-07-29 11:29:55 +00:00
|
|
|
$debug = TRUE;
|
2010-07-24 19:14:41 +00:00
|
|
|
ini_set('display_errors', 1);
|
|
|
|
ini_set('display_startup_errors', 0);
|
|
|
|
ini_set('log_errors', 0);
|
|
|
|
ini_set('error_reporting', E_ALL);
|
2010-07-29 11:29:55 +00:00
|
|
|
} else {
|
|
|
|
$debug = FALSE;
|
|
|
|
ini_set('display_errors', 0);
|
|
|
|
ini_set('display_startup_errors', 0);
|
|
|
|
ini_set('log_errors', 0);
|
|
|
|
ini_set('error_reporting', 0);
|
2010-07-24 19:14:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
include("../includes/defaults.inc.php");
|
|
|
|
include("../config.php");
|
|
|
|
include("../includes/common.php");
|
|
|
|
include("../includes/rewrites.php");
|
2010-07-28 19:43:02 +00:00
|
|
|
include("includes/functions.inc.php");
|
2010-07-24 19:14:41 +00:00
|
|
|
include("includes/authenticate.inc.php");
|
|
|
|
|
|
|
|
if(!$config['allow_unauth_graphs']) {
|
|
|
|
if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
|
|
|
|
}
|
|
|
|
|
2010-07-25 14:21:05 +00:00
|
|
|
# if($_GET['device']) {
|
|
|
|
# $_GET['id'] = $_GET['device'];
|
|
|
|
# $device_id = $_GET['device'];
|
|
|
|
# } elseif($_GET['if']) {
|
|
|
|
# $_GET['id'] = $_GET['if'];
|
|
|
|
# } elseif($_GET['port']) {
|
|
|
|
# $_GET['id'] = $_GET['port'];
|
|
|
|
# } elseif($_GET['peer']) {
|
|
|
|
# $_GET['id'] = $_GET['peer'];
|
|
|
|
# }
|
2010-07-24 19:14:41 +00:00
|
|
|
|
|
|
|
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', mres($_GET['type']), $graphtype);
|
|
|
|
|
|
|
|
$type = $graphtype['type'];
|
|
|
|
$subtype = $graphtype['subtype'];
|
|
|
|
|
|
|
|
if($debug) {print_r($graphtype);}
|
|
|
|
|
|
|
|
$from = mres($_GET['from']);
|
|
|
|
$to = mres($_GET['to']);
|
|
|
|
$width = mres($_GET['width']);
|
|
|
|
$height = mres($_GET['height']);
|
|
|
|
$title = mres($_GET['title']);
|
|
|
|
$vertical = mres($_GET['vertical']);
|
|
|
|
$legend = mres($_GET['legend']);
|
|
|
|
$id = mres($_GET['id']);
|
|
|
|
|
|
|
|
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
|
|
|
|
|
2010-07-28 19:43:02 +00:00
|
|
|
# $os = gethostosbyid($device_id);
|
|
|
|
# if($config['os'][$os]['group']) {$os_group = $config['os'][$os]['group'];}
|
2010-07-24 19:14:41 +00:00
|
|
|
# if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".inc.php")) {
|
|
|
|
# /// Type + OS Specific
|
|
|
|
# include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".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");
|
|
|
|
# } elseif(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) {
|
|
|
|
# /// Type Specific
|
|
|
|
# include($config['install_dir'] . "/html/includes/graphs/$type.inc.php");
|
|
|
|
# }
|
|
|
|
|
|
|
|
if(is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) {
|
2010-07-28 19:43:02 +00:00
|
|
|
include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php");
|
2010-08-01 14:17:06 +00:00
|
|
|
if($auth) {
|
|
|
|
include($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php");
|
|
|
|
}
|
2010-08-02 02:40:17 +00:00
|
|
|
} else {
|
|
|
|
graph_error("Graph Template Missing");
|
2010-07-24 19:14:41 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 17:25:44 +00:00
|
|
|
function graph_error ($string) {
|
|
|
|
global $width, $height;
|
|
|
|
header('Content-type: image/png');
|
2010-08-02 02:40:17 +00:00
|
|
|
$im = imagecreate($width+79, $height);
|
|
|
|
$orange = imagecolorallocate($im, 255, 225, 225);
|
2010-08-01 17:25:44 +00:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
2010-07-24 19:14:41 +00:00
|
|
|
|
2010-08-02 02:40:17 +00:00
|
|
|
if(!$auth)
|
2010-08-01 17:25:44 +00:00
|
|
|
{
|
2010-08-02 02:40:17 +00:00
|
|
|
graph_error("Unauthorized");
|
|
|
|
} else {
|
2010-08-01 17:25:44 +00:00
|
|
|
if($no_file)
|
2010-08-01 14:17:06 +00:00
|
|
|
{
|
2010-08-01 17:25:44 +00:00
|
|
|
graph_error("Missing RRD");
|
|
|
|
} else {
|
2010-08-01 14:17:06 +00:00
|
|
|
if($rrd_options)
|
|
|
|
{
|
|
|
|
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>"); }
|
|
|
|
# $thing = popen($config['rrdtool'] . " -",'w');
|
|
|
|
# fputs($thing, "graph $graphfile $rrd_options");
|
|
|
|
# pclose($thing);
|
|
|
|
if(is_file($graphfile)) {
|
|
|
|
header('Content-type: image/png');
|
|
|
|
$fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd);
|
|
|
|
unlink($graphfile);
|
|
|
|
} else {
|
2010-08-01 17:25:44 +00:00
|
|
|
graph_error("Drawing Error");
|
2010-08-01 14:17:06 +00:00
|
|
|
}
|
2010-08-01 17:25:44 +00:00
|
|
|
} else {
|
|
|
|
graph_error("Definition Error");
|
2010-07-24 19:14:41 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-01 17:25:44 +00:00
|
|
|
}
|
2010-07-24 19:14:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
?>
|