<html>
<head>
<title>EZ Shopper Database Backup</title>
</head>
<body bgcolor = "#FFFFFF">
<center><img src = ./images/backme.gif><h2><font face=verdana size=3>--EZ Shopper Database Backup--</font></h2></center>
<?php

/***************************************************************************
 *		backup.php	                                           *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *
 *   File Info:		Backup utility                                     *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/

include_once("./config.php");
$conn = @mysql_connect($server,$user,$password)
		or die("Unable to connect to SQL database...");
$rs = @mysql_select_db($database,$conn) 
		or die("Unable to select the database 'mydata'...Please press 'Create Database' to create new database.");
echo "<center><font face = Verdana size = 2 color = $highlight><b>Please be patient whilst your database is backed up!!!</b></font></center><br><center><img src=images/line.gif border=0 width=500></center>";

$query = "show tables";
$query_result = mysql_query($query,$conn);
echo "<center><table border=0 width =500>";
while ($row = mysql_fetch_array($query_result))
{
	$filename = "./backup/$row[0]_" . time() . ".txt"; // identify the filename one per table
	$fp = fopen($filename,'w9');			// open the file
	$query1 = "select * from $row[0]";
	$query_result1 = mysql_query($query1,$conn);

	while ($row1 = mysql_fetch_row($query_result1))
	{
		foreach ($row1 as $key => $value)
		{
			fwrite($fp,"'$value'\t");
		}
	}
	fclose($fp);
	echo "<tr><td align=center><img src = ./images/window.gif></td><td><font face=verdana size=2>Table $row[0] successfully backed up!</font></td></tr>";
}
echo "</table></center><center><img src=images/line.gif border=0 width=500></center><br><center><b><font face=verdana size=2 color=navy>All database files have been successfully backed up to 'BACKUP' folder...</font></b></center><br>";
echo "<center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 height=18></a></center><br>";
include ("./your-footer.inc");
?>
</body>
</html>