Displaying " . sizeof($graphs) . " Exported Graph" . ((sizeof($graphs) > 1) ? "s" : "") . ""); fwrite($fp_index, HTML_GRAPH_HEADER_TWO); /* for each graph... */ $i = 0; $k = 0; if ((sizeof($graphs) > 0) && (sizeof($rras) > 0)) { foreach ($graphs as $graph) { check_remove($cacti_export_path . "/thumb_" . $graph["local_graph_id"] . ".png"); check_remove($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html"); /* settings for preview graphs */ $graph_data_array["use"] = true; $graph_data_array["graph_start"] = "-60000"; $graph_data_array["graph_height"] = "100"; $graph_data_array["graph_width"] = "300"; $graph_data_array["graph_nolegend"] = true; $graph_data_array["export"] = true; $graph_data_array["export_filename"] = "thumb_" . $graph["local_graph_id"] . ".png"; rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array); /* generate html files for each graph */ $fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w"); fwrite($fp_graph_index, HTML_HEADER); fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE); fwrite($fp_graph_index, "Graph - " . get_graph_title($graph["local_graph_id"]) . ""); fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO); fwrite($fp_graph_index, ""); /* reset vars for actual graph image creation */ reset($rras); unset($graph_data_array); /* generate graphs for each rra */ foreach ($rras as $rra) { $graph_data_array["graph_nolegend"] = false; $graph_data_array["export"] = true; $graph_data_array["export_filename"] = "graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png"; rrdtool_function_graph($graph["local_graph_id"], $rra["id"], $graph_data_array); /* write image related html */ fwrite($fp_graph_index, "
\n
" . $rra["name"] . "

"); } fwrite($fp_graph_index, ""); fwrite($fp_graph_index, HTML_GRAPH_FOOTER); fwrite($fp_graph_index, HTML_FOOTER); fclose($fp_graph_index); /* main graph page html */ fwrite($fp_index, "" . get_graph_title($graph["local_graph_id"]) . "\n"); $i++; $k++; if (($i == 2) && ($k < count($graphs))) { $i = 0; fwrite($fp_index, ""); } } }else{ fwrite($fp_index, "No Graphs Found."); } fwrite($fp_index, HTML_GRAPH_FOOTER); fwrite($fp_index, HTML_FOOTER); fclose($fp_index); } function check_remove($filename) { if (file_exists($filename) == true) { unlink($filename); } } define("HTML_GRAPH_HEADER_ONE", " "); define("HTML_GRAPH_FOOTER", "
"); define("HTML_GRAPH_HEADER_TWO", "
\n

"); define("HTML_HEADER", " cacti \n
Preview View


"); define("HTML_FOOTER", "
"); ?>