-
Notifications
You must be signed in to change notification settings - Fork 11
/
ajax.php
63 lines (61 loc) · 1.85 KB
/
ajax.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php session_start();
require_once 'lib.php';
if (isset($_GET['deck'])) {
$deckid = $_GET['deck'];
$deck = new Deck($deckid);
$result = array();
$result["id"] = $deckid;
if ($deck->id != 0) {
$result["found"] = 1;
$result["name"] = $deck->name;
$result["archetype"] = $deck->archetype;
$result["maindeck"] = $deck->maindeck_cards;
$result["sideboard"] = $deck->sideboard_cards;
} else {
$result["found"] = 0;
}
json_headers();
echo json_encode($result);
} elseif (isset($_GET['addplayer']) && isset($_GET['event'])) {
$event = new Event($_GET['event']);
if ($event->authCheck($_SESSION['username'])) {
$result = array();
$new = $_GET['addplayer'];
if ($event->addPlayer($new)) {
$player = new Player($new);
$result["success"] = true;
$result["player"] = $player->name;
$result["verified"] = $player->verified;
$result["event_running"] = $event->active == 1;
} else {
$result["success"] = false;
}
json_headers();
echo json_encode($result);
}
} elseif (isset($_GET['delplayer']) && isset($_GET['event'])) {
$event = new Event($_GET['event']);
if ($event->authCheck($_SESSION['username'])) {
$old = $_GET['delplayer'];
$result = array();
$result['success'] = $event->removeEntry($old);
$result['player'] = $old;
json_headers();
echo json_encode($result);
}
} elseif (isset($_GET['dropplayer']) && isset($_GET['event'])) {
$event = new Event($_GET['event']);
if ($event->authCheck($_SESSION['username'])) {
$result = array();
$playername = $_GET['dropplayer'];
$event->dropPlayer($playername);
$result['success'] = true;
$result['player'] = $playername;
$result['eventname'] = $event->name;
$result['round'] = $event->current_round;
json_headers();
echo json_encode($result);
}
} else {
error_headers();
}