Fork me on GitHub

trying to convert phpnuke block to postnuke  Bottom

  • hmmm.. .ok.. i guess i am doing sumthin wrong.. i have been looking around... and trying to find answers. i have what i think is a basic block for phpnuke. it makes a call to an XML page located on the Teamwarfare site. i checked around, and the impression i was under was that i could simply create a block using the core PHP block. when i do.. its looking for sumthin, cause it slows down loading the page. but when everything loads... all that is there is an empty block i am adding the original black as well as what i have put into the core/php block... any help would be great... if i can get this stuff going i am planning on completely changing over to postnuke there is also a working version of it on our current site located at http://lght.cjb.net

    here is the original block

    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=The+Illuminati","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;
    ?>


    and i tried this to replace it

    Code

    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=The+Illuminati","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;


    any help would be greatly appreciated

    thanx
  • From a quick (real quick though ;)) llook at the code the output ends up in the variable $content. So add the line

    Code

    echo $content;
    to the end of the code.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Hey...Cool...lemme me (us) know if this thing works out...I would love to have it... an AA:O / TWL Match Block..

    Thanks,
    AmmoDump
  • Did you get this to work? I need one for Call of Duty United Offensive.
  • Anyone?
  • 0 users

This list is based on users active over the last 60 minutes.