<?
error_reporting(0);
foreach ($_POST as $varname => $varvalue) {
$$varname = $varvalue;
}
foreach ($_GET as $varname => $varvalue) {
$$varname = $varvalue;
}
foreach ($_SERVER as $varname => $varvalue) {
$$varname = $varvalue;
}
if($debug) {
error_reporting(1);
error_reporting(E_ALL);
}
include "functions.php";
$page = $_GET['page'];
$display = 1;
$hquery = "SELECT * FROM nHosts";
$hresults = mysql_query($hquery);
$hrows = mysql_num_rows($hresults);
$gquery = "SELECT * FROM nHostgroups";
$gresults = mysql_query($gquery);
$grows = mysql_num_rows($gresults);
$squery = "SELECT * FROM nServices";
$sresults = mysql_query($squery);
$srows = mysql_num_rows($sresults);
if((!$hrows) || (!$grows) || (!$srows)) {
$display = 0;
}
if((!$grows) && (!$hrows)) {
$disable = "disabled";
}
echo "<center><b><h2>Nagios</b></center><br>";
echo "<table bgcolor='000000' cellpadding=0 border=0 cellspacing=0 align='center' width='80%'>\n";
echo "\t<tr>\n";
echo "\t\t<td>\n";
if($display) {
echo "<table cellpadding=0 border=0 cellspacing=1 width='100%'>";
echo "<tr>";
echo "<td bgcolor='#FFFFFF' align='center'>";
echo "<a href='$modulepath/report.php' target='_blank'>Run report</a>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
echo "\t\t\t<table cellpadding=0 border=0 cellspacing=1 width='100%'>\n";
echo "\t\t\t\t<tr>\n";
echo "<td bgcolor='#D3DCE3' align='center'><b>Import Files</b></td>";
echo "</tr>";
echo "\t\t\t\t<tr>\n";
echo "<td bgcolor='#FFFFFF' align='center'>";
if(!$display) {
echo "<font color='red'>Database not fully populated</font>";
}
echo "<table width='100%' border='0'>";
echo "<tr><td><img src='#' width='180' height='1'></td><form method='post' action='index.php?page=$page' enctype=\"multipart/form-data\"><td>";
echo "<input type='hidden' name='type' value='hosts'>";
echo " <b>Hosts</b><br>";
echo " <input type='file' name='userfile'> <input type='submit' value='Import'>($hrows hosts in db)";
echo "</td></form></tr>";
echo "<tr><td><img src='#' width='180' height='1'></td><form method='post' action='index.php?page=$page' enctype=\"multipart/form-data\"><td>";
echo "<input type='hidden' name='type' value='hostgroups'>";
echo " <b>Hostgroups</b><br>";
echo " <input type='file' name='userfile'> <input type='submit' value='Import'>($grows hostgroups in db)";
echo "</td></form></tr>";
echo "<tr><td><img src='#' width='180' height='1'></td><form method='post' action='index.php?page=$page' enctype=\"multipart/form-data\"><td>";
echo "<input type='hidden' name='type' value='services'>";
echo " <b>Services</b><br>";
echo " <input type='file' name='userfile' $disable> <input type='submit' value='Import' $disable>($srows services in db)";
echo "</td></form></tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>\n";
echo "\t\t</td>";
echo "\t</tr>";
echo "</table>\n";
?>