[A-Za-z0-9]+)_(?P.+)/', mres($_GET['type']), $graphtype); $type = $graphtype['type']; $subtype = $graphtype['subtype']; if ($debug) {print_r($graphtype); } $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; if (is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) { if (isset($config['allow_unauth_graphs_cidr']) && count($config['allow_unauth_graphs_cidr']) > 0) { foreach ($config['allow_unauth_graphs_cidr'] as $range) { if (Net_IPv4::ipInNetwork($_SERVER['REMOTE_ADDR'], $range)) { $auth = "1"; break; } } } include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php"); if (isset($auth) && $auth) { include($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php"); } } else { graph_error("Graph Template Missing"); } function graph_error($string) { global $config, $width, $height, $debug, $graphfile, $rrd_options, $rrd_switches; #$rrd_options .= " HRULE:0#cc0000"; #$rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches; echo(rrdtool_graph($graphfile, " --title='".$string."' -l 0 -u 100 -E --start -10y --end now --width $width --height $height -c BACK#ff9999cc -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal HRULE:0#cc0000")); if ($height > "99") { #$rrd_cmd .= " --only-graph"; } $woo = shell_exec($rrd_cmd); if ($debug) { echo("
".$rrd_cmd."
"); } if (is_file($graphfile) && !$debug) { header('Content-type: image/png'); $fd = fopen($graphfile,'r'); fpassthru($fd); fclose($fd); unlink($graphfile); exit(); } } else { if (!$debug) { header('Content-type: image/png'); } $im = imagecreate($width, $height); $orange = imagecolorallocate($im, 255, 225, 225); $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); exit(); } } if ($error_msg) { graph_error($graph_error); } elseif (!$auth) { if ($width < 200) { graph_error("No Auth"); } else { graph_error("No Authorisation"); } } else { #$rrd_options .= " HRULE:0#999999"; if ($no_file) { if ($width < 200) { graph_error("No RRD"); } else { graph_error("Missing RRD Datafile"); } } else { if ($rrd_options) { if ($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; } rrdtool_graph($graphfile, " $rrd_options"); if ($debug) { echo("
".$rrd_cmd."
"); } if (is_file($graphfile) && !$debug) { header('Content-type: image/png'); $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); unlink($graphfile); } else { if ($width < 200) { graph_error("Draw Error"); } else { graph_error("Error Drawing Graph"); } } } else { if ($width < 200) { graph_error("Def Error"); } else { graph_error("Graph Definition Error"); } } } } ?>