Topic: [php] application addon breaks template

I using a addon/plugin in my pixelpost photoblog that pulls in an xml feed for my links page.  On my local server using apache + php4 or 5 it works fine, but when i go to my webhost it breaks the template on every page and does not render where the tag is in place.

local:
http://blinking8s.com/stuff/pixelpost_feed_working.jpg

web server:
http://blinking8s.com/stuff/pixelpost_feed_break.jpg

the addon code:

<?php

//author: Guilherme Pinto (www.fotogram.com)

$addon_name = "Photoblogs.org Bookmarks Feed Parser";
$addon_description = "Parses RSS feed from Photoblogs.org and builds an unordered list with the title and the link opening in a new window. <br /><b>Make sure to change the code to point to your feed, not mine</b>.<br /> Extra tag is &lt;PHOTOBLOGS_BOOKMARKS_FEED&gt;";
$addon_version = "1.1";


$currentElements = array();
$feedArray = array();

// IMPORTANT :: change URL below for appropriate feed. YOU WANT YOUR BOOKMARKS, NOT MINE smile
readXml("http://www.photoblogs.org/rss/user/blinking8s/+sort:alpha");

// start building the list
$list = "<ul>\n";

// loop through the array building each item
foreach($feedArray as $item)
{
    $list .= "<li><a href='" . $item['link'] . "' target='_new'>" .  $item['title'] . "</a></li>\n";
}

// close the list
$list .= "</ul>\n";

$tpl = str_replace("<PHOTOBLOGS_BOOKMARKS_FEED>",$list,$tpl);

/////////////////////////////////////////////
// FUNCTIONS
/////////////////////////////////////////////

// Reads XML file into formatted html
function readXML($xmlFile)
{

    $xmlParser = xml_parser_create();
   
    xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, false);
    xml_set_element_handler($xmlParser, startElement, endElement);
    xml_set_character_data_handler($xmlParser, characterData);
     
    // fetch file using curl and write to server
    $ch = curl_init($xmlFile);
    $feed = fopen("feed.xml", "w");
   
    curl_setopt($ch, CURLOPT_FILE, $feed);
    curl_setopt($ch, CURLOPT_HEADER, 0);
   
    curl_exec($ch);
    curl_close($ch);
    fclose($feed);
   
    // read fetched and saved file and parse
    $fp = fopen("feed.xml", "r");
         
    while($data = fread($fp, filesize("feed.xml")))
    {
        xml_parse($xmlParser, $data, feof($fp));
    }
   
     xml_parser_free($xmlParser);
}

// Sets the current XML element, and pushes itself onto the element hierarchy
function startElement($parser, $name, $attrs)
{
   
    global $currentElements, $itemCount;
   
    array_push($currentElements, $name);
   
    if($name == "item"){$itemCount += 1;}

}

// Prints XML data; finds highlights and links
function characterData($parser, $data)
{

    global $currentElements, $feedArray, $itemCount;
   
    $currentCount = count($currentElements);
    $parentElement = $currentElements[$currentCount-2];
    $thisElement = $currentElements[$currentCount-1];
   
    if($parentElement == "item")
    {
     $feedArray[$itemCount-1][$thisElement] = $data;
    }
    else
    {
     switch($name)
     {
       case "title":
           break;
       case "link":
           break;
       case "description":
           break;
       case "language":
           break;
       case "item":
           break;
     }
    }
   
}

// If the XML element has ended, it is poped off the hierarchy
function endElement($parser, $name)
{
    global $currentElements;
   
    $currentCount = count($currentElements);
    if($currentElements[$currentCount-1] == $name)
    {
     array_pop($currentElements);
    }

}

?>


im no php or it guru, so im totally baffled...it works for other people on other servers, so i guess i need to figure out what is dirty/wrong with the code.

i'll be stoked once i finish my photoblog on rails though...hehe

any ideas?

Last edited by blinking8s (2006-10-10 03:30:19)

...

Re: [php] application addon breaks template

I just got home... Off the top of my head, I can't see a problem... but I'll pick through it later once I get things settled down (just got back from field trip with the kiddo, etc.).

However....

i'll be stoked once i finish my photoblog on rails though...hehe

I've been planning one of those myself. Maybe we should team up. What I'm thinking of is super simple and lightweight. It might not be robust enough for what you have in mind, but we should still knock heads on it.

Re: [php] application addon breaks template

haha...i knew you would be the first to reply to this.

I guess I need to dig through the phpinfo and find out what is different between the two, but most of that stuff just reads like garble to me. Host support came back and said it was a browser rendering issue (haha), others think its an issue with the output settings, and there is also the possibility that its an issue with the settings for globals on the web server, however on my local server i have not switched them on, and ont he web server they are on.

I first encountered the issue months ago, and still now I havent found a solution each time I have tried.

-----

haha...i would love to team up! im still in the planning stages as i learn more about ror, and ive already had several request for a photoblog on rails in the last few weeks.

just hit me up on IM.

Last edited by blinking8s (2006-10-10 22:47:35)

...

Re: [php] application addon breaks template

Kelli and I were just talking on IM last night about a photoblog (she was showing me a layout she did for one).  I suggested maybe she try doing one in Rails, and she says, "I bet Will would be interested in that" ... 2 hours later I log onto Rails Forum and see this post. big_smile

Josh Catone helps run this place
Rails Forum - Rails Jobs

Re: [php] application addon breaks template

haha...it's a small world i guess.

kelli needs to clear some space in that crazy schedule though, she's going to lose her mind if she keeps staying so busy!

I never found a solution to my issue posted here, it's def a configuration with the server that doesn't like the code, I'm just not a big enough IT/server-side geet to figure out what/why.

...