Solved

RSS feed issue on my website

Posted on 2008-10-01
6
381 Views
Last Modified: 2013-11-18
Hello, I'm having an urgent issue with my RSS feeds that I use on my site. For some reason the feeds that I have are suddenly not coming on my site. Now I've checked the feeds and made sure that they are still working or if it sees information when I hit the rss feed directly and that's fine. So right now I need someone to look at my code and see if there is something even though the code has not be modified for sometime now. I really need to get his fixed because it stops a lot of stuff to happen on my site:

www.coloradocutthroat.com/index.php

It's cutting off my menus and a whole bunch of stuff
<? 

  # where is the feed located?

  $url = "http://nvgaonline.com/Forums/index.php?act=rssout&id=3";

  # create object to hold data and display output

  $rss_parser = new myRSSParser($url);

  $rawoutput = $rss_parser->getRawOutput();	# returns string containing HTML

  $items = $rawoutput['RSS']['CHANNEL'][0]['ITEM'];

?>

<ul>

<?

	for($i=0; $i<5; $i++) {

?>                

	<li><a href="<?=$items[$i]['LINK']?>" title="<?=strip_tags($items[$i]['TITLE'])?>" target="_blank"><?=strip_tags($items[$i]['TITLE'])?></a></li>

<?

}

?>

</ul>

                <br />

              </div>

              <div id="nvgaNews"><img src="images/coloradoCutthroatConnection_NVGAtheIndustry.gif" alt="" width="241" height="12" /><br />

<br />

<? 

  # where is the feed located?

  $url = "http://nvgaonline.com/Forums/index.php?act=rssout&id=2";

  # create object to hold data and display output

  $rss_parser = new myRSSParser($url);

  $rawoutput = $rss_parser->getRawOutput();	# returns string containing HTML

  $items = $rawoutput['RSS']['CHANNEL'][0]['ITEM'];

?>

<ul>

<?

	for($i=0; $i<4; $i++) {

?>                

	<li><a href="<?=$items[$i]['LINK']?>" title="<?=strip_tags($items[$i]['TITLE'])?>" target="_blank"><?=strip_tags($items[$i]['TITLE'])?></a></li>

<?

}

?>

Open in new window

0
Comment
Question by:DancingFighterG
  • 5
6 Comments
 

Author Comment

by:DancingFighterG
ID: 22619582
I'm also getting the following error on some page:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.

http://www.coloradocutthroat.com/tournamentsAndEvents.php
0
 

Author Comment

by:DancingFighterG
ID: 22619726
I've made a backup of my code and took out the rss feed out of the index.php section but I want to know what is going on with the feeds
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 22623823
Two things come immediately to mind.  Where is the code for class myRSSParser?  And where is the PHP that generates the home page.  The script is ending prematurely.  Set error reporting to E_ALL and try the home page again.  Standing by, ~Ray
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:DancingFighterG
ID: 22626196
Attached is the code snippet of the file that parsing the RSS feed!! Try it for your self using the code I posted above and let me know if it works for you
<?PHP 

	

	# Original PHP code by Chirp Internet: www.chirp.com.au

  # Please acknowledge use of this code by including this header.
 

  class myRSSParser

  {

    # keeps track of current and preceding elements

    var $tags = array();
 

    # array containing all feed data

    var $output = array();
 

    # return value for display functions

    var $retval = "";
 

    # constructor for new object

    function myRSSParser($file)

    {

      # instantiate xml-parser and assign event handlers

      $xml_parser = xml_parser_create("");

      xml_set_object($xml_parser, $this);

      xml_set_element_handler($xml_parser, "startElement", "endElement");

      xml_set_character_data_handler($xml_parser, "parseData");
 

      # open file for reading and send data to xml-parser

      $fp = @fopen($file, "r") or die("myRSSParser: Could not open $file for input");

      while($data = fread($fp, 4096)) {

        xml_parse($xml_parser, $data, feof($fp)) or die(

          sprintf("myRSSParser: Error <b>%s</b> at line <b>%d</b><br>",

          xml_error_string(xml_get_error_code($xml_parser)),

          xml_get_current_line_number($xml_parser))

        );

      }

      fclose($fp);
 

      # dismiss xml parser

      xml_parser_free($xml_parser);

    }
 

    function startElement($parser, $tagname, $attrs=array())

    {

      # RSS 2.0 - ENCLOSURE

      if($tagname == "ENCLOSURE" && $attrs) {

        $this->startElement($parser, "ENCLOSURE");

        foreach($attrs as $attr => $attrval) {

          $this->startElement($parser, $attr);

          $this->parseData($parser, $attrval);

          $this->endElement($parser, $attr);

        }

        $this->endElement($parser, "ENCLOSURE");

      }
 

      # check if this element can contain others - list may be edited

      if(preg_match("/^(RDF|RSS|CHANNEL|IMAGE|ITEM)/", $tagname)) {

        if($this->tags) {

          $depth = count($this->tags);

          list($parent, $num) = each($tmp = end($this->tags));

          if($parent) $this->tags[$depth-1][$parent][$tagname]++;

        }

        array_push($this->tags, array($tagname => array()));

      } else {

        if(!preg_match("/^(A|B|I)$/", $tagname)) {

          # add tag to tags array

          array_push($this->tags, $tagname);

        }

      }

    }
 

    function endElement($parser, $tagname)

    {

      if(!preg_match("/^(A|B|I)$/", $tagname)) {

        # remove tag from tags array

        array_pop($this->tags);

      }

    }
 

    function parseData($parser, $data)

    {

      # return if data contains no text

      if(!trim($data)) return;

      $evalcode = "\$this->output";

      foreach($this->tags as $tag) {

        if(is_array($tag)) {

          list($tagname, $indexes) = each($tag);

          $evalcode .= "[\"$tagname\"]";

          if(${$tagname}) $evalcode .= "[" . (${$tagname} - 1) . "]";

          if($indexes) extract($indexes);

        } else {

          if(preg_match("/^([A-Z]+):([A-Z]+)$/", $tag, $matches)) {

            $evalcode .= "[\"$matches[1]\"][\"$matches[2]\"]";

          } else {

            $evalcode .= "[\"$tag\"]";

          }

        }

      }

      eval("$evalcode = $evalcode . '" . addslashes($data) . "';");

    }
 

    # display a single channel as HTML

    function display_channel($data, $limit)

    {

      extract($data);

      if($IMAGE) {

        # display channel image(s)

        foreach($IMAGE as $image) $this->display_image($image);

      }

      if($TITLE) {

        # display channel information

        $this->retval .= "<h1>";

        if($LINK) $this->retval .= "<a href=\"$LINK\" target=\"_blank\">";

        $this->retval .= stripslashes($TITLE);

        if($LINK) $this->retval .= "</a>";

        $this->retval .= "</h1>\n";

        if($DESCRIPTION) $this->retval .= "<p>$DESCRIPTION</p>\n\n";

        $tmp = array();

        if($PUBDATE) $tmp[] = "<small>Published: $PUBDATE</small>";

        if($COPYRIGHT) $tmp[] = "<small>Copyright: $COPYRIGHT</small>";

        if($tmp) $this->retval .= "<p>" . implode("<br>\n", $tmp) . "</p>\n\n";

        $this->retval .= "<div class=\"divider\"><!-- --></div>\n\n";

      }

      if($ITEM) {

        # display channel item(s)

        foreach($ITEM as $item) {

          $this->display_item($item, "CHANNEL");

          if(is_int($limit) && --$limit <= 0) break;

        }

      }

    }
 

    # display a single image as HTML

    function display_image($data, $parent="")

    {

      extract($data);

      if(!$URL) return;
 

      $this->retval .= "<p>";

      if($LINK) $this->retval .= "<a href=\"$LINK\" target=\"_blank\">";

      $this->retval .= "<img src=\"$URL\"";

      if($WIDTH && $HEIGHT) $this->retval .= " width=\"$WIDTH\" height=\"$HEIGHT\"";

      $this->retval .= " border=\"0\" alt=\"$TITLE\">";

      if($LINK) $this->retval .= "</a>";

      $this->retval .= "</p>\n\n";

    }
 

    # display a single item as HTML

    function display_item($data, $parent)

    {

      extract($data);

      if(!$TITLE) return;
 

      $this->retval .=  "<p><b>";

      if($LINK) $this->retval .=  "<a href=\"$LINK\" target=\"_blank\">";

      $this->retval .= stripslashes($TITLE);

      if($LINK) $this->retval .= "</a>";

      $this->retval .=  "</b>";

      if(!$PUBDATE && $DC["DATE"]) $PUBDATE = $DC["DATE"];

      if($PUBDATE) $this->retval .= " <small>($PUBDATE)</small>";

      $this->retval .=  "</p>\n";
 

      # use feed-formatted HTML if provided

      if($CONTENT["ENCODED"]) {

        $this->retval .= "<p>" . stripslashes($CONTENT["ENCODED"]) . "</p>\n";

      } elseif($DESCRIPTION) {

        $this->retval .=  "<p>" . stripslashes($DESCRIPTION) . "</p>\n\n";

      }
 

      # RSS 2.0 - ENCLOSURE

      if($ENCLOSURE) {

        $this->retval .= "<p><small><b>Media:</b> <a href=\"{$ENCLOSURE['URL']}\">";

        $this->retval .= $ENCLOSURE['TYPE'];

        $this->retval .= "</a> ({$ENCLOSURE['LENGTH']} bytes)</small></p>\n\n";

      }
 

      if($COMMENTS) {

        $this->retval .= "<p style=\"text-align: right;\"><small>";

        $this->retval .= "<a href=\"$COMMENTS\">Comments</a>";

        $this->retval .= "</small></p>\n\n";

      }

    }
 

    function fixEncoding($input, $output_encoding)

    {

      $encoding = mb_detect_encoding($input);

      switch($encoding) {

        case 'ASCII':

        case $output_encoding:

          return $input;

        case '':

          return mb_convert_encoding($input, $output_encoding);

        default:

          return mb_convert_encoding($input, $output_encoding, $encoding);

      }

    }
 

    # display entire feed as HTML

    function getOutput($limit=false, $output_encoding='UTF-8')

    {

      $this->retval = "";

      $start_tag = key($this->output);
 

      switch($start_tag) {

        case "RSS":

          # new format - channel contains all

          foreach($this->output[$start_tag]["CHANNEL"] as $channel) {

            $this->display_channel($channel, $limit);

          }

          break;
 

        case "RDF:RDF":

          # old format - channel and items are separate

          foreach($this->output[$start_tag]["CHANNEL"] as $channel) {

            $this->display_channel($channel, $limit);

          }

          foreach($this->output[$start_tag]["ITEM"] as $item) {

            $this->display_item($item, $start_tag);

          }

          break;
 

        case "HTML":

          die("Error: cannot parse HTML document as RSS");
 

        default:

          die("Error: unrecognized start tag '$start_tag' in getOutput()");

      }
 

      return $this->fixEncoding($this->retval, $output_encoding);

    }
 

    # return raw data as array

    function getRawOutput($output_encoding='UTF-8')

    {

      return $this->fixEncoding($this->output, $output_encoding);

    }

  }

?> 

Open in new window

0
 

Author Comment

by:DancingFighterG
ID: 22626210
I need too verify if it's my code, which as been working from jump, or is it the web host!!
0
 

Author Comment

by:DancingFighterG
ID: 22652311
ok, I found that it was the web hosting that was giving me problems not my code like I thought. Thanks!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now