PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Cablespider
New Member
New Member


Joined: Jul 02, 2004
Posts: 7
Location: Occupied Chicago

PostPosted: Sun Jun 05, 2005 3:52 pm Reply with quote Back to top

I've tried and tried to get this block code to a module but lack serious knowledge. I was wondering if someone could help me out. The block slows the site down bigtime. I like the look of the block and the info it contains but would rather see it in module form. I'd appreciate anyone's help on this.

Code:
<?php

if (eregi("block-TWL.php", $PHP_SELF)) {
Header("Location: index.php");
die();
}
//Let keep those pesky little parsing errors to ourselves.
error_reporting(0);
//Added by [STAB]-Ravenstone
//Enter your clan TWL XML URL here.
$file = "http://www.teamwarfare.com/xml/viewteam_v2.asp?team=Armed+Insanity";
//Comment out this file line to see how your script reacts to TWL's XML feed being out.
class LadderInfo1 {
   var $ladder;
   var $ladderhtmllink;
   var $ladderxmllink;
   var $rank;
   var $wins;
   var $losses;
   var $forfeits;
   var $status;
   var $opponentname;
   var $opponenthtmllink;
   var $opponentxmllink;
   var $date;
   var $maps;
   var $sides;

function LadderInfo1() {
   $maps = array();
   $sides = array();
}
}

class LeagueInfo1 {
   var $league;
   var $leaguehtmllink;
   var $leaguexmllink;
   var $conference;
   var $division;
   var $status;
   var $opponentname;
   var $opponenthtmllink;
   var $opponentxmllink;
   var $date;
   var $maps;

function LeagueInfo1() {
   $maps = array();
}
}

class Team1 {
   var $name;
   var $url;
   var $email;
   var $founder;
   var $description;
   var $ircserver;
   var $channel;
   var $status;
   var $LadderInfo1;
   var $LeagueInfo1;

function Team1() {
   $this->LadderInfo1 = array();
   $this->LeagueInfo1 = array();
}
}

   $Team1 = new Team1();

function formatDate2($datetime) {
   $splitDate = split(" ", $datetime);
      array_splice($splitDate, 3, 0, date("Y"));

if (count($splitDate) > 0) {
$datetime = $splitdate[0];

for ($j = 0; $j < count($splitDate); $j++) {
$datetime = $datetime." ".$splitDate[$j];
}

$timestamp = (int)strtotime($datetime);
putenv("TZ=EST5EDT");
$datetime = strftime("%D %r %Z", $timestamp);
}

return $datetime;
}

function formatDate3($datetime) {
$timestamp = (int)strtotime($datetime);
putenv("TZ=EST5EDT");
$datetime = strftime("%A, %B %d", $timestamp);

return $datetime;
}

function xml_get_children1($vals, &$i) {
$children = array();
if (isset($vals[$i]['value'])) $children[] = $vals[$i]['value'];

while (++$i < count($vals)) {
switch ($vals[$i]['type']) {
case 'cdata':
$children[] = $vals[$i]['value'];
break;

case 'complete':
$children[] = array(
'tag' => $vals[$i]['tag'],
'attributes' => isset($vals[$i]['attributes'])? $vals[$i]['attributes'] : null,
'value' => $vals[$i]['value'],
);
break;

case 'open':
$children[] = array(
'tag' => $vals[$i]['tag'],
'attributes' => isset($vals[$i]['attributes'])? $vals[$i]['attributes'] : null,
'children' => xml_get_children1($vals, $i),
);
break;

case 'close':
return $children;
}
}
}

function xml_get_tree1($file) {
$data = join('', file($file));

$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $vals, $index);
xml_parser_free($parser);

return array(
'tag' => $vals[0]['tag'],
'attributes' => isset($vals[0]['attributes'])? $vals[0]['attributes'] : null,
'children' => xml_get_children1($vals, $i = 0),
);
}

$tree = xml_get_tree1($file);

foreach ($tree['children'] as $children) {
if ($children['tag'] == "teaminformation") {
$Team1->name = $tree['children'][0]['children'][0]['value'];
$Team1->url = $tree['children'][0]['children'][1]['value'];
$Team1->email = $tree['children'][0]['children'][2]['value'];
$Team1->founder = $tree['children'][0]['children'][5]['value'];
$Team1->description = $tree['children'][0]['children'][6]['value'];
$Team1->ircserver = $tree['children'][0]['children'][3]['value'];
$Team1->channel = $tree['children'][0]['children'][3]['attributes']['channel'];
$Team1->status = $tree['children'][0]['children'][4]['value'];
} else if ($children['tag'] == "competitioninformation") {
if (array_key_exists("children", $children)) {
foreach ($children['children'] as $comp) {
if ($comp['tag'] == "ladder") {
$lil = count($Team1->LadderInfo1);
$Team1->LadderInfo1[$lil] = new LadderInfo1();
$Team1->LadderInfo1[$lil]->ladder = $comp['attributes']['name'];
$Team1->LadderInfo1[$lil]->ladderhtmllink = $comp['children'][0]['children'][0]['value'];
$Team1->LadderInfo1[$lil]->ladderxmllink = $comp['children'][0]['children'][1]['value'];
$Team1->LadderInfo1[$lil]->rank = $comp['children'][1]['value'];
$Team1->LadderInfo1[$lil]->wins = $comp['children'][2]['value'];
$Team1->LadderInfo1[$lil]->losses = $comp['children'][3]['value'];
$Team1->LadderInfo1[$lil]->forfeits = $comp['children'][4]['value'];
$Team1->LadderInfo1[$lil]->status = $comp['children'][5]['attributes']['status'];

} else if ($comp['tag'] == "league") {
$lil = count($Team1->LeagueInfo1);
$Team1->LeagueInfo1[$lil] = new LeagueInfo1();
$Team1->LeagueInfo1[$lil]->league = $comp['attributes']['name'];
$Team1->LeagueInfo1[$lil]->leaguehtmllink = $comp['children'][0]['children'][0]['value'];
$Team1->LeagueInfo1[$lil]->leaguexmllink = $comp['children'][0]['children'][1]['value'];
$Team1->LeagueInfo1[$lil]->conference = $comp['children'][1]['value'];
$Team1->LeagueInfo1[$lil]->division = $comp['children'][2]['value'];
$Team1->LeagueInfo1[$lil]->status = $comp['children'][3]['children'][0]['attributes']['status'];

if (array_key_exists("children", $comp['children'][3])) {
$Team1->LeagueInfo1[$lil]->opponent = $comp['children'][3]['children'][0]['children'][0]['value'];
$Team1->LeagueInfo1[$lil]->opponenthtmllink = $comp['children'][3]['children'][0]['children'][1]['children'][0]['value'];
$Team1->LeagueInfo1[$lil]->opponentxmllink = $comp['children'][3]['children'][0]['children'][1]['children'][1]['value'];
$Team1->LeagueInfo1[$lil]->date = formatDate2($comp['children'][3]['children'][0]['children'][5]['value'])." 10:00 PM EST";
$Team1->LeagueInfo1[$lil]->maps[0] = $comp['children'][3]['children'][0]['children'][2]['attributes']['name'];
$Team1->LeagueInfo1[$lil]->maps[1] = $comp['children'][3]['children'][0]['children'][3]['attributes']['name'];
$Team1->LeagueInfo1[$lil]->maps[2] = $comp['children'][3]['children'][0]['children'][4]['attributes']['name'];
}
}
}
}
}
}

$html = "
<table bgcolor=\"".$bgcolor1."\" width=\"100%\" cellspacing=\"0\" cellpadding=\"1\">
<tr>
<td align=\"center\" colspan=\"3\">
</td>
</tr>";
for ($i = 0; $i < count($Team1->LadderInfo1); $i++) {
$html .= "
<tr>
<td align=\"center\" colspan=\"3\"><b><a href=\"".$Team1->LadderInfo1[$i]->ladderhtmllink."\">".$Team1->LadderInfo1[$i]->ladder."</a></b></td>
</tr>
<tr>
<td align=\"center\" colspan=\"3\">
Current Rung: <font color=yellow>".$Team1->LadderInfo1[$i]->rank."</font color></td>
</tr>
<tr>
<td align=\"center\" colspan=\"3\">
Record: <b><font color=green>".$Team1->LadderInfo1[$i]->wins."W </font color><font color=red>".$Team1->LadderInfo1[$i]->losses."L </font color><font color=orange>".$Team1->LadderInfo1[$i]->forfeits."F </font color></b>
</td>
</tr>";


$html .= "
<tr>
<td align=\"center\" colspan=\"3\">&nbsp;</td>
</tr>";
}

for ($i = 0; $i < count($Team1->LeagueInfo1); $i++) {
$html .= "
<tr>
<td align=\"center\" colspan=\"3\"><b><a href=\"".$Team1->LeagueInfo1[$i]->leaguehtmllink."\">".$Team1->LeagueInfo1[$i]->league."</a></b></td>
</tr>
<tr>
<td align=\"center\" colspan=\"3\">
Conference: ".$Team1->LeagueInfo1[$i]->conference." Division: ".$Team1->LeagueInfo1[$i]->division."
</td>
</tr>";
}


$html .= "</table>";

//Added by [STAB]-Ravenstone to display xml data if availabe and a message if not.
Only registered users can see links on this board!
Get registered or login to the forums!


if($Team1->name == NULL)
{
   $content .= "<center><b>&nbsp; XML Service Unavailable</b></center>";
}
else
{
$content = $html;
}
//I only take credit for the code in between the comments nothing more.
//If you wrote this code and feel I am taking credit for it please email me so I can add your name to the file I have
//with the due credit it deserves
Only registered users can see links on this board!
Get registered or login to the forums!

?>
View user's profile Send private message Visit poster's website
sting
Involved
Involved


Joined: Sep 23, 2003
Posts: 460
Location: Somewhere out there...

PostPosted: Sun Jun 05, 2005 7:03 pm Reply with quote Back to top

If you have an example of it somewhere on a site, I can take a look at it.

-sting
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Sun Jun 05, 2005 7:31 pm Reply with quote Back to top

Real quick and not tested
Code:
<?
if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {
    die ("You can't access this file directly...");
}

require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
//get_lang($module_name);
$pagetitle = "- $module_name";
global $prefix, $db, $sitename, $admin, $module_name;
include("header.php");
OpenTable();

//Let keep those pesky little parsing errors to ourselves.
error_reporting(0);
//Added by [STAB]-Ravenstone
//Enter your clan TWL XML URL here.
$file = "http://www.teamwarfare.com/xml/viewteam_v2.asp?team=Armed+Insanity";
//Comment out this file line to see how your script reacts to TWL's XML feed being out.

// ALL YOUR OTHER CODE DOWN TO ...
Code:

//Added by [STAB]-Ravenstone to display xml data if availabe and a message if not.
Only registered users can see links on this board!
Get registered or login to the forums!


if($Team1->name == NULL)
{
   $content .= "<center><b>&nbsp; XML Service Unavailable</b></center>";
}
else
{
$content = $html;
}
echo $content;
//I only take credit for the code in between the comments nothing more.
//If you wrote this code and feel I am taking credit for it please email me so I can add your name to the file I have
//with the due credit it deserves
Only registered users can see links on this board!
Get registered or login to the forums!

CloseTable();
include("footer.php");
?>
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
sting
Involved
Involved


Joined: Sep 23, 2003
Posts: 460
Location: Somewhere out there...

PostPosted: Sun Jun 05, 2005 8:04 pm Reply with quote Back to top

or not... lol

-sting
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Cablespider
New Member
New Member


Joined: Jul 02, 2004
Posts: 7
Location: Occupied Chicago

PostPosted: Sun Jun 05, 2005 9:31 pm Reply with quote Back to top

I activated the block so you can see it in that form.
Only registered users can see links on this board!
Get registered or login to the forums!


I made an index.php file, put in the code and put the file in a folder called TWL and activated the module. There is a link in the Nav menu called TWL Standings. No output unfortunately. I'm wondering why the block can parse the XML link but not when it's a module. I've been getting the same results. I do appreciate your time gents.
View user's profile Send private message Visit poster's website
ShosMeister
New Member
New Member


Joined: Jun 08, 2005
Posts: 18
Location: Harpers Ferry, WV

PostPosted: Wed Jun 08, 2005 8:28 am Reply with quote Back to top

Did you get this working? I modified/wrote a block for our site when we were in TWL and did not notice the block slowing down the site. Maybe there is something else doing it?

I checked your link and did not see TWL Standings anywhere and the site was very slow to load. Now, that may be on my side but then again, maybe not. The only way to be sure is to turn off some of the blocks one at a time and note the differences in loading.

Anyway, if you are active in TWL, one thing that I added to my block was to automatically import the challenges into vWar (which I notice you are using as well). If you'd like that little snippet, I'd be happy to share. It's still in the block though.
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum