<?php
require_once '../../config/prepend.php';
$_COOKIE['checkcookie'] = 1;

if (isset($_REQUEST['login']) &&
	isset($_REQUEST['pass']) &&
	isset($_REQUEST['hach']) )
{
	$url =
	'http://'.$_SERVER['SERVER_NAME'].'/'.
	'?page=main&lang=fr&secure=8f66c76ce72b8f45dadfe49fd5db90e0'.
	'&action=logon&login='.$_REQUEST['login'].'&pass='.$_REQUEST['pass'].
	'&hach='.$_REQUEST['hach'];
	header('Location: '.$url);
	exit;
}
?>
<html>
<head>
<title>CONNEXION EXTRANET</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?=CHARSET?>" />
<link rel="stylesheet" type="text/css" media="all" href="./style.css" />
<script type="text/javascript" src="./md5.js"></script>
<script type="text/javascript">
<!--
function doChallengeResponse() {
	if (document.forms[0].login.value!='' && document.forms[0].pass.value!=''){
	   	str = document.forms[0].login.value+'|'+document.forms[0].pass.value;
	   	document.forms[0].hach.value = MD5(str);
	   	document.forms[0].pass.value = '';
	   	return true;
	}else{
		alert('Veuillez remplir les champs "login" et "pass".');
		return false;
	}
}

function checkCookie(){
	if(!document.cookie)
	{
		var message = "Votre navigateur n'accepte pas les cookies. " +
			"L'interface de consultation Scores & Décisions " +
			"risque de ne pas fonctionner correctement.<br/>" +
			"Contactez votre administrateur.";
		if (document.getElementById)
		{
    		document.getElementById("message").innerHTML = message;
    	}
 	 	else if (document.all)
    	{
    		document.all["message"].innerHTML = message;
    	}
	}
}
// -->
</script>
</head>
<body>
<form name="form_logon" action="./index.php" enctype="multipart/form-data"
	method="post" onsubmit="return doChallengeResponse();">
<h2>CONNEXION EXTRANET</h2>
	<table>
	<tbody>
	<tr>
		<td class="data">Login</td>
		<td colspan="2" class="inserttext">
		<input id="login" name="login" size="20" value="" type="text">
		</td>
	</tr>
	<tr>
		<td class="data">Pass</td>
		<td colspan="2" class="inserttext">
		<input id="pass" name="pass" size="20" value="" type="password">
		</td>
	</tr>
	<tr>
		<td class="data"></td>
		<td colspan="2" class="inserttext">
		<input value="OK" class="bouton" type="submit">
		</td>
	</tr>
	</tbody>
	</table>
	<input name="hach" value="" type="hidden">
	<input name="action" value="logon" type="hidden">
	<input name="lang" value="fr" type="hidden">
	<input name="resolution" value="1280*800" type="hidden">
	<input name="nbcolors" value="16" type="hidden">
	<input name="secure" value="8f66c76ce72b8f45dadfe49fd5db90e0" type="hidden">
</form>
<noscript>
JavaScript semble être désactivé dans votre navigateur Internet.
L'interface de consultation Scores & Décisions nécessite l'activation du
JavaScript pour fonctionner correctement.
<br/>
Contactez votre administrateur .
</noscript>
<div id="message">&nbsp;</div>
<script type="text/javascript">
checkCookie();
</script>
<?php include('footer.php');?>
</body>
</html>