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
175
176
|
<?php
//Return if no variables are set (exit)
if (isset($_GET['serverip']) != 1) return;
// Get server IP info
list($serverip, $serverport) = split(":", addslashes($_GET[serverip]));
$queryport = preg_replace('/\D/', '', $serverport)+1;
// check for valid ip address, no ipv6 support
if (!preg_match('/(\w{1,3}\.){3}\w{1,3}/', $serverip)) {
die('bla');
}
//If there is no IP, return (exit)
if (strlen($serverip) == 0) return;
//Open UDP socket to server
$sock = fsockopen("udp://" . $serverip, $queryport, $errno, $errstr,4);
//Check if we have a socket open, if not, display error message
if (!$sock) {
echo "$errstr ($errno)<br>\n";
exit;
}
fputs($sock,"\\status\\\player_property\Health\\\game_property\ElapsedTime\\\game_property\RemainingTime\\");
$gotfinal = False;
$data = "";
//Set starttime, for possible loop expiration, so the server doesn't get too much work.
$starttime = Time();
//Loop until final packet has been received.
while(!($gotfinal == True || feof($sock))) {
//Get data
if(($buf = fgetc($sock)) == FALSE) {
usleep(100); // wait for additional data? :S whatever
}
//Add to databuffer
$data .= $buf;
//Check if final item (queryid) has been received
if (strpos($data,"final\\") != False) {
$gotfinal = True;
}
//Protect webserver against massive loop.
if ((Time() - $starttime) > 5) {
echo "Data receiving took too long. Cancelled.<P>";
$gotfinal = True;
}
}
//Close socket
fclose ($sock);
//Split chunks by \
$chunks = split('[\]', $data);
$mappic = strtolower("images/maps/".$map.".jpg");
if (file_exists($mappic)) {
} else {
$mappic = ("images/maps/blank.jpg");
}
$mapname = getiteminfo("mapname",$chunks);
$mappic = strtolower("images/maps/".$mapname.".jpg");
IF (file_exists($mappic)) {
} else {
$mappic = "images/maps/blank.jpg";
}
$r_hostname = getiteminfo("hostname",$chunks);
$r_gametype = getiteminfo("gametype",$chunks);
$r_adminname = getiteminfo("adminname",$chunks);
$r_adminemail = getiteminfo("adminemail",$chunks);
$r_password = getiteminfo("password",$chunks);
$r_timelimit = getiteminfo("timelimit",$chunks);
$r_remainingtime = GetMinutes(getiteminfo("RemainingTime",$chunks)) . " mins";
$r_elapsedtime = GetMinutes(getiteminfo("ElapsedTime",$chunks)) . " mins";
$r_goalteamscore = getiteminfo("goalteamscore",$chunks);
$r_numplayers = getiteminfo("numplayers",$chunks);
$r_minplayers = getiteminfo("minplayers",$chunks);
$r_maxplayers = getiteminfo("maxplayers",$chunks);
$r_maxteams = getiteminfo("maxteams",$chunks);
$r_balanceteams = getiteminfo("balanceteams",$chunks);
$r_tournament = getiteminfo("tournament",$chunks);
$r_friendlyfire = getiteminfo("friendlyfire",$chunks);
$r_gamestyle = getiteminfo("gamestyle",$chunks);
echo'
<table class = "box" border="0" cellpadding="0" cellspacing="0" width="720">
<tbody><tr>
<td class="heading" colspan="4" align="center">Server Status for '.$r_hostname.'</td>
</tr>
<tr>
<td class="dark" align="center" width="110">Server IP</td>
<td class="grey" align="center" width="350"><a class="grey" href="unreal://'.$serverip.':'.$serverport.'">'.$serverip.':'.$serverport.'</a></td>
<td class="tooltip" align="center" rowspan="5" colspan="2"><img border="0" alt="'.$mapname.'" title="'.$mapname.'" src="'.$mappic.'"></td>
</tr>
<tr>
<td class="dark" align="center">Map Name</td>
<td class="grey" align="center">'.$mapname.'</td>
</tr>
<tr>
<td class="dark" align="center" width="110">Match Type</td>
<td class="grey" align="center">'.$r_gametype.'</td>
</tr>
<tr>
<td class="dark" align="center">Server Info</td>
<td class="grey" align="center">Admin: '.$r_adminname.'<br />Email: '.$r_adminemail.'</td>
</tr>
<tr>
<td class="dark" align="center">Game Info</td>
<td class="grey" align="center">
Goal Team Score: '.$r_goalteamscore.'<br />
Min Players: '.$r_minplayers.'<br />
Max Players: '.$r_maxplayers.'<br />
Max Teams: '.$r_maxteams.'<br />
Balanced Teams: '.$r_balanceteams.'<br />
Tournament Mode: '.$r_tournament.'<br />
Friendly Fire: '.$r_friendlyfire.'<br />
Game Style: '.$r_gamestyle.'<br /><br />
Time Limit: '.$r_timelimit.'<br />
Time Remaining: '.$r_remainingtime.'<br />
Time Elapsed: '.$r_elapsedtime.'<br />
Password Required: '.$r_password.'<br />
</td>
</tr>
</tbody></table>
<br>
<table class = "box" border="0" cellpadding="0" cellspacing="0" width="720">
<tbody>
<tr>
<td class="heading" colspan="5" align="center">Player Information</td>
</tr>
<tr>
<td class="smheading" align="center" width="270">Player</td>
<td class="smheading" align="center">Frags</td>
<td class="smheading" align="center">Team</td>
<td class="smheading" align="center">Ping</td>
<td class="smheading" align="center">Health</td>
</tr>';
//Loop through all players
for ($i = 0; $i < $r_numplayers; $i++) {
$actualid = $i;
$itemx = $i+1;
$r_playername = getiteminfo("player_" . $actualid,$chunks);
$r_playerfrags = getiteminfo("frags_" . $actualid,$chunks);
$r_playerteam = getiteminfo("team_" . $actualid,$chunks);
$r_playerping = getiteminfo("ping_" . $actualid,$chunks);
$r_playerhealth = getiteminfo("Health_" . $itemx,$chunks);
echo'<tr>
<td class="grey" align="center">'.$r_playername.'</td>
<td class="grey" align="center">'.$r_playerfrags.'</td>
<td class="grey" align="center">'.$r_playerteam.'</td>
<td class="grey" align="center">'.$r_playerping.'</td>
<td class="grey" align="center">'.$r_playerhealth.'</td>
</tr>';
}
echo'</tbody></table>';
?>
|