-
Notifications
You must be signed in to change notification settings - Fork 4
/
reload.php
174 lines (174 loc) · 6.48 KB
/
reload.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
$Timer = MicroTime(true);
// Get all files
require_once 'html/config.php';
require_once 'functions.php';
require 'query/SourceQuery/bootstrap.php';
require 'query/minecraft/src/MinecraftPing.php';
require 'query/minecraft/src/MinecraftPingException.php';
require 'query/minecraft/src/MinecraftQuery.php';
require 'query/minecraft/src/MinecraftQueryException.php';
require 'html/type/minecraft/jsonconversion.php';
require 'html/type/minecraft/minecraftcolor.php';
require 'html/tailcustom.php';
include 'query/cron/cache/minecraft.php';
use xPaw\SourceQuery\SourceQuery;
const SQ_TIMEOUT = 1;
const SQ_ENGINE = SourceQuery::SOURCE;
$ServerID = (int)$_GET['id'];
// start session
session_start();
$username = $_SESSION['username'] ?? 'public';
session_write_close();
// Get the allowed servers
$conn = mysqli_connect($DB_SERVER, $DB_USERNAME, $DB_PASSWORD, $DB_NAME);
$sql = "SELECT server FROM users WHERE username='$username'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$id = $row["server"];
}
}
$id = json_decode($id);
if (!in_array($ServerID, $id)) {
http_response_code(401);
var_dump(http_response_code());
exit;
}
// Get server information from database
$sql = "SELECT IP, type, Queryport, GamePort, Name FROM serverconfig WHERE ID='$ServerID'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$ip = $row['IP'];
$type = $row['type'];
$qport = $row['Queryport'];
$gport = $row['GamePort'];
$name = $row['Name'];
}
}
mysqli_close($conn);
switch ($type) {
case "csgo":
case "valheim":
case "protocol-valve":
case "arkse":
case "vrising":
case "dayz":
case "rust":
include 'query/sourcequery.php';
break;
case "minecraft":
include 'query/minecraftquery.php';
break;
}
$serverstatus = json_decode($queryresult);
include 'html/type/query.php';
// Clean up query result.
$response['Username'] = $username;
$response['ID'] = $ServerID;
$response['Status'] = $status;
$response['Name'] = $title;
$response['IP'] = $ip;
$response['QueryPort'] = $qport;
$response['GamePort'] = $gport;
$response['Players'] = $countplayers;
$response['MaxPlayers'] = $maxplayers;
$response['raw']['Type'] = $type;
$response['raw']['Logo'] = $img;
$response['raw']['Version'] = $version;
$response['raw']['ConnectLink'] = $connectlink;
switch ($type) {
case "csgo":
case "valheim":
case "protocol-valve":
case "arkse":
case "vrising":
case "rust":
case "dayz":
//if ($password == "true") {$password = "True";} elseif ($password == "false") {$password = "False";}
$response['raw']['OS'] = $Os;
$response['raw']['Password'] = $password;
$response['raw']['Map'] = $map;
break;
case "minecraft":
$response['raw']['MOTD'] = $motd;
$response['raw']['Players'] = $playerlist ?? 0;
break;
}
switch ($type) {
case "arkse":
require ('html/type/arkse/modlist.php');
$response['raw']['Players'] = $playerlist ?? 0;
$response['raw']['InGameDay'] = $ingameday;
$response['raw']['ClusterID'] = $clusterid;
$response['raw']['Battleye'] = $battleye;
$response['raw']['PVP'] = $pvp;
$response['raw']['HasMods'] = $hasmods;
if ($hasmods) {
foreach ($mods as $mod) {
if (!isset($count)){$count=0;}
$response['raw']['Mods'][$count]['ModID'] = $mod;
$response['raw']['Mods'][$count]['ModLink'] = 'https://steamcommunity.com/sharedfiles/filedetails/?id='.$mod;
$convertedmod = $modlist['ArkModName'][$mod];
if (!empty($convertedmod)) {
$response['raw']['Mods'][$count]['ModName'] = $convertedmod;
} else {
$response['inmodlist'] = "not in list";
// If mod is not in modlist, get the mod from the steamcommunity website and store the mod in the modlist file
$convertedmod = substr(get_title("https://steamcommunity.com/sharedfiles/filedetails/?id=$mod"), 16);
$response['raw']['Mods'][$count]['ModName'] = $convertedmod;
$convertedmod = str_replace("'", "\'", $convertedmod);
$convertedmod = '$modlist[\'ArkModName\']'."[$mod] = '$convertedmod';";
file_put_contents("html/type/arkse/modlist.php", $convertedmod . "\n", FILE_APPEND);
}
$count++;
}
}
$response['raw']['MapLink'] = $maplink;
break;
case "csgo":
$response['raw']['Players'] = $playerlist ?? 0;
$response['raw']['MapLink'] = $maplink;
if (isset($serverstatus->rules)) {
$response['raw']['HasRules'] = 1;
$response['raw']['Rules'] = $csgorule;
}
break;
case "vrising":
$response['raw']['Players'] = $playerlist ?? 0;
$response['raw']['Description'] = $description;
$response['raw']['Bloodbound'] = $bloodbound;
$response['raw']['CastleHeartDamageMode'] = $bloodbound;
$response['raw']['InGameDay'] = $ingameday;
$response['raw']['Tags'] = $GameTags;
$response['raw']['MapLink'] = $maplink;
break;
case "dayz":
$response['raw']['Tags'] = $GameTags;
$response['raw']['MapLink'] = $maplink;
break;
case "rust":
$mapurl = "https://rustmaps.com/map/".$worldsize."_".$seed."?embed=img_i_l";
$metas = get_meta_tags($mapurl);
if (isset($metas['twitter:image'])) {
$metas = ($metas['twitter:image']);
$maplink = str_replace('FullLabeledMap.png', 'Thumbnail.png', $metas);
} else {
$maplink = "html/img/map/rustgenerate.webp";
}
$response['raw']['Players'] = $playerlist ?? 0;
$response['raw']['Seed'] = $seed;
$response['raw']['WorldSize'] = $worldsize;
$response['raw']['RustUptime'] = $rustuptime;
$response['raw']['MapLink'] = $maplink;
$response['raw']['Website'] = $rustwebsite;
$response['raw']['PVP'] = $pvp;
$response['raw']['FPS'] = $rustfps;
$rustdesc = str_replace("\\n", "<br>",$rustdesc);
$response['raw']['Description'] = $rustdesc;
$response['raw']['Tags'] = $GameTags;
break;
}
$response['QueryTime'] = Number_Format(MicroTime(true) - $Timer, 4, '.', '');
echo json_encode($response);