TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 25, 2024, 08:19:54 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,173
  • Total Topics: 21,219
  • Online today: 319
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 317
  • Total: 317

How to add php file to blocks

Started by fodvapor, June 01, 2008, 08:23:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Vapor

I know there is an option to add a php block, but where do i place the file ? Root ? Includes ?

Here is example of the file :


<?php
$clanid
="69320";

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.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);

// Display Clan Info
echo "<b>Clan Info:</b><br>\n";

foreach(
$claninfo as $key => $value) {
 echo 
"$key$value<br>\n";
}


// Display Clan Stats
echo "<br><br><b>Clan Info:</b><br>\n";

foreach(
$clanstats as $key => $value) {
 echo 
"$key$value<br>\n";
}

// Display Player Stats
echo "<br><br><b>Player Stats:</b><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 
"<img border=\"0\" src=\"./images/$statuspic\" width=\"42\" height=\"16\"> <a target=\"_blank\" href=\"$playerurl\"><font size=\"2\" color=\"#789e2c\">$playername ($playerhonor)</font></a><br>";
}
?>



thx for the help

G6Cad

Remove the php tags <?php ?> from the start and end of the code and paste the rest in a php block

Vapor

Great! I will give a try...thanks

Vapor

Ok...i have found a different file to use.


<?php

$clanid
="69320";

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.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);

// Display Clan Info
echo "<center><font class=\"title\"><b>AAO Tracker Data</b></font><br><br></center>";
echo 
"<table align=center><tr>";
echo 
"<tr height=40><td colspan=3 align=center><b> Clan Info:</b><br></td></tr>\n";
foreach(
$claninfo as $key => $value) {
if (
$key=="CLANSTATSURL") {
 echo 
"<td align=left>$key:</td> <td width=10> </td> <td align=left><a href=$value>Clan AAO Tracker Stats</a><br></td></tr>\n";
 }
  else {
   echo 
"<td align=left>$key:</td> <td width=10> </td> <td align=left>$value<br></td></tr>\n";
  }
}
echo 
"</table>";

echo 
"<br><br>";

// Display Clan Stats
echo "<table align=center><tr>";
echo 
"<tr height=40><td colspan=3 align=center><b>Clan Data:</b><br></td></tr>\n";
foreach(
$clanstats as $key => $value) {
 echo 
"<td align=left>$key: <td width=10> </td> <td align=left>$value<br></td></tr>\n";
}
echo 
"</table>";

echo 
"<br><br>";

// Display Player Stats
echo "<br><br><b>Player Stats:</b><br>\n";

echo 
"<table border='1' cellpadding='0' cellspacing='1' style='border-collapse: collapse' bordercolor='#789e2c'
width='100%' id='AutoNumber1'>"
;
echo 
"<tr>";
echo 
"<td width='5%'>Status</td>";
echo 
"<td width='15%'>Player</td>";
echo 
"<td width='5%'>Honor</td>";
echo 
"<td width='10%'>Time Played</td>";
echo 
"<td width='10%'>Score</td>";
echo 
"<td width='10%'>Kills</td>";
echo 
"<td width='10%'>Deaths</td>";
echo 
"<td width='10%'>Fragrate</td>";
echo 
"</tr>";
echo 
"</table>";

foreach(
$playerstats as $key => $value) {
$playername=$playerstats[$key][PLAYERNAME];
$playerhonor=$playerstats[$key][PLAYERHONOR];
$playerurl=$playerstats[$key][PLAYERSTATSURL];
$playertime=$playerstats[$key][PLAYERTIME];
$playerscore=$playerstats[$key][PLAYERSCORE];
$playerkills=$playerstats[$key][PLAYERKILLS];
$playerdeaths=$playerstats[$key][PLAYERDEATHS];
$playerfragrate= @round($playerstats[$key][PLAYERKILLS]/$playerstats[$key][PLAYERDEATHS], 2);

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


echo 
"<table border='1' cellpadding='0' cellspacing='1' style='border-collapse: collapse' bordercolor='#789e2c'

width='100%' bgcolor= '000000' id='AutoNumber1'>"
;
echo 
"<tr>";
echo 
"<td width='5%'><img border=\"0\" src=\"./images/$statuspic\" width=\"42\"

height=\"16\"></td>"
;
echo 
"<td width='15%'><a target=\"_blank\" href=\"$playerurl\"><font size=\"2\">$playername</font></a></td>";
echo 
"<td width='5%'>$playerhonor</td>";
echo 
"<td width='10%'>$playertime</td>";
echo 
"<td width='10%'>$playerscore</td>";
echo 
"<td width='10%'>$playerkills</td>";
echo 
"<td width='10%'>$playerdeaths</td>";
echo 
"<td width='10%'>$playerfragrate</td>";
echo 
"</tr>";
echo 
"</table>";
echo 
"";
}
?>



Now...the file is named : clan_tracker.php
and it is located in the ROOT of my webserver. How do i get it to pull the xml feed ? You can preview it here :www.nwogaming.com (scroll to bottom of mainpage)
It is only showing the text...no members or images.

*sorry if i am not using the correct terminology, i am not good at php files or code at all !

Thank you for the help !

IchBin

There's no need to put the files on your server if you do as G6 has suggested.

Vapor

#5
ok...but i still cannot see it pulling the xml feed ?

But if you go here : http://aaotracker.com/livefeed/xml_clanprofile.php?clanid=69320
that is actually what the feed is supposed to pull and sort into that php file, but its all french to me and i dont know how to check and see if it is correct or not.

Thanks for the help

JPDeni

We've just been through this with someone else using exactly the same code. He had exactly the same problem. You might try doing a search. As I recall, he ended up using an iframe.

Vapor

Well i have done a search...with the following :
aaotracker, aao tracker, aao, americasarmy, americas army, tracker


And none of them supply an iframe solution....if i use an iframe is it possible to alter the background of the iframe? If so, could you show me an example?

Thank you

JPDeni

Try http://www.tinyportal.net/index.php?topic=24132.0

At the moment, it's the topic just below this one in the board.

As for iframes, the best suggestion I have is to do a google search for html iframe. You can find all sorts of information on the 'net -- much more than I can give you.

Vapor

I will try the iframe solution for the time being...and let you know how it turns out.

Thank you for the help :)