<?php
/**
 * @package linea21.core
 * @subpackage admin
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

ob_start();
session_start();
include_once("../config/define.php");
include_once("../config/server.php");
include_once("../lib/no_cache.php");
include_once('../languages/' . LANGUAGE . '/lang_common.'. CHARSET .'.php');
include_once("../class/system/class." . SQL . ".php");

$sql_entity = SQL;
$sql_object = new $sql_entity;
$sql_object->DBInitialise();
$sql_object->DBConnexion();

include_once(SQL . ".inc.php");
// ////////////////////////////////////
// TENTATIVE D'AUTHENTIFICATION
// ////////////////////////////////////
if (isset($_POST['valid'])) {
    include_once("../lib/functions_auth.php");

    $auth_res = AuthenthificationProcess($_POST['login'], $_POST['password'], 'ADMIN');
    if ($auth_res === true) {
        header("Location: index.php");
    } 
} 

?>

<?php
echo '<?xml version="1.0" encoding="' . CHARSET . '"?>' . END_LINE;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $GLOBALS['lang']['header']['title']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>" />
<meta http-equiv="content-language" content="<?php echo LANGUAGE; ?>" />
<link rel="icon" type="image/gif" href="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/favicon.gif" />
<link type="text/css" rel="StyleSheet" href="../gfx/<?php echo THEME_ADMIN; ?>/css/admin_common.css" />
<link type="text/css" rel="StyleSheet" href="../gfx/<?php echo THEME_ADMIN; ?>/css/admin_login.css" />
</head>
<body>
<div id="content_auth">
	<h1 style="display:none;"><?php echo $lang['divers']['auth']; ?></h1>
	<img src="../gfx/<?php echo THEME_ADMIN; ?>/images/admin/auth_logo.png" id="logo" alt="logo" />
	<div id="title">
		<p><?php echo $lang['divers']['title_login']; ?></p>
	</div>
	<div id="auth">
		<p class="error_auth">
		<?php
		if(isset($auth_res)) echo $auth_res;
		?>
		</p>
	<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
		<div id="formu">
			<label for="login"><?php echo $lang['divers']['login']; ?> : </label>
			<input type="text" maxlength="20" class="loginfield" name="login" id="login" /><br /><br />
			<label for="password"><?php echo $lang['divers']['password']; ?> : </label>
			<input type="password" maxlength="20" class="loginfield" name="password" id="password" />
			<div class="validation">
			<input type="submit" value="<?php echo $GLOBALS['lang']['btn']['valid'] ?>" size="15" name="valid" id="valid" class="button" />
			</div>
		</div>
	</form>
	</div>
	<p class="bottom">
	<?php echo $lang['divers']['auth_mess1']; ?>
	</p>
	<p class="bottom">
	<?php echo $lang['divers']['auth_mess2']; ?>
	<a href="mailto:<?php echo SITE_CITY_MAIL; ?>" class="emphase"><?php echo SITE_CITY_MAIL; ?></a>
	</p>
</div>
</body>
</html>