-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
59 lines (52 loc) · 1.35 KB
/
api.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
<?php
// Required get api header
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
// Required get api variables
if (!isset($_GET["data"])) {
echo json_encode(array(
"status" => 400,
"error" => "No data file specified",
));
exit();
}
if (!isset($_GET["function"])) {
echo json_encode(array(
"status" => 400,
"error" => "No function specified",
));
exit();
}
if (!isset($_GET["club_id"])) {
echo json_encode(array(
"status" => 400,
"error" => "No club_id specified",
));
exit();
}
// Check if the data file exists by reading the json file
// read the json file
$data = json_decode(file_get_contents("datalist.json"), true);
foreach ($data["public"] as $file) {
if ($file["id"] == $_GET["data"]) {
require_once "data/" . $file["id"] . ".php";
continue;
}
echo json_encode(array(
"status" => 400,
"error" => "Data file not found",
));
}
// Check if the function exists
if ($_GET["function"] == "getNotFinished") {
echo json_encode(getNotFinished($_GET["club_id"]));
} else if ($_GET["function"] == "getFinished") {
echo json_encode(getFinished($_GET["club_id"]));
} else if ($_GET["function"] == "getTeams") {
echo json_encode(getTeams($_GET["club_id"]));
} else {
echo json_encode(array(
"status" => 400,
"error" => "Function not found",
));
}