Location: PHPKode > projects > WaterFlea Database Maintenance Tool > waterflea-0.6-beta/index.php
<?php

/*#####################################################################################

WaterFlea - Database Maintenance Tool
Copyright (C) Benjamin Rafael F. Intal

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

WaterFlea project site is at http://www.sourceforge.net/projects/waterflea/
WaterFlea website is at http://waterflea.sourceforge.net/

If you have questions or suggestions, please visit the said URLs above,
or you could contact me via email at <hide@address.com> - just mention in the
WaterFlea in the subject and what it's all about.

#######################################################################################*/

/////// NO VALIDATION YET ////////////
////// NO ENUM RADIO BUTTONS YET //////////

session_start();

/*
	required files
*/

include ("include/_Uploading.php");
include ("include/_AdminAccess.php");
include ("include/_Display.php");

require_once ("include/_Database.php");
require_once ("include/Admin.php");

/*
	initialization
*/

foreach ($HTTP_GET_VARS as $var => $value)
{
	$$var = $value;
};

if (! isset($table))
{
	$table = null;
}
if (! isset($rows))
{
	$rows = 10;
}
if (! isset($delete))
{
	$delete = null;
}
if (! isset($edit))
{
	$edit = null;
}
if (! isset($save))
{
	$save = null;
}
if (! isset($saveNew))
{
	$saveNew = null;
}
if (! isset($add))
{
	$add = null;
}
if (! isset($page))
{
	$page = 0;
}
if (! isset($number))
{	
	$number = 10;
}

/*
	initialize database
*/

$db = new Admin();

/*
	initialize server / script variables
*/

// script name (this file)
$currentFile = substr(strrchr($_SERVER['PHP_SELF'],'/'),1);
// php version (integer)
$phpVer = substr(strrchr($_SERVER['SERVER_SOFTWARE'],'PHP'),2,1);
settype ($phpVer, 'int');

/*
	initialize common script parameters for easy form get methods
*/

// construct common get params
$getParams = array();
$getParams[] = array('page',$page);
$getParams[] = array('number', $number);

/*
	html headers
*/

?>
<!-- javascript validators -->
<html>
<head>
<title>WaterFlea - DB Maintenance Tool</title>
<script language="JavaScript1.2" src="js/admin.js"></script>
<link href="css/admin.css" media="all" rel="Stylesheet" type="text/css" />
</head>
<body>
<?

/*
	WATERFLEA LOGO
*/

$logoIfLogged = "
	<table border='0'>
	<tr>
	<td>
	<img src='images/waterflea_vsmall.jpg'>
	</td><td>
	<img src='images/waterflea_title.jpg'>
	</td>
	</table>
	<hr length='100%' depth='1' size='1' noshadow>
	";
$logoIfNotLogged = "
	<div align='center'>
	<img src='images/waterflea_big.jpg'>
	</div>
	<hr length='100%' depth='1' size='1' noshadow>
	";

/*
	check for log outs
*/

if (isset($logout))
{
	unset($_SESSION['logged']);
}

/*
	check for proper configuration of scripts & database
*/

$checkingOkay = 1;
if (! isset($_SESSION['logged']))
{
	$checkingError = 'Unidentified configuration error!';
	//print ("<div style='display: none;'>");
	/*
		SCRIPTS CONFIG CHECKS
	*/
	/*
		DATABASE CONFIG CHECKS
	*/
	// check if we can connect to the db
	$checker = $db->checkConnect();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}
	// check if database exists
	$checker = $db->checkDatabase();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}
	// check if there are tables
	$checker = $db->checkTables();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}
	// check if admin user table exists
	$checker = $db->checkAdminTable();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}
	// check if admin table has a 'username' field
	$checker = $db->checkAdminUser();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}
	// check if admin table has a 'password' field
	$checker = $db->checkAdminPass();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}
	// check if there is an admin
	$checker = $db->checkAdmin();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}
	/*
		FILESYSTEM CHECKS
	*/
	// check if defined upload folder is writable
	$checker = $db->checkUploadable();
	if ($checker !== true && $checkingOkay == 1)
	{
		$checkingOkay = 0;
		$checkingError = $checker;
	}

	print ("</div>");
}
if ($checkingOkay == 0)
{
	echo $logoIfNotLogged;
	// ask for user pass
	?>
	<div align="center">
	<table cellpadding="0" cellspacing="0" border="0"><tr><td align="center" valign="top">
	<div class="bordered1">
	<div class="margined0">
	There was an error in the configuration of the scripts
	and/or the database. Please contact the Administrator.<br><br>
	<font color="red"><?=$checkingError?></font>
	</div>
	</div>
	</td></tr></table>
	</div>
	<?
}
else
{

/*
	log in method
*/

if (! isset($_SESSION['logged']))
{
	if (! isset($_POST['user']) || ! isset($_POST['pass']))
	{
		echo $logoIfNotLogged;
		// ask for user pass
		?>
		<div align="center">
		<table cellpadding="0" cellspacing="0" border="0"><tr><td align="center" valign="top">
		<div class="bordered1">
		<div class="margined0">
		You must log in to access the database.<br>
		<form method='post' action='<?=$currentFile?>?login=Y'>
		Username: <input type="text" name="user" value=""><br>
		Password: <input type="password" name="pass" value=""><br>
		<input type="submit" name="submit" value="Log in">
		</form>
		</div>
		</div>
		</td><td valign="top"><img src="images/tab_admin_login.jpg"></td></tr></table>
		</div>
		<?
	}
	else
	{
		// log in
		if ($db->login($_POST['user'], $_POST['pass']))
		{
			$_SESSION['logged'] = true;
		}
		else
		{
			echo $logoIfNotLogged
			// ask for user pass
			?>
			<div align="center" style="color: red">
			Invalid username / password!
			</div>
			<div align="center">
			<table cellpadding="0" cellspacing="0" border="0"><tr><td align="center" valign="top">
			<div class="bordered1">
	                <div class="margined0">
			You must log in to access the database.<br>
			<form method='post' action='<?=$currentFile?>?login=Y'>
			Username: <input type="text" name="user" value=""><br>
			Password: <input type="password" name="pass" value=""><br>
			<input type="submit" name="submit" value="Log in">
			</form>
			</div>
			</div>
			</td><td valign="top"><img src="images/tab_admin_login.jpg"></td></tr></table>
			</div>
			<?
		}
	}
}

/*
	logged in process
*/

if (isset($_SESSION['logged']))
{
	echo $logoIfLogged;

	/*
		MAIN PAGE
	*/

	// log out button
	?>
	<div align='right'>
	<form method='post' action='<?=$currentFile?>?logout=Y'>
	<input type="submit" name="submit" value="Log out">
	</form>
	</div>
	<?

if ($table == null)
{
	// table list
	$arr = $db->getTables();
	?>
	<div align="center">
	<table cellpadding="0" cellspacing="0" border="0"><tr><td valign="top">
	<div class="bordered0" align="left"> 
	<div class="margined0">
	<?
	foreach ($arr as $elem)
	{
		?>
		<a href='<?=$currentFile?>?table=<?=$elem[0]?>'>
		<?=$elem[0]?>
		</a><br>
		<?
	}
	?>
	</div>
	</div>
	</td><td valign="top"><img src="images/tab_table_list.jpg"></td></tr></table>
	</div>
	<?
}
else
{

	/*
		INITIALIZE PAGE VARIABLES
	*/

	$numChoices = array(1,2,3,10,20,30,50,100,200,500);
	// get table keys
	$keys = $db->getKeys($table);
	// get table fields
	$arr = $db->getTableFields($table);
	$fields = array();
	foreach ($arr as $elem)
	{
		$fields[] = $elem[0];
	}

	/*
		FILE UPLOADING PROCESS
	*/

	if (isset ($uploadedFile))
	{
		$errorCode = $db->checkFileBeingUploaded($_FILES['userfile']['error'], $_FILES['userfile']['type'], $_FILES['userfile']['size'], $uploadSupportedFileFormat, $uploadMaxFileSize);

		// image properly uploaded
		if ($errorCode == 0)
		{
			$newFilename = $db->uploadFile($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);
			if ($newFilename == '')
			{
				// error uploading
				?>
				<script>
					alert ("Error uploading file!");
				</script>
				<?
				$err = 1;
			}
			else
			{
				?>
				<script>
					alert ("File has been successfully uploaded and stored in the database!\n\nNew file: <?=$newFilename?>");
				</script>
				<?
				foreach ($fields as $field)
				{
					if ($uploadFile == "Upload File: $field")
					{
						$_GET["EDIT_$field"] = $newFilename;
					}
				}
			}
		}
		else
		{
			?>
			<script>
			alert ("<?=$db->getUploadError($errorCode)?>\n\nValue of filename in database was set to blank.");
			</script>
			<?
			foreach ($fields as $field)
			{
				if ($uploadFile == "Upload File: $field")
				{
					$_GET["EDIT_$field"] = '';
				}
			}
		}
		unset($uploadFile);
	}

	/*
		DELETE PROCESS
	*/

	// delete process
	if ($del != null)
	{
		$deleteThese = array();
		foreach ($keys as $key)
		{
			if ($_GET["GET_$key"] != null)
			{
				$deleteThese[] = array($key,$_GET["GET_$key"]);
			}
		}
		if ($db->delRow($table,$deleteThese) == true)
		{
			?>
			<script>
			alert ("Successfully deleted row!")
			</script>
			<?
		}
		else
		{
			?>
			<script>
			alert ("Failed to deleted row!")
			</script>
			<?
		}
	}

	/*
		SAVE EDITED PROCESS
	*/
	
	if ($save != null || isset($uploadedFile))
	{
		$deleteThese = array();
		foreach ($keys as $key)
		{
			if ($_GET["GET_$key"] != null)
			{
				$deleteThese[] = array($key,$_GET["GET_$key"]);
			}
		}
		$saveThese = array();
                $tableProperties = $db->getFieldProperties($table);
		foreach ($fields as $field)
		{
                        $altProcess = 0;
                        foreach ($tableProperties['CurrentTimeStamp'] as $f)
                        {
                                if ($f == $field)
                                {
                                        $saveThese[] = array($field,$db->getDateNow());
                                        $altProcess = 1;
                                }
                        }
			foreach ($tableProperties['Passwords'] as $f)
			{
				if ($f == $field)
				{
					$saveThese[] = array($field,"password('".$_GET["EDIT_$field"]."')");
					$altProcess = 1;
				}
			}
                        if ($altProcess == 0)
                        {
				$saveThese[] = array($field,$_GET["EDIT_$field"]);
                        }
		}
		
		if ($db->delRow($table,$deleteThese) == true)
		{
			if ($db->saveRow($table, $saveThese) == true)
			{
	                        ?>
	                        <script>
	                        alert ("Successfully saved row!")
	                        </script>
	                        <?
	                }
	                else
	                {
	                        ?>
	                        <script>
	                        alert ("Failed to save row!")
	                        </script>
	                        <?
        	        }
		}
                else
                {
	                ?>
	                <script>
	       	        alert ("Failed to save row!")
	                </script>
	                <?
                }
	}

	/*
		SAVE NEW ENTRY PROCESS
	*/

	if ($saveNew != null)
	{
		$saveThese = array();
		$tableProperties = $db->getFieldProperties($table);
		foreach ($fields as $field)
		{
			$altProcess = 0;
			foreach ($tableProperties['CurrentTimeStamp'] as $f)
			{
				if ($f == $field)
				{
					$saveThese[] = array($field,$db->getDateNow());
					$altProcess = 1;
				}
			}
			foreach ($tableProperties['Passwords'] as $f)
			{
				if ($f == $field)
				{
					$pass = $_GET["NEW_$field"];
					$saveThese[] = array($field,"password('$pass')");
					$altProcess = 1;
				}
			}
			if ($altProcess == 0)
			{
				$saveThese[] = array($field,$_GET["NEW_$field"]);
			}
		}
		if ($db->saveRow($table, $saveThese) == true)
		{
		        ?>
		        <script>
		        alert ("Successfully added new entry!")
		        </script>
		        <?
	        }
	        else
	        {
		        ?>
		        <script>
		        alert ("Failed to add new entry!")
		        </script>
		        <?
                }
	}

	/*
		MAIN DOCUMENT
	*/

	// document top
	?>
	<div align='center'>
	<table cellpadding="0" cellspacing="0" border="0">
	<tr><td align="center">
	<div class="bordered1">
	<div class="margined0">
	<div>
	<a href='<?=$currentFile?>'>Back to index</a>
	</div>

        <div align='center'>
	<form method='get' action='<?=$currentFile?>'>
        <input type='hidden' name='table' value='<?=$table?>'>
	<?
        foreach ($getParams as $param)
        {
        	print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
        }
	?>
	<input type='submit' name='refresh' value='Refresh page'>
	</form>
	</div>

	<!-- number to display per page -->
	<div align="center">
	<form action='<?=$currentFile?>' method='get'>
	<select name='number'>
	<?
	foreach ($numChoices as $num)
	{
		if ($num == $number)
		{
			print ("<option value='$num' selected>$num");
		}
		else
		{
			print ("<option value='$num'>$num");
		}
	}
	?>
	</select>
	<input type='hidden' name='table' value='<?=$table?>'>
	<input type='hidden' name='page' value='0'>
	<?
	foreach ($getParams as $param)
	{
		if ($param[0] != 'number' && $param[0] != 'page')
		{
			print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
		}
	}
	?>
	<input type='submit' name='changeNumber' value='Number of Rows per Page'>
	</form>
	</div>

	<!-- pages -->
	<div align="center">Page Navigation<br>
	<?
	for ($i = 1; $i <= $db->getPages($table, $number); $i++)
	{
		if ($i-1 == $page)
		{
			print (" $i ");
		}
		else
		{
			$o = $i - 1;
			print ("<a href='$currentFile?table=$table&page=$o&number=$number'> $i </a>");
		}
		if ($i != $db->getPages($table, $number))
		{
			print ("|");
		}
	}
	?>
	</div>
	</div>
	</td><td valign="top"><img src="images/tab_table_controls.jpg">
	</td></tr></table>
	</div>

	<!-- display keys -->
	<div align="left">
	Keys:
	<?
	foreach ($keys as $elem)
	{
		echo " [",$elem,"] ";
	}
	?>
	</div>

	<!-- table header -->
	<table cellpadding="1" cellspacing="2" width="100%">
	<tr>
	<?
	foreach ($fields as $f)
	{
		?>
		<td valign="top" align="center" bgcolor="<?=TABLE_HEADER_COLOR?>">
		<div><?=$f?></div>
		</td>
		<?
	}


	?>
	<td valign="top" align="center" bgcolor="<?=TABLE_HEADER_COLOR?>">
	<div>Control</div>
	</td>
	</tr>
	<?

	$arr = $db->getRows($table,'','',$page,$number);
	foreach ($arr as $elem)
	{
		$checker = count($keys);
		$temp = 0;

		// check if row is being edited
		if ($edit != null)
		{
			foreach ($keys as $key)
			{
				if ($_GET["GET_$key"] == $elem[$key])
				{
					$temp++;
				}
			}
		}

		if ($edit != null && $checker == $temp)
		{
			$props = $db->getFieldProperties($table);

			// table row (EDITING)
			?>
			<tr bgcolor="<?=TABLE_BODY_BGCOLOR_EDITING?>">
			<form action='<?=$currentFile?>' method='get'>
			<?
			$j = 0;
			foreach ($fields as $i)
			{
				?><td valign="top" align="center"><div><?
				if ($j == 0)
				{
					?><a name="editMe"></a><?
					$j++;
				}
				if ($db->isFieldUploadFile($props,$i))
				{
					print ("
					<input type='submit' name='uploadFile' value='Upload File: $i' onclick='return confirmUpload()'>
					<input type='hidden' name='EDIT_$i' value='$elem[$i]'>
					");
				}
				else if ($db->isFieldEnum($props,$i))
				{
					$choices = $db->getEnumChoices($table,$i);
					if ($choices != false)
					{
						?><select name="EDIT_<?=$i?>"><?
						foreach ($choices as $c)
						{
							if ($c == $elem[$i])
							{
								?><option value="<?=$c?>" SELECTED><?=$c?><?	
							}	
							else
							{
								?><option value="<?=$c?>"><?=$c?><?	
							}
						}
						?></select><?
					}
					else
					{
						print ("<input type='text' name='EDIT_$i' value='$elem[$i]'>");
					}
				}
				else
				{
					if ($db->isFieldEditable($props,$i))
					{
						print ("<input type='text' name='EDIT_$i' value='$elem[$i]'>");
					}
					else
					{
						print ("<input type='text' name='EDIT_$i' value='$elem[$i]' disabled>");
					}
				}
				?></div></td><?
			}
			?>
			<td valign="top" align="center">
			<div>
			<input type='hidden' name='table' value='<?=$table?>'>
			<?
		        foreach ($keys as $key)
		        {
				print ("<input type='hidden' name='GET_$key' value='$elem[$key]'>");
		        }
			foreach ($getParams as $param)
			{
				print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
			}
			?>
			<input type="reset" value="Reset">
			<input type="submit" value="Cancel" name="cancel">
			<input type="submit" value="Save" name="save" onclick="return confirmSave(this)">
			</div>
			</td>
			</form>
			</tr>
			<?

		}
		else
		{
			// table row (NOT EDITING)
			?><tr onMouseOver="this.bgColor='<?=TABLE_BODY_BGCOLOR_HIGHLIGHT?>';" onMouseOut="this.bgColor='<?=TABLE_BODY_BGCOLOR?>';"><?
			$props = $db->getFieldProperties($table);
			foreach ($fields as $i)
			{
				if ($db->isFieldUploadFile($props,$i))
				{
					// ASSUMES AN IMAGE
					// check if file exists
					if (file_exists($elem[$i]))
					{
						list($width, $height) = getimagesize($elem[$i]);
						?>
						<td valign="top" align="center"><div>
						<a href="#" onClick="window.open('<?=$elem[$i]?>','<?=$elem[$i]?>','width=<?=$width?>,height=<?=$height?>')"><?=$db->trimString($elem[$i])?></a>
						</div></td>
						<?
					}
					else
					{
						?>
						<td valign="top" align="center"><div>
						<?=$db->trimString($elem[$i])?><br><font size='-1'><b>File does not exist!</b></font>
						</div></td>
						<?
					}
				}
				else
				{
					?>
					<td valign="top" align="center"><div>
					<?=$db->trimString($elem[$i])?>
					</div></td>
					<?
				}
			}
			?>
			<td valign="top" align="center"><div>
			<form action='<?=$currentFile?>#editMe' method='get'>
			<input type='hidden' name='table' value='<?=$table?>'>
			<?
		        foreach ($keys as $key)
		        {
				print ("<input type='hidden' name='GET_$key' value='$elem[$key]'>");
		        }
			foreach ($getParams as $param)
			{
				print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
			}
			?>
			<input type="submit" value="Delete" name="del" onclick="return confirmDel(this)">
			<input type="submit" value="Edit" name="edit"></form></div></td></tr>
			<?
		}
	}
	?>
	</table>
	<?

	/*
		ADD NEW ROW DISPLAY
	*/

	if ($add != null)
	{
		// get table field properties
		$props = $db->getFieldProperties($table);
		?>
		<div align="center">
		<table cellpadding="0" cellspacing="0" border="0"><tr><td align="center" valign="top">
		<div class="bordered2">
		<div class="margined0">
		<form method='get' action='<?=$currentFile?>'>
		<input type='hidden' name='table' value='<?=$table?>'>
		<?
		foreach ($getParams as $param)
		{
			print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
		}
		foreach ($fields as $i)
		{
			?><div align="center"><?
			if ($db->isFieldUploadFile($props,$i))
			{
				print ("$i: <font color='red' size='-1'>Once saved, you can upload files for this entry at the table above.</font>");
				print ("<input type='hidden' name='NEW_$i' value=''>");
			}
			else if ($db->isFieldEnum($props,$i))
			{
				$choices = $db->getEnumChoices($table,$i);
				if ($choices != false)
				{
					?><?=$i?>: <select name="NEW_<?=$i?>"><?
					foreach ($choices as $c)
					{
						?><option value="<?=$c?>"><?=$c?><?	
					}
					?></select><?
				}
				else
				{
					print ("$i: <input type='text' name='NEW_$i' value=''>");
				}
			}
			else
			{
				if ($db->isFieldEditable($props,$i))
				{
					print ("$i: <input type='text' name='NEW_$i' value=''>");
				}
				else
				{
					print ("$i: <input type='text' name='NEW_$i' value='' disabled>");
				}
			}
			?></div><?
		}
		?>
		<div align="center">
		<input type="submit" name="saveNew" value="Save new entry">
		<input type="reset" name="reset" value="Reset">
		<input type="submit" name="cancel" value="Cancel">
		</div>
		</form>
		</div>
		</div>
		</td><td valign="top"><img src="images/tab_add_new_entry.jpg"></td></tr></table>
		</div>
		<?
	}
	else
	{
		print ("<form method='get' action='$currentFile'>");
		print ("<input type='hidden' name='table' value='$table'>");
		foreach ($getParams as $param)
		{
			print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
		}
		?>
		<div align="center">
		<input type="submit" name="add" value="Add new entry">
		</form>
		</div>
		<?
	}

	/*
		UPLOAD FILE DISPLAY
	*/
	if (isset ($uploadFile))
	{
		// get field name for file upload
		$temp = '';
		foreach ($fields as $field)
		{
			if ($uploadFile == "Upload File: $field")
			{
				$temp = $field;
			}
		}
		// encode all get data for action url
		// accepting page (for the file upload) would save the file in the specified directory
		//	and update the database
		$p = '';
		foreach ($getParams as $param)
		{
			$p .= "$param[0]=$param[1]&";
		}
		foreach ($fields as $field)
		{
			$chk = 0;
		        foreach ($keys as $key)
		        {
				if ($field == $key)
				{
					$chk = 1;
				}
		        }
			if ($chk == 1)
			{
				$p .= "GET_$field=".$_GET["GET_$field"]."&";
			}
			else
			{
				$p .= "EDIT_$field=".$_GET["EDIT_$field"]."&";
			}
		}
		$l = $p . "table=$table";
		$p .= "table=$table&uploadedFile=1&uploadFile=$uploadFile";
		?>
		<br>
		<div align='center'>
		<table cellpadding="0" cellspacing="0" border="0"><tr><td align="center" valign="top">
		<div class="bordered2">
		<div class="margined0">
		<table callpadding="0" cellspacing="0" border="0"><tr><td align="right" valign="top">
		<form enctype='multipart/form-data' action='<?=$currentFile?>?<?=$p?>' method='POST'>
		<?
		$formats = '';
		foreach ($uploadSupportedFileFormat as $f)
		{
			$formats .= $f .", ";
		}
                $formats = substr($formats, 0, strlen($formats)-2);
		?>
		<input type="hidden" name="MAX_FILE_SIZE" value="<?=$uploadMaxFileSize?>" />
		<input name="userfile" type="file" />
		<input type="submit" value="Send File" />
		</form>
		</td><td align="left" valign="top">
		<form action='<?=$currentFile?>?<?=$l?>' method='POST'>
		<input type="submit" name="cancel" value="Cancel" />
		</form>
		</td></tr></table>
		Max file size: <?=$uploadMaxFileSize?> bytes <br>
		File formats supported: <?=$formats?>
		</div>
		</div>
		</td><td valign="top"><img src="images/tab_file_upload.jpg"></td></tr></table>
		</div>
		<?
	}
	
	/*
		FIELD PROPERTIES
	*/

	?><br><?
	if (! isset ($showProperties))
	{
		?>
		<div align="center">
		<form method='get' action='<?=$currentFile?>#fieldProperties'>
		<input type="hidden" name="showProperties" value="1">
		<?
		print ("<input type='hidden' name='table' value='$table'>");
		foreach ($getParams as $param)
		{
			print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
		}
		?>
		<input type="submit" name="submit" value="Show field properties">
		</form>
		</div>
		<?
	}
	else
	{
                ?>
		<a name="fieldProperties"></a>
                <div align="center">
		<form method='get' action='<?=$currentFile?>'>
		<?
		print ("<input type='hidden' name='table' value='$table'>");
		foreach ($getParams as $param)
		{
			print ("<input type='hidden' name='$param[0]' value='$param[1]'>");
		}
		?>
                <input type="submit" name="submit" value="Hide field properties">
                </form>
		</div>
                <?
	
	$arr = $db->getProperties();
	$arr2 = $db->getFieldProperties($table);
	asort($arr[0]);
	?>
	<div align="center">
	<table cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top">
	<div class="bordered3">
	<div class="margined0">
	<?
	foreach ($arr[0] as $prop)
	{
		?>
		<div class="properties0">
		<a name="<?=$prop?>"></a>
		&nbsp;<?=$prop?>:
		</div>
		<div>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		Property '<i><?=$arr[1][$prop]['fieldProperty']?></i>' <i><?=$arr[1][$prop]['checkingCondition']?></i> '<i><?=$arr[1][$prop]['checker']?></i>'.
		</div>
		<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<?
		if ($arr[1][$prop]['fieldIsEditable'] == 1)
		{
			?> Editable? <i>True</i> <?
		}
		else
		{
			?> Editable? <i>False</i> <?
		}
		?>
		</div>
		<div>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description:
		<i><?=$arr[1][$prop]['desc']?></i>
		</div>
		<?
		foreach ($arr2[$prop] as $f)
		{
			?>
			<div class="properties1">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			[<?=$f?>]
			&nbsp;&nbsp;<a href="#<?=$f?>"><img src="images/tip.jpg" border="0"></a>
			</div>
			<?
		}
		?>
		<hr length='100%' depth='1' size='1' noshadow>
		<?
	}
	?>
	<br>
	<b><i>Alternate View (fields):</i></b>
	<br>
	<br>
	<?
	foreach ($fields as $f)
	{
		?>
		<div class="properties0">
		<a name="<?=$f?>"></a>
		&nbsp;[<?=$f?>]
		</div>
		<?
	        foreach ($arr[0] as $prop)
	        {
		foreach ($arr2[$prop] as $p)
		{
			if ($f == $p)
			{
				?>
				<div class="properties1">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<?=$prop?>
				&nbsp;&nbsp;<a href="#<?=$prop?>"><img src="images/tip.jpg" border="0"></a>
				</div>
				<?
			}
		}
		}
		?>
		<hr length='100%' depth='1' size='1' noshadow>	
		<?
	}
	?>
	</div>
	</div>
	</td><td valign="top"><img src="images/tab_field_properties.jpg"></td></tr></table>
	</div>
	<?
	}
}
}
}
?>
</body>
</html>
Return current item: WaterFlea Database Maintenance Tool