$value) { if ($key !== "password") { $_POST[$key] = sanitize($value); } } } // Condition pour une connection if ($_SESSION["src"] == "login" && isset($_POST["email"], $_POST["password"]) && $_POST["email"] !== "" && $_POST["password"] !== "" ) { if (isset($_POST["rememberMe"]) && $_POST["rememberMe"] == "on") { $_POST["rememberMe"] = 1; } else { $_POST["rememberMe"] = 0; } login(0, $_POST["email"], $_POST["password"], $_POST["rememberMe"]); // Condition pour une connection auto } elseif ($_SESSION["src"] == "autoLogin" && isset($_COOKIE["autoLogin"]) && $_SESSION["loggedIn"] ) { // Si connection par cookie, on le décode avant de le passer à la fonction. login(json_decode(base64_decode($_COOKIE["autoLogin"]))); // Condition pour une déconnection } elseif ($_SESSION["src"] == "logout" && isset($_SESSION["loggedIn"]) && $_SESSION["loggedIn"] ) { logout(); // Condition pour une inscription } elseif ($_SESSION["src"] == "register" && isset($_POST["email"], $_POST["password"] ) && $_POST["email"] !== "" && $_POST["password"] !== "" ) { if (isset($_POST["is_client"]) && $_POST["is_client"] == "on") { $_POST["is_client"] = 1; } else { $_POST["is_client"] = 0; } if (isset($_POST["is_pro"]) && $_POST["is_pro"] == "on") { $_POST["is_pro"] = 1; } else { $_POST["is_pro"] = 0; } if (isset($_POST["is_admin"]) && $_POST["is_admin"] == "on") { $_POST["is_admin"] = 1; } else { $_POST["is_admin"] = 0; } register($_POST["email"], $_POST["password"], $_POST["is_client"], $_POST["is_pro"], $_POST["is_admin"] ); // Condition pour une modification des infos } elseif ($_SESSION["src"] == "userInfo" // Vérification des données si client && (isset($_SESSION["loggedIn"], $_SESSION["userId"], $_SESSION["isClient"], $_POST["lastname"], $_POST["firstname"], $_POST["phoneNumber"], $_POST["adress"], $_POST["zipCode"], $_POST["city"] ) && $_SESSION["isClient"] && $_POST["lastname"] !== "" && $_POST["firstname"] !== "" && $_POST["phoneNumber"] !== "" && $_POST["adress"] !== "" && $_POST["zipCode"] !== "" && $_POST["city"] !== "" // Ou si pro || isset($_SESSION["loggedIn"], $_SESSION["userId"], $_SESSION["isPro"], $_POST["lastname"], $_POST["firstname"], $_POST["phoneNumber"], $_POST["adress"], $_POST["zipCode"], $_POST["city"], $_POST["jobs"], $_POST["degree"], $_POST["capability"], $_POST["description"] ) && $_SESSION["isPro"] && $_POST["lastname"] !== "" && $_POST["firstname"] !== "" && $_POST["phoneNumber"] !== "" && $_POST["adress"] !== "" && $_POST["zipCode"] !== "" && $_POST["city"] !== "" && $_POST["degree"] !== "" && $_POST["capability"] !== "" && $_POST["description"] !== "" ) ) { modify_user_info($_POST, $_SESSION["userId"], $_SESSION["isPro"]); // Condition pour l'administration du site } elseif ($_SESSION["src"] == "admin" && isset($_SESSION["loggedIn"], $_SESSION["isAdmin"], ) && $_SESSION["loggedIn"] && $_SESSION["isAdmin"] && (isset($_POST["userId"]) || isset($_POST["addCategoryNameEn"], $_POST["addCategoryNameFr"] ) || isset($_POST["delCategoryId"]) ) ) { // Suppression d'un utilisateur if (isset($_POST["userId"]) && $_POST["userId"] !== "" ) { delete($_POST["userId"]); // Ajout d'un catégorie d'emploi } elseif (isset($_POST["addCategoryNameEn"]) && isset($_POST["addCategoryNameFr"]) && $_POST["addCategoryNameEn"] !== "" && $_POST["addCategoryNameFr"] !== "" ) { job_category_add($_POST["addCategoryNameEn"], $_POST["addCategoryNameFr"]); // Suppression d'une categorie d'emploi }elseif (isset($_POST["delCategoryId"]) && $_POST["delCategoryId"] !== "" ) { job_category_del($_POST["delCategoryId"]); } // Condition pour un enregistrement d'une mission } elseif ($_SESSION["src"] == "mission" && isset($_SESSION["loggedIn"], $_SESSION["isClient"], $_POST["subject"], $_POST["note"], $_POST["review"], $_POST["proId"] ) && $_SESSION["loggedIn"] && $_SESSION["isClient"] && $_POST["subject"] !== "" && $_POST["note"] !== "" && $_POST["review"] !== "" && $_POST["proId"] !== "" ) { register_mission($_POST["subject"], $_POST["note"], $_POST["review"], $_SESSION["userId"], $_POST["proId"] ); // Condition pour une recherche } 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); } // Condition pour le changement de la langue } elseif (isset($_SESSION["src"], $_POST["langSel"]) && ($_POST["langSel"] == "en" || $_POST["langSel"] == "fr") ) { set_language($_POST["langSel"]); // Enfin, si requete invalide } else { http_response_code(404); die(); } } else { http_response_code(404); die(); } ?>