fehlerhaftes Auslesen per UDP

Dungeonwatcher
Hi! cool

Ich versuche seit einiger Zeit die Daten von CoD4 von meinem Server vernünftig auszulesen. Das ganze sieht zur Zeit so aus:

--> http://www.dungeon-bbs.de/forum/cod.php

Wie man dort sieht, stimmen die Ergebnisse von CoD4 und CoDWaW nicht mit dem im Server eingestellten überein. Bei beiden Servern ist Antilag aktiviert und funktioniert auch. Angezeigt wird aber, das es deaktiviert ist.

Das ganze passiert mit diesem PHP Script:

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
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:
// Call of Duty 4 ----------------------------------------------------------------------------------------------------
$connect = fsockopen($server_ip, $server_port4, $errno, $errstr, 5);

if ($connect)
	{
		socket_set_timeout ($connect, 1, 000000);
//		$send = "ÿÿÿÿgetstatus\n";
//		$send =($connect, "ÿÿÿÿ" . chr (0x02) . "getstatus");
		fwrite($connect, "ÿÿÿÿ" . chr (0x02) . "getstatus");
		$debug1 = fputs($connect, $send);
		$debug2 = fwrite ($connect, $send);
		$output = fread ($connect, 1);
		if (! empty ($output))
			{
				do
					{
						$status_pre = socket_get_status ($connect);
						$output = $output . fread ($connect, 1);
						$status_post = socket_get_status ($connect);
					}
					while ($status_pre['unread_bytes'] != $status_post['unread_bytes']);
			};
		fclose($connect);

		$output = explode ("\\", $output);
		$max_index = array_search ("sv_maxclients", $output);$max_clients4 = $output[$max_index+1];
		$max_index = array_search ("sv_privateClients", $output);$privat4 = $output[$max_index+1];
		$max_index = array_search ("mapname", $output);$mapname4 = $output[$max_index+1];
		$max_index = array_search ("sv_hostname", $output);$hostname4 = $output[$max_index+1];
		$max_index = array_search ("g_gametype", $output);$gametype4 = $output[$max_index+1];
		$max_index = array_search ("sv_punkbuster", $output);$punkbuster4 = $output[$max_index+1];
		$max_index = array_search ("sv_pure", $output);$pure4 = $output[$max_index+1];
		$max_index = array_search ("sv_voice", $output);$voice4 = $output[$max_index+1];
		$max_index = array_search ("g_antilag", $output);$alag4 = $output[$max_index+1];
		$max_index = array_search ("pswrd", $output);$passwort4 = $output[$max_index+1];
		$max_index = array_search ("_Location", $output);$Standort4 = $output[$max_index+1];
		$max_index = array_search ("_Admin", $output);$admin4 = $output[$max_index+1];
		$max_index = array_search ("_Website", $output);$Web4 = $output[$max_index+1];
		$max_index = array_search ("_Host", $output);$Host4 = $output[$max_index+1];
		$max_index = array_search ("_Email", $output);$EMail4 = $output[$max_index+1];
		$max_index = array_search ("_IRC", $output);$IRC4 = $output[$max_index+1];
		$max_index = array_search ("_ICQ", $output);$ICQ4 = $output[$max_index+1]; 
		$max_index = array_search ("gamename", $output);$gamename4 = $output[$max_index+1];
		$max_index = array_search ("shortversion", $output);$Version4 = $output[$max_index+1];
		$max_index = array_search ("_Mod", $output);$Mod4 = $output[$max_index+1];
		$max_index = array_search ("sv_maxPing", $output);$maxPing4 = $output[$max_index+1];
		$max_index = array_search ("sv_minPing", $output);$minPing4 = $output[$max_index+1];
		$max_index = array_search ("fs_game", $output);$fsgame4 = $output[$max_index+1];

		if ($Maps[$mapname4] || "") {$mapnamelong4 = $Maps[$mapname4];}
		if ($mapnamelong4 == "") {$mapnamelong4 = $mapname4;}
		if ($fsgame4 == "_Admin") {$fsgame4 = "";}
		if ($Host4 == "_Admin") {$Host4 = "";}
		if ($Host4 == "Admin") {$Host4 = "";}
		if ($Mod4 == "_Admin") {$Mod4 = "";}
		if ($Mod4 == "Admin") {$Mod4 = "";}
		if ($IRC4 == "_Admin") {$IRC4 = "";}
		if ($IRC4 == "#") {$IRC4 = "-";}
		if ($ICQ4 == "_Admin") {$ICQ4 = "-";}
		if ($ICQ4 == "Admin") {$ICQ4 = "-";}
		if ($maxPing4 == "_Admin") {$maxPing4 = "-";}
		if ($Web4 == "_Admin") {$Web4 = "-";}
		if ($minPing4 == "_Admin") {$minPing4 = "-";}
		if ($gametype4 == "ctf") {$gametype4 = "Capture the Flag";}
		if ($gametype4 == "dm") {$gametype4 = "Deathmatch";}
		if ($gametype4 == "dom") {$gametype4 = "Domination";}
		if ($gametype4 == "koth") {$gametype4 = "Hauptquartier";}
		if ($gametype4 == "war") {$gametype4 = "Krieg";}
		if ($gametype4 == "tdm") {$gametype4 = "Team Deathmatch";}
		if ($gametype4 == "sd") {$gametype4 = "Suchen und Zerstören";}
		if ($gametype4 == "sab") {$gametype4 = "Sabotage";}

		$last_value = count($output) - 1;
		$players4_string = $output[$last_value];
		$players4_string = explode("\n", $players4_string);
		for ($i = 1; $i != count($players4_string); $i++)
			{
				$split = explode(" ", $players4_string[$i], 3);
				$playerlist4[$i-1]['score4'] = $split[0];
				$playerlist4[$i-1]['ping4'] = $split[1];
				$playerlist4[$i-1]['player4'] = $split[2];
			}

		function cmp4 ($a, $b)
			{
				if ($a["score4"] > $b["score4"])
					{
						return -1;
					}
				if ($a["score4"] < $b["score4"])
					{
						return 1;
					}
				if ($a["score4"] == $b["score4"])
					{
						return 0;
					}
			}
		@usort($playerlist4, "cmp4");
		$players4 = count($playerlist4) - 1;
	}

	$template->assign_vars(array(
	'SERVER_IP'				=> $serverip,
	'SERVER_PORT4'			=> $server_port4,
	'VERSION4'				=> $Version4,
	'GAMENAME4'				=> $gamename4,
	'GAMETYPE4'				=> $gametype4,
	'PLAYERS4'				=> $players4,
	'MAX_PLAYERS4'			=> $max_clients4,
	'PRIVAT4'				=> $privat4,
	'MIN_PING4'				=> $minPing4,
	'MAX_PING4'				=> $maxPing4,
	'MAP_NAME4'				=> $mapnamelong4,
	'FS_GAME4'				=> $fsgame4,
	'MAP_MAP4'				=> $mapname4,
	'L_SERVER_IP'			=> $lang['server_ip'],
	'L_SERVER_PORT'			=> $lang["server_port"],
	'L_SERVER_HOSTNAME' 	=> farben($hostname),
	'L_SERVER_PORT'			=> $lang["server_port"],
	'L_SERVER_GAME'			=> $lang["server_game"],
	'L_SERVER_GAME_TYPE'	=> $lang["server_game_type"],
	'L_SERVER_VERSION'		=> $lang["server_version"],
	'L_SERVER_GAMER'		=> $lang["server_gamer"],
	'L_SERVER_SLOTS'		=> $lang["server_slots"],
	'L_SERVER_PING'			=> $lang["server_ping"],
	'L_GAMER_NAME'			=> $lang["gamer_name"],
	'L_GAMER_POINT'			=> $lang["gamer_point"],
	'L_GAMER_PING'			=> $lang["gamer_ping"],
	'L_GAMER_ONLINE'		=> $lang["gamer_online"],
	'L_MAX_PLAYERS'			=> $lang["max_players"],
	'L_FS_GAME'				=> $lang["fs_game"],
	'L_OFFLINE'				=> $lang["offline"],
	'MAP_MAP4'				=> (@file_exists('./images/cod/4/'.$mapname4.'.jpg')) ? '<img src="./images/cod/4/'.$mapname4.'.jpg" border="0" alt="" />' : '<img src="./images/cod/unknown.jpg" border="0" alt="" />',
	'PURE4'					=> ($pure4 == 1 ? "<img src='./images/cod/pu_an.jpg' alt='Original' title='Original' border='0' />" : "<img src='./images/cod/pu_aus.jpg' alt='unPure' title='unPure'>"),
	'PASSWORD4'				=> ($passwort4 == 1 ? "<img src='./images/cod/lo_an.jpg' alt='mit Passwort' title='nur mit Passwort' border='0' />" : "<img src='./images/cod/lo_aus.jpg' alt='ohne Passwort' title='ohne Passwort' border='0' />"),
	'ALAG4'					=> ($alag4 == 1 ? "<img src='./images/cod/al_an.jpg' alt='mit Antilag' title='mit Antilag' border='0' />" : "<img src='./images/cod/al_aus.jpg' alt='ohne Antilag' title='ohne Antilag' border='0' />"),
	'VOICE4'				=> ($voice4 == 1 ? "<img src='./images/cod/gv_an.jpg' alt='mit GameVoice' title='mit Gamevoice' border='0' />" : "<img src='./images/cod/gv_aus.jpg' alt='ohne GameVoice' title='ohne Gamevoice' border='0' />"),
	'PUNKBUSTER4'			=> ($punkbuster4 == 1 ? "<img src='./images/cod/pb_an.jpg' alt='mit PunkBuster' title='mit Punkbuster' border='0' />" : "<img src='./images/cod/pb_aus.jpg' alt='ohne Punkbuster' title='ohne Punkbuster' border='0' />")
	)
);



Wenn ich mir per echo $arag4; anzeigen lasse, wird ein _Admin ausgegeben. Was mache ich hier falsch?

Bye
Kelli
Das ist einfach in sich kaputt.
In echt. Da hilft eigentlich nur Ausdrucken, zerreißen, Schnippsel mit Benzin übergießen und anzünden.

Dann vi! starten und neu schreiben.

Wenn hier z.B.
$max_index = array_search ("sv_voice", $output);$voice4 = $output[$max_index+1];

sv_voice nicht vorhanden ist kommt bei array_search false raus. Dann ist $max_index = $output[NULL+1]

Irgendwer hat das schonmal gemerkt und schnell und schmutzig mit den ganzen Zeilen
if ($fsgame4 == "_Admin") {$fsgame4 = "";}
if ($Host4 == "_Admin") {$Host4 = "";}
if ($Host4 == "Admin") {$Host4 = "";}
if ($Mod4 == "_Admin") {$Mod4 = "";}
if ($Mod4 == "Admin") {$Mod4 = "";}

versucht die Symptome zu umgehen. Die Ursache ist aber immernoch vorhanden und jetzt stolperst du wieder drüber das es irgendeinen Key in deiner Serverantwort nicht gibt und das Array sich deswegen um einen Zähler verschiebt.

Um das zu umgehen müsstest du vorher prüfen ob eine bestimmte Nadel überhaupt im Heuhaufen ist, z.b. mit if in_array{}
Das gibt aber ein hässlichen if else Spagetti block, dann lieber gleich neu schreiben und über den Antwortstring loopen damit das Array dann so aussieht
serverdata[sv_hostname]
serverdata[sv_pure]

dann ist es egal ob es für CoD1, CoD7 oder MoH ist.
Dungeonwatcher
Moin! cool

Ufff, mein "schöner" Code wird "zerrissen". Grübel
Zum Glück ist er aber nicht von mir sondern vor ca. 2 Jahren mal hier im Forum gefunden. Augen rollen

Egal, ich glaube verstanden zu haben was da falsch läuft. Mal schauen ob ich die Tage Zeit finde und es schaffe das Script umzuschreiben.

THNX

Bye
Nightwing

Zitat:

Original von Dungeonwatcher
Zum Glück ist er aber nicht von mir sondern vor ca. 2 Jahren mal hier im Forum gefunden. Augen rollen

Lass mich raten, das waren die Livestats?

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
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:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
<?php

include_once ("functions.php");

// In diesem Bereich sind die einzigsten Änderungen die am Script vorgenommen werden müssen
// ****************************************************************************************

// Serverparameter:

$server_ip = "78.143.44.221";	// Server IP
$server_port = "28960"; 		// Query Port

// ****************************************************************************************
// Ab hier bitte nichts mehr ändern, außer man weiß was man tut und will das Script an das eigene Design anpassen:

// Verbindungsaufbau
$server_ip = "udp://" . $server_ip;
$serverip = substr($server_ip, 6);
$connect = fsockopen($server_ip, $server_port, $errno, $errstr, 30);

if ($connect) {

  socket_set_timeout ($connect, 1, 000000);
  $send = "ÿÿÿÿgetstatus\n";
  $debug1 = fputs($connect, $send);
  $debug2 = fwrite ($connect, $send);
  $output = fread ($connect, 1);
  
  if (! empty ($output)) {
  
    do {
	
      $status_pre = socket_get_status ($connect);
      $output = $output . fread ($connect, 1);
      $status_post = socket_get_status ($connect);
    } while ($status_pre['unread_bytes'] != $status_post['unread_bytes']);
  };
  
  // Verbindung schliessen
  fclose($connect);

  // Verarbeite Daten
  $output = explode ("\\", $output);
  if (in_array("sv_maxclients", $output)) {$max_index = array_search ("sv_maxclients", $output);$max_clients = $output[$max_index+1];}
  if (in_array("sv_privateClients", $output)) {$max_index = array_search ("sv_privateClients", $output);$privat = $output[$max_index+1];}
  if (in_array("mapname", $output)) {$max_index = array_search ("mapname", $output);$mapname = $output[$max_index+1];}
  if (in_array("sv_hostname", $output)) {$max_index = array_search ("sv_hostname", $output);$hostname = $output[$max_index+1];}
  if (in_array("g_gametype", $output)) {$max_index = array_search ("g_gametype", $output);$gametype = $output[$max_index+1];}
  if (in_array("sv_punkbuster", $output)) {$max_index = array_search ("sv_punkbuster", $output);$punkbuster = $output[$max_index+1];}
  if (in_array("sv_pure", $output)) {$max_index = array_search ("sv_pure", $output);$pure = $output[$max_index+1];}
  if (in_array("sv_voice", $output)) {$max_index = array_search ("sv_voice", $output);$voice = $output[$max_index+1];}
  if (in_array("g_antilag", $output)) {$max_index = array_search ("g_antilag", $output);$alag = $output[$max_index+1];}
  if (in_array("pswrd", $output)) {$max_index = array_search ("pswrd", $output);$passwort = $output[$max_index+1];}
  if (in_array("_Location", $output)) { $max_index = array_search ("_Location", $output);$Standort = $output[$max_index+1];}
  if (in_array("_Admin", $output)) { $max_index = array_search ("_Admin", $output);$admin = $output[$max_index+1];}
  if (in_array("_Website", $output)) { $max_index = array_search ("_Website", $output);$Web = $output[$max_index+1];}
  if (in_array("_Host", $output)) { $max_index = array_search ("_Host", $output);$Host = $output[$max_index+1];}
  if (in_array("_Email", $output)) { $max_index = array_search ("_Email", $output);$EMail = $output[$max_index+1];}
  if (in_array("_IRC", $output)) { $max_index = array_search ("_IRC", $output);$IRC = $output[$max_index+1]; }
  if (in_array("_ICQ", $output)) { $max_index = array_search ("_ICQ", $output);$ICQ = $output[$max_index+1]; }
  if (in_array("gamename", $output)) {$max_index = array_search ("gamename", $output);$gamename = $output[$max_index+1];}
  if (in_array("shortversion", $output)) {$max_index = array_search ("shortversion", $output);$Version = $output[$max_index+1];}
  if (in_array("protocol", $output)) {$max_index = array_search ("protocol", $output);$protokol = $output[$max_index+1];}
  if (in_array("sv_maxPing", $output)) {$max_index = array_search ("sv_maxPing", $output);$maxPing = $output[$max_index+1];}
  if (in_array("sv_minPing", $output)) {$max_index = array_search ("sv_minPing", $output);$minPing = $output[$max_index+1];}
  if (in_array("_Mod", $output)) { $max_index = array_search ("_Mod", $output); $Mod = $output[$max_index+1];} else {$Mod = "---";}
  if (in_array("fs_game", $output)) {$max_index = array_search ("fs_game", $output);$fsgame = $output[$max_index+1];} else {$fsgame = "---";}

  // Gamename Short
  if ($gamename == "Call of Duty") $gamename_short = "CoD";
  if ($gamename == "CoD:United Offensive") $gamename_short = "CoD UO";
  if ($gamename == "Call of Duty 2") $gamename_short = "CoD 2";
  if ($gamename == "Call of Duty 4") $gamename_short = "CoD 4 MW";  
  if ($gamename == "Call of Duty: World at War") $gamename_short = "CoD WW";

  // Ermittlung der Version CoD WW
  if ($protokol == 94) $Version_codww = "1.1";
  else if ($protokol == 95) $Version_codww = "1.2";
  else if ($protokol == 96) $Version_codww = "1.3";
  else if ($protokol == 97) $Version_codww = "1.4";
  else if ($protokol == 99) $Version_codww = "1.5";
  else if ($protokol == 100) $Version_codww = "1.6";
  else if ($protokol == 101) $Version_codww = "1.7";

  // Gametypes
  if ($gametype == "re") {$gametype = "Retrieval";$gametype_short = "RE";}
  if ($gametype == "dm") {$gametype = "Deathmatch";$gametype_short = "DM";}
  if ($gametype == "sd") {$gametype = "Suchen und Zerstören";$gametype_short = "SD";} 
  if ($gametype == "tdm") {$gametype = "Team Deathmatch";$gametype_short = "TDM";}
  if ($gametype == "war") {$gametype = "Team Deathmatch";$gametype_short = "TDM";}
  if ($gametype == "bel") {$gametype = "Hinter feindl. Linien";$gametype_short = "BEL";}
  if ($gametype == "hq") {$gametype = "Hauptquartier";$gametype_short = "HQ";}
  if ($gametype == "dom") {$gametype = "Domination";$gametype_short = "DOM";}
  if ($gametype == "ctf") {$gametype = "Capture the Flag";$gametype_short = "CTF";}
  if ($gametype == "bas") {$gametype = "Base Assault";$gametype_short = "BAS";}
  if ($gametype == "koth") {$gametype = "Hauptquartier";$gametype_short = "KOTH";}
  if ($gametype == "sab") {$gametype = "Sabotage";$gametype_short = "SAB";}
  if ($gametype == "twar") {$gametype = "Krieg";$gametype_short = "TWAR";}
  if ($gametype == "ctfb") {$gametype = "Capture the Flag back";$gametype_short = "CTFB";}
  if ($gametype == "ch") {$gametype = "Capture and hold";$gametype_short = "CH";}
  if ($gametype == "htf") {$gametype = "Hold the Flag";$gametype_short = "HTF";}
  if ($gametype == "vip") {$gametype = "V.I.P.";$gametype_short = "VIP";}
  if ($gametype == "wrz") {$gametype = "Warzone";$gametype_short = "WRZ";}
  
  // Erweiterte PB Abfrage
  $pb_sig = "livestats/bilder/pb/$serverip-$server_port.png";

  if (file_exists($pb_sig)) {

	$pb_stream = 1;
  } 

  else {

	$pb_stream = 0;
  }

  if ($punkbuster == 1 && $pb_stream == 0) $pb = "aktiv";
  else if ($punkbuster == 1 && $pb_stream == 1) $pb = "aktiv & streaming";
  else if ($punkbuster == 0) $pb = "inaktiv";
  
  $last_value = count($output) - 1;
  $players_string = $output[$last_value];
  $players_string = explode("\n", $players_string);
  
  for ($i = 1; $i != count($players_string); $i++) {
  
	$split = explode(" ", $players_string[$i], 3);
	$playerlist[$i-1]['score'] = $split[0];
	$playerlist[$i-1]['ping'] = $split[1];
	$playerlist[$i-1]['player'] = $split[2];

  }
	  
  @usort($playerlist, "cmp");
	$players = count($playerlist) - 1;

  // Maps für CoD
  if ($gamename_short == "CoD") {
  
	include_once ("livestats/maps_cod.php");
	
	$mappic_folder = "cod";
	$GameIcon_small = "cod_icon.gif";
	$GameIcon_big = "cod_font.png";
  
	if ($Maps[$mapname] || "") {
  
	  $mapnamelong = $Maps[$mapname];
	}
  
	if ($mapnamelong == "") {
  
	  $mapnamelong = $mapname;
	}
  }
  
  // Maps für CoD UO
  else if ($gamename_short == "CoD UO") {
  
	include_once ("livestats/maps_coduo.php");
	
	$mappic_folder = "coduo";
	$GameIcon_small = "coduo_icon.gif";
	$GameIcon_big = "coduo_font.png";
  
	if ($Maps[$mapname] || "") {
  
	  $mapnamelong = $Maps[$mapname];
	}
  
	if ($mapnamelong == "") {
  
	  $mapnamelong = $mapname;
	}
  }
  
  // Maps für CoD 2
  else if ($gamename_short == "CoD 2") {
  
	include_once ("livestats/maps_cod2.php");
	
	$mappic_folder = "cod2";
	$GameIcon_small = "cod2_icon.gif";
	$GameIcon_big = "cod2_font.png";
  
	if ($Maps[$mapname] || "") {
  
	  $mapnamelong = $Maps[$mapname];
	}
  
	if ($mapnamelong == "") {
  
	  $mapnamelong = $mapname;
	}
  }
  
  // Maps für CoD 4 MW
  else if ($gamename_short == "CoD 4 MW") {
  
	include_once ("livestats/maps_cod4.php");
	
	$mappic_folder = "cod4";
	$GameIcon_small = "cod4_icon.gif";
	$GameIcon_big = "cod4_font.png";
  
	if ($Maps[$mapname] || "") {
  
	  $mapnamelong = $Maps[$mapname];
	}
  
	if ($mapnamelong == "") {
  
	  $mapnamelong = $mapname;
	}
  }
  
  // Maps für CoD WW
  else if ($gamename_short == "CoD WW") {
  
	include_once ("livestats/maps_codww.php");
	
	$mappic_folder = "codww";
	$GameIcon_small = "codww_icon.gif";
	$GameIcon_big = "codww_font.png";
  
	if ($Maps[$mapname] || "") {
  
	  $mapnamelong = $Maps[$mapname];
	}
  
	if ($mapnamelong == "") {
  
	  $mapnamelong = $mapname;
	}
  }
  
  // Ist ein Mappic vorhanden?
  $mappic = "livestats/bilder/small/$mappic_folder/$mapname.jpg";

  if (file_exists($mappic)) {

	$mappic_small = $mapname.".jpg";
  } 

  // Sonst nehme unknown.jpg
  else {

	$mappic_small = "unknown.jpg";
  }
  
  $img_offline = "livestats/bilder/general/offline.png";
}

// Server online
if ($max_clients){
?>
<table border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td valign="top">
      <table border="0" cellspacing="0" cellpadding="0">
       <tr>
        <td class="backtds">
	     <table border="0" cellspacing="0" cellpadding="0">
          <tr>
           <td ><strong>Server:</strong><br/>
                <div class="sBoxAbs"><?=farben($hostname)?></div>
           </td>
          </tr>
          <?php if ($gamename_short != "CoD WW"){ ?>
		  <tr>
           <td ><strong>Game:</strong><br/>&nbsp;
           <img style="vertical-align: middle;" src="livestats/bilder/general/<?php echo $GameIcon_small ?>" width="16" height="16">  <?php echo $gamename_short ?> (v <?php echo $Version?>)</td>
          </tr>
		  <?php }else{ ?>
          <tr>
           <td ><strong>Game:</strong><br/>&nbsp;
           <img style="vertical-align: middle;" src="livestats/bilder/general/<?php echo $GameIcon_small ?>" width="16" height="16"> <?php echo $gamename_short ?> (v <?php echo $Version_codww ?>)</td>
          </tr>
		  <?php }?>
          <tr>
           <td ><strong>IP Adresse:</strong><br/>&nbsp;
		   <a href="hlsw://<?=$serverip?>:<?=$server_port?>"><?=$serverip?>:<?=$server_port?></a>
          </tr>
          <tr>
           <td ><strong>Mod:</strong><br/>&nbsp;
		   <?=farben($Mod)?></a>
          </tr>
          <tr>
           <td ><strong>Player:</strong><br/>&nbsp;
           <?=$players?> / <?=$max_clients - $privat?> (+<?=$privat?>)</td>
          </tr>
          <tr>
           <td ><strong>Gametype:</strong><br/>&nbsp;
           <?=$gametype?></td>
          </tr>
          <tr>
           <td ><strong>Punkbuster:</strong><br/>&nbsp;
           <?=$pb?></td>
          </tr>
          <tr>
            <td><strong>Serverinfo:<br/>&nbsp;
            <a href="index.php?site=server">Hier klicken</a>
          </td>
       </tr>
        </table>
	</td>
       </tr>
	   	   <tr>
         <td height="10">&nbsp;</td>
       </tr>
       <tr>
        <td class="backtds"><img src="livestats/bilder/small/<?php echo $mappic_folder?>/<?php echo $mappic_small ?>" width="130" height="90"><br></td>
       </tr>
       <tr>
	    <td ><strong>Map:</strong><br/>
		  <div class="sBoxAbs"><?=$mapnamelong?></div>
		</td>
       </tr>
      </table>
     </td>
    </tr>
   </table>
<?
}
// Server offline
else {
?>
<table border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td valign="top">
      <table border="0" cellspacing="0" cellpadding="0">
       <tr>
        <td class="backtds">
	     <table border="0" cellspacing="0" cellpadding="0">
          <tr>
           <td ><strong>Server:</strong><br/>&nbsp;
            <font color="#ff0000">Server ist Offline</font>
           </td>
          </tr>
          <tr>
           <td ><strong>Game:</strong><br/>&nbsp;
           ---</td>
          </tr>
          <tr>
           <td ><strong>IP Adresse:</strong><br/>&nbsp;
		   <a href="hlsw://<?=$serverip?>:<?=$server_port?>"><?=$serverip?>:<?=$server_port?></a>
          </tr>
          <tr>
           <td ><strong>Mod:</strong><br/>&nbsp;
		   ---</a>
          </tr>
          <tr>
           <td ><strong>Player:</strong><br/>&nbsp;
           xx / xx (+x)</td>
          </tr>
          <tr>
           <td ><strong>Gametype:</strong><br/>&nbsp;
           ---</td>
          </tr>
          <tr>
           <td ><strong>Punkbuster:</strong><br/>&nbsp;
           <?=$pb?></td>
          </tr>
          <tr>
            <td><strong>Serverinfo:<br/>&nbsp;
            <a href="index.php?site=server">Hier klicken</a>
          </td>
       </tr>
        </table>
	</td>
       </tr>
	   	   <tr>
         <td height="10">&nbsp;</td>
       </tr>
       <tr>
        <td <img src="<?=$img_offline?>" width="130" height="90" border="0"><br></td>
       </tr>
       <tr>
	    <td ><strong>Map:</strong><br/>&nbsp;
		  ---
		</td>
       </tr>
      </table>
     </td>
    </tr>
   </table>
<?
}
?>


Falls Du das gesamte brauchst --> PN an mich.
Ist zwar auch widerlicher Spaghetti Code, aber funzt. Zunge raus

ToM
Kelli
Hab mal Dungeons Version verunstaltet. Zeile 29-32

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
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:
<?php

// Call of Duty 4 ----------------------------------------------------------------------------------------------------
$connect = fsockopen($server_ip, $server_port4, $errno, $errstr, 5);

if ($connect)
	{
		socket_set_timeout ($connect, 1, 000000);
		fwrite($connect, "ÿÿÿÿ" . chr (0x02) . "getstatus");
		$debug1 = fputs($connect, $send);
		$debug2 = fwrite ($connect, $send);
		$output = fread ($connect, 1);
		if (! empty ($output))
			{
				do
					{
						$status_pre = socket_get_status ($connect);
						$output = $output . fread ($connect, 1);
						$status_post = socket_get_status ($connect);
					}
					while ($status_pre['unread_bytes'] != $status_post['unread_bytes']);
			};
		fclose($connect);

/** $string ist CVar\Wert 
* \Game\CoD2\Map\mp_carentan\_Location\Germany\
*
**/
		$var = explode ("\\", $output);                               # $var[] ist array mit 1=cvar 2=Wert 3=cvar 4=Wert etc... var[0] = "Serverresponseÿÿÿÿ crap"
		for ($i=1; $i <= count($var) - 2; $i=$i+2) {                    # Ungerade wird zu Key von cvar[] ... 
			$j=$i+1;                                                          #...gerade wird zu dem passendem Wert
			$cvar["$var[$i]"] = $var[$j];                               # $cvar[servername] => CoD Server
		} 
		if ($cvar[g_gametype] == "ctf") {$cvar[g_gametype] = "Capture the Flag";}
		if ($cvar[g_gametype] == "dm") {$cvar[g_gametype] = "Deathmatch";}
		if ($cvar[g_gametype] == "dom") {$cvar[g_gametype] = "Domination";}
		if ($cvar[g_gametype] == "koth") {$cvar[g_gametype] = "Hauptquartier";}
		if ($cvar[g_gametype] == "war") {$cvar[g_gametype] = "Krieg";}
		if ($cvar[g_gametype] == "tdm") {$cvar[g_gametype] = "Team Deathmatch";}
		if ($cvar[g_gametype] == "sd") {$cvar[g_gametype] = "Suchen und Zerstören";}
		if ($cvar[g_gametype] == "sab") {$cvar[g_gametype] = "Sabotage";}


    $output = explode ("\\", $output);
		$last_value = count($output) - 1;
		$players4_string = $output[$last_value];
		$players4_string = explode("\n", $players4_string);
		for ($i = 1; $i != count($players4_string); $i++)
			{
				$split = explode(" ", $players4_string[$i], 3);
				$playerlist4[$i-1]['score4'] = $split[0];
				$playerlist4[$i-1]['ping4'] = $split[1];
				$playerlist4[$i-1]['player4'] = $split[2];
			}

		function cmp4 ($a, $b)
			{
				if ($a["score4"] > $b["score4"])
					{
						return -1;
					}
				if ($a["score4"] < $b["score4"])
					{
						return 1;
					}
				if ($a["score4"] == $b["score4"])
					{
						return 0;
					}
			}
		@usort($playerlist4, "cmp4");
		$players4 = count($playerlist4) - 1;
	}

	$template->assign_vars(array(
	'SERVER_IP'				=> $cvarserverip,
	'SERVER_PORT4'			=> $server_port4,
	'VERSION4'				=> $cvar[shortversion],
	'GAMENAME4'				=> $cvar[gamename],
	'GAMETYPE4'				=> $cvar[g_gametype],
	'PLAYERS4'				=> $players4,
	'MAX_PLAYERS4'			=> $cvar[sv_maxclients],
	'PRIVAT4'				=> $cvar[pswrd],
	'MIN_PING4'				=> $cvar[sv_minPing],
	'MAX_PING4'				=> $cvar[sv_maxPing],
	'MAP_NAME4'				=> $cvar[mapname],
	'FS_GAME4'				=> $cvar[fs_game],
	'L_SERVER_IP'			=> $lang['server_ip'],
	'L_SERVER_PORT'			=> $lang["server_port"],
	'L_SERVER_HOSTNAME' 	=> farben($cvar[sv_hostname]),
	'L_SERVER_PORT'			=> $lang["server_port"],
	'L_SERVER_GAME'			=> $lang["server_game"],
	'L_SERVER_GAME_TYPE'	=> $lang["server_game_type"],
	'L_SERVER_VERSION'		=> $lang["server_version"],
	'L_SERVER_GAMER'		=> $lang["server_gamer"],
	'L_SERVER_SLOTS'		=> $lang["server_slots"],
	'L_SERVER_PING'			=> $lang["server_ping"],
	'L_GAMER_NAME'			=> $lang["gamer_name"],
	'L_GAMER_POINT'			=> $lang["gamer_point"],
	'L_GAMER_PING'			=> $lang["gamer_ping"],
	'L_GAMER_ONLINE'		=> $lang["gamer_online"],
	'L_MAX_PLAYERS'			=> $lang["max_players"],
	'L_FS_GAME'				=> $lang["fs_game"],
	'L_OFFLINE'				=> $lang["offline"],
	'MAP_MAP4'				=> (@file_exists('./images/cod/4/'.$mapname4.'.jpg')) ? '<img src="./images/cod/4/'.$mapname4.'.jpg" border="0" alt="" />' : '<img src="./images/cod/unknown.jpg" border="0" alt="" />',
	'PURE4'					=> ($pure4 == 1 ? "<img src='./images/cod/pu_an.jpg' alt='Original' title='Original' border='0' />" : "<img src='./images/cod/pu_aus.jpg' alt='unPure' title='unPure'>"),
	'PASSWORD4'				=> ($passwort4 == 1 ? "<img src='./images/cod/lo_an.jpg' alt='mit Passwort' title='nur mit Passwort' border='0' />" : "<img src='./images/cod/lo_aus.jpg' alt='ohne Passwort' title='ohne Passwort' border='0' />"),
	'ALAG4'					=> ($alag4 == 1 ? "<img src='./images/cod/al_an.jpg' alt='mit Antilag' title='mit Antilag' border='0' />" : "<img src='./images/cod/al_aus.jpg' alt='ohne Antilag' title='ohne Antilag' border='0' />"),
	'VOICE4'				=> ($voice4 == 1 ? "<img src='./images/cod/gv_an.jpg' alt='mit GameVoice' title='mit Gamevoice' border='0' />" : "<img src='./images/cod/gv_aus.jpg' alt='ohne GameVoice' title='ohne Gamevoice' border='0' />"),
	'PUNKBUSTER4'			=> ($punkbuster4 == 1 ? "<img src='./images/cod/pb_an.jpg' alt='mit PunkBuster' title='mit Punkbuster' border='0' />" : "<img src='./images/cod/pb_aus.jpg' alt='ohne Punkbuster' title='ohne Punkbuster' border='0' />")
	)
);
?>


Verbesserungsfähig... aber für den Anfang.

Ergibt für das array cvar()
print_r ($cvar)
Array ( [_Admin] => Absolut Normale Spieler [_B3] => = true [_Email] => info@internationaloldstars.de [_IRC] => # [_Location] => Germany [_URL] => www.internationaloldstars.de [_Website] => http://www.internationaloldstars.de [fs_game] => awe3b7 [g_antilag] => 0 [g_gametype] => Team Deathmatch [g_needpass] => 0 [gamename] => Call of Duty 2 [mapname] => mp_burgundy [protocol] => 118 [scr_friendlyfire] => 1 [scr_killcam] => 1 [shortversion] => 1.3 [sv_allowAnonymous] => 0 [sv_floodProtect] => 1 [sv_hostname] => Absolut Normale Spieler. [sv_maxclients] => 64 [sv_maxPing] => 200 [sv_maxRate] => 25000 [sv_minPing] => 0 [sv_privateClients] => 0 [sv_punkbuster] => 1 [sv_pure] => 1 [sv_voice] => 0 [pswrd] => 0 [mod] => 1 )

Ich hab jetzt unten bei den Template nicht alles geändert, nur Beispielhaft bei einigen Werten um das Prinzip deutlich zu machen.
=ASSN=Renk
Hi Leute,
Ich such jetzt schon ne ganze Weile nach einem Script das mir den Serverstatus meines Servers (COD UO) anzeigt. COD4 unterstützung wäre ganz cool aber ist nicht so wichtig. Jetzt komme ich eigentlich bei ziemlich jeder Spur zu euch ins Forum, aber alle Beiträge die ich finde, verlinken auf alte Forenseiten oder Downloads die nicht mehr verfügbar sind oder ich finde nur einen Teil. Gibts dieses Livestats Script noch irgendwo? Oder das Serverquery Script auf das hier verwiesern wird?

Vielen Dank im Vorraus


Gruß Johannes
Horrid
SQuery gibt es hier in den Downloads:
http://www.phpnuke-clan.net

Ist aber für PHP-Nuke gedacht, keine Ahnung ob das Dir weiterhilft.
=ASSN=Renk
Hi Horrid,
Danke für deine Antwort. Ich dachte dabei aber eher an eine kleine unabhängige PHP Lösung wie die von Nightwish (die ist aber leider nirgends auffindbar, jedenfalls für mich^^). Das könnte man dann auch überall nutzen.

Gruß Johannes

EDIT:Ich meine von Nightwing Augenzwinkern