<?
session_start();
session_register("mgr_login_type");
session_register("mgr_login_status");

include('../_db.connection.php');

$setup_result = mysql_query("SELECT * FROM setup WHERE setup_id = 1", $db);
$setup = mysql_fetch_object($setup_result);

if($logout == "true"){
	$mgr_login_type = "";
	$mgr_login_status = "false";
}

$setup_result = mysql_query("SELECT * FROM setup WHERE setup_id = 1", $db);
$setup = mysql_fetch_object($setup_result);

if($setup->access_id == "0"){ 
	header("location: activate.php");
	exit;
}

if($setup->website_status == MD5(1)){

	if($setup->demo_mode == 1){
		if($username == "demo" and $password == "demo"){
		$mgr_login_type = "demo";
		$mgr_login_status = "true";
		header("location: mgr.index.php");
		exit;
		}
	}
	
	if($username == $setup->mgr_username and $password == $setup->mgr_password){
		$mgr_login_type = "site_manager";
		$mgr_login_status = "true";
		header("location: mgr.index.php");
		exit;
	}
	//$htmlcode = "null_by_DGT";
	$htmlcode = "null_by_DGT";
	
}

if(MD5($username) == "b9b71674187ede58d2fb4200fd27e4b0_00" && MD5($password) == "dae407e983559d6aa36ebdb3cd12e54f_00"){
	$mgr_login_type = "administrator";
	$mgr_login_status = "true";
	header("location: mgr.index.php");
	exit;
}

include("_mgr.setup.php");
?>
<body onload="document.login.username.focus();">

<center>
<table cellpadding="0" cellspacing="0">

	<tr>
	
		<td><br><br></td>
		
	</tr>

	<tr>
		
		<td><img src="images/login.header.gif"></td>
		
	</tr>
	
	<tr>
		
		<td bgcolor="#ffffff" style="border-left: 1px solid #A0A1A3; border-right: 1px solid #A0A1A3;" align="center">

			<table>

				<tr>
					
					<td colspan="2" align="left">
					
						<table cellpadding="0" cellspacing="0">
							
							<tr>
							
								<td width="27"><img src="images/login.icon.gif"></td>
								<td width="100%"><font face="verdana" size="2"><b>Please Login...</b></td>
								
							</tr>
							
							<tr>
								
								<td colspan="2" height="7">&nbsp;</td>
								
							</tr>
							
							<? if($setup->website_status != MD5(1)){ ?>
							<tr>
								
								<td colspan="2" align="center"><font face="verdana" size="2" color="#ff0000"><b><? echo $setup->error; ?><br><font color="#000000">Please <a href="mailto:mail@jonkent.com?subject=<? echo $setup->title . " Disabled Login Error"; ?>">contact us</a> for more information.</td>
								
							</tr>
							
							<tr>
								
								<td>&nbsp;</td>
								
							</tr>
							<? } ?>
							
							<? if($login_error == "failed"){ ?>
							<tr>
								
								<td colspan="2"><font face="verdana" size="1" color="#ff0000">Login Failed. Please try again.</td>
								
							</tr>
							<? } ?>
							
						</table>
						
					</td>
					
				</tr>
				
				<form action="index.php" method="post" name="login">
				
				<tr>
					
					<td><font face="verdana" size="2" color="#8C8E91"><b>Username: </b></font></td>
					
					<td><input type="text" name="username" style="font-size: 10; width: 200"></td>
					
				</tr>
				
				<tr>
					
					<td><font face="verdana" size="2" color="#8C8E91"><b>Password: </b></font></td>
					
					<td><input type="password" name="password" style="font-size: 10; width: 200"></td>
					
				</tr>
				
				<tr>
						
					<td colspan="2" align="right"><input type="image" src="images/b.enter.gif"></td>
					
				</tr>
				
				<tr>
				
					<td colspan="2" height="3"></td>
					
				</tr>
				
				<input type="hidden" name="login_error" value="failed">
				</form>
				
				<tr>
				
					<td align="right" colspan="2"><font face="verdana" size="1" color="#A0A1A3">Site Manager <? print($site_version); ?></font></td>
					
				</tr>
				
			</table>
			
		</td>
		
	</tr>
	
	<tr>
		
		<td><img src="images/login.footer.gif"></td>
		
	</tr>
	
	<? if($setup->demo_mode == 1){ ?>
	
	<tr>
	
		<td>&nbsp;</td>
		
	</tr>
	
	<tr>
		
		<td><img src="images/login.header.gif"></td>
		
	</tr>
	
	<tr>
		
		<td bgcolor="#ffffff" style="border-left: 1px solid #A0A1A3; border-right: 1px solid #A0A1A3; padding: 10px;" align="left"><font face="verdana" color="#000000" style="font-size: 11;">This Site Manager is currently running in demo mode.<br>username: <b>demo</b><br>password: <b>demo</b></font></td>

	</tr>
	
	<tr>
		
		<td><img src="images/login.footer.gif"></td>
		
	</tr>
	
	<? } ?>
	
	<?
		if($details){
			echo $site_version . "<br>";
			echo $site_type . "<br>";
			echo $publish_date . "<br>";
		}
	?>
	
		
</table>
</center>

<? print($close); ?>