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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 195,856
  • Total Topics: 21,292
  • Online today: 1,096
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 494
  • Total: 495
  • @rjen

phpbox issue

Started by Storm2, May 23, 2008, 06:46:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Storm2

Using SMF 1.1.5 and TinyPortal v1.0.5 beta 1

When I try to place this code in a phpbox it won`t work but when it is just a php page it is working fine.

$clanid="64736";
$clanid2="68296";

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



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



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];
}

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];
}

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;
  }
}

echo "<body bgcolor=\"#000000\">";


echo "<font color=#ffffff size=1><b>TRACKER STATUS<br>MAIN SQUAD:</b></font><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=\"$statuspic\"><a target=\"_blank\" href=\"$playerurl\"><font size=\"2\" color=\"#FFFFFF\">$playername</font></a><br>";
}
echo "</body>";


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


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];
}

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];
}

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;
  }
}

echo "<font color=#ffffff size=1><br><b>TRACKER STATUS<br>BETA SQUAD:</b></font><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=\"$statuspic\"><a target=\"_blank\" href=\"$playerurl\"><font size=\"2\" color=\"#FFFFFF\">$playername</font></a><br>";
}
echo "</body>";


http://www.teamcp.com/forum/tracker/test.php

Anyone an idea what is wrong with it?

Crip

Kinda large for a phpbox ant it?
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



Storm2

No idea, is there a max size for?

Crip

Not sure, but it does work in an article and there more advanced than a regular phpbox -- but I mat be wrong ?
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



JPDeni

QuoteWhen I try to place this code in a phpbox it won`t work
How does it not work? What happens? Error message? Blank page? Wrong printout? Let me know what I'm looking for.

I've got some awfully long php boxes, so I don't think the length of code is the problem. It could be just the fact that he's got html tags in there that don't belong:


<body...


and


</body>


I don't know that it would cause a problem, but it certainly isn't necessary in either a php block or php article.

Storm2

#5
Blank page(box) it just stays blank, no error message.

Sorry it is showing the

echo "<font color=#ffffff size=1><b>TRACKER STATUS<br>MAIN SQUAD:</b></font><br>\n";

TRACKER STATUS
MAIN SQUAD:


echo "<font color=#ffffff size=1><br><b>TRACKER STATUS<br>BETA SQUAD:</b></font><br>\n";

TRACKER STATUS
BETA SQUAD:

correct, but it is not parsing the rest somehow.
(I also removed all body tags.)

Ianedres

#6
Is the XML extension disabled in your server configuration?

Scratch that - didn't see the link.

Storm2

You mean in the apache server?
Np  ;)

Storm2

After trying the same code (without the body tags) in an php article I get an error message:
Quote
Fatal error: Cannot redeclare starttag() (previously declared in /home/public_html/forum/Sources/Load.php(1818) : eval()'d code(52) : eval()'d code:6) in /home/public_html/forum/Sources/Load.php(1818) : eval()'d code(1331) : eval()'d code on line 10

JPDeni

Do you want this in a box or an article?

This website is proudly hosted on Crocweb Cloud Website Hosting.