Example #1
0
			<html>
			<head>
				<link rel='shortcut icon' href='<?php 
            print html_get_theme_images_path("favicon.ico");
            ?>
' type='image/x-icon'>
				<link href='<?php 
            print html_get_theme_images_path("favicon.ico");
            ?>
' rel='image/x-icon'>
				<title><?php 
            echo _("Cacti");
            ?>
</title>
				<link href='<?php 
            print html_get_theme_css();
            ?>
' rel='stylesheet'>
			</style>
			</head>

			<br><br>

			<table width='450' align='center'>
				<tr>
					<td colspan='2'><img src='<?php 
            print html_get_theme_images_path("auth_deny.gif");
            ?>
' border='0' alt='" . _("Access Denied") . "'></td>
				</tr>
				<tr height='10'><td></td></tr>
Example #2
0
function auth_display_custom_error_message($message)
{
    /* kill the session */
    setcookie(session_name(), "", time() - 3600, "/");
    /* print error */
    print "<html>\n<head>\n";
    print "     <title>" . "Cacti" . "</title>\n";
    print "     <link href=\"" . html_get_theme_css() . "\" rel=\"stylesheet\">";
    print "</head>\n";
    print "<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n<br><br>\n";
    display_custom_error_message($message);
    print "</body>\n</html>\n";
}
Example #3
0
function export() {
	require_once(CACTI_BASE_PATH . "/lib/sys/rrd.php");

	/* count how many graphs are created */
	$total_graphs_created = 0;

	export_log(_("Running graph export"));

	$cacti_root_path = CACTI_BASE_PATH;
	$cacti_export_path = read_config_option("path_html_export");

	/* copy the css/images on the first time */
	if (file_exists("$cacti_export_path/main.css") == false) {
		copy("$cacti_root_path/" . html_get_theme_css(), "$cacti_export_path/main.css");
		copy("$cacti_root_path/themes" . read_config_option("current_theme") . "/images/tab_cacti.gif", "$cacti_export_path/tab_cacti.gif");
		copy("$cacti_root_path/themes" . read_config_option("current_theme") . "/images/cacti_backdrop.gif", "$cacti_export_path/cacti_backdrop.gif");
		copy("$cacti_root_path/themes" . read_config_option("current_theme") . "/images/transparent_line.gif", "$cacti_export_path/transparent_line.gif");
		copy("$cacti_root_path/themes" . read_config_option("current_theme") . "/images/shadow.gif", "$cacti_export_path/shadow.gif");
	}

	/* if the index file already exists, delete it */
	check_remove($cacti_export_path . "/index.html");

	/* open pointer to the new index file */
	$fp_index = fopen($cacti_export_path . "/index.html", "w");

	/* get a list of all graphs that need exported */
	$graphs = db_fetch_assoc("select
		graph_templates_graph.id,
		graph_templates_graph.local_graph_id,
		graph_templates_graph.height,
		graph_templates_graph.width,
		graph_templates_graph.title_cache,
		graph_templates.name,
		graph_local.host_id
		from graph_templates_graph left join graph_templates on (graph_templates_graph.graph_template_id=graph_templates.id)
		left join graph_local on (graph_templates_graph.local_graph_id=graph_local.id)
		where graph_templates_graph.local_graph_id!=0 and graph_templates_graph.export='on'
		order by graph_templates_graph.title_cache");
	$rras = db_fetch_assoc("select
		rra.id,
		rra.name
		from rra
		order by timespan");

	/* write the html header data to the index file */
	fwrite($fp_index, HTML_HEADER);
	fwrite($fp_index, HTML_GRAPH_HEADER_ONE);
	fwrite($fp_index, "<strong>" . sprintf(_("Displaying '%i' Exported Graph%s"), sizeof($graphs), ((sizeof($graphs) > 1) ? "s" : "")) . "</strong>");
	fwrite($fp_index, HTML_GRAPH_HEADER_TWO);

	/* open a pipe to rrdtool for writing */
	$rrdtool_pipe = rrd_init();

	/* 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["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, $rrdtool_pipe);
		$total_graphs_created++;

		/* 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, "<strong>" . _("Graph") . " - " . $graph["title_cache"] . "</strong>");
		fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO);
		fwrite($fp_graph_index, "<td>");

		/* 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["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, $rrdtool_pipe);
			$total_graphs_created++;

			/* write image related html */
			fwrite($fp_graph_index, "<div align=center><img src='graph_" . $graph["local_graph_id"] . "_" . $rra["id"] . ".png' border=0></div>\n
				<div align=center><strong>" . $rra["name"] . "</strong></div><br>");
		}

		fwrite($fp_graph_index, "</td>");
		fwrite($fp_graph_index, HTML_GRAPH_FOOTER);
		fwrite($fp_graph_index, HTML_FOOTER);
		fclose($fp_graph_index);

		/* main graph page html */
		fwrite($fp_index, "<td align='center' width='" . (98 / 2) . "%'><a href='graph_" . $graph["local_graph_id"] . ".html'><img src='thumb_" . $graph["local_graph_id"] . ".png' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n");

		$i++;
		$k++;

		if (($i == 2) && ($k < count($graphs))) {
			$i = 0;
			fwrite($fp_index, "</tr><tr>");
		}

	}
	}else{ fwrite($fp_index, "<td><em>" . _("No Graphs Found.") . "</em></td>");
	}

	/* close the rrdtool pipe */
	rrd_close($rrdtool_pipe);

	fwrite($fp_index, HTML_GRAPH_FOOTER);
	fwrite($fp_index, HTML_FOOTER);
	fclose($fp_index);

	return $total_graphs_created;
}