For those that are tying to run the default aao tracker clan roster script it
will not work on Clan Solutions' servers.
This is due to;
1. His script is not very secure
2. It use the Fopen remote url functions (which for those that do not know is a security issue
3. fopen is disabled on all web_hosting account due to this.
Here's how to fix that not-so-secure aao tracker script
Here's what you need to do, if you want this to work on your site.
in the aaotracker_profile.php
replace it all from
the start of the php down to the // player stats area
The main thing is to get the cUrl bits
PHP Code:
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $xmllink);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
PHP Code:
We use cUrl instead of the fopen_ulr
<?php
$clanid="";
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);
}
function aSortBySecondIndex($multiArray, $secondIndex, $dir) {
while (list($firstIndex, ) = each($multiArray))
$indexMap[$firstIndex] = $multiArray[$firstIndex][$secondIndex];
if ($dir==0)
asort($indexMap);
else
arsort($indexMap);
while (list($firstIndex, ) = each($indexMap))
if (is_numeric($firstIndex))
$sortedArray[] = $multiArray[$firstIndex];
else $sortedArray[$firstIndex] = $multiArray[$firstIndex];
return $sortedArray;
}
// 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.com/livefeed/xml_clanprofile.php?clanid=xxxxxxxx";
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $xmllink);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$data = xml_parse($xml_parser, $file_contents);
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;
}
$playerstats[$pid][PLAYERFRAG]=round($playerstats[$pid][PLAYERKILLS]/$playerstats[$pid][PLAYERDEATHS],2);
}
// Now we have 3 arrays with all stats and infos
// print_r($claninfo);
// print_r($clanstats);
// print_r($playerstats);
// Display Player Stats