test_setup.php
changeset 1 58094faf794d
child 2 9a485c41cfcf
equal deleted inserted replaced
0:2cd8c1649ba9 1:58094faf794d
       
     1 <?php
       
     2 
       
     3 // +--------------------------------------------------------------------+
       
     4 // | PowerAdmin								|
       
     5 // +--------------------------------------------------------------------+
       
     6 // | Copyright (c) 1997-2002 The PowerAdmin Team			|
       
     7 // +--------------------------------------------------------------------+
       
     8 // | This source file is subject to the license carried by the overal	|
       
     9 // | program PowerAdmin as found on http://poweradmin.sf.net		|
       
    10 // | The PowerAdmin program falls under the QPL License:		|
       
    11 // | http://www.trolltech.com/developer/licensing/qpl.html		|
       
    12 // +--------------------------------------------------------------------+
       
    13 // | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
       
    14 // |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>			|
       
    15 // +--------------------------------------------------------------------+
       
    16 
       
    17 // Filename: test_setup.php
       
    18 // Description: tests your PowerAdmin install.
       
    19 // Adding tables? Increase the total count to (2^numberoftables)-1
       
    20 // Substract its binary value and put it in the last failure close.
       
    21 // Yes this is binary, why? Because thats cool! Squeeky geeky stuff!
       
    22 //
       
    23 // $Id: test_setup.php,v 1.4 2003/01/08 00:40:08 azurazu Exp $
       
    24 //
       
    25 
       
    26 include_once("inc/header.inc.php");
       
    27 require_once("inc/config.inc.php");
       
    28 require_once("inc/database.inc.php");
       
    29 
       
    30 // Initialize variables
       
    31 global $db;
       
    32 $bad_array = array();
       
    33 $check_tables = array('zones', 'users', 'records', 'domains');
       
    34 
       
    35 function error()
       
    36 {
       
    37 	return true;
       
    38 }
       
    39 
       
    40 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'error');
       
    41 
       
    42 foreach($check_tables as $table)
       
    43 {
       
    44 	if(DB::isError($db->query("select * from $table")))
       
    45 	{
       
    46 		$bad_array[] = $table;
       
    47 	}
       
    48 }
       
    49 
       
    50 $bad = (count($bad_array) == 0) ? false : true;
       
    51 
       
    52 // Start error or message output
       
    53 
       
    54 echo "<P>";
       
    55 
       
    56 if($bad)
       
    57 {
       
    58 	?><TABLE CLASS="error"><TR><TD CLASS="error"><H2>Not all tables are ok!</H2><?
       
    59 }
       
    60 else
       
    61 {
       
    62 	?><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2>Successful!</H2><?
       
    63 }
       
    64 ?>
       
    65 <BR>
       
    66 <FONT STYLE="font-weight: Bold">
       
    67 <?
       
    68 if($bad)
       
    69 {
       
    70 	?>Sorry, but there are error(s) found in the following table(s):<?
       
    71 	foreach($bad_array as $table)
       
    72 	{
       
    73 		echo " '$table'";
       
    74 		}
       
    75 		?>.</P><P>Please fix these errors and run the script again.</P><?
       
    76 	}
       
    77 	else
       
    78 	{
       
    79 		echo "Successful! Everything is set up ok, you can rumble!";
       
    80 	}
       
    81 ?>
       
    82 <BR></TD></TR></TABLE></P>
       
    83 <?
       
    84 	include_once("inc/footer.inc.php");
       
    85 ?>