You are here: Re: Certain .php files try to download instead of display « All PHP « IT news, forums, messages
Re: Certain .php files try to download instead of display

Posted by BaGMaN on 07/07/06 07:06

The xp & 2003 boxes have the exact same setup(versions and configs).
Works on the xp but not the 2003.
The page gets xml data from another site, parses it, and then displays
it. I'm thinking it's some difference on how it interacts with 2003,
either security wise or some setting that needs to be different in the
2003. Below is the code incase I am missing something there.

$clanid="46589";

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://aaotracker.4players.de/livefeed/xml_clanprofile.php?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";

foreach($playerstats as $key => $value) {
$playername=$playerstats[$key][PLAYERNAME];
$playerhonor=$playerstats[$key][PLAYERHONOR];
$playerurl=$playerstats[$key][PLAYERSTATSURL];

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

echo "<img border=\"0\" src=\"./images/$statuspic\" width=\"42\"
height=\"16\"> <a target=\"_blank\" href=\"$playerurl\"><font
size=\"2\"

color=\"#000000\">$playername ($playerhonor)</font></a><br>";
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация