Code
<?php
/************************************************************************/
/* TeamWarfare Standings-XML reader for PHPNUKE 6.0 */
/* ================================================= */
/* */
/* Copyright (c) 2003 */
/* http://phpnuke.org */
/* */
/* Version 1, modified by BurZurk */
/* http://www.nomercygiven.com */
/* Props to: Rodimus for the XMP parser (www.82nd.net) */
/* Humpa for the block/phpnuke help (www.nukeforums.com) */
/* */
/* Last Edited - 18 March 2003 */
/* */
/* This Block shows the TeamWarfare standings for all ladders of a */
/* given team from www.teamwarfare.com Laddername, rung #, W/L/T info */ /* */
/* 1- goto your team page, under your profile find "xml version" */
/* copy this link and paste below where indicated */
/* 2- save and upload the block to your "blocks" directory */
/* 3- In php admin section "blocks" enable "block-ladderinfo" */
/* be sure to call it "TWL Ladders" or whatever you want to appear */
/* at the head of the block */
/* 4- Done ;) */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (eregi("block-ladderinfo.php", $PHP_SELF)) {
header("Location: index.php");
die();
}
ob_start();
$insideitem = false;
$tag = "";
$twf_rank = "";
$twf_wins = "";
$twf_losses = "";
$twf_forfeits = "";
$twf_status = "";
$search = "America's Army ";
$replace = "a";
function startElement($parser, $tagName, $attrs) {
global $insideitem,$tag, $twf_status;
if ($insideitem) {
$tag = $tagName;
}
elseif ($tagName == "LADDER") {
while (list ($key, $val) = each ($attrs)) {
if ($key == "NAME")
print "<table align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
print "<tr><td colspan=\"2\"><u><b>";
echo str_replace("America's Army", "", $val);
print "</b></u><br><br></td></tr>";
}
$insideitem = true;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $twf_rank, $twf_wins, $twf_losses, $twf_forfeits;
if ($insideitem) {
switch ($tag) {
case "RANK": $twf_rank = $data; $tag = "";break;
case "WINS": $twf_wins = $data; $tag = "";break;
case "LOSSES": $twf_losses = $data; $tag = "";break;
case "FORFEITS": $twf_forfeits = $data; $tag = "";$insideitem = false; break;
}
}
}
function endElement($parser, $tagName) {
global $insideitem, $tag, $twf_rank, $twf_wins, $twf_losses, $twf_forfeits, $twf_status;
if ($tagName == "LADDER") {
print "<TR><TD valign=\"middle\">Rank:</td><TD valign=\"middle\"><STRONG>#$twf_rank<br></STRONG></td></tr>";
print "<TR><TD valign=\"middle\">Wins:</td><TD valign=\"middle\"><STRONG>$twf_wins<br></STRONG></TD></tr>";
print "<TR><TD valign=\"middle\">Losses:</td><TD valign=\"middle\"><STRONG>$twf_losses<br></STRONG></TD></tr>";
print "<TR><TD valign=\"middle\">Forfeits:</td><TD valign=\"middle\"><STRONG>$twf_forfeits<br></STRONG></TD></tr>";
print "</table><br>";
}
//$temp = true;
//$tagName = '';
}
// Create an XML parser
$xml_parser = xml_parser_create();
// Set the functions to handle opening and closing tags
xml_set_element_handler($xml_parser, "startElement", "endElement");
// Set the function to handle blocks of character data
xml_set_character_data_handler($xml_parser, "characterData");
// print "<hr>\n";
print "<TABLE BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" WIDTH=\"100%\">\n";
print "<TR><TD ALIGN=\"center\" WIDTH=\"100%\" VALIGN=\"top\" >\n";
// Open the XML file for reading- PASTE YOUR LINK BELOW.
$fp = fopen("http://www.teamwarfare.com/xml/viewteam_v2.asp?team=%3DSEC8%3DOutlaws","r") or die("Error reading RSS data.");
// Read the XML file 4KB at a time
while ($data = fread($fp, 4096))
// Parse each 4KB chunk with the XML parser created above
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
// Close the XML filef
fclose($fp);
// Free up memory used by the XML parser
xml_parser_free($xml_parser);
print "</TD></TR>";
print "</TABLE><BR>";
// end of file
$output = ob_get_contents();
ob_end_clean();
$content = $output;
?>
/************************************************************************/
/* TeamWarfare Standings-XML reader for PHPNUKE 6.0 */
/* ================================================= */
/* */
/* Copyright (c) 2003 */
/* http://phpnuke.org */
/* */
/* Version 1, modified by BurZurk */
/* http://www.nomercygiven.com */
/* Props to: Rodimus for the XMP parser (www.82nd.net) */
/* Humpa for the block/phpnuke help (www.nukeforums.com) */
/* */
/* Last Edited - 18 March 2003 */
/* */
/* This Block shows the TeamWarfare standings for all ladders of a */
/* given team from www.teamwarfare.com Laddername, rung #, W/L/T info */ /* */
/* 1- goto your team page, under your profile find "xml version" */
/* copy this link and paste below where indicated */
/* 2- save and upload the block to your "blocks" directory */
/* 3- In php admin section "blocks" enable "block-ladderinfo" */
/* be sure to call it "TWL Ladders" or whatever you want to appear */
/* at the head of the block */
/* 4- Done ;) */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (eregi("block-ladderinfo.php", $PHP_SELF)) {
header("Location: index.php");
die();
}
ob_start();
$insideitem = false;
$tag = "";
$twf_rank = "";
$twf_wins = "";
$twf_losses = "";
$twf_forfeits = "";
$twf_status = "";
$search = "America's Army ";
$replace = "a";
function startElement($parser, $tagName, $attrs) {
global $insideitem,$tag, $twf_status;
if ($insideitem) {
$tag = $tagName;
}
elseif ($tagName == "LADDER") {
while (list ($key, $val) = each ($attrs)) {
if ($key == "NAME")
print "<table align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
print "<tr><td colspan=\"2\"><u><b>";
echo str_replace("America's Army", "", $val);
print "</b></u><br><br></td></tr>";
}
$insideitem = true;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $twf_rank, $twf_wins, $twf_losses, $twf_forfeits;
if ($insideitem) {
switch ($tag) {
case "RANK": $twf_rank = $data; $tag = "";break;
case "WINS": $twf_wins = $data; $tag = "";break;
case "LOSSES": $twf_losses = $data; $tag = "";break;
case "FORFEITS": $twf_forfeits = $data; $tag = "";$insideitem = false; break;
}
}
}
function endElement($parser, $tagName) {
global $insideitem, $tag, $twf_rank, $twf_wins, $twf_losses, $twf_forfeits, $twf_status;
if ($tagName == "LADDER") {
print "<TR><TD valign=\"middle\">Rank:</td><TD valign=\"middle\"><STRONG>#$twf_rank<br></STRONG></td></tr>";
print "<TR><TD valign=\"middle\">Wins:</td><TD valign=\"middle\"><STRONG>$twf_wins<br></STRONG></TD></tr>";
print "<TR><TD valign=\"middle\">Losses:</td><TD valign=\"middle\"><STRONG>$twf_losses<br></STRONG></TD></tr>";
print "<TR><TD valign=\"middle\">Forfeits:</td><TD valign=\"middle\"><STRONG>$twf_forfeits<br></STRONG></TD></tr>";
print "</table><br>";
}
//$temp = true;
//$tagName = '';
}
// Create an XML parser
$xml_parser = xml_parser_create();
// Set the functions to handle opening and closing tags
xml_set_element_handler($xml_parser, "startElement", "endElement");
// Set the function to handle blocks of character data
xml_set_character_data_handler($xml_parser, "characterData");
// print "<hr>\n";
print "<TABLE BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" WIDTH=\"100%\">\n";
print "<TR><TD ALIGN=\"center\" WIDTH=\"100%\" VALIGN=\"top\" >\n";
// Open the XML file for reading- PASTE YOUR LINK BELOW.
$fp = fopen("http://www.teamwarfare.com/xml/viewteam_v2.asp?team=%3DSEC8%3DOutlaws","r") or die("Error reading RSS data.");
// Read the XML file 4KB at a time
while ($data = fread($fp, 4096))
// Parse each 4KB chunk with the XML parser created above
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
// Close the XML filef
fclose($fp);
// Free up memory used by the XML parser
xml_parser_free($xml_parser);
print "</TD></TR>";
print "</TABLE><BR>";
// end of file
$output = ob_get_contents();
ob_end_clean();
$content = $output;
?>
Is there one for Post? and if not could someone tell me what to modify for this to work? I was getting a parse error on line 1 (I'm a newb to code if you haven't noticed). [/code]
