Location: PHPKode > projects > NaWui > nawui/database.php
<?php

define("PAGE_ID","database");
define("PAGE_TITLE","Database Maintenance");

require_once("includes/main.inc.php");
include_once("html_wrap/head.inc.php");


$totalcount = 0;
$rowcolor = "dataOdd";
$message = "";
$action = (isset($action)) ? strtolower($action) : "";
$tables = (isset($tables)) ? $tables : "";


#
if ($action == "Yes" && is_array($tables))	{

		if ($result = $Plugin->ClearTables($tables))
			$message = "<font color=\"#00AA00\">All objects were sucessfuly cleared.</font>";
		else
			$message = "<font color=\"#FF2222\">Error clearing objects from tables.</font>";
}


$databases = array( 
		"host" => $Plugin->GetObjectsCount("host"),
		"hostgroup" => $Plugin->GetObjectsCount("hostgroup"),
		"contact" => $Plugin->GetObjectsCount("contact"),
		"contactgroup" => $Plugin->GetObjectsCount("contactgroup"),
		"service" => $Plugin->GetObjectsCount("service"),
		"serviceescalation" => $Plugin->GetObjectsCount("serviceescalation"),
		"timeperiod" => $Plugin->GetObjectsCount("timeperiod"),
		"command" => $Plugin->GetObjectsCount("command")
		);
		

# Try to get the nagios.cfg from previous import
$nagioscfg = $Plugin->GetConfig("nagioscfg");

?>
<br>
<div align="center">
<form action="yesnodb.php" target="clear_database_popup" method="POST">
<table cellpadding="2" cellspacing="4" border="0">
<tr>
  <td colspan="2">&nbsp;<?=$message?>&nbsp;
  </td>
</tr>
 <tr class="<?=$rowcolor?>">
   <td colspan="2" align="center">
     &nbsp;
     Please select the databases you want to clear:
     &nbsp;
   </td>
 </tr>
<?
foreach ($databases as $key => $count) {

	$rowcolor = ($rowcolor != "dataOdd") ? "dataOdd" : "dataEven";

	$key_name = ucfirst($key)."s";
	$count = ($count == "") ? 0 : $count;
	print <<<HTML
 <tr class="$rowcolor">
   <td align="center">
    <input type="checkbox" name="tables[]" value="$key">
   </td>
   <td>&nbsp;'$key_name' table ($count objects)</td>
 </tr>
HTML;
}
$rowcolor = ($rowcolor != "dataOdd") ? "dataOdd" : "dataEven"; 
?>
<tr class="<?=$rowcolor?>">
   <td colspan="2" align="center">
    <input type="submit" name="action" value="Clear" onclick="nw=window.open('', 'clear_database_popup', 'resizable=no, scrollbars=1, copyhistory=0, width=350, height=150');nw.opener=self;">
  </td>
 </tr>
</table>
</form>
</div>
<?

?>
<?

include_once("html_wrap/tail.inc.php");

?>
Return current item: NaWui