<?php

include("config.inc");

if (isset($_POST[username]) && isset($_POST[password]))
 {
	session_name("AeroMail");
	session_save_path(SESSION_SAVE_PATH);
	session_start();

	$_SESSION[user] = $_POST[username];
	$_SESSION[pass] = $_POST[password];

	Header("Location: index.php");
	exit;
}
// If we got this far, they need to be prompted for their credentials.

    # Forcibly delete any old cookies.
    setcookie("AeroMail", "", mktime() - 1,"/", getenv("SERVER_NAME"), 0);
    echo "<html>\n<head>\n";
    include("style.php");
    ?>
<title><?php echo "Login - ".PROG_NAME ?></title>
</head>
<script language="JavaScript">
function dofocus() {
    document.login.username.focus()
}
</script>
<body bgcolor="<?php echo COLOR_BG ?>" text="<?php echo COLOR_FONT ?>" topmargin=11 link="<?php echo COLOR_LINK ?>" alink="<?php echo COLOR_ALINK ?>" vlink="<?php echo COLOR_VLINK ?>" onload=dofocus()>

<form name="login" action="login.php" method=POST>
<center>
<table bgcolor=<?php echo COLOR_HEAD ?> cellpadding=0 celspacing=0 border=0><tr><td>
 <table border=0 cellpadding=3 cellspacing=1>
  <tr>
   <td colspan=2 bgcolor=<?php echo COLOR_HEAD ?> align=center>
    <font face=<?php echo FONT ?> size=4><b><?php echo PROG_NAME ?>: Login</b></font>
   </td>
  </tr>
  <tr>
   <td bgcolor=<?php echo COLOR_TITLE ?>>
    <b>Username</b>
   </td>
   <td bgcolor=<?php echo COLOR_TITLE ?>>
    <b>Password</b>
   </td>
  </tr>
  <tr>
   <td bgcolor=<?php echo COLOR_ROW_ON ?>>
    <input type="text" size="15" name="username">
   </td>
   <td bgcolor=<?php echo COLOR_ROW_ON ?>>
    <input type="password" size="15" name="password">
   </td>
  </tr>
  <tr>
   <td bgcolor=<?php echo COLOR_HEAD ?> colspan=2 align=right>
    <input type="submit" value="Login">
   </td>
  </tr>
 </table>
</td></tr></table>
</form>
</center>
</body>
</html>
