function reconnectSession($db) { if (!isset($_POST["teamPassword"])) { echo json_encode(array("success" => false, "message" => "Session invalide")); error_log("invalid session : " . json_encode($_SESSION)); error_log(json_encode($_REQUEST)); return; } $res = commonLoginTeam($db, $_POST["teamPassword"]); if (!$res->success) { echo json_encode($res); error_log("invalid session and bad password : "******"teamID"]; error_log("reconnexion de session acceptée " . json_encode($_REQUEST)); // TODO: factoriser ce qui suit (copier-collé issu de data.php) $stmt = $db->prepare("SELECT TIME_TO_SEC(TIMEDIFF(NOW(), `team`.`startTime`)) as `timeUsed`, `endTime`, UNIX_TIMESTAMP() as `timeNow` FROM `team` WHERE `ID` = ?"); $stmt->execute(array($teamID)); $row = $stmt->fetchObject(); $_SESSION["startTime"] = $row->timeNow - intval($row->timeUsed); if ($row->endTime != null) { $_SESSION["closed"] = true; } return true; }
function loginTeam($db, $password) { echo json_encode(commonLoginTeam($db, $password)); }