$value) { if ($key !== "password") { $_POST[$key] = sanitize($value); } } } // Ensuite on redirige en fonction de la varaible "src" de la session // et on vérifie que la data nécessaire est bien présente. // Sinon: raise 404 if ($_SESSION["src"] == "login" && isset($_POST["email"], $_POST["password"]) && $_POST["email"] !== "" && $_POST["password"] !== "" ) { if (isset($_POST["rememberMe"]) && $_POST["rememberMe"] == "on") { $_POST["rememberMe"] = true; } else { $_POST["rememberMe"] = false; } login(0, $_POST["email"], $_POST["password"], $_POST["rememberMe"]); } elseif ($_SESSION["src"] == "autoLogin" && isset($_COOKIE["autoLogin"]) && $_SESSION["loggedIn"] == false ) { // Si connection par cookie, on le décode avant de le passer à la fonction. login(json_decode(base64_decode($_COOKIE["autoLogin"]))); } elseif ($_SESSION["src"] == "logout" && isset($_SESSION["loggedIn"]) && $_SESSION["loggedIn"] == true ) { logout(); } elseif ($_SESSION["src"] == "register" && isset($_POST["email"], $_POST["password"] ) && $_POST["email"] !== "" && $_POST["password"] !== "" ) { if (isset($_POST["is_admin"]) && $_POST["is_admin"] == "on") { $_POST["is_admin"] = 1; } else { $_POST["is_admin"] = 0; } if (isset($_POST["is_user"]) && $_POST["is_user"] == "on") { $_POST["is_user"] = 1; } else { $_POST["is_user"] = 0; } if (isset($_POST["is_consultant"]) && $_POST["is_consultant"] == "on") { $_POST["is_consultant"] = 1; } else { $_POST["is_consultant"] = 0; } register($_POST["email"], $_POST["password"], $_POST["is_admin"], $_POST["is_user"], $_POST["is_consultant"] ); } elseif ($_SESSION["src"] == "userInfo" && isset($_SESSION["loggedIn"], $_SESSION["id"], $_POST["lastname"], $_POST["firstname"], $_POST["job"], $_POST["degree"], $_POST["capability"], $_POST["description"], $_POST["phoneNumber"], $_POST["adress"], $_POST["zipCode"], $_POST["city"] ) && $_SESSION["loggedIn"] == true && $_SESSION["id"] !== "" && $_POST["lastname"] !== "" && $_POST["firstname"] !== "" ) { modify_user_info($_POST["lastname"], $_POST["firstname"], $_POST["job"], $_POST["degree"], $_POST["capability"], $_POST["description"], $_POST["phoneNumber"], $_POST["adress"], $_POST["zipCode"], $_POST["city"], $_SESSION["id"] ); } elseif ($_SESSION["src"] == "delete" && isset($_SESSION["loggedIn"], $_SESSION["isAdmin"], $_POST["id"] ) && $_SESSION["loggedIn"] == true && $_SESSION["isAdmin"] == true && $_POST["id"] !== "" ) { delete($_POST["id"]); } elseif ($_SESSION["src"] == "mission" && isset($_SESSION["loggedIn"], $_SESSION["isUser"], $_POST["subject"], $_POST["note"], $_POST["review"], $_POST["consultantId"] ) && $_SESSION["loggedIn"] == true && $_SESSION["isUser"] == true && $_POST["subject"] !== "" && $_POST["note"] !== "" && $_POST["review"] !== "" && $_POST["consultantId"] !== "" ) { register_mission($_POST["subject"], $_POST["note"], $_POST["review"], $_SESSION["id"], $_POST["consultantId"] ); } elseif ($_SESSION["src"] == "index" && (isset($_POST["search"]) && $_POST["search"] !== "") || (isset($_POST["searchInfo"]) && $_POST["searchInfo"] !== "") ) { if (isset($_POST["search"])) { search($_POST["search"], true); } else { search($_POST["searchInfo"], false); } } elseif (isset($_SESSION["src"], $_POST["langSel"]) && ($_POST["langSel"] == "en" || $_POST["langSel"] == "fr") ) { set_language($_POST["langSel"]); } else { http_response_code(404); die(); } } else { http_response_code(404); die(); } ?>