if( isset($_SESSION['authorized']) and $_SESSION['authorized']==true ){
date_default_timezone_set("Europe/Paris");
$date = date("Y-m-d");
$heure = date("H:i:s");
$heurefin = date("H:i:s", time()+3600);
$dateheure= $date." ".$heure;
$dateheurefin= $date." ".$heurefin;
***HIDDEN LDAP ACCESS DATA***
$link = mysql_connect("xxx", "xxx", "xxx") or die("Impossible de se connecter : " . mysql_error()); mysql_select_db("wordpress");
/*
* Vérification des conditions et mise à jour des dates du certificat
*/
if(isset($_POST['datedeb'])and!empty($_POST['datedeb']) and isset($_POST['datefin'])and !empty($_POST['datefin']))
if(strtotime($_POST['datedeb'])Echec de la mise à jour du certificat ! La date de fin doit être postérieur à la date de début.
';
}
/*
* Recherche d'un collaborateur dans l'active directory
*/
if(isset($_POST["nom"]) and !empty($_POST["nom"]))
{
if (preg_match("/[^a-zàâçéèêëîïôûùüÿñæœ .-]+$/i", $_POST["nom"]))
{
echo '';
echo '
';
}
if(isset($_POST["mail"]))
{
if(isset($_POST["dateheure"]))
{
$heure_enreg = date("Y-m-d H:i:s",strtotime($_POST["dateheure"]));
$date_enr = date('d-m-Y H:i:s',strtotime($_POST["dateheure"]));
if(preg_match("#^(((0[1-9]|[12]\d|3[01])[\/\.-](0[13578]|1[02])[\/\.-]((19|[2-9]\d)\d{2})\s(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]))|((0[1-9]|[12]\d|30)[\/\.-](0[13456789]|1[012])[\/\.-]((19|[2-9]\d)\d{2})\s(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]))|((0[1-9]|1\d|2[0-8])[\/\.-](02)[\/\.-]((19|[2-9]\d)\d{2})\s(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]))|((29)[\/\.-](02)[\/\.-]((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))\s(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])))$#",$date_enr))
{
if( strtotime($_POST["dateheure"]) < date(time()))
{
$h = date("H",strtotime($_POST["dateheure"]));
$req = "SELECT *
FROM xxxx
WHERE xxx='".$_POST["mail"]."'
and DATE(xxx) = '".date("Y-m-d",strtotime($_POST["dateheure"]))."'
and (((HOUR(xxx) >= 12 and HOUR(xxx) < 14 and ".$h." >= 12 and ".$h." < 14)) or
(HOUR(xxx) >= 18 and HOUR(xxx) < 20 and ".$h." >= 18 and ".$h." < 20))";
$res = mysql_query($req,$link)or die(mysql_error());
if(mysql_num_rows($res)==0)
{
$requete = "INSERT
INTO xxxx (xxx,xxx,xxx,xx)
VALUES (1,'".$heure_enreg."','".$_POST["log"]."','".$_POST["mail"]."')";
$res = mysql_query($requete,$link);
$msg= "Collaborateur enregistré.\n";
}
else
{
$msg= "Echec de mise à jour! Collaborateur déja inscrit dans ce crénau.";
}
}
else
{
$msg= "Echec de mise à jour! Vous ne pouvez pas inscrire un participant pour une date future.";
}
}
else
{
$msg= "Echec de mise à jour! Le format de la date est incorrect.";
}
echo '