<?php
ob_Start();
$currentCookieParams = session_get_cookie_params();
// Cookie secure
session_set_cookie_params($currentCookieParams['lifetime'], $currentCookieParams['path'], $currentCookieParams['domain'], true, true);
$ok = @session_start();
if ($ok === false) {
header('Location:index.php');
exit();
}
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
require_once("../common.php");
require_once("../classes/class.factory.php");
require_once("../classes/constant.inc");
if ((isset($_POST['posted'])) &&
(isset($_POST['login'])) &&
(isset($_POST['password'])) &&
(isset($_SESSION['OUTcaptcha'])) &&
(isset($_POST['captcha']))) {
if ($_SESSION['OUTcaptcha'] != $_POST['captcha']){
die("ERROR: Wrong captcha, try again.");
}
date_default_timezone_set('Europe/Paris');
$login = trim(sanitizeInput($_POST["login"]));
if (!isValidEmail($login)) die("ERROR: Invalid Email");
$password = trim(sanitizeInput($_POST["password"]));
$result = factory::isValidUser($login, $password);
if ($result != false) {
session_regenerate_id(true); // regenerate session identifier after verifying to elimiate session fixation attack
$_SESSION['fmsuserid'] = strtolower($login);
$_SESSION['fmsuserrole'] = $result;
$_SESSION['fmswg'] = INSTANCE;
$_SESSION["fmsuseragent"] = md5(ENCKEY . $_SERVER['HTTP_USER_AGENT']); // to protect against session hijacking
$_SESSION['fmslastactivity'] = time();
$ipaddress = getIPaddress();
$_SESSION['fmssignature'] = md5("Ucx327Jh%" . $ipaddress . "iPCc");
ob_end_clean();
die("Login successful..");
} else {
session_destroy();
die("ERROR: Unable to login. Please contact IPCC secretariat if you are a valid user.");
}
} else {
die("ERROR: Problem with the website, not your login. Try refreshing the page.");
}
ob_flush();