session_start();
//error_reporting(E_ALL);
require('applications/functions.php');
require('applications/settings.php');
// si c'est une première connexion crée $_SESSION['logged']=0 etc
// si c'est un tentative d'authentification ou l'authorisation est déjà faite il verifie le mot de passe
// et si c'est bon il met $_SESSION['logged']=1
if ($_GET["p"]=="CS")
{
session_destroy();
echo "";
}
if ($_GET["p"]=="activate")
{
require("applications/activate.php");
}
if (!isset($_SESSION["logged"]))
{
$_SESSION["logged"]=0;
}
// si il y avait une faute de mot de passe ça remet à 0 $_SESSION['pwdError']
if (!isset($_SESSION["pwdError"]))
{
$_SESSION["pwdError"]=0;
}
if ((isset($_POST["userID"])) and (isset($_POST["pwd"])))
{
$userID=$_POST["userID"];
$pwd=$_POST["pwd"];
$_SESSION["userID"]=$userID;
$_SESSION["pwd"]=$pwd;
$logged=checkLogin($userID, $pwd);
$_SESSION["logged"]=$logged;
if ($logged==0)
{
$_SESSION["pwdError"]=1;
}
//echo "".$userID." ".$logged." userID ".$_SESSION["id"]."";
}
elseif ($_SESSION["logged"]!=0)
{
$userID=$_SESSION["userID"];
$pwd=$_SESSION["pwd"];
$logged=checkLogin($userID, $pwd);
$_SESSION["logged"]=$logged;
//echo "".$userID." logged ".$logged."";
}
include('applications/accueil.php');
?>