$value) { $vars[$name] = $value; } list($type, $subtype) = extract_graph_type($vars['type']); if (is_numeric($vars['device'])) { $device = device_by_id_cache($vars['device']); } elseif (!empty($vars['device'])) { $device = device_by_name($vars['device']); } // FIXME -- remove these $width = $vars['width']; $height = $vars['height']; $title = $vars['title']; $vertical = $vars['vertical']; $legend = $vars['legend']; $output = (!empty($vars['output']) ? $vars['output'] : 'default'); $from = parse_at_time($_GET['from']) ?: Config::get('time.day'); $to = parse_at_time($_GET['to']) ?: Config::get('time.now'); $graph_type = (isset($vars['graph_type']) ? $vars['graph_type'] : Config::get('webui.graph_type')); $period = ($to - $from); $base64_output = ''; $prev_from = ($from - $period); $graphfile = Config::get('temp_dir') . '/' . strgen(); require Config::get('install_dir') . "/includes/html/graphs/$type/auth.inc.php"; //set default graph title $graph_title = format_hostname($device); if ($auth && is_custom_graph($type, $subtype, $device)) { include(Config::get('install_dir') . "/includes/html/graphs/custom.inc.php"); } elseif ($auth && is_mib_graph($type, $subtype)) { include Config::get('install_dir') . "/includes/html/graphs/$type/mib.inc.php"; } elseif ($auth && is_file(Config::get('install_dir') . "/includes/html/graphs/$type/$subtype.inc.php")) { include Config::get('install_dir') . "/includes/html/graphs/$type/$subtype.inc.php"; } else { graph_error("$type*$subtype "); // Graph Template Missing"); } function graph_error($string) { global $vars, $debug, $graphfile; $vars['bg'] = 'FFBBBB'; include 'includes/html/graphs/common.inc.php'; $rrd_options .= ' HRULE:0#555555'; $rrd_options .= " --title='".$string."'"; rrdtool_graph($graphfile, $rrd_options); if ($height > '99') { shell_exec($rrd_cmd); d_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 (!$debug) { header('Content-type: image/png'); } $im = imagecreate($width, $height); $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); } } if ($error_msg) { // We have an error :( graph_error($graph_error); } elseif ($auth === null) { // We are unauthenticated :( if ($width < 200) { graph_error('No Auth'); } else { graph_error('No Authorisation'); } } else { // $rrd_options .= " HRULE:0#999999"; if ($graph_type === 'svg') { $rrd_options .= " --imgformat=SVG"; if ($width < 350) { $rrd_options .= " -m 0.75 -R light"; } } if ($no_file) { if ($width < 200) { graph_error('No RRD'); } else { graph_error('Missing RRD Datafile'); } } elseif ($command_only) { echo "
RRDTool Command
"; echo ""; echo "rrdtool ".rrdtool_build_command("graph", $graphfile, $rrd_options); echo ""; $return = rrdtool_graph($graphfile, $rrd_options); echo "
RRDTool Output
"; echo ""; echo "$return"; echo ""; unlink($graphfile); echo '