<?php
define( '_UEXEC', 1 ); 
/************************************************************************
	UebiMiau is a GPL'ed software developed by 
	
	 - Aldoir Ventura - aldoir@users.sourceforge.net
	 - http://uebimiau.sourceforge.net
	
	Fell free to contact, send donations or anything to me :-)
	São Paulo - Brasil
	
	**********************************************
	Version 3.2.0 Upgrades and templates developed by
	 
	 - Todd Henderson - Lead Developer
	 - http://tdah.us
	 - Email: todd@tdah.us
	 
	 - Dave Rodgers - Project Consultant
	 - http://www.manvel.net 
	 - Email: Davenmanvel@inbox.com
	
	Feel free to contact us, send donations or anything to me as well...
	
	Special thanks to the developers at telaen.org, codeworxtech.com, tinymce.moxiecode.com
	without help this project wouldn't be possible 

	**********************************************
	- File:			admin/index.php
	- Developer: 	Todd Henderson / Mods by Laurent (AdNovea)
	- Date:			November 4, 2008
	- version:		(3.2.0) 1.0
	- Description:  Administration login page

*************************************************************************/
	
	require_once('common.php');
error_reporting (E_ALL );
	$date = date(LOG_DATE);

define("ADMIN_DATABASE",RPATH_ROOT.$temporary_directory.DB_ADMIN);
define("ADMIN_LOGS",RPATH_ROOT.$temporary_directory.DB_LOG_FILE);		

if (!file_exists($absolute_path.$temporary_directory.'system_admin/chatdata.ucf'))
    fopen($absolute_path.$temporary_directory.'chat/chatdata.ucf',"a+");
if (!file_exists($absolute_path.$temporary_directory.'system_admin/log.ucf'))
     fopen($absolute_path.$temporary_directory.'system_admin/log.ucf',"a+");
     
 
   

// Logout the admin user
	if ( isset($_GET['logout']) && ($_GET['logout'] == "ok") ) {
		
	// Log report	
		$line = "<span class=\"log_date\">$date</span><span class=\"log_event\"><b>".$_SESSION['userName']."</b> has quit the Administration.</span><br>\n";
		$file = fopen(ADMIN_LOGS, 'a+');
		fwrite($file, $line);
		fclose($file);
		
		logoutUser();
		header("Location: index.php?lid=$lid&tid=$tid");
		
	}
// Backup the Webmail
	if ( isset($_GET['backup']) && ($_GET['backup'] == "ok") ){
		header("Location: ./backup/backup.php");
}

// Reset the Chat Room
	if ( isset($_GET['resetchat']) && ($_GET['resetchat'] == "ok") ) {
		
	// Clear messages, uploaded and users files 
		$file = fopen($absolute_path.$temporary_directory.DB_CHAT_DATA, 'w');
		fwrite($file, "$admin_chat_reset_admin [".$_SESSION['userName']."]");
		fclose($file);
		
		$folder = dir($absolute_path.$temporary_directory.DB_CHAT_UPLOAD);
		while ($entry = $folder->read()) if ($entry != "." && $entry != "..") {
			unlink($absolute_path.$temporary_directory.DB_CHAT_UPLOAD.$entry);
		}
		$folder->close();
		if (file_exists($absolute_path.$temporary_directory.DB_CHAT_ONLINE)) unlink($absolute_path.$temporary_directory.DB_CHAT_ONLINE);
		
	// Log report	
		$line = "<span class=\"log_date\">$date</span><span class=\"log_event\"><b>".$_SESSION['userName']."</b> has reseted the Chat room.</span><br>\n";
		$file = fopen(ADMIN_LOGS, 'a+');
		fwrite($file, $line);
		fclose($file);
	}


// Log user if needed
	checkUser();


// Display admin buttons page
	echo DOC_TYPE."
		<html>
		<head>
			<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$default_char_set\">
			<title>$admin_title</title>
			<link href=\"../themes/$selected_theme/css/admin.css\" rel=\"stylesheet\" type=\"text/css\">
		</head>
		
		<body>
			<center>
			<div id=\"main\" style=\"width: 589px; height: 450px\">
			  
			  <div class=\"caption\">$admin_title</div>
			  
			  <div id=\"icon\">&nbsp;</div>
			  
			  <div id=\"result1\" style=\"width: 450px; height: 350px\">
				
				<table width=\"100%\" class=\"login_table\">
				
<tr><td colspan=\"2\">$admin_hello ".$_SESSION['userName']." ! <br><br></td></tr>
				
				
				
				<tr><td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=config\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_config\" class=\"button large_button\">
					</form>
				</td><td>
					<form class=\"form2\" method=\"POST\" action=\"log.php\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_view_log\" class=\"button large_button\">
					</form>
				</td></tr>
				
				
				
				<tr><td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=languages\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_languages\" class=\"button large_button\">
					</form>
				</td><td>
					<form class=\"form2\" action=\"javascript: if (window.confirm('$admin_chat_msg')) location='index.php?lid=$lid&tid=$tid&resetchat=ok';\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_chat_reset\" class=\"button large_button\">
					</form>
				</td></tr>
				
				
				
				
				<tr><td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=themes\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_themes\" class=\"button large_button\">
					</form>
				</td><td>
					<form class=\"form2\" action=\"register.php?lid=$lid&tid=$tid\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_register\" class=\"button large_button\">
					</form>
				</td></tr>
				
				
				<tr><td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=chat\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_chat\" class=\"button large_button\">
					</form>
				</td>			
					<td>
					<form class=\"form2\" action=\"javascript: if (window.confirm('$admin_backup_msg')) location='index.php?lid=$lid&tid=$tid&backup=ok';\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_backup_site\" class=\"button large_button\">
					</form>
				</td>
					</tr>
				
			
			
				<td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=calendar\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_calendar\" class=\"button large_button\">
					</form>					
				</td>
				
						<td>
						<form action=\"\">
					<input type=\"button\" value=\"$admin_view_backups\" onclick=\"javascript:location='backup/viewer.php?lid=$lid&tid=$tid&veiwbackups=ok'\" class=\"button large_button\" >
					</form>					
				</td>
				
				</tr>
				
				<tr>
				
				<td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=pop3\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_pop\" class=\"button large_button\">
					</form>
				</td>
						<td>
						<form action=\"\">
					<input type=\"button\" value=\"$admin_filemanager\" onclick=\"javascript:location='./filemanager/admin.php?lid=$lid&tid=$tid&files=ok'\" class=\"button large_button\" >
					</form>					
				</td>
				</tr>
				
				
				<tr>		<td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=backup\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_backup\" class=\"button large_button\">
					</form>
				</td>
							<td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=help\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_help\" class=\"button large_button\">
					</form>
				</td>
						
						
						
				
										
				</tr>
				
					<tr>			<td>
					<form class=\"form2\" method=\"POST\" action=\"editor.php?load=paths\">
						<input type=\"hidden\" name=\"lid\" value=\"$lid\">
						<input type=\"hidden\" name=\"tid\" value=\"$tid\">
						<input type=\"submit\" value=\"$admin_edit_paths\" class=\"button large_button\">
					</form>
				</td>
			
						<td>
					<form action=\"\">
					<input type=\"button\" value=\"$admin_logout\" onclick=\"javascript:location='index.php?lid=$lid&tid=$tid&logout=ok'\" class=\"button large_button\" style=\"font-weight: bold;\">
					</form>
				</td>
				
				</tr>
				
				</table>

		  </div>
		  <div id=\"source\">Uebimiau ".SW_VERSION."</div>
		</div>
		</center>
		
	</body>
	</html>
	";

?>