<?php error_reporting(E_ALL ^ E_NOTICE);
session_start();?>
<?php 
include("../includes/connection.php"); 
include("../includes/func.php");


if (!empty($_POST)) {
	
	$sql="select * from user_master where active=1 and user_type in (1) and user_name='".pdbfx("username")."'";
	
	$cmd = mysql_query($sql);
	$rs = mysql_fetch_array($cmd);
	 
	if (cmpfx($rs["user_name"], $_POST["username"]) && cmpfx($rs["password"], $_POST["password"])) {
		$_SESSION["admin"] = $_POST["username"];
		$_SESSION["user_type"] =$rs["user_type"];
		
		redirectS("home.php");
	}
	else {
		
		setErr("Invalid Username / Password");
		redirectS("index.php");
	}
}

if ($_GET["e"] == "1")
	seterr("Your session has expired.");
if ($_GET["l"] == "1")
	seterr("Your have successfully logged out.");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Webmaster Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="includes/style.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">
	function validate(frm) {
		var errMsg = "";
		/*
		if (frm.username.value == "") {
			errMsg += "\"Username\" field is empty\n";
		}
		*/
		if (frm.password.value == "") {
			errMsg += "\"Password\" field is empty\n";
		}
		
		if (errMsg != "") {
			alert(errMsg);
			return (false);
		} else
			return (true);
	}
</script>
</head>

<body>
<form action="index.php" method="post" onSubmit="return validate(this);">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td height="80"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="bgExtraDarkGray">
            <tr>
                <td height="60" class="topHeader">&nbsp;Welcome! Administrator<br><br>
				<font size=1>(Use With IE 5.5 or Higher or with Javascript enabled browsers) </font><br><br></td>
            </tr>
            <tr class="bgDarkGray">
                <td>&nbsp;</td>
            </tr>
        </table></td>
    </tr>
    <tr>
        <td height="200" align="center" valign="middle"><table width="500"  border="0" cellpadding="0" cellspacing="1" class="bgExtraDarkGray">
            <tr>
                <td class="bgLightGray">&nbsp;</td>
            </tr>
            <tr>
                <td height="70" class="bgWhite"><table width="100%" border="0">
					<?php getErr("3"); ?>
                    <tr>
                        <td align="right" class="LabelBold">&nbsp;</td>
                        <td align="left">&nbsp;</td>
                        <td align="left">&nbsp;</td>
                    </tr>
                    <tr>
                        <td width="39%" align="right" class="LabelBold">Username</td>
                        <td width="9%" align="left">&nbsp;</td>
                        <td width="52%" align="left"><input type="text" name="username"></td>
                    </tr>
                    <tr>
                        <td align="right" class="LabelBold">Password</td>
                        <td align="left">&nbsp;</td>
                        <td align="left"><input type="password" name="password"></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td align="left">&nbsp;</td>
                        <td align="left">&nbsp;</td>
                    </tr>
                </table></td>
            </tr>
            <tr>
                <td align="right" class="bgLightGray"><input name="btnLogin" type="submit" value="Login">
				<input type="reset" name="btnReset"></td>
            </tr>
        </table><br>
		</td>
    </tr>
	<?php include("includes/footer.php"); ?>
</table>
</form>
</body>
</html>
