Esempio n. 1
0
 public function trackSession()
 {
     global $isv_db, $sessFound;
     $sess_id = session_id();
     if (!isLoggedIn()) {
         //check if the session is in our db and add if not found
         checkUserSession($sess_id);
         if ($sessFound > 0) {
             //we update last activity
             $stmt = $isv_db->prepare("UPDATE sessions SET last_activity=UTC_TIMESTAMP() where sess_id=?");
             $stmt->bind_param('s', $sess_id);
             $stmt->execute();
             $stmt->close();
         } else {
             //add session
             $stmt = $isv_db->prepare("INSERT INTO sessions (sess_id,last_activity) VALUES (?,UTC_TIMESTAMP())");
             $stmt->bind_param('s', $sess_id);
             $stmt->execute();
             $stmt->close();
         }
     } else {
         $stmt = $isv_db->prepare("UPDATE users SET last_activity=UTC_TIMESTAMP() where id=?");
         $stmt->bind_param('s', $_SESSION['isv_user_id']);
         $stmt->execute();
         $stmt->close();
         checkUserSession($sess_id);
         if ($sessFound > 0) {
             //we update last activity
             $stmt = $isv_db->prepare("UPDATE sessions SET user_id=?,last_activity=UTC_TIMESTAMP() where sess_id=?");
             $stmt->bind_param('is', $_SESSION['isv_user_id'], $sess_id);
             $stmt->execute();
             $stmt->close();
         } else {
             //add session
             $stmt = $isv_db->prepare("INSERT INTO sessions (sess_id,user_id,last_activity) VALUES (?,?,UTC_TIMESTAMP())");
             $stmt->bind_param('si', $sess_id, $_SESSION['isv_user_id']);
             $stmt->execute();
             $stmt->close();
         }
     }
 }
$datesarray = getDatesSession($idsession);
for ($f = 0; $f < $nbrdates; $f++) {
    $rowd = mysqli_fetch_array($datesarray);
    //debug($row);
    $datessession = $datessession . getDatefr($rowd["date_session"]) . " <br>";
    $iddate = $rowd["id_datesession"];
    //donner la derniere id
}
$placesoccupee = countPlaceSession($idsession, 0);
$enattente = countPlaceSession($idsession, 2);
$placesrestantes = $nbplace - $placesoccupee;
//tester la présence de tarifs ateliers
$testTarifAtelier = TestTarifs();
if ($b == 2) {
    //verification d'inscription
    if (FALSE != checkUserSession($idsession, $iduser)) {
        $datesarray2 = getDatesSession($idsession);
        //boucler pour insérer le nombre de dates par sessions
        for ($f = 0; $f < $nbrdates; $f++) {
            $row2 = mysqli_fetch_array($datesarray2);
            addUserSession($idsession, $iduser, $idstatut, $row2["id_datesession"]);
        }
        echo geterror(25);
        header("Location:index.php?a=30&b=1&idsession=" . $idsession);
    } else {
        echo geterror(21);
        header("Location:index.php?a=30&b=1&idsession=" . $idsession);
    }
}
if ($b == 3) {
    if (FALSE != delUserSession($idsession, $iduser)) {
$espaces = getAllepn();
// si b =2 inscription a un atelier
if ($b == 2) {
    if (FALSE != addUserAtelier($idatelier, 0, $_SESSION["iduser"])) {
        echo "<div class=\"row\"><div class=\"col-md-6\"> <div class=\"alert alert-info alert-dismissable\"> \n\t\t\t\t<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>\n                    <h4><i class=\"icon fa fa-info\"></i>Inscription valid&eacute;e</h4></div></div></div>";
    }
}
// si b=3 desinscription a un atelier
if ($b == 3) {
    delUserAtelier($idatelier, $_SESSION["iduser"]);
    echo "<div class=\"row\"><div class=\"col-md-6\"> <div class=\"alert alert-info alert-dismissable\"> \n\t\t\t\t<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>\n\t\t\t\t <h4><i class=\"icon fa fa-info\"></i>D&eacute;sinscription effectu&eacute;e</h4></div></div></div>";
}
//si b==6 inscription a une session
if ($b == 6) {
    //verification d'inscription
    if (FALSE != checkUserSession($idsession, $_SESSION["iduser"])) {
        $nbrdates = $_GET["nbd"];
        $datesarray2 = getDatesSession($idsession);
        //boucler pour insérer le nombre de dates par sessions
        for ($f = 0; $f < $nbrdates; $f++) {
            $row2 = mysqli_fetch_array($datesarray2);
            addUserSession($idsession, $_SESSION["iduser"], 0, $row2["id_datesession"]);
        }
        echo geterror(25);
    } else {
        echo geterror(21);
    }
}
// si b=7 desinscription a une session
if ($b == 7) {
    delUserSession($idsession, $_SESSION["iduser"]);