Go Back   CLAN SOLUTIONS, LLC. > CLAN SOLUTIONS, LLC. AAO Server Hosting > Scripts, Coding

Reply
 
Thread Tools Display Modes
Old April 13th, 2007, 17:37   #1
ntburchf
Administrator
 
ntburchf's Avatar
 
Join Date: Oct 2002
Location: Texas
Age: 50
Posts: 470
AAO Tracker Fix (Security)

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 ($chCURLOPT_URL$xmllink); 
curl_setopt ($chCURLOPT_RETURNTRANSFER1); 
curl_setopt ($chCURLOPT_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 ($chCURLOPT_URL$xmllink); 
curl_setopt ($chCURLOPT_RETURNTRANSFER1); 
curl_setopt ($chCURLOPT_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
ntburchf is offline   Reply With Quote
Old April 13th, 2007, 17:43   #2
ntburchf
Administrator
 
ntburchf's Avatar
 
Join Date: Oct 2002
Location: Texas
Age: 50
Posts: 470
So what you end up with is a script that looks like
example
PHP Code:
<?php
 
$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;

 
$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=xxxx";

$ch curl_init();
$timeout 5// set to zero for no timeout
curl_setopt ($chCURLOPT_URL$xmllink);
curl_setopt ($chCURLOPT_RETURNTRANSFER1);
curl_setopt ($chCURLOPT_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
echo "<center><br><br><b><font color=\"#FF0000\">Player Status:</font></b></center><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 
"<center><img border=\"0\" src=\"./images/$statuspic\" width=\"13\" height=\"13\"> <a target=\"_blank\" href=\"$playerurl\"><font size=\"2\" color=\"#C0C0C0\">$playername ($playerhonor)</font></a></center><br>";
}
?>
ntburchf is offline   Reply With Quote
Old August 20th, 2009, 23:59   #3
David
 
Join Date: Aug 2009
Posts: 1
Thanks

These are all the sites very informative.I m happy to see that.Thanks for sharing this.Thanks to you.






Get Real Finance Quotes
David is offline   Reply With Quote
Old August 25th, 2009, 02:26   #4
jason.rocksmith
 
Join Date: Aug 2009
Posts: 18
hi how u doing guys ..
hope u all having fun with this site well its an awesome site and the foru, is also going great 1Y0-A03 exam
and i have a wonderful thing for you 70-562 examthid willl make u a full professional and you will enjoy more on the site.
==============================
642-655 examhttp://www.exam-builder.com/642-655.htmbest of luck..
jason.rocksmith is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:28.


 

    Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
       
Darkness Style by Bluepearl Design - Ver3.0

Designed by Bluepearl Design