TinyPortal
Development => Support => Topic started by: sliderofVp on January 06, 2007, 10:57:18 AM
To the php coders
I'm working on a iframe php it's a standalone script for my tp smf, that parses xml from my aa gaming site, i've got it set up the way i want it except I want to have a marquee that shows the clan info above the members that scrolls from right to left in a single line that will show HONOR: SCORE: KILLS: DEATHS: KDRATIO: ROE: . Here is what the code looks like http://www.vpclan.com/aaotracker_clanprofile.php (http://www.vpclan.com/aaotracker_clanprofile.php). Here is the code snippet that shows the info:
// Display Clan Stats
echo "<b>Clan Stats:</b><br><br>\n";
foreach($clanstats as $key => $value) {
echo "$key: $value<br>\n";
}
Here is all of the code:
><?php
$clanid="7706";
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 Stats
echo "<b>Clan Stats:</b><br><br>\n";
foreach($clanstats as $key => $value) {
echo "$key: $value<br>\n";
}
foreach($playerstats as $key => $value) {
$playername=$playerstats[$key][PLAYERNAME];
$playerhonor=$playerstats[$key][PLAYERHONOR];
$playerurl=$playerstats[$key][PLAYERSTATSURL];
$playerkills=$playerstats[$key][PLAYERKILLS];
$playerscore=$playerstats[$key][PLAYERSCORE];
$playertime=floor(($playerstats[$key][PLAYERTIME])/60/60);
if($playerstats[$key][PLAYERSTATUS]=="1") $statuspic="ponline.gif";
else $statuspic="poffline.gif";
echo "<img border=\"0\" src=\"./images/$statuspic\" width=\"16\" height=\"16\"> <a target=\"_blank\" href=\"$playerurl\"><font size=\"1\" color=\"#F7DDAA\">$playername</font></a><br>";
}
?>
And here is the xml feed from my gaming tracker site http://aaotracker.com/livefeed/xml_clanprofile.php?clanid=7706 (http://aaotracker.com/livefeed/xml_clanprofile.php?clanid=7706)
You guys are all great and have been using tp for a while and we love it thanks in advance, any help would be much appreciated...
thx for the help, but I figured it out by accident...
Hi all. Using this code above I'm getting this error message "Parse error: syntax error, unexpected '<' in /opt/lampp/htdocs/arma/Sources/Load.php(1736) : eval()'d code(231) : eval()'d code on line 1"
Any ideas on that ?
Thanks in advance.
This is a 10 month old topic.
If you are using a php article.. you need to remove these tags
Start
<?php
End
?>
TinyPortal php blocks and articles already have the php open and close tags built in, so any native php code needs to have them removed.
Quote from: Zetan on October 04, 2007, 12:32:47 PM
This is a 10 month old topic.
If you are using a php article.. you need to remove these tags
Start
<?php
End
?>
TinyPortal php blocks and articles already have the php open and close tags built in, so any native php code needs to have them removed.
Thanks a lot my friend.
You're welcome.