1
BrUnZaEvZ
can some oene fiix this code
  • 2006/1/10 23:14

  • BrUnZaEvZ

  • Just popping in

  • Posts: 6

  • Since: 2006/1/9 2


Can someone fix this code so it works in a custom block in xoops...

$clanid="5701";

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://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 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 Player Stats
echo "

Player Stats:
n"
;

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

// if($playerstats[$key][PLAYERRANK]=="1") $playerrank=$playerstats[$key][PLAYERRANK];
// else $playerrank=0;

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

 echo 
"0" src="./images/ranksmall_$playerrank.gif" width="16" height="16"> 0" src="./images/$statuspic" width="42" height="16"> _blank" href="$playerurl">2" color="#000000">$playername
";
}
?>

2
Will_H
Re: can some oene fiix this code
  • 2006/1/10 23:31

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


not really how it works...you are going to need to give us alittle more...

Like what it is you are trying to accomplish.

its great that you found the variables for what you want to display... but what is this from? is this a XOOPS module? or did you import in a script? or worse case... did you just cut this out of some code?


*** it looks like a snippet from vsp ***

3
BrUnZaEvZ
Re: can some oene fiix this code
  • 2006/1/10 23:36

  • BrUnZaEvZ

  • Just popping in

  • Posts: 6

  • Since: 2006/1/9 2


Quote:

Biteronboard wrote:
not really how it works...you are going to need to give us alittle more...

Like what it is you are trying to accomplish.

its great that you found the variables for what you want to display... but what is this from? is this a XOOPS module? or did you import in a script? or worse case... did you just cut this out of some code?


*** it looks like a snippet from vsp ***


if i link it on my web page it looks like this

it's show my klan members if they are online (Battlefield2)

but i realy want to show this on the front page...

sorry my web page are in Norwegian and sorry for my bad English typing

4
Will_H
Re: can some oene fiix this code
  • 2006/1/10 23:39

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


ok so why not use an