<?php require_once "libraries/head.php"; if (!isLogin()) { sendAjaxRedirect("login.php"); } if (isset($_POST["groupid"]) && isset($_POST["newstatus"])) { if (!isValidID($_POST["groupid"]) || !isValidID($_POST["newstatus"])) { sendAjaxResErr("Group ID or Status invalid!"); } $result = executeChange($_SESSION["userID"], $_POST["groupid"], $_POST["newstatus"]); if ($result === true) { sendAjaxResSuc("Change group status successfully!"); } else { sendAjaxResErr($result); } } function executeChange($userID, $groupID, $newStatus) { $newStatus = $newStatus; if ($newStatus !== "1" && $newStatus !== "2" && $newStatus !== "3") { return "Invalid status!"; } $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return "Could not find this group!"; } if ($group->getActivateStatus() === $newStatus) {
<?php require_once "libraries/head.php"; if (isLogin()) { sendAjaxRedirect("index.php"); } if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["confirmpw"]) && isset($_POST["firstname"]) && isset($_POST["lastname"]) && isset($_POST["gender"])) { $result = execSignup($_POST["username"], $_POST["password"], $_POST["confirmpw"], $_POST["firstname"], $_POST["lastname"], $_POST["gender"]); if ($result === true) { sendAjaxResSuc(); } else { sendAjaxResErr($result); } } function execSignup($username, $password, $confirmpw, $firstname, $lastname, $gender) { if ($username == "" || !isValidUsername($username)) { return "Username is empty or invalid!"; } if ($password == "" || !isValidPassword($password)) { return "Password is empty or invalid!"; } if ($confirmpw == "" || !isValidPassword($confirmpw)) { return "Confirm Password is empty or invalid!"; } if ($firstname == "" || !isValidName($firstname)) { return "First Name is empty or invalid!"; } if ($lastname == "" || !isValidName($lastname)) { return "Last Name is empty or invalid!"; }