<?php require_once("includes/acl.inc"); ?>
<p class="pgtitle">System: Statistics</p>
<?php
if($settings['USE_MRTG']) {
if (!file_exists('mrtg/load.html')) {
infobox("No statistics available", "Did you install mrtg and configure it according to the README file?".
" Run the configuration check to see if you did it correctly".
"<br>(But don't panic, it might just be that MRTG haven't been run yet and outputed any files)");
} else {
// settings default selected
$selected[''.$_POST['stat'].''] = "selected";
// printing the select box
print "<form name=\"stats\" method=\"post\" action=\"\">".
"<select name=\"stat\">".
"<option $selected[load] value=\"load\">System Statistics - Load</option>\n".
"<option $selected[processes] value=\"processes\">System Statistics - Processes</option>\n".
"<option $selected[swap] value=\"swap\">System Statistics - Swap</option>\n".
"<option $selected[uptime] value=\"uptime\">System Statistics - Uptime</option>\n".
"<option $selected[tcp] value=\"tcp\">System Statistics - Open Connections</option>\n".
"</select> <input type=\"submit\" name=\"changestat\" value=\"Change\"><br>\n".
"</form>\n";
// a change switch thingy
if (isset($_POST['stat'])) {
switch ($_POST['stat']) {
case "load":
$statfile = 'mrtg/load.html';
break;
case "processes":
$statfile = 'mrtg/processes.html';
break;
case "swap":
$statfile = 'mrtg/swap.html';
break;
case "uptime":
$statfile = 'mrtg/uptime.html';
break;
case "tcp":
$statfile = 'mrtg/tcp.html';
break;
default:
$statfile = 'mrtg/load.html';
}
// setting default stat page if none is selected
} else {
$statfile = 'mrtg/load.html';
}
// puts the contents of the mrtg output in a variable and clean up some unwanted html tags (so it validates :)
$mrtgfile = file_get_contents("$statfile");
$unwanted = array('@<head[^>]*?>.*?</head>@si','@<!DOCTYPE[^>]*?>hide@address.com','@<BODY[^>]*?>hide@address.com','@</BODY>hide@address.com','@<HTML>hide@address.com','@</HTML>hide@address.com');
$cleaned = preg_replace($unwanted, '', $mrtgfile);
// replaces the img src tags so it's correct according to the GUI
$fixedmrtg = str_replace('SRC="','SRC="mrtg/', $cleaned);
print "$fixedmrtg";
}
} else {
errorbox("Disabled","MRTG is disabled in the config file, correct this if you want to use MRTG");
}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>
</td></tr>