Il y a actuellement 168 visiteurs
Mercredi 24 Avril 2024
accueilactualitésdossierscomparer les prixtélécharger gratuitement vos logicielsoffres d'emploiforum informatique
Connexion
Créer un compte

Parse error ...

Besoin d'aide pour configurer un serveur ? Vous souhaitez obtenir des conseils pour référencer votre site ? Un petit souci pour accéder à votre FTP ? Des soucis de programmation en PHP / ASP / HTML / XHTML / XML / XSLT / CSS / ReactJS / AngularJS / VueJS / CGI / PERL / C / MySQL / PostgreSQL ??? Nous avons peut-être la solution dans ce forum ...

Parse error ...

Message le 11 Avr 2005 16:18

salut a tous,

j'ai un ch'tit soucis avec un script php. il est sencé récupérer les status d'un serveur de jeu, mais au lieu de cela, j'obtiens le p'tit message suivant:

Parse error: parse error, unexpected $ in /home/httpd/html/livestatus/index.php on line 290


voici le script complet:

<?php
/*
Okay. This is the hacked-up version of the livestatus script we use a dontcamp.com.
It should work once you plug in the right ip and port below. I don't intend this script
to be a normal package deal with support and all that. I still don't have enough time to
devote to getting this all polished and gift-wrapped. I tried to take out all the stylesheet
and link references to dontcamp.com that I could, so it should work alright.

That all said, if you aren't a php guy, this script should work for you. If you are a PHP guy,
I apologize for the lack of comments, and wish you luck on tearing this down and rebuilding it
should you choose to do so. Hopefully it's nice to your error logs. :D

BF:V support is very easy to add, if we're calling this a 1.0, it'll be in 1.1.

--dst
*/

//The Variables
//The page output is template-ish at the bottom for easier customization of the final product.

//Team names. Team 1 is red, Team 2 is blue.
$t1name = 'Axis';
$t2name = 'Allies';

//Your game server IP
$bfip = '192.168.1.2';

//Your game server's GameSpy query port, default 23000 for BF1942
$bfport = '23000';

//How many seconds to wait for the query to return.
//Might need to be set higher for slower connections.
$timeout = '2';

//How often you'd like the page to autorefresh, in seconds.
//Delete all the lines with $refresh in it to make it not auto-refresh.
$refresh = '60';

//A few different options passable through the browser address.
//Adding ?debug=1 will spit out the arrays of data from the server
//The sort variable is handled via the script, so click around to figure it out.
if (!array_key_exists('sort', $_REQUEST)) $sort = 'score'; else $sort = $_REQUEST['sort'];
if (!array_key_exists('debug', $_GET)) $debug = '0'; else $debug = $_GET['debug'];


//Function Definitions
function stripquotes($string) {
$string = trim($string, "\"");
return $string;
}

function superstrip ($str) {
$str = ereg_replace('<[^>]*>|\([^)]*\)|\{[^}]*\}|\[[^]]*\]|\|[^|]*\|', '', $str);
$str = ereg_replace('[^[:alnum:]]', '', $str);
$str = strtolower($str);
return $str;
}

function cleanascii ($string) {
$count = strlen($string);
$i = '0';
$newstring = '';
while ($i < $count) {
$astring[] = $string{$i};
$i++;
}
foreach ($astring as $value) {
$ord = ord($value);
$good = "&#$ord;";
$value = ereg_replace("[^[:alnum:][:punct:][:space:]]|<|>|\"|\'|&", $good, $value);
$newstring .= $value;
}
return $newstring;
}

//The part that gathers and chews UDP data aka unreliable world
$socket = fsockopen("udp://$bfip", $bfport);
fwrite($socket, "\\info\\");
$buffer = "";
$sockstatus = socket_get_status($socket);
while ( substr($buffer,-7) != "\final\\" && !$sockstatus['timed_out'] ) {
socket_set_timeout($socket, $timeout);
$buffer .= fread($socket,1);
$sockstatus = socket_get_status($socket);
}
$pair = explode("\\", $buffer);
for ($i=1; $i<count($pair)-2; $i++) { // -2 because the last pair is "final"
if ( $pair[$i] != "queryid" ) {
$info[$pair[$i]] = $pair[$i+1];
}
$i++;
}
if ($sockstatus['timed_out'] == 1) {
$error = 'Server is temporarily down or changing maps.';
unset($sockstatus['timed_out']); }

$socket = fsockopen("udp://$bfip", $bfport);
fwrite($socket, "\\players\\");
$buffer = "";
$sockstatus = socket_get_status($socket);
while ( substr($buffer,-7) != "\final\\" && !$sockstatus['timed_out']) {
socket_set_timeout($socket, $timeout);
$buffer .= fread($socket,1);
$sockstatus = socket_get_status($socket);
}

$pair = explode("\\", $buffer);
reset($pair);
each($pair);
for ($i=1; $i<count($pair)-2; $i++) { // -2 because the last pair is "final"
each($pair);
for ($i=1; $i<count($pair)-2; $i++) { // -2 because the last pair is "final"
each($pair);
for ($i=1; $i<count($pair)-2; $i++) { // -2 because the last pair is "final"
$array = each($pair);
$rule = $array[1];
if ( $rule != "queryid" ) {
$array = each($pair);
$value = $array[1];
$array = explode("_", $rule);
//Dupe name prevention:
if ($array[1] < @$info['numplayers'] && $array[0] != "teamname") {
$game[$array[0]]['p'.$array[1]] = $value; }
} else {
each($pair); }
$i++;
}
fclose($socket);

//Content Generation
if (@$info && @$info['numplayers'] == 0) {
$error = 'Server is empty or changing maps.';
unset($info);
}

if (@$game['error']) {
$error = $game['error'];
}

if ($info['tickets2'] > $info['tickets1']) {
$tickets = $info['tickets2'] - $info['tickets1'];
if ($tickets == '1') $tickets = "<b>$tickets</b> ticket";
else $tickets = "<b>$tickets</b> tickets";
$twinning = "<b>$t2name</b> is currently winning by $tickets."; }
elseif ($info['tickets1'] > $info['tickets2']) {
$tickets = $info['tickets1'] - $info['tickets2'];
if ($tickets == '1') $tickets = "<b>$tickets</b> ticket";
else $tickets = "<b>$tickets</b> tickets";
$twinning = "<b>$t1name</b> is currently winning by $tickets."; }
else {
$twinning = "The teams are currently tied at <b class=highlight>{$info['tickets1']}</b> tickets"; };

switch ($sort) {
case 'score':
@array_multisort($game['score'], SORT_DESC, $game['kills'], SORT_DESC, $game['deaths'], SORT_ASC);
$sortprint = 'score'; break;
case 'kills':
@array_multisort($game['kills'], SORT_DESC, $game['score'], SORT_DESC, $game['deaths'], SORT_ASC);
$sortprint = 'kills'; break;
case 'deaths':
@array_multisort($game['deaths'], SORT_DESC, $game['kills'], SORT_DESC, $game['score'], SORT_DESC);
$sortprint = 'deaths'; break;
case 'ping':
@array_multisort($game['ping'], SORT_ASC, $game['score'], SORT_DESC, $game['kills'], SORT_DESC, $game['deaths'], SORT_ASC);
$sortprint = 'ping'; break;
case 'lowername':
foreach ($game['playername'] as $key => $value) {
$value = html_entity_decode($value);
$game['lowername'][$key] = superstrip($value); }
array_multisort($game['lowername'], SORT_ASC, SORT_STRING, $game['score'], SORT_DESC, $game['kills'], SORT_DESC, $game['deaths'], SORT_ASC);
$sortprint = 'player name'; break; }

if (@$game[$sort]) foreach ($game[$sort] as $player => $crap) {
$playername = &$game['playername'][$player];
if ($stripout) $playername = superstrip($playername);
$keyhash = &$game['keyhash'][$player];
$score = &$game['score'][$player];
$kills = &$game['kills'][$player];
$deaths = &$game['deaths'][$player];
$ping = &$game['ping'][$player];
$team = &$game['team'][$player];

$playername = cleanascii($playername);
$listadd = "\t<tr>
<td><a href=\"$link$keyhash\"$color>$playername</a></TD>
<td align=center>$score</TD>
<td align=center>$kills</TD>
<td align=center>$deaths</TD>
<td align=center>$ping</TD>
</tr>\n";
if ($team == 1) {
$t1list .= $listadd;
$t1score += $score;
$t1kills += $kills;
$t1deaths += $deaths;
$t1ping += $ping;
$t1++;
}
if ($team == 2) {
$t2list .= $listadd;
$t2score += $score;
$t2kills += $kills;
$t2deaths += eaths;
$t2ping += $ping;
$t2++;
}
$numplayers++;
}

if ($small == 1) echo("<center><table border=0 width=640>");
if ($small != 1) {
//Page output goes here
?>


<html>
<head>
<title><?=$info['hostname'];?> Live Server Status</title>
<meta http-equiv='refresh' content='<?=$refresh;?>'>
</head>
<body>
<div align=center>
<table border=0 width=600>
<tr><td colspan=2 align=center>
<h1><?=$info['hostname'];?> Server Status:</h1>
There are <b><?=$info['numplayers'];?></b> out of <b><?=$info['maxplayers'];?></b> players currently playing.<br><br>
The current map is <?= ucwords($info['mapname']);?></span></b></a>.<br><?=$twinning?>
</td></tr>
<tr><td colspan=2><hr width=96%></td></tr>
<tr><td valign=top width=50%>
<TABLE border=0 cellspacing=0 cellpadding=1 width=100%>
<TR><td height="17" valign=bottom bgcolor="#847D49"><?=$t2name;?> Team</TD>
<td colspan=4 nowrap bgcolor="#847D49">Tickets: <b><?=$info['tickets2'];?></b></td></tr>
<TR><td width="60%" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=lowername"><b class=x-small>&nbsp;Players: <?=$t2;?></b></a></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=score"><img src="/images/status/score.jpg" alt="Sort by Score" title="Sort by Score" border=0></a></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=kills"><img src="/images/status/kills.jpg" alt="Sort by Kills" title="Sort by Kills" border=0></a></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=deaths"><img src="/images/status/deaths.jpg" alt="Sort by Deaths" title="Sort by Deaths" border=0></a></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=ping"><img src="/images/status/ping.jpg" alt="Sort by Ping" title="Sort by Ping" border=0></a></TD></TR>
<?=$t2list;?></table>
</td>
<td valign=top width=50%>
<TABLE border=0 cellspacing=0 cellpadding=1 width=100%>
<TR><td height="17" valign=bottom bgcolor="#847D49"><?=$t1name;?> Team</TD>
<td colspan=4 nowrap bgcolor="#847D49">Tickets: <b><?=$info['tickets1'];?></b></td></tr>
<TR><td width="60%" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=lowername"><b class=x-small>&nbsp;Players: <?=$t1;?></b></a></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=score"><img src="/images/status/score.jpg" alt="Sort by Score" title="Sort by Score" border=0></a></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=kills"><img src="/images/status/kills.jpg" alt="Sort by Kills" title="Sort by Kills" border=0></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=deaths"><img src="/images/status/deaths.jpg" alt="Sort by Deaths" title="Sort by Deaths" border=0></a></TD>
<td width="10%" align="center" bgcolor="#847D49"><a href="<?=$_SERVER['SCRIPT_NAME'];?>?sort=ping"><img src="/images/status/ping.jpg" alt="Sort by Ping" title="Sort by Ping" border=0></a></TD></TR>
<?=$t1list;?></table></tr>
<tr>
<td valign=top width=50%>
<TABLE border=0 cellspacing=0 cellpadding=1 width=100%>
<TR><td width='60%'></TD>
<td align='center'><?=$t2score;?></TD>
<td align='center'><?=$t2kills;?></TD>
<td align='center'><?=$t2deaths;?></TD>
<td align='center'><? if ($t2 > 0) echo intval($t2ping/$t2);?></TD></TR>
</TABLE></td>
<td valign=top width=50%>
<TABLE border=0 cellspacing=0 cellpadding=1 width=100%>
<TR><td width='60%'></TD>
<td align='center'><?=$t1score;?></TD>
<td align='center'><?=$t1kills;?></TD>
<td align='center'><?=$t1deaths;?></TD>
<td align='center'><? if ($t1 > 0) echo intval($t1ping/$t1);?></TD></TR>
</TABLE></td></tr>
<tr><td colspan=2><hr width=96%></td></tr>
<tr><td colspan=2 align=center>
Page generated <?=date("l F dS, Y");?> at <?=date("g:i:s T");?>.</td></tr>
</table>
</center>
</body>
</html>
<?
}
if ($debug == 1) {
echo("<pre>");
echo("Sorted Player List<br>");
echo print_r($game);
echo("<br>--<br>");
echo("Server Info<br>");
echo print_r($info);
echo("<br>--<br>");
echo("</pre>");
}
?>



la ligne 290 est a ligne apres le >?

merci
twister
Visiteur
Visiteur
 
Messages: 2
Inscription: 17 Mar 2004 12:55
 



Sujets similaires

Message Résolu - Skype sur Windows 10 : A JavaScript error occurred
Re,,Excuse moi tout à l'heure j'ai eu droit à une urgence ordinatoresque, mon frère m'a amené un PC a améliorer donc voir le coût à envisager et commander les pièces. Quand c'est pour la famille ou une association c'est toujours urgent, nous c'est de famille assister les gens moi par le net et l'aid ...
Réponses: 9

Message Retour à l'état d'usine: problème "error"
Bonjour,Mon pc étant relativement lent (windows 7 edition familliale premium 64bits, asus x5die de 2008) j'ai voulue le remettre aux paramètres d'usine via la touche f9 au démarrage de windows. En option j'ai choisis de ne refaire que la partition système C.Voici la procédure que j'ai suivi (pour un ...
Réponses: 15

Message Crash VIDEO SCHEDULER INTERNAL ERROR
Bonjour,j'ouvre ce sujet pour vous expliquer le problème que je rencontre actuellement.En jeu (sur fifa 19 avec overclocking) Mon ordinateur à crasher et l'écran BSOD est apparut, je vous joint le rapport WhoCrashed ainsi que ma configuration."Crash Dump Analysis-------------------------------- ...
Réponses: 4

Message Kernel data inpage error et écran bleu
Bonjour,depuis aujourd'hui, mon Pc s'arrête brutalement, puis un écran bleu apparait avec le message suivant : Kernel data inpage errorPuis mon pc redémarre en faisant une réparation.Mon PC fonctionne sous windows 8.1.Merci d'avance de votre aide.Cordialement Manu
Réponses: 9

Message "Server Error in '/Mail' Application."
BonjourJe n'arrive plus à ouvrir ma boîte mail.Une redirection se fait automatiquement et j'ai ces messages : Runtime ErrorDescription: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed r ...
Réponses: 1

Message PC ne démarre pas : Error code : 0XC000000F
Bonjour, J'ai actuellement un PC sous W8.1 mais il ne démarre pas. Lors de sa mise en route j'ai le message d'erreur suivant : Your PC/DEVICE isn't connected or can't be accessedError code : 0XC000000FLors de la tentative de réparation avec un CD de W8 ou W10 en lançant l'outil de redémarrage systè ...
Réponses: 3

Message SMART error sur un DD WD
Salut à tous.j'ai un DD qui affiche une erreur SMART au lancement. C'est un DD que j'ai pas utilisé depuis un petit moment et la je me suis dis "tiens, et si j'arrive a récupérer 250GO pour du stockage ?"Du coup j'aimerais savoir si c'est grave? si ca se rattrape? est-ce que je peux m'en s ...
Réponses: 2


Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 2 invités


.: Nous contacter :: Flux RSS :: Données personnelles :.