-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathQueryMS.php
More file actions
41 lines (39 loc) · 1.05 KB
/
QueryMS.php
File metadata and controls
41 lines (39 loc) · 1.05 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
<?php
require 'sql.conf.php';
$db = mysql_connect ($sqlc["server"], $sqlc["user"], $sqlc["pass"]);
if (!mysql_select_db ($sqlc["db"])) {
echo "Could not select database " . mysql_error ();
exit;
}
$query = "SELECT externalIp,externalPort,internalIp,internalPort,useNat,guid,gameType,gameName,connectedPlayers,playerLimit,passwordProtected,comment,updated FROM MasterServer WHERE (UNIX_TIMESTAMP()-updated) < 20 AND gameType='".$_REQUEST["gameType"]."';";
// echo ($query);
$res = mysql_query ($query);
if (!$res) {
echo "Could not execute query: " . mysql_error ();
exit;
}
$rows = mysql_num_rows ($res);
$cols = mysql_num_fields ($res);
$show = 0;
for ($i = 0; $i < $rows; $i ++) {
$row = mysql_fetch_row ($res);
if ($show == 1) {
print ";";
} else {
$show = 1;
}
if ($row[4] == "1" && $row[0] == $_SERVER['REMOTE_ADDR']) {
print $row[2].",".$row[3].",0";
} else {
print $row[0].",".$row[1].",".$row[4];
}
for ($j = 5; $j < $cols; $j ++) {
print ",".$row[$j];
}
}
if ($rows == 0) {
print "empty";
}
mysql_free_result ($res);
mysql_close ($db);
?>