-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetLobby.php
More file actions
57 lines (42 loc) · 1.39 KB
/
Copy pathgetLobby.php
File metadata and controls
57 lines (42 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
// Lobby test
require_once 'debugSettings.php';
require_once '../dbinfo/dbcred.php';
require_once 'DBSessionHandler.php';
$handler = new DBSessionHandler();
session_set_save_handler($handler);
session_start();
header('Content-Type: application/json');
if ( !isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true ) {
$status = "Unauthenticated access attempt.";
$response = array('status' => $status);
echo json_encode($response);
exit;
}
require_once 'BingoCard.php';
require_once 'User.php';
require_once 'Game.php';
//require_once 'Lobby.php';
require_once 'LobbyManager.php';
require_once 'gameManager.php';
$lobbyManager = new LobbyManager();
$gameManager = new gameManager();
if($_SESSION['role'] == 'overlord' || $_SESSION['role'] == 'manager'){
if(isset($_POST['REMOVE_USER'])) {
$email = htmlspecialchars($_POST['REMOVE_USER']);
$lobbyManager->removeUserFromLobby($email);
}
if(isset($_POST['ADD_USER_TO_GAME'])) {
$email = htmlspecialchars($_POST['ADD_USER_TO_GAME']);
$lobby = $lobbyManager->removeUserFromLobby($email);
$result = $gameManager->addPlayerToGame($email);
echo json_encode($result);
exit;
}
}
if(!$lobbyManager->userInLobby($_SESSION['email']) && !$gameManager->userInGame($_SESSION['email'])){
$lobbyManager->addUser($_SESSION['email']);
}
$lobby = $lobbyManager->getLobby();
echo json_encode($lobby);
?>