| Code:
|
http://battletracker.com/clanfeed/bc2/xxx/claninfo.xml
(you put in your own clanid where xxx is)
|
| Code:
|
<?php
if (eregi("block-bf2clanprofile.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
global $user, $cookie, $prefix, $db, $user_prefix, $stack;
$clanid="xxxx";
function startTag($parser, $name, $attrs) {
global $stack;
$tag=array("name"=>$name,"attrs"=>$attrs);
array_push($stack,$tag);
}
function cdata($parser, $cdata) {
global $stack,$i;
if(trim($cdata)) {
$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://bf2tracker.com/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);
// Displays Header Image
$content .= "<center><a href=\"http://www.bf2tracker.com/bf2_clanprofile.php?clanid=5328\" target=\"_blank\" ><img src=\"./stats/images/EGDogTags.png\" border=\"0\" alt=\"UppFor members playerstatus\"></a></center><br><br>";
// Display Clan Info
$content .="<Marquee Behavior='Scroll' Direction='Up' Height='200' Width='100%' ScrollAmount='2' ScrollDelay='1' onMouseOver='this.stop()' onMouseOut='this.start()'>";
foreach($playerstats as $key => $value) {
$playername=$playerstats[$key][PLAYERNAME];
$playerurl=$playerstats[$key][PLAYERSTATSURL];
if($playerstats[$key][PLAYERRANK]!="") $playerrank=$playerstats[$key][PLAYERRANK];
else $playerrank=0;
if($playerstats[$key][PLAYERSTATUS]=="1") $statuspic="ponline.gif";
else $statuspic="poffline.gif";
$content .="<a target=\"_blank\" href=\"$playerurl\"><font size=\"2\" color=\"#FFFFFF\">$playername</font></a><br><img border=\"0\" src=\"./stats/images/ranksmall_$playerrank.gif\" width=\"60\" height=\"16\"><img border=\"0\" src=\"./stats/images/$statuspic\" width=\"42\" height=\"16\"><BR><br>";
}
$content .="</marquee>";
//echo $content;
?>
|