This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
live.php
53 lines (50 loc) · 1.38 KB
/
live.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
<?php
function getAbleSlot() {
global $env;
$mysqli = db_start();
$stmt = $mysqli->prepare("SELECT * FROM `live_slot` WHERE is_testing = ? AND used < max;");
$stmt->bind_param("s", $env["is_testing"]);
$stmt->execute();
$row = db_fetch_all($stmt);
$stmt->close();
$mysqli->close();
if ($row[0]["id"]) {
return $row[0]["id"];
} else {
return false;
}
}
function setSlot($id, $mode) {
global $env;
$mysqli = db_start();
if ($mode) {
$stmt = $mysqli->prepare("UPDATE `live_slot` SET used = used + 1 WHERE id = ?;");
} else {
$stmt = $mysqli->prepare("UPDATE `live_slot` SET used = used - 1 WHERE id = ?;");
}
$stmt->bind_param("s", $id);
$stmt->execute();
$stmt->close();
$mysqli->close();
}
function getSlot($id) {
global $env;
$mysqli = db_start();
$stmt = $mysqli->prepare("SELECT * FROM `live_slot` WHERE id = ?;");
$stmt->bind_param("s", $id);
$stmt->execute();
$row = db_fetch_all($stmt);
$stmt->close();
$mysqli->close();
return $row[0]["id"] ? $row[0] : false;
}
function getLive($id) {
$mysqli = db_start();
$stmt = $mysqli->prepare("SELECT * FROM `live` WHERE id = ?;");
$stmt->bind_param("s", $id);
$stmt->execute();
$row = db_fetch_all($stmt);
$stmt->close();
$mysqli->close();
return $row[0]["id"] ? $row[0] : false;
}