erreur dans un block PHP

Petit nouveau ! | 8 Messages

14 févr. 2010, 09:32

Bonjour,
Etant le fondateur d'un forum http://silent-hunters-unit.eu.xooit.fr/portal.php, un membre m'avait fait un block PHP que j'avais insérer dans une image.
Tout fonctionnait parfaitement, jusqu'à que j'ai l'erreur suivante :
"Warning: file_get_contents(http://battletracker.com/clanfeed/aa3/2 ... aninfo.xml) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /mnt/102/sda/2/5/shudepot/battle/Battletracker.php on line 41"

1° Mon membre est indisponible, en ce moment
2° Je suis un gros noob en PHP, le html, ça va.

Merci de votre aide
<style type="text/css">* { font-family:arial,sans-serif;font-size: 8pt; }</style>

<?php
// no need for this with AA3 and Battletracker
$clanid="24651";

function startTag($parser, $name, $attrs) {
global $stack;

$tag=array("name"=>$name,"attrs"=>$attrs);
array_push($stack,$tag);
}

function cdata($parser, $cdata) {
global $stack;

$stack[count($stack)-1]['cdata'] .= $cdata;
}

function endTag($parser, $name) {
global $stack;

$stack[count($stack)-2]['children'][] = $stack[count($stack)-1];
array_pop($stack);
}


// Parse XML

$stack = array();
$claninfo = array();
$clanstats = array();
$playerstats = array();

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_parser, "cdata");

$xmllink="http://battletracker.com/clanfeed/aa3/24651/claninfo.xml";
// link for AA2 $xmllink="http://aaotracker.com/livefeed/xml_clanp…?clanid=$clanid";
$data = xml_parse($xml_parser,file_get_contents($xmllink));
if(!$data) die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));

xml_parser_free($xml_parser);


// Get Data

// Get Clan Profile Data
for($i = 0; $i < sizeof($stack[0][children][0][children]); $i++) {
$valname=$stack[0][children][0][children][$i][name];
$claninfo[$valname]=$stack[0][children][0][children][$i][cdata];
}

// Get Clan Stats Data
for($i = 0; $i < sizeof($stack[0][children][1][children]); $i++) {
$valname=$stack[0][children][1][children][$i][name];
$clanstats[$valname]=$stack[0][children][1][children][$i][cdata];
}

// Get Player Data
for($i = 0; $i < sizeof($stack[0][children][2][children]); $i++) {
for($x = 0; $x < sizeof($stack[0][children][2][children][$i][children]); $x++) {
$valname=$stack[0][children][2][children][$i][children][$x][name];
$value=$stack[0][children][2][children][$i][children][$x][cdata];
if($valname=="PLAYERID") $pid=$value;
$playerstats[$pid][$valname]=$value;
}
}

// Now we have 3 arrays with all stats and infos
//print_r($claninfo);
//print_r($clanstats);
//print_r($playerstats);

// Display Clan Info
//echo "<b>Clan Info:</b><br>\n";

foreach($claninfo as $key => $value) {
//echo "$key: $value<br>\n";
}
// Display Clan Stats
//echo "<br><br><b>Clan Info:</b><br>\n";
foreach($clanstats as $key => $value) {
//echo "$key: $value<br>\n";
}
// Display Player Stats
//echo "<br><br><b>Player Stats:</b><br>\n";
$i = 1;
echo '<table width="450">';
foreach($playerstats as $key => $value) {
$playername=$playerstats[$key][PLAYERNAME];
$playerhonor=$playerstats[$key][PLAYERHONOR];
$playerurl=$playerstats[$key][PLAYERSTATSURL];

if($playerstats[$key][PLAYERSTATUS]=="1") $statuspic="online.gif";
else $statuspic="offline.gif";

if ($playerstats[$key][PLAYERSTATUS]=="1") $pcolor="##00FF00";
else $pcolor="#000000";

if (($i % 3) == 0)
	{
	echo '</tr>';
	}
	
if ($i == 1 OR ($i % 3) == 0)
	{
	echo '<tr>';
	}
	
echo "<td width=\"150\"><img border=\"0\" src=\"./$statuspic\" width=\"8\" height=\"8\"> <a target=\"_blank\" href=\"$playerurl\"><font size=\"2\" color=\"$pcolor\">$playername</font></a></td>";
$i++;
}
echo '</table>';
?> 

ViPHP
ViPHP | 3607 Messages

14 févr. 2010, 11:53

Bonjorus,
le problème vient de cette ligne:
$data = xml_parse($xml_parser,file_get_contents($xmllink));
Php n'arrive pas à récupérer le contenu de ton fichier xml...
Une des raisons possible, c'est que tu n'as pas activé la directive: "allow_url_fopen" dans ton php.ini
Sur quel type d'hébergement es-tu? as-tu un phpinfo à nous montrer?

Petit nouveau ! | 8 Messages

14 févr. 2010, 11:59

comment fais tu un phpinfo ??
Je viens de regarder, il me dit "aucune table trouvée"

ViPHP
ViPHP | 3607 Messages

14 févr. 2010, 12:15

Bonjour,
crée un fichier php comportant les lignes suivantes:
<?php
phpinfo();
?>
Met le sur ton serveur, et on regardera le résultat :)

Petit nouveau ! | 8 Messages

14 févr. 2010, 13:04


ViPHP
ViPHP | 3607 Messages

14 févr. 2010, 13:10

Il semblerait que la directive soit activée... :/
Remplace cette ligne:
$data = xml_parse($xml_parser,file_get_contents($xmllink));
par
if($xml_content = file_get_contents($xmllink)){
    $data = xml_parse($xml_parser,$xml_content);
}
else {
    echo 'Le fichier '.$xmllink.' est inaccessible!';
}

Petit nouveau ! | 8 Messages

14 févr. 2010, 13:24

Je viens de faire la manip, j'ai envoyer le fichier, tout en gardant l'ancien que j'ai renommé en .old
Image

ViPHP
ViPHP | 3607 Messages

14 févr. 2010, 14:07

Houlà....
Qu'est-ce que c'est que ce screenshot de phpmyadmin? On à parlé nul part de base de donnée... oO

Petit nouveau ! | 8 Messages

15 févr. 2010, 19:43

Une bonne âme charitable, pour me dépatouiller, merci.

ViPHP
ViPHP | 3607 Messages

15 févr. 2010, 19:45

Commence par répondre aux questions ;)
Et essaye de faire ce qu'on te demande (même si tu n'es pas un dieux en php!) et si tu ne comprends pas ce qui est demandé, on essayera de détailler!

Petit nouveau ! | 8 Messages

15 févr. 2010, 20:24

Excuse, mais je crois que l'on ne s"était pas compris.
- J'ai changé les lignes dans le fichiers
- Le fichier "php;info est là : http://shudepot.free.fr/info.php
- Et tu as également ce dossier: http://shudepot.free.fr/battle/

ViPHP
ViPHP | 3607 Messages

15 févr. 2010, 22:20

Bonsoir,

Tu as fait ce que je te dit ci après, dans le fichier battletracker.php ?
Il semblerait que la directive soit activée... :/
Remplace cette ligne:
$data = xml_parse($xml_parser,file_get_contents($xmllink));
par
if($xml_content = file_get_contents($xmllink)){
    $data = xml_parse($xml_parser,$xml_content);
}
else {
    echo 'Le fichier '.$xmllink.' est inaccessible!';
}

Petit nouveau ! | 8 Messages

16 févr. 2010, 05:34

Tout a fait, d'ailleurs dans ce dossier http://shudepot.free.fr/battle/, tu as les deux fichiers.

Petit nouveau ! | 8 Messages

20 févr. 2010, 10:17

ne serais ce pas une piste pour mon problème ??
php-debutant/probleme-php-include-chez- ... 51760.html