<?php
/************************************************************************
	UebiMiau is a GPL'ed software developed by 
	 - Aldoir Ventura - aldoir@users.sourceforge.net
	 - http://uebimiau.sourceforge.net São Paulo - Brasil
   		
	***********************************************************************
	Version 3.2.0 Upgrades and templates developed by
	 - Todd Henderson - Lead Developer - http://tdah.us 
	 - Dave Rodgers - Developer - http://www.manvel.net 
	 - Laurent (AdNovea) - Developer - http://adnovea.free.fr
	 
	***********************************************************************
	 - Special thanks to the developers at 
	codeworxtech.com, tinymce.moxiecode.com
	telaen.org, phptoys.com, winged.info, ngcoders.com
	without help this project wouldn't be possible 
	
	***********************************************************************

	- File:			restore.php
	- Developer: 	Created by Laurent (AdNovea)
	- Date:			November 4, 2008
	- version:		(3.2.0) 1.0
	- Description:  Restore previously backuped configuration

*************************************************************************/

 require("./config.install.php");
 define("ADMIN_DATABASE",$cwd.$temporary_directory.DB_ADMIN); 
 define("ADMIN_LOGS",$cwd.$temporary_directory.DB_LOG_FILE);
	
	$file = $cwd.CFG_CONFIG;
	if (file_exists ("$file.bak")) {
		unlink($file);
		$error = rename("$file.bak",$file);
		if ($error) {
	} else 
		$error = false;
		}
			
	$file = $cwd.CFG_PATHS;
  if (file_exists ("$file.bak")) {
			unlink($file);
			$error = rename("$file.bak",$file);
			
			if ($error) {
	} else 
		$error = false;
		}	
	
	$file = $cwd.CFG_MAIL;
  if (file_exists ("$file.bak")) {
			unlink($file);
			$error = rename("$file.bak",$file);
				if ($error) {
	} else 
		$error = false;
		
		}		
	
	// Log report	
		$line = "<span class=\"log_date\">$date</span><span class=\"log_event\"><b>admin</b> has restored the webmail.</span><br>\n";
		$file = fopen(ADMIN_LOGS, 'a+');
		fwrite($file, $line);
		fclose($file);
?>
	<table width="100%" border="0" cellspacing="0" cellpadding="5">
		<tr height="26">
		<td colspan="2" bgcolor="f7f7f7"background="images/bar.gif"  class="menuheader"><strong><?php echo _STG_RESTORE; ?></strong> </td>
	</tr>
	<tr><td width="25%"><img src="images/T-dah.gif" border="0" align="right" alt=""></td>
		<td align="left"><br><br><br>
		<?php 
			echo _STG_RESTORED; 
			if ($error) echo "<font color=\"#008800\"><b> "._STG_RESTORED_SUCCESS."</b></font>"; 
			else echo "<font color=\"#FF0000\"><b> "._STG_RESTORED_ERROR."</b></font>"; 
		?><br><br><br><br>
		</td>
	</tr>
	</table>

	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td align="left">
				<div align="right">
					<a href="<?php echo "./index.php?lid=$lid"; ?>" class="menulink"><?php echo _STG5_FRONT1;?> &nbsp; &nbsp; &nbsp;
					<a href="<?php echo RPATH_ROOT."index.php?lid=$lid"; ?>" class="menulink"><?php echo _STG5_FRONT;?></a> &nbsp; &nbsp; &nbsp;
					<a href="<?php echo RPATH_ROOT.PATH_ADMIN."index.php?lid=$lid"; ?>" class="menulink"><?php echo _STG5_ADMIN;?></a> &nbsp; &nbsp;
				</div>
			</td>
		</tr>
	</table>
