Cod2livestats

Flipje
Hello,

I downloaded the cod2livestats program from this site and I'm trying to run it on a website (server supports php). I filled in the IP and port number of the server but I get this error:

Parse error: syntax error, unexpected $end in C:\wamp\www\cod2livestats\stats.php on line 280 (http://knorp.ocp-s.tudelft.nl/cod2livestats/index.php)


I tried several things but can't get it working. I hope someone can give me the answer to my problem or a suggestion how to fix it.
Kelli

Zitat:

Original von Flipje
Parse error: syntax error, unexpected $end in C:\wamp\www\cod2livestats\stats.php on line 280 .


looks like you forget a semicolon, a " or ). Have you edited the config.php or the stats.php? Double check your chances:

// Serverparameter:
$server_ip = "213.202.211.44"; // Server IP
$server_port = "27000"; // Query Port

// Maps, hier den ingame Mapname an erster Stelle eintragen und hinten den Angezeigten Namen:
// Die Bilder für die Maps kommen in /bilder/images unter den ingame mapname mit der Endung .jpg
// also für Matmata: "/bilder/images/mp_matmata.jpg"

$Maps = array(
"mp_breakout" => "Villers-Bocage, Frankreich",
"mp_farmhouse" => "Beltot, Frankreich",
"mp_carentan" => "Carentan, Frankreich",
"mp_leningrad" => "Leningrad, Russland",
"mp_railyard" => "Stalingrad, Russland",
"mp_matmata" => "Matmata, Tunesien",
"mp_brecourt" => "Brecourt, Frankreich");

or, if everything seems to be ok, post your stats.php
Flipje
Thank you for your reply.

I edited the config.php and checked for missing semicolons but everything seems to be fine. It is strange because I use the original files so I presume it should be ok.

Here's the stats.php:

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:
<?php
// In diesem Bereich sind die einzigsten Änderungen die am Script vorgenommen werden müssen
// ****************************************************************************************

include ("config.php");

// Serverparameter:
// $server_ip = "213.202.211.44";	// Server IP
// $server_port = "27000"; 		// Query Port

// Maps, hier den ingame Mapname an erster Stelle eintragen und hinten den Angezeigten Namen:
// Die Bilder für die Maps kommen in /bilder/images unter den ingame mapname mit der Endung .jpg
// also für Matmata: "/bilder/images/mp_matmata.jpg"

// $Maps = array(
// "mp_breakout" => "Villers-Bocage, Frankreich",
// "mp_farmhouse" => "Beltot, Frankreich",
// "mp_carentan" => "Carentan, Frankreich",
// "mp_leningrad" => "Leningrad, Russland",
// "mp_railyard" => "Stalingrad, Russland",
// "mp_matmata" => "Matmata, Tunesien",
// "mp_brecourt" => "Brecourt, Frankreich");

// ****************************************************************************************
// Ab hier bitte nichts mehr ändern, außer man weiß was man tut und will das Script an das eigene Design anpassen:
$img_offline = "bilder/images/offline.jpg";

function farben($string) {
$string = str_replace("^0", "<font color=\"lightgray\">", $string);
$string = str_replace("^1", "<font color=\"red\">", $string);
$string = str_replace("^2", "<font color=\"green\">", $string);
$string = str_replace("^3", "<font color=\"yellow\">", $string);
$string = str_replace("^4", "<font color=\"blue\">", $string);
$string = str_replace("^5", "<font color=\"lightblue\">", $string);
$string = str_replace("^6", "<font color=\"magenta\">", $string);
$string = str_replace("^7", "<font color=\"white\">", $string);
$string = str_replace("^8", "<font color=\"lightgray\">", $string);
$string = str_replace("^9", "<font color=\"white\">", $string);
return $string . "</font>";
}
function farbig($string) {
$string = str_replace("^0", "", $string);
$string = str_replace("^1", "", $string);
$string = str_replace("^2", "", $string);
$string = str_replace("^3", "", $string);
$string = str_replace("^4", "", $string);
$string = str_replace("^5", "", $string);
$string = str_replace("^6", "", $string);
$string = str_replace("^7", "", $string);
$string = str_replace("^8", "", $string);
$string = str_replace("^9", "", $string);
return $string;
}

$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 = "ÿÿÿÿ" . 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_clients = $output[$max_index+1];
$max_index = array_search ("sv_privateClients", $output);$privat = $output[$max_index+1];
$max_index = array_search ("mapname", $output);$mapname = $output[$max_index+1];
$max_index = array_search ("sv_hostname", $output);$hostname = $output[$max_index+1];
$max_index = array_search ("g_gametype", $output);$gametype = $output[$max_index+1];
$max_index = array_search ("sv_punkbuster", $output);$punkbuster = $output[$max_index+1];
$max_index = array_search ("sv_pure", $output);$pure = $output[$max_index+1];
$max_index = array_search ("sv_voice", $output);$voice = $output[$max_index+1];
$max_index = array_search ("g_antilag", $output);$alag = $output[$max_index+1];
$max_index = array_search ("pswrd", $output);$passwort = $output[$max_index+1];

$max_index = array_search ("_Location", $output);$Standort = $output[$max_index+1];
$max_index = array_search ("_Admin", $output);$admin = $output[$max_index+1];
$max_index = array_search ("_Website", $output);$Web = $output[$max_index+1];
$max_index = array_search ("_Host", $output);$Host = $output[$max_index+1];
$max_index = array_search ("_Email", $output);$EMail = $output[$max_index+1];
$max_index = array_search ("_IRC", $output);$IRC = $output[$max_index+1];
$max_index = array_search ("_ICQ", $output);$ICQ = $output[$max_index+1]; 

$max_index = array_search ("gamename", $output);$gamename = $output[$max_index+1];
$max_index = array_search ("shortversion", $output);$Version = $output[$max_index+1];
$max_index = array_search ("_Mod", $output);$Mod = $output[$max_index+1];
$max_index = array_search ("sv_maxPing", $output);$maxPing = $output[$max_index+1];
$max_index = array_search ("sv_minPing", $output);$minPing = $output[$max_index+1];
$max_index = array_search ("fs_game", $output);$fsgame = $output[$max_index+1];

if ($Maps[$mapname] || "") {$mapnamelong = $Maps[$mapname];}
if ($mapnamelong == "") {$mapnamelong = $mapname;}

if ($fsgame == "_Admin") {$fsgame = "";}
if ($Host == "_Admin") {$Host = "";}
if ($Host == "Admin") {$Host = "";}
if ($Mod == "_Admin") {$Mod = "";}
if ($Mod == "Admin") {$Mod = "";}
if ($IRC == "_Admin") {$IRC = "";}
if ($IRC == "#") {$IRC = "-";}
if ($ICQ == "_Admin") {$ICQ = "-";}
if ($ICQ == "Admin") {$ICQ = "-";}
if ($maxPing == "_Admin") {$maxPing = "-";}
if ($Web == "_Admin") {$Web = "-";}
if ($minPing == "_Admin") {$minPing = "-";}

if ($gamename == "Call of Duty 2") {$GameIcon = "cod2";}

if ($gametype == "re") {$gametype = "Retrieval";}
if ($gametype == "dm") {$gametype = "Deathmatch";}
if ($gametype == "sd") {$gametype = "Suchen and Zerstören";} 
if ($gametype == "tdm") {$gametype = "Team Deathmatch";}
if ($gametype == "bel") {$gametype = "Hinter feindl. Linien";}
if ($gametype == "hq") {$gametype = "Hauptquartier";}
if ($gametype == "dom") {$gametype = "Domination";}
if ($gametype == "ctf") {$gametype = "Capture the Flag";}
if ($gametype == "bas") {$gametype = "Base Assault";}

$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];
}

function cmp ($a, $b) {
	if ($a["score"] > $b["score"]) {
	return -1;
	}
	if ($a["score"] < $b["score"]) {
	return 1;
	}
	if ($a["score"] == $b["score"]) {
	return 0;
	} 	
}
@usort($playerlist, "cmp");
$players = count($playerlist) - 1;
}

// Server erreichbar :
if (!$max_clients) {
?>

<table align="center" >
<tr>
    <td><font size="2"><font color="#DADADA"><center><br><br> IP : <?=$serverip?> : <?=$server_port?> <br></font></font><br>
    <img src="<?=$img_offline?>" border="0"><br><br><font color="#DADADA">Der Server ist OffLine <br>Es werden keine Daten vom Server empfangen.<br>Bitte überprüfen Sie die richtige Eingabe der IP-Adresse und des Serverports<br>Der Server wird in 60 Sek. neu abgefragt.</font></center></td>
</tr>

</table>
<?
exit;
}
//Ausgabe:
?>

      <link rel="stylesheet" href="Style.css"> 

<table border="0" align="center" cellspacing="0" width="700">
    <tr>
      <td width="700" cellspacing="0" ><center><font size="4"><?=farben($hostname)?></font></font></center></td>
    </tr>
</table>

<table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td width="256" valign="top">
      <table border="0" cellspacing="0" cellpadding="0">
       <tr>
	   <tr>
         <td width="256"><img src="bilder/images/line_s_up.gif" width="256" height="10"></td>
       </tr>
        <td class="backtds">
	     <table width="256" border="0" cellspacing="0" cellpadding="0">
          <tr>
           <td align="right" width="100">Spiel : </td>
           <td width="156"><font color="#FF0000"><?=$gamename?></font></td>
          </tr>
          <tr>
           <td align="right" width="100">Version : </td>
           <td width="156"><font color="#FF0000"> <?=$Version?></font></td>
          </tr>
          <tr>
           <td align="right" width="100">IP : </td>
           <td width="156"><font color="#FF0000"> <?=$serverip?> : <?=$server_port?></font></td>
          </tr>
          <tr>
           <td align="right" width="100">Spieltyp : </td>
           <td width="156"><font color="#FF0000"> <?=$gametype?></font></td>
          </tr>
          <tr>
           <td align="right" width="100">Spieler : </td>
           <td width="156"><font color="#FF0000"><?=$players?> / <?=$max_clients?></font></td>
          </tr>
          <tr>
           <td align="right" width="100">Res. Slots : </td>
           <td width="156"><font color="#FF0000"><?=$privat?></font></td>
          </tr>
          <tr>
           <td align="right" width="100">Min / Max Ping :</td>
           <td width="156"><font color="#FF0000"> <?=$minPing?>ms / <?=$maxPing?>ms</font></td>
          </tr>
        </table>
	</td>
       </tr>
	   <tr>
         <td><img src="bilder/images/line_s_down.gif" width="256"></td>
       </tr>
	   	   <tr>
         <td height="10">&nbsp;</td>
       </tr>
	   <tr>
         <td><img src="bilder/images/line_s_up.gif" width="256"></td>
       </tr>
       <tr>
        <td class="backtds" width="256"><center><img src="./bilder/images/<?=(file_exists("./bilder/images/$mapname.jpg") ? $mapname.".jpg" : "unknown.jpg")?>" alt="<?=(file_exists("./bilder/images/$mapname.jpg") ? $x[mapname].".jpg" : "unknown.gif")?>" style="border: 0px solid #000000;"><br></center></td>
       </tr>
       <tr>
        <td class="backtds" width="256"><center><?=$mapnamelong?></center></font></td>
       </tr>
	   <tr>
         <td><img src="bilder/images/line_s_down.gif" width="256"></td>
       </tr>
	   <tr>
         <td height="10">&nbsp;</td>
       </tr>
       <tr>
        <td width="256"><center><font color="#FF0000"><?=($pure == 1 ? "<img src='./bilder/images/pu_an.jpg' alt='Pure'>" : "<img src='./bilder/images/pu_aus.jpg' alt='unPure'>")?><?=($passwort == 1 ? "<img src='./bilder/images/lo_an.jpg' alt='mit Passwort'>" : "<img src='./bilder/images/lo_aus.jpg' alt='ohne Passwort'>")?><?=($alag == 1 ? "<img src='./bilder/images/al_an.jpg' alt='mit Antilag'>" : "<img src='./bilder/images/al_aus.jpg' alt='ohne Antilag'>")?><?=($voice == 1 ? "<img src='./bilder/images/gv_an.jpg' alt='mit GameVoice'>" : "<img src='./bilder/images/gv_aus.jpg' alt='ohne GameVoice'>")?></font></center></td>
       </tr>
       <tr>
        <td width="256"><center><font color="#FF0000"><?=($punkbuster == 1 ? "<img src='./bilder/images/pb_an.jpg' alt='mit PunkBuster'>" : "<img src='./bilder/images/pb_aus.jpg' alt='ohne Punkbuster'>")?></font></center></td>
       </tr>
      </table>
     </td>
     <td valign="top">
	  <table width="430" border="0" cellpadding="0" cellspacing="0" align="center">
	  <tr>
         <td><img src="bilder/images/line_m_up.gif" width="430"></td>
      </tr>
	  <tr>
	  <td class="backtdm" >
      <table width="420" border="0" cellpadding="0" cellspacing="0" align="center">
       <tr>
        <td >Spieler Name:</td>
        <td width="54">Punkte:</td>
        <td width="64">Ping:</td>
       </tr>
       <?
       for ($i = 0; $i != (count($playerlist) -1); $i++) {
       ?>
       <tr>
        <td><?=farben(str_replace("\"", "", $playerlist[$i]['player']))?></td>
        <td width="54"><?//=$players_string[$j]?><?=$playerlist[$i]['score']?></td>
        <td width="64"><?//=$players_string[$j]?><?=$playerlist[$i]['ping']?></td>
       </tr>
        <?  } ?>
      </table>
	  </td>
	  </tr>
	  <tr>
         <td><img src="bilder/images/line_m_down.gif" width="430"></td>
      </tr>
	  </table>
     </td>
    </tr>
   </table>



I hope you can find something....
Deichgraf
Hi,

In Line 280 is the following:

Zitat:


</table>


But, when you use a PHP-Scrpit you must start with:

Zitat:


<?php


And end the Scipt with:

Zitat:


?>


I think you lost the last Line.... set this @Line 281.
I hope thats it!

BtW:
I have see this sign @Line 169? Is it right there?

Greetz
Der "Deichgraf"
Kelli
@Flipje
I cant see no syntax error, but the coder used a lot of short opening tags
<?
this could be a server side setting on your php installation:

Zitat:


; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On

http://de2.php.net/manual/en/ini.core.php#ini.short-open-tag

You should
a) check / chance your php.ini "short_open_tag = On"
or b) every occur of <? replace with <?php

all other thinks looks fine, i cannot imagine another problem here. verwirrt

@Deichgraf, Das ist ein html / php mix. Nicht schön, beschisssen zu lesen, aber prinzipiell ok so. Er springt einfach immer hinundher, hier zB.:
<td><font size="2"><font color="#DADADA"><center><br><br> IP : <?=$serverip?> : <?=$server_port?> <br></font>
Ich bin mir nicht ganz sicher was das =(istgleich) soll, aber ich hab nie den "short Tag" Benutzt, das mag so richtig sein. Augen rollen
Deichgraf
Hi,

@Kellerkind

ein PHP/HTML mix? Das hab ich so noch nie gesehen. Zugegeben, ich
mach das noch nicht so lange, das war aber eine plausible Erklärung.
Da waren nochmehr "?>" zwischendurch, ob das sooo gut ist...

Aber wie der Kollege schon sagt, er hat das so gesaugt, und geht
davon (zurecht) aus, das es funzt....

Vielleicht sollten wir den Thread so Englisch wie möglich halten smile
Sonst versteht der Kollege nur die hälfte....

Wobei mein Englisch dafür "watt fürn Ar*** is" grosses Grinsen
MikeTNT
Two minutes ago I tested cod2livestats on my server without problems. I'm using PHP5 at the moment. So I wonder, why you get an error message.

Which version of php is in use on your server?

cu Mike
OLD MAN WITH GUN

Zitat:

Original von Kellerkind
Ich bin mir nicht ganz sicher was das =(istgleich) soll, aber ich hab nie den "short Tag" Benutzt, das mag so richtig sein. Augen rollen

http://de2.php.net/manual/en/language.ba...-syntax.phpmode
Beispiel 10.2 Augenzwinkern
Kelli
ahhh, thx. So, if the OPs server doesn't understand the short tags, and if he cant chance the short_open_tag in the global config, he must replace every occur of <? with <?php, and every occur of <?= with <?php echo
Or just use another script. Augen rollen
Flipje
ah, now it works smile I already changed the short_open_tag to "On" but noyhing happend so I tried to replace the <? for <?php but nothing happend...

Now I replaced the <? php= to <? php echo and now it works grosses Grinsen grosses Grinsen grosses Grinsen


Thank you all for the replies!!!