forked from rpiambulance/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.delete_game.php
40 lines (30 loc) · 1.07 KB
/
.delete_game.php
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
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST') {
session_id($_POST['session_id']);
session_start();
require_once ".functions.php";
require_once ".gcal.php";
$googleCalendar = new GoogleCalendar();
$connection = openDatabaseConnection();
if(!isset($_POST['game_id'])) {
return;
}
$user = getUser($_POST['session_id'], $connection);
$username = $user['username'];
$gameId = $_POST['game_id'];
$statement = $connection->prepare("SELECT * FROM members WHERE username=:username");
$statement->bindParam(':username', $username);
$statement->execute();
$memberInfo = $statement->fetchAll(PDO::FETCH_ASSOC)[0];
$memberId = $memberInfo['id'];
if($memberInfo['admin'] === '1') {
$googleCalendar->deleteEvent($gameId, true);
$statement = $connection->prepare("DELETE FROM games_crews WHERE gameid = :gameId");
$statement->bindParam(':gameId', $gameId);
$statement->execute();
$statement = $connection->prepare("DELETE FROM games WHERE id = :gameId");
$statement->bindParam(':gameId', $gameId);
$statement->execute();
}
}
?>