-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
99 lines (99 loc) · 5.13 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
include_once "config.php";
$retarr = array();
$reqcommands = array("version", "retrievedata","isvalid");
if(isset($_GET["req"]) and in_array($_GET["req"],$reqcommands)){
$retarr["response"] = "OK";
if($_GET["req"] == "version"){
$retarr["command"]["name"] = "version";
$retarr["command"]["arguments"]["none"] = "none";
$retarr["result"]["version"] = "SFR-A9I003";
}
elseif($_GET["req"] == "isvalid"){
if(isset($_GET["token"])){
$sql = "SELECT * FROM token WHERE token='".mysqli_real_escape_string($link,$_GET["token"])."'";
if($result = mysqli_query($link,$sql)){
if(mysqli_num_rows($result) == 1){
while($row = mysqli_fetch_array($result)){
if($row["expire"] > time()){
$retarr["response"] = "OK";
$retarr["command"]["name"] = "isvalid";
$retarr["command"]["arguments"]["token"] = mysqli_real_escape_string($link,$_GET["token"]);
$retarr["env"]["version"] = "SFR-A9I003";
$retarr["result"]["isvalid"] = "YES";
$retarr["result"]["token_exists"] = "YES";
$retarr["result"]["expired"] = "NO";
} else {
$retarr["response"] = "OK";
$retarr["command"]["name"] = "isvalid";
$retarr["command"]["arguments"]["token"] = mysqli_real_escape_string($link,$_GET["token"]);
$retarr["env"]["version"] = "SFR-A9I003";
$retarr["result"]["isvalid"] = "NO";
$retarr["result"]["token_exists"] = "YES";
$retarr["result"]["expired"] = "YES";
}
}
} else {
$retarr["response"] = "OK";
$retarr["command"]["name"] = "isvalid";
$retarr["command"]["arguments"]["token"] = mysqli_real_escape_string($link,$_GET["token"]);
$retarr["env"]["version"] = "SFR-A9I003";
$retarr["result"]["isvalid"] = "NO";
$retarr["result"]["token_exists"] = "NO";
$retarr["result"]["expired"] = "NO";
}
} else {
$retarr["response"] = "FAILED";
$retarr["command"]["name"] = "isvalid";
$retarr["command"]["arguments"]["token"] = mysqli_real_escape_string($link,$_GET["token"]);
$retarr["env"]["version"] = "SFR-A9I003";
}
}else {
$retarr["response"] = "MISSING_ARGUMENT";
$retarr["command"]["name"] = "isvalid";
$retarr["command"]["arguments"]["token"] = "null";
$retarr["env"]["version"] = "SFR-A9I003";
}
}
elseif ($_GET["req"] == "retrievedata"){
if(isset($_GET["token"])){
$sql = "SELECT * FROM token WHERE token='".mysqli_real_escape_string($link,$_GET["token"])."'";
if($result = mysqli_query($link,$sql)){
if(mysqli_num_rows($result) == 1) {
while ($row = mysqli_fetch_array($result)) {
$retarr["response"] = "OK";
$retarr["command"]["name"] = "retrievedata";
$retarr["command"]["arguments"]["token"] = mysqli_real_escape_string($link,$_GET["token"]);
$retarr["env"]["version"] = "SFR-A9I003";
$retarr["result"]["username"] = $row["username"];
$retarr["result"]["expire"] = $row["expire"];
$retarr["result"]["create"] = $row["creation"];
$retarr["result"]["permission"] = $row["permission"];
$retarr["result"]["command"] = $row["command"];
$retarr["result"]["creator"] = $row["creator"];
}
} else {
$retarr["response"] = "INVALID_ARGUMENT";
$retarr["command"]["name"] = "retrievedata";
$retarr["command"]["arguments"]["token"] = mysqli_real_escape_string($link,$_GET["token"]);
$retarr["env"]["version"] = "SFR-A9I003";
}
} else {
$retarr["response"] = "FAILED";
$retarr["command"]["name"] = "retrievedata";
$retarr["command"]["arguments"]["token"] = mysqli_real_escape_string($link,$_GET["token"]);
$retarr["env"]["version"] = "SFR-A9I003";
}
}else {
$retarr["response"] = "MISSING_ARGUMENT";
$retarr["command"]["name"] = "retrievedata";
$retarr["command"]["arguments"]["token"] = "null";
$retarr["env"]["version"] = "SFR-A9I003";
}
}
} else {
$retarr["response"] = "Invalid or No Command Entered.";
$retarr["command_received"] = $_GET["req"];
$retarr["available_commands"] = $reqcommands;
}
die(json_encode($retarr));