-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessadmin.php
More file actions
executable file
·51 lines (37 loc) · 1.56 KB
/
Copy pathprocessadmin.php
File metadata and controls
executable file
·51 lines (37 loc) · 1.56 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
<?php
include('config.php');
switch($_POST['action']) {
default:
die();
break;
case "start":
$checkgames = mysql_query("SELECT `current` FROM `games`") or die(mysql_error());
$games = mysql_fetch_array($checkgames);
$game = $games['current'];
$new = $game + 1;
// Update
$compacsql = mysql_query("UPDATE `games` SET `current` = '$new'") or die(mysql_error());
break;
case "end":
// Time to loop through the players and minus 1
$playerssql = mysql_query("SELECT `id`, `games`, `status` FROM `bookings` WHERE `status` = '1'") or die(mysql_error());
while($players = mysql_fetch_array($playerssql)) {
$gamecount = $players['games'] - 1;
$id = $players['id'];
// Update
$compacsql = mysql_query("UPDATE `bookings` SET `games` = '$gamecount' WHERE `id` = '$id'") or die(mysql_error());
}
break;
case "clear":
// Deactive the players who have finished and open the computers to bookings
$playerssql = mysql_query("SELECT `id`, `computer`, `games`, `status` FROM `bookings` WHERE `status` = '1' AND `games` = '0'") or die(mysql_error());
while($players = mysql_fetch_array($playerssql)) {
$id = $players['id'];
$cid = $players['computer'];
// Update Bookings
$compacsql = mysql_query("UPDATE `bookings` SET `status` = '0' WHERE `id` = '$id'") or die(mysql_error());
// Update COmputers
$compacsql = mysql_query("UPDATE `computers` SET `status` = '1' WHERE `id` = '$cid'") or die(mysql_error());
}
break;
}