<?php

include("config.inc.php");
include(THEME_FILE);
include(LANGUAGE_FILE);
include('layout.inc.php');
define('VERSION', "AeroMail");
 
if (isset($user) && isset($pass))
{
    session_name("AeroMail");
    session_save_path(SESSION_SAVE_PATH);
    session_start();
    session_register("user", "pass");
	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);

function content()
{
    // Just for login, make the screen as small as possible
    print "<table width=\"100\"><tr><td>"; 
    content_start();
    ?>
    <form name="login" action="login.php" method="POST">
    <?php
    header_start();
    header_left();
    $title = PROG_NAME . ": " . L_LOGON;
    $title = str_replace(" ", "&nbsp;", $title);
    echo $title;
    header_left_right_end();

    header_end();
    body_compose_start();
    title_start();
    title_left();
    echo "<label for=\"user\">";
    echo L_USERNAME;
    echo "</label>";
    title_left_end();
    title_data();
    ?>
    <input type="text" name="user" id="user" size="20" value="<?php print $user; ?>">
    <?php
    title_data_end();
    title_end();
    
    title_start();
    title_left();
    echo "<label for=\"pass\">";
    echo L_PASSWORD;
    echo "</label>";
    title_left_end();
    title_data();
    ?>
    <input type="password" name="pass" id="pass" size="20" value="">
    <?php
    title_data_end();
    title_end();

    body_end();

    header_start();
    header_right();
    ?>
    <input type="submit" value="<?php print L_LOGON_BTN ?>">
    <?php

    header_left_right_end();
    header_end();
    print "</form>";
    content_end();
    print "</td></tr></table>";
?>
<script type="text/javascript">
<!--
document.login.user.focus();
//-->
</script>
<?php
}

/* MAIN */
include(HTML_TEMPLATE);
?>
