php RSS feed display

Discussion in 'PHP' started by Luke Jones, Jul 6, 2007.

  1. #1
    Please help!
    To display an RSS feed on a php page I can use this include:
    <?php
    include("http://MYURL/rss2html?XMLFILE=http://news.google.com/news%3fhl%3den%26ned%3dus%26q%3dsSEARCHQUERY%26ie%3dUTF-8%26output%3drss&TEMPLATE=http://MYURL/templates/site/template.htm");
    ?>
    I want to change "SEARCHQUERY" for the query that the visitor entered in the search box on the previous page.
    How can I do this?

    Please help!
     
    Luke Jones, Jul 6, 2007 IP
  2. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Any answers?
     
    Luke Jones, Jul 7, 2007 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    query.php:
    <?php
    $searchquery = $_GET['searchquery'];
    include("http://MYURL/rss2html?XMLFILE=http://news.google.com/news%3fhl%3den%26ned%3dus%26q%3ds" . $searchquery . "%26ie%3dUTF-8%26output%3drss&TEMPLATE=http://MYURL/templates/site/template.htm");
    ?>
    PHP:
    search.html:
    
    <form name="search" action="query.php" method="post">
    Search query: 
    <input type="text" name="searchquery">
    <input type="submit" value="Submit">
    </form>
    
    HTML:
     
    crazyryan, Jul 7, 2007 IP
  4. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for your reply. Unfortunately it won't work.
     
    Luke Jones, Jul 7, 2007 IP
  5. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Crazyryan,
    It is working, thank you.
    I now have a problem with spaces in the search query. For example, "music album". The space between music and album breaks the rss feed.
    Do you know how to fix this?

    Thanks
     
    Luke Jones, Jul 7, 2007 IP
  6. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Replace
    $searchquery = $_GET['searchquery'];
    with
    $searchquery = urlencode($_GET['searchquery']);
     
    MMJ, Jul 7, 2007 IP
  7. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    MMJ, thanks for your reply.
    The error message has now changed and I'm closer to getting it to work. But it's still not working.
    Please take a look at http://searches4.info
    I'm displaying the rss feed on the page, and not as a link in the address bar, so there is still a space that breaks the feed.
    Please tell me what to do.

    Thanks
     
    Luke Jones, Jul 7, 2007 IP
  8. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ok, I've done it! I had to add urlencode($searchquery) to the rss include as well.
    Thanks a lot; I'm very grateful.
     
    Luke Jones, Jul 7, 2007 IP
  9. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I have another question, which you will probably be able to answer.
    I would like to parse all the urls in the rss feeds, so that Googlebot will index them as part of my site, with my url.
    How do I do that?

    Thanks
     
    Luke Jones, Jul 7, 2007 IP
  10. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You will have to parse the XML.

    I gotta go now, I'll see if I can help later. :)
     
    MMJ, Jul 7, 2007 IP
  11. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Ok,
    Please come back later, there are things in your head that I need!
     
    Luke Jones, Jul 7, 2007 IP
  12. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #12
    ansi, Jul 7, 2007 IP
  13. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Thanks Ansi.
    I already have a parser set up on my site, rss2html, so I don't need to create a parser. I just need to know how to parse all the urls in the feeds so that they have my url in them.
    I'm assuming I can do this with rss2html, but I don't know how.
     
    Luke Jones, Jul 7, 2007 IP
  14. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Well post your code so we can find out. :)
     
    MMJ, Jul 7, 2007 IP
  15. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    You want me to post the rss2html script here?
     
    Luke Jones, Jul 8, 2007 IP
  16. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #16
    dpending on how large it is, www.pastebin.ca might be a better soulution. this way it is all jumbled up in the little preview box.
     
    ansi, Jul 8, 2007 IP
  17. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Ok, here's the parser script:

    (1st part)

    // ==========================================================================

    $ReadErrorString = "";

    if (function_exists("FeedForAll_scripts_getRFDdate") === FALSE) {
    Function FeedForAll_scripts_getRFDdate($datestring) {
    if ($datestring[10] != "T") {
    // Might be a RFC 822 date
    if (($retVal = strtotime($datestring)) != -1) {
    return $retVal;
    }
    }

    $startTZ = 19;

    $year = substr($datestring, 0, 4);
    $month = substr($datestring, 5, 2);
    $day = substr($datestring, 8, 2);
    $hour = substr($datestring, 11, 2);
    $minute = substr($datestring, 14, 2);
    $second = substr($datestring, 17, 2);
    if ($datestring[$startTZ] == ".") {
    $curChar = $datestring[$startTZ];
    while (($startTZ < strlen($datestring)) && ($curChar != "Z") && ($curChar != "+") && ($curChar != "-")) {
    $startTZ++;
    $curChar = $datestring[$startTZ];
    }
    }
    if ($datestring[$startTZ] == "Z") {
    $offset_hour = 0;
    $offset_minute = 0;
    } else {
    if (substr($datestring, $startTZ, 1) == "-") {
    $offset_hour = substr($datestring, $startTZ+1, 2);
    $offset_minute = substr($datestring, $startTZ+4, 2);
    } else {
    $offset_hour = -1*substr($datestring, $startTZ+1, 2);
    $offset_minute = -1*substr($datestring, $startTZ+4, 2);
    }
    }
    return gmmktime((int)($hour+$offset_hour), (int)($minute+$offset_minute), (int)$second, (int)$month, (int)$day, (int)$year);
    }
    }

    if (function_exists("FeedForAll_scripts_convertEncoding") === FALSE) {
    Function FeedForAll_scripts_convertEncoding($XMLstring, $missingEncodingDefault="ISO-8859-1", $destinationEncoding="UTF-8") {
    $results = NULL;
    $inputEncoding = $missingEncodingDefault;
    $workString = $XMLstring;

    if (function_exists("mb_convert_encoding") !== FALSE) {

    if (preg_match("/<\?xml(.*)\?>/", $XMLstring, $results) === FALSE) return FALSE;

    if (count($results) == 0) return FALSE;

    $initialXMLHeader = $results[0];
    $results[0] = str_replace("'", "\"", str_replace(" ", "", $results[0]));

    if (($location = stristr($results[0], "encoding=")) !== FALSE) {
    $parts = split("\"", $location);

    if (strcasecmp($parts[1], $destinationEncoding) == 0) {
    return $XMLstring;
    }
    $inputEncoding = $parts[1];
    $modifiedXMLHeader = str_replace($inputEncoding, $destinationEncoding, $initialXMLHeader);
    } else {
    $modifiedXMLHeader = str_replace("?>", " encoding=\"$destinationEncoding\" ?>", $initialXMLHeader);
    }
    $workString = str_replace($initialXMLHeader, $modifiedXMLHeader, $workString);

    if (($newResult = mb_convert_encoding($workString, $destinationEncoding, $inputEncoding)) !== FALSE) {
    return $newResult;
    }
    }
    if (function_exists("iconv") !== FALSE) {

    if (preg_match("/<\?xml(.*)\?>/", $XMLstring, $results) === FALSE) return FALSE;

    if (count($results) == 0) return FALSE;

    $initialXMLHeader = $results[0];
    $results = str_replace(" ", "", $results);
    $results = str_replace("'", "\"", $results);

    if (($location = stristr($results[0], "encoding=")) !== FALSE) {
    $parts = split("\"", $location);

    if (strcasecmp($parts[1], $destinationEncoding) == 0) {
    return $XMLstring;
    }
    $inputEncoding = $parts[1];
    $modifiedXMLHeader = str_replace($inputEncoding, $destinationEncoding, $initialXMLHeader);
    } else {
    $modifiedXMLHeader = str_replace("?>", " encoding=\"$destinationEncoding\" ?>", $initialXMLHeader);
    }
    $workString = str_replace($initialXMLHeader, $modifiedXMLHeader, $workString);

    if (($newResult = iconv($inputEncoding, "$destinationEncoding//TRANSLIT", $workString)) !== FALSE) {
    return $newResult;
    }
    }
    return FALSE;
    }
    }

    if (function_exists("FeedForAll_preProcessXML") === FALSE) {
    Function FeedForAll_preProcessXML($XMLString) {
    //
    // It seems that the PHP XML processor doesn't like a lot of the entities
    $XMLString = str_replace("&iexcl;", "¡", $XMLString);
    $XMLString = str_replace("&cent;", "¢", $XMLString);
    $XMLString = str_replace("&pound;", "£", $XMLString);
    $XMLString = str_replace("&curren;", "¤", $XMLString);
    $XMLString = str_replace("&yen;", "Â¥", $XMLString);
    $XMLString = str_replace("&brvbar;", "¦", $XMLString);
    $XMLString = str_replace("&sect;", "§", $XMLString);
    $XMLString = str_replace("&uml;", "¨", $XMLString);
    $XMLString = str_replace("&copy;", "©", $XMLString);
    $XMLString = str_replace("&ordf;", "ª", $XMLString);
    $XMLString = str_replace("&laquo;", "«", $XMLString);
    $XMLString = str_replace("&not;", "¬", $XMLString);
    $XMLString = str_replace("&shy;", "­", $XMLString);
    $XMLString = str_replace("&reg;", "®", $XMLString);
    $XMLString = str_replace("&macr;", "¯", $XMLString);
    $XMLString = str_replace("&deg;", "°", $XMLString);
    $XMLString = str_replace("&plusmn;", "±", $XMLString);
    $XMLString = str_replace("&sup2;", "²", $XMLString);
    $XMLString = str_replace("&sup3;", "³", $XMLString);
    $XMLString = str_replace("&acute;", "´", $XMLString);
    $XMLString = str_replace("&micro;", "µ", $XMLString);
    $XMLString = str_replace("&para;", "¶", $XMLString);
    $XMLString = str_replace("&middot;", "·", $XMLString);
    $XMLString = str_replace("&cedil;", "¸", $XMLString);
    $XMLString = str_replace("&sup1;", "¹", $XMLString);
    $XMLString = str_replace("&ordm;", "º", $XMLString);
    $XMLString = str_replace("&raquo;", "»", $XMLString);
    $XMLString = str_replace("&frac14;", "¼", $XMLString);
    $XMLString = str_replace("&frac12;", "½", $XMLString);
    $XMLString = str_replace("&frac34;", "¾", $XMLString);
    $XMLString = str_replace("&iquest;", "¿", $XMLString);
    $XMLString = str_replace("&Agrave;", "À", $XMLString);
    $XMLString = str_replace("&Aacute;", "Á", $XMLString);
    $XMLString = str_replace("&Acirc;", "Â", $XMLString);
    $XMLString = str_replace("&Atilde;", "Ã", $XMLString);
    $XMLString = str_replace("&Auml;", "Ä", $XMLString);
    $XMLString = str_replace("&Aring;", "Ã…", $XMLString);
    $XMLString = str_replace("&AElig;", "Æ", $XMLString);
    $XMLString = str_replace("&Ccedil;", "Ç", $XMLString);
    $XMLString = str_replace("&Egrave;", "È", $XMLString);
    $XMLString = str_replace("&Eacute;", "É", $XMLString);
    $XMLString = str_replace("&Ecirc;", "Ê", $XMLString);
    $XMLString = str_replace("&Euml;", "Ë", $XMLString);
    $XMLString = str_replace("&Igrave;", "Ì", $XMLString);
    $XMLString = str_replace("&Iacute;", "Í", $XMLString);
    $XMLString = str_replace("&Icirc;", "ÃŽ", $XMLString);
    $XMLString = str_replace("&Iuml;", "Ï", $XMLString);
    $XMLString = str_replace("&ETH;", "Ð", $XMLString);
    $XMLString = str_replace("&Ntilde;", "Ñ", $XMLString);
    $XMLString = str_replace("&Ograve;", "Ã’", $XMLString);
    $XMLString = str_replace("&Oacute;", "Ó", $XMLString);
    $XMLString = str_replace("&Ocirc;", "Ô", $XMLString);
    $XMLString = str_replace("&Otilde;", "Õ", $XMLString);
    $XMLString = str_replace("&Ouml;", "Ö", $XMLString);
    $XMLString = str_replace("&times;", "×", $XMLString);
    $XMLString = str_replace("&Oslash;", "Ø", $XMLString);
    $XMLString = str_replace("&Ugrave;", "Ù", $XMLString);
    $XMLString = str_replace("&Uacute;", "Ú", $XMLString);
    $XMLString = str_replace("&Ucirc;", "Û", $XMLString);
    $XMLString = str_replace("&Uuml;", "Ü", $XMLString);
    $XMLString = str_replace("&Yacute;", "Ý", $XMLString);
    $XMLString = str_replace("&THORN;", "Þ", $XMLString);
    $XMLString = str_replace("&szlig;", "ß", $XMLString);
    $XMLString = str_replace("&agrave;", "à", $XMLString);
    $XMLString = str_replace("&aacute;", "á", $XMLString);
    $XMLString = str_replace("&acirc;", "â", $XMLString);
    $XMLString = str_replace("&atilde;", "ã", $XMLString);
    $XMLString = str_replace("&auml;", "ä", $XMLString);
    $XMLString = str_replace("&aring;", "Ã¥", $XMLString);
    $XMLString = str_replace("&aelig;", "æ", $XMLString);
    $XMLString = str_replace("&ccedil;", "ç", $XMLString);
    $XMLString = str_replace("&egrave;", "è", $XMLString);
    $XMLString = str_replace("&eacute;", "é", $XMLString);
    $XMLString = str_replace("&ecirc;", "ê", $XMLString);
    $XMLString = str_replace("&euml;", "ë", $XMLString);
    $XMLString = str_replace("&igrave;", "ì", $XMLString);
    $XMLString = str_replace("&iacute;", "í", $XMLString);
    $XMLString = str_replace("&icirc;", "î", $XMLString);
    $XMLString = str_replace("&iuml;", "ï", $XMLString);
    $XMLString = str_replace("&eth;", "ð", $XMLString);
    $XMLString = str_replace("&ntilde;", "ñ", $XMLString);
    $XMLString = str_replace("&ograve;", "ò", $XMLString);
    $XMLString = str_replace("&oacute;", "ó", $XMLString);
    $XMLString = str_replace("&ocirc;", "ô", $XMLString);
    $XMLString = str_replace("&otilde;", "õ", $XMLString);
    $XMLString = str_replace("&ouml;", "ö", $XMLString);
    $XMLString = str_replace("&divide;", "÷", $XMLString);
    $XMLString = str_replace("&oslash;", "ø", $XMLString);
    $XMLString = str_replace("&ugrave;", "ù", $XMLString);
    $XMLString = str_replace("&uacute;", "ú", $XMLString);
    $XMLString = str_replace("&ucirc;", "û", $XMLString);
    $XMLString = str_replace("&uuml;", "ü", $XMLString);
    $XMLString = str_replace("&yacute;", "ý", $XMLString);
    $XMLString = str_replace("&thorn;", "þ", $XMLString);
    $XMLString = str_replace("&yuml;", "ÿ", $XMLString);
    $XMLString = str_replace("&ensp;", " ", $XMLString);
    $XMLString = str_replace("&emsp;", " ", $XMLString);
    $XMLString = str_replace("&thinsp;", " ", $XMLString);
    $XMLString = str_replace("&zwnj;", "*", $XMLString);
    $XMLString = str_replace("&zwj;", "*", $XMLString);
    $XMLString = str_replace("&lrm;", "‎", $XMLString);
    $XMLString = str_replace("&rlm;", "‏", $XMLString);
    $XMLString = str_replace("&ndash;", "–", $XMLString);
    $XMLString = str_replace("&mdash;", "—", $XMLString);
    $XMLString = str_replace("&lsquo;", "‘", $XMLString);
    $XMLString = str_replace("&rsquo;", "’", $XMLString);
    $XMLString = str_replace("&sbquo;", "‚", $XMLString);
    $XMLString = str_replace("&ldquo;", "“", $XMLString);
    $XMLString = str_replace("&rdquo;", "”", $XMLString);
    $XMLString = str_replace("&bdquo;", "„", $XMLString);
    $XMLString = str_replace("&dagger;", "†", $XMLString);
    $XMLString = str_replace("&Dagger;", "‡", $XMLString);
    $XMLString = str_replace("&bull;", "•", $XMLString);
    $XMLString = str_replace("&hellep;", "…", $XMLString);
    $XMLString = str_replace("&permil;", "‰", $XMLString);
    $XMLString = str_replace("&prime;", "′", $XMLString);
    $XMLString = str_replace("&Prime;", "″", $XMLString);
    $XMLString = str_replace("&lsaquo;", "‹", $XMLString);
    $XMLString = str_replace("&rsaquo;", "›", $XMLString);
    $XMLString = str_replace("&oline;", "‾", $XMLString);
    $XMLString = str_replace("&frasl;", "⁄", $XMLString);
    $XMLString = str_replace("&euro;", "⁈", $XMLString);
    return $XMLString;
    }
    }

    if (function_exists("FeedForAll_scripts_readFile") === FALSE) {
    Function FeedForAll_scripts_readFile($filename, $useFopenURL, $useCaching = 0) {
    GLOBAL $connectTimeoutLimit;
    GLOBAL $ReadErrorString;

    if ($useCaching);

    $ReadErrorString = "";
    $result = "";
    if (stristr($filename, "://")) {
    if ($useFopenURL) {
    if (($fd = @fopen($filename, "rb")) === FALSE) {
    return FALSE;
    }
    while (($data = fread($fd, 4096)) != "") {
    $result .= $data;
    }
    fclose($fd);
    } else {
    // This is a URL so use CURL
    $curlHandle = curl_init();
    curl_setopt($curlHandle, CURLOPT_URL, $filename);
    curl_setopt($curlHandle, CURLOPT_HEADER, 0);
    curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curlHandle, CURLOPT_USERAGENT, "FeedForAll rssFilter.php v2");
    // curl_setopt($curlHandle, CURLOPT_AUTOREFERER, 1);
    curl_setopt($curlHandle, CURLOPT_REFERER, $filename);
    if (!(ini_get("safe_mode") || ini_get("open_basedir"))) {
    curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, 1);
    }
    if (isset($connectTimeoutLimit) && $connectTimeoutLimit != 0) {
    curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, $connectTimeoutLimit);
    }
    curl_setopt($curlHandle, CURLOPT_MAXREDIRS, 10);
    $result = curl_exec($curlHandle);
    if (curl_errno($curlHandle)) {
    $ReadErrorString = curl_error($curlHandle);
    curl_close($curlHandle);
    return FALSE;
    }
    curl_close($curlHandle);
    }
    } else {
    // This is a local file, so use fopen
    if (($fd = @fopen($filename, "rb")) === FALSE) {
    return FALSE;
    }
    while (($data = fread($fd, 4096)) != "") {
    $result .= $data;
    }
    fclose($fd);
    }
    return $result;
    }
    }

    class rootItemClass {
    var $operateAs;
    var $title;
    var $description;
    var $contentEncoded;
    var $link;
    var $pubDate;
    var $pubDate_t;
    var $pubDateDC;
    var $enclosureURL;
    var $enclosureLength;
    var $enclosureType;
    var $categoryArray;
    var $category;
    var $categoryDomain;
    var $guid;
    var $guidIsPermaLink;
    var $author;
    var $comments;
    var $source;
    var $sourceURL;
    var $creativeCommons;
    var $rssMeshExtra;
    var $rssMeshFeedImageTitle;
    var $rssMeshFeedImageUrl;
    var $rssMeshFeedImageLink;
    var $rssMeshFeedImageDescription;
    var $rssMeshFeedImageHeight;
    var $rssMeshFeedImageWidth;
    var $atomID;
    var $atomUpdated;
    var $atomContent;
    var $atomContentStartPos;
    var $atomAuthorEmail;

    var $contentEncodedUsed;

    var $itemStartPos;
    var $itemFullText;

    // Constructor
    Function rootItemClass($operateAs) {
    $this->operateAs = $operateAs;
    $this->title = "";
    $this->description = "";
    $this->contentEncoded = "";
    $this->link = "";
    $this->pubDate = "";
    $this->pubDate_t = 0;
    $this->pubDateDC = "";
    $this->enclosureURL = "";
    $this->enclosureLength = "";
    $this->enclosureType = "";
    $this->categoryArray = Array();
    $this->category = "";
    $this->categoryDomain = "";
    $this->guid = "";
    $this->guidIsPermaLink = "";
    $this->author = "";
    $this->comments = "";
    $this->source = "";
    $this->sourceURL = "";
    $this->creativeCommons = "";
    $this->rssMeshExtra = "";
    $this->rssMeshFeedImageTitle = "";
    $this->rssMeshFeedImageUrl = "";
    $this->rssMeshFeedImageLink = "";
    $this->rssMeshFeedImageDescription = "";
    $this->rssMeshFeedImageHeight = "";
    $this->rssMeshFeedImageWidth = "";
    $this->atomID = "";
    $this->atomUpdated = "";
    $this->atomContent = "";
    $this->atomContentStartPos = 0;
    $this->atomAuthorEmail = "";

    $this->contentEncodedUsed = 0;

    $this->itemStartPos = 0;
    $this->itemFullText = "";
    }

    Function getValueOf($elementName) {
    if ($elementName == "~~~ItemTitle~~~") {
    return $this->title;
    }
    elseif ($elementName == "~~~ItemDescription~~~") {
    return $this->description;
    }
    elseif ($elementName == "~~~ItemContentEncoded~~~") {
    return $this->contentEncoded;
    }
    elseif ($elementName == "~~~ItemLink~~~") {
    return $this->link;
    }
    elseif ($elementName == "~~~ItemPubDate~~~") {
    return $this->pubDate;
    }
    elseif ($elementName == "~~~ItemPubDateAsNumber~~~") {
    return $this->pubDate_t;
    }
    elseif ($elementName == "~~~ItemEnclosureUrl~~~") {
    return $this->enclosureURL;
    }
    elseif ($elementName == "~~~ItemEnclosureType~~~") {
    return $this->enclosureType;
    }
    elseif ($elementName == "~~~ItemEnclosureLength~~~") {
    return $this->enclosureLength;
    }
    elseif ($elementName == "~~~ItemGuid~~~") {
    return $this->guid;
    }
    elseif ($elementName == "~~~ItemAuthor~~~") {
    return $this->author;
    }
    elseif ($elementName == "~~~ItemComments~~~") {
    return $this->comments;
    }
    elseif ($elementName == "~~~ItemSource~~~") {
    return $this->source;
    }
    elseif ($elementName == "~~~ItemSourceUrl~~~") {
    return $this->sourceURL;
    }
    elseif ($elementName == "~~~ItemCategory~~~") {
    if (count($this->categoryArray)) {
    return $this->categoryArray[0]["Category"];
    }
    }
    elseif ($elementName == "~~~ItemCategoryDomain~~~") {
    if (count($this->categoryArray)) {
    return $this->categoryArray[0]["Domain"];
    }
    }
    elseif ($elementName == "~~~ItemCreativeCommons~~~") {
    return $this->creativeCommons;
    }
    elseif ($elementName == "~~~ItemRssMeshExtra~~~") {
    return $this->rssMeshExtra;
    }
    elseif ($elementName == "~~~ItemRssMeshFeedImageTitle~~~") {
    return $this->rssMeshFeedImageTitle;
    }
    elseif ($elementName == "~~~ItemRssMeshFeedImageUrl~~~") {
    return $this->rssMeshFeedImageUrl;
    }
    elseif ($elementName == "~~~ItemRssMeshFeedImageLink~~~") {
    return $this->rssMeshFeedImageLink;
    }
    elseif ($elementName == "~~~ItemRssMeshFeedImageDescription~~~") {
    return $this->rssMeshFeedImageDescription;
    }
    elseif ($elementName == "~~~ItemRssMeshFeedImageHeight~~~") {
    return $this->rssMeshFeedImageHeight;
    }
    elseif ($elementName == "~~~ItemRssMeshFeedImageWidth~~~") {
    return $this->rssMeshFeedImageWidth;
    }
    return NULL;
    }

    Function getArrayOfFields() {
    $result = Array();

    $result[] = "~~~ItemTitle~~~";
    $result[] = "~~~ItemDescription~~~";
    $result[] = "~~~ItemContentEncoded~~~";
    $result[] = "~~~ItemLink~~~";
    $result[] = "~~~ItemPubDate~~~";
    $result[] = "~~~ItemPubDateAsNumber~~~";
    $result[] = "~~~ItemEnclosureUrl~~~";
    $result[] = "~~~ItemEnclosureType~~~";
    $result[] = "~~~ItemEnclosureLength~~~";
    $result[] = "~~~ItemGuid~~~";
    $result[] = "~~~ItemAuthor~~~";
    $result[] = "~~~ItemComments~~~";
    $result[] = "~~~ItemSource~~~";
    $result[] = "~~~ItemSourceUrl~~~";
    $result[] = "~~~ItemCategory~~~";
    $result[] = "~~~ItemCategoryDomain~~~";
    $result[] = "~~~ItemCreativeCommons~~~";
    $result[] = "~~~ItemRssMeshExtra~~~";
    $result[] = "~~~ItemRssMeshFeedImageTitle~~~";
    $result[] = "~~~ItemRssMeshFeedImageUrl~~~";
    $result[] = "~~~ItemRssMeshFeedImageLink~~~";
    $result[] = "~~~ItemRssMeshFeedImageDescription~~~";
    $result[] = "~~~ItemRssMeshFeedImageHeight~~~";
    $result[] = "~~~ItemRssMeshFeedImageWidth~~~";

    return $result;
    }

    }

    $startingClassName = "rootItemClass";
    if (function_exists("rssFilter_extendClass")) {
    $startingClassName = rssFilter_extendClass($startingClassName);
    }

    if (function_exists("FeedForAll_parseExtensions_extendClass")) {
    $currentBaseClassName = FeedForAll_parseExtensions_extendClass($startingClassName);
    } else {
    $currentBaseClassName = $startingClassName;
    }
    eval('class baseItemClassWithExtensions extends ' . $currentBaseClassName . ' {}');

    class baseItemClass extends baseItemClassWithExtensions {
    Function baseItemClass($operateAs) {
    $parentClass = get_parent_class($this);
    $this->$parentClass($operateAs);
    }
    }
     
    Luke Jones, Jul 8, 2007 IP
  18. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #18
    yep, i'm not reading that...
     
    ansi, Jul 8, 2007 IP
  19. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    (second part)

    class rootRSSParserClass {
    var $operateAs;
    var $gotROOT;
    var $feedTYPE;
    var $wholeString;
    var $level;
    var $tag;
    var $noFutureItems;

    var $currentItem;

    var $FeedTitle;
    var $FeedDescription;
    var $FeedContentEncoded;
    var $FeedLink;
    var $FeedPubDate;
    var $FeedPubDateDC;
    var $FeedPubDate_t;
    var $FeedLastBuildDate;
    var $FeedImageURL;
    var $FeedImageTitle;
    var $FeedImageLink;
    var $FeedImageDescription;
    var $FeedImageHeight;
    var $FeedImageWidth;
    var $FeedCreativeCommons;
    var $FeedAtomUpdated;
    var $FeedAtomContent;
    var $FeedAtomContentStartPos;
    var $FeedAtomAuthorEmail;

    var $contentEncodedUsed;

    var $noon_t;

    var $Items;

    //
    var $insideChannel = FALSE;
    var $level_channel;
    var $insideChannelImage = FALSE;
    var $level_channelImage;
    var $insideItem = FALSE;
    var $level_item;
    var $insideAtomAuthor = FALSE;

    Function rootRSSParserClass($operateAs) {
    $this->operateAs = $operateAs;
    $this->gotROOT = 0;
    $this->feedTYPE = "RSS";
    $this->wholeString = "";
    $this->level = 0;
    $this->tag = "";
    $this->noFutureItems = 0;;

    $this->FeedImageURL = "";
    $this->FeedImageTitle = "";
    $this->FeedImageLink = "";
    $this->FeedImageDescription = "";
    $this->FeedImageHeight = "";
    $this->FeedImageWidth = "";
    $this->currentItem;

    $this->FeedTitle = "";
    $this->FeedDescription = "";
    $this->FeedContentEncoded = "";
    $this->FeedLink = "";
    $this->FeedPubDate = "";
    $this->FeedPubDateDC = "";
    $this->FeedPubDate_t = 0;
    $this->FeedLastBuildDate = "";
    $this->FeedImageURL = "";
    $this->FeedImageTitle = "";
    $this->FeedImageLink = "";
    $this->FeedImageDescription = "";
    $this->FeedImageHeight = "";
    $this->FeedImageWidth = "";
    $this->FeedCreativeCommons = "";
    $this->FeedAtomUpdated = "";
    $this->FeedAtomContent = "";
    $this->FeedAtomContentStartPos = 0;
    $this->FeedAtomAuthorEmail = "";

    $this->contentEncodedUsed = 0;

    $this->noon_t = mktime(12, 0, 0, date("m"), date("d"), date("Y"));

    $this->Items = Array();

    //
    $this->insideChannel = FALSE;
    $this->level_channel = 0;
    $this->insideChannelImage = FALSE;
    $this->level_channelImage = 0;
    $this->insideItem = FALSE;
    $this->level_item = 0;
    }

    function startElement($parser, $tagName, $attrs) {
    GLOBAL $debugLevel;

    $this->level++;
    $this->tag = $tagName;
    if ($this->gotROOT == 0) {
    $this->gotROOT = 1;
    if (strstr($tagName, "RSS")) {
    $this->feedTYPE = "RSS";
    }
    elseif (strstr($tagName, "RDF")) {
    $this->feedTYPE = "RDF";
    }
    elseif (strstr($tagName, "FEE")) {
    $this->feedTYPE = "FEE";
    $this->insideChannel = TRUE;
    $this->level_channel = 1;
    }
    }
    elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) {
    if (isset($debugLevel) && ($debugLevel >= 2)) {
    echo "DIAG: startElement(\$parser, $tagName, \$attrs)<br>\n";
    }

    $this->insideItem = TRUE;
    $this->level_item = $this->level;
    $this->currentItem = new baseItemClass($this->operateAs);

    //
    // Find the start of the <item> or <entry>
    $this->currentItem->ItemStartPos = xml_get_current_byte_index($parser);
    if ($this->wholeString[$this->currentItem->ItemStartPos] != "<") {
    $startToHere = substr($this->wholeString, 0, $this->currentItem->ItemStartPos);
    $this->currentItem->ItemStartPos = strrpos($startToHere, "<");
    }
    }
    elseif ($this->insideChannel && (($tagName == "AUTHOR") && ($this->feedTYPE == "FEE"))) {
    $this->insideAtomAuthor = TRUE;
    }
    elseif ($this->insideItem && (($tagName == "AUTHOR") && ($this->feedTYPE == "FEE"))) {
    $this->insideAtomAuthor = TRUE;
    }
    elseif (($this->insideItem) && ($tagName == "ENCLOSURE")) {
    if (isset($attrs["URL"])) {
    $this->currentItem->enclosureURL = $attrs["URL"];
    }
    if (isset($attrs["TYPE"])) {
    $this->currentItem->enclosureType = $attrs["TYPE"];
    }
    if (isset($attrs["LENGTH"])) {
    $this->currentItem->enclosureLength = $attrs["LENGTH"];
    }
    }
    elseif (($this->insideItem) && ($tagName == "SOURCE")) {
    if (isset($attrs["URL"])) {
    $this->currentItem->sourceURL = $attrs["URL"];
    }
    }
    elseif (($this->insideItem) && ($tagName == "CATEGORY")) {
    if (isset($attrs["DOMAIN"])) {
    $this->currentItem->categoryDomain = $attrs["DOMAIN"];
    }
    }
    elseif (($this->insideItem) && ($tagName == "GUID")) {
    if (isset($attrs["ISPERMALINK"])) {
    $this->currentItem->guidIsPermaLink = $attrs["ISPERMALINK"];
    }
    }
    elseif (($tagName == "LINK") && ($this->feedTYPE == "FEE")) {
    if ($this->insideItem) {
    if (isset($attrs["REL"]) && ($attrs["REL"] == "enclosure")) {
    $this->currentItem->enclosureURL = $attrs["HREF"];
    $this->currentItem->enclosureType = $attrs["TYPE"];
    $this->currentItem->enclosureLength = $attrs["LENGTH"];
    }
    elseif (isset($attrs["HREF"]) && ((isset($attrs["TYPE"]) && ($attrs["TYPE"] == "text/html")) || !isset($attrs["TYPE"]))) {
    $this->currentItem->link = $attrs["HREF"];
    }
    } else {
    if (isset($attrs["HREF"]) && ((isset($attrs["TYPE"]) && ($attrs["TYPE"] == "text/html")) || !isset($attrs["TYPE"]))) {
    $this->FeedLink = $attrs["HREF"];
    }
    }
    }
    elseif ($tagName == "CHANNEL") {
    $this->insideChannel = TRUE;
    $this->level_channel = $this->level;
    }
    elseif (($tagName == "IMAGE") && ($this->insideChannel == TRUE)) {
    $this->insideChannelImage = TRUE;
    $this->level_channelImage = $this->level;
    }
    elseif ($tagName == "CONTENT") {
    if ($this->insideItem == TRUE) {
    if (isset($attrs["TYPE"]) && ($attrs["TYPE"] == "xhtml")) {
    //
    // Find the start of the <content ... >
    $this->currentItem->atomContentStartPos = xml_get_current_byte_index($parser);
    if ($this->wholeString[$this->currentItem->atomContentStartPos] != "<") {
    $startToHere = substr($this->wholeString, 0, $this->currentItem->atomContentStartPos);
    $this->currentItem->atomContentStartPos = strrpos($startToHere, "<");
    }
    }
    } else {
    if (isset($attrs["TYPE"]) && ($attrs["TYPE"] == "xhtml")) {
    //
    // Find the start of the <content ... >
    $this->FeedAtomContentStartPos = xml_get_current_byte_index($parser);
    if ($this->wholeString[$this->FeedAtomContentStartPos] != "<") {
    $startToHere = substr($this->wholeString, 0, $this->FeedAtomContentStartPos);
    $this->FeedAtomContentStartPos = strrpos($startToHere, "<");
    }
    }
    }
    }
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_startElemend($parser, $this, $tagName, $attrs);
    }
    }

    function endElement($parser, $tagName) {
    GLOBAL $debugLevel;

    $this->tag = "";
    $this->level--;
    if (($this->insideItem) && ($tagName == "CATEGORY")) {
    $this->currentItem->categoryArray[] = Array("Category" => $this->currentItem->category, "Domain" => $this->currentItem->categoryDomain);
    $this->currentItem->category = "";
    $this->currentItem->categoryDomain = "";
    }
    elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) {
    if (isset($debugLevel) && ($debugLevel >= 2)) {
    echo "DIAG: endElement(\$parser, $tagName)<br>\n";
    }

    $this->UseItem = TRUE;

    //
    // Do any special processing to convert ATOM to RSS 2.0
    if ($this->feedTYPE == "FEE") {
    if ($this->currentItem->guid == "") {
    // There was no GUID, use ID
    $this->currentItem->guid = $this->currentItem->atomID;
    $this->currentItem->guidIsPermaLink = "false";
    }
    }

    //
    // The the whole item string
    $pos = xml_get_current_byte_index($parser) - 2;
    if ($this->wholeString[$pos] != ">") {
    $hereToEnd = substr($this->wholeString, $pos);
    $closePos = strpos($hereToEnd, ">");
    } else {
    $closePos = 0;
    }
    $this->currentItem->itemFullText = substr($this->wholeString, $this->currentItem->ItemStartPos, $pos + $closePos - $this->currentItem->ItemStartPos+1);

    //
    // Get the pubDate from pubDate first and then dc:date
    if (trim($this->currentItem->pubDate) != "") {
    $this->currentItem->pubDate = trim($this->currentItem->pubDate);
    $this->currentItem->pubDate_t = strtotime($this->currentItem->pubDate);
    }
    elseif (($this->feedTYPE == "FEE") && (trim($this->currentItem->atomUpdated) != "")) {
    $this->currentItem->atomUpdated = trim($this->currentItem->atomUpdated);
    $this->currentItem->pubDate_t = FeedForAll_scripts_getRFDdate($this->currentItem->atomUpdated);
    $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t);
    }
    elseif (trim($this->currentItem->pubDateDC) != "") {
    $this->currentItem->pubDate_t = FeedForAll_scripts_getRFDdate($this->currentItem->pubDateDC);
    $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t);
    } else {
    $this->currentItem->pubDate_t = time();
    $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t);
    }

    if (($this->operateAs == "rssFilter") && function_exists("rssFilter_useItem")) {
    GLOBAL $_REQUEST;

    $this->UseItem = rssFilter_useItem($this->currentItem);

    if (isset($_REQUEST["testScript"])) {
    if ($this->UseItem) {
    echo "USING Item: ".htmlentities($this->currentItem->title)."<br>\n";
    } else {
    echo "NOT Using: ".htmlentities($this->currentItem->title)."<br>\n";
    }
    }
    }

    if ($this->operateAs == "rssMesh") {
    if (($this->itemLimit >= 0) && (count($this->Items) >= $this->itemLimit)) {
    $this->UseItem = FALSE;
    }
    }
    elseif ($this->operateAs == "rss2html") {
    if (($useUniq = FeedForAll_rss2html_UseUniqueLink($this->currentItem->title, $this->currentItem->description, $this->currentItem->link, $this->currentItem->guid)) != -1) {
    if ($useUniq == 0) {
    if (isset($debugLevel) && ($debugLevel >= 2)) {
    echo "DIAG: FeedForAll_rss2html_UseUniqueLink() => 0, Not using<br>\n";
    }

    $this->UseItem = FALSE;
    }
    }
    if ($this->noFutureItems) {
    if (($this->currentItem->pubDate_t - $this->noon_t) > 43200) {
    if (isset($debugLevel) && ($debugLevel >= 2)) {
    echo "DIAG: future pubdate, Not using<br>\n";
    }
    $this->UseItem = FALSE;
    }
    }
    }

    if ($this->UseItem) {
    if (isset($debugLevel) && ($debugLevel >= 2)) {
    echo "DIAG: Using item \"".$this->currentItem->title."\"<br>\n";
    }

    //
    // Clean up some of the values
    $this->currentItem->title = trim($this->currentItem->title);
    $this->currentItem->description = trim($this->currentItem->description);
    if ($this->feedTYPE == "FEE") {
    $this->currentItem->atomContent = trim($this->currentItem->atomContent);
    $this->currentItem->description = $this->currentItem->atomContent;
    } else {
    $this->currentItem->description = $this->currentItem->description;
    }
    if (trim($this->currentItem->contentEncoded) == "") {
    if ($this->operateAs != "rssMesh") {
    $this->currentItem->contentEncoded = $this->currentItem->description;
    }
    } else {
    $this->currentItem->contentEncoded = trim($this->currentItem->contentEncoded);
    }
    if (trim($this->currentItem->description) == "") {
    $this->currentItem->description = trim($this->currentItem->contentEncoded);
    }
    $this->currentItem->link = trim($this->currentItem->link);
    $this->currentItem->guid = trim($this->currentItem->guid);
    $this->currentItem->guidIsPermaLink = trim($this->currentItem->guidIsPermaLink);
    if ($this->feedTYPE == "FEE") {
    $this->currentItem->atomAuthorEmail = trim($this->currentItem->atomAuthorEmail);
    $this->currentItem->author = trim($this->currentItem->atomAuthorEmail);
    }
    $this->currentItem->author = trim($this->currentItem->author);
    if ($this->currentItem->creativeCommons == "") {
    $this->currentItem->creativeCommons = trim($this->FeedCreativeCommons);
    } else {
    $this->currentItem->creativeCommons = trim($this->currentItem->creativeCommons);
    }
    if ($this->operateAs == "rss2sql") {
    if (($this->currentItem->source == "") && ($this->sourceFeedURL != "")) {
    $this->currentItem->source = $this->FeedTitle;
    $this->currentItem->sourceURL = $this->sourceFeedURL;
    }
    }
    $this->currentItem->source = trim($this->currentItem->source);
    $this->currentItem->sourceURL = trim($this->currentItem->sourceURL);
    $this->currentItem->enclosureURL = trim($this->currentItem->enclosureURL);
    $this->currentItem->enclosureLength = trim($this->currentItem->enclosureLength);
    $this->currentItem->enclosureType = trim($this->currentItem->enclosureType);
    $this->currentItem->comments = trim($this->currentItem->comments);
    $this->currentItem->rssMeshExtra = trim($this->currentItem->rssMeshExtra);
    $this->currentItem->rssMeshFeedImageTitle = trim($this->currentItem->rssMeshFeedImageTitle);
    $this->currentItem->rssMeshFeedImageUrl = trim($this->currentItem->rssMeshFeedImageUrl);
    $this->currentItem->rssMeshFeedImageLink = trim($this->currentItem->rssMeshFeedImageLink);
    $this->currentItem->rssMeshFeedImageDescription = trim($this->currentItem->rssMeshFeedImageDescription);
    $this->currentItem->rssMeshFeedImageHeight = trim($this->currentItem->rssMeshFeedImageHeight);
    $this->currentItem->rssMeshFeedImageWidth = trim($this->currentItem->rssMeshFeedImageWidth);
    if ($this->operateAs == "rss2html") {
    //
    // Escape any links
    $this->currentItem->link = FeedForAll_rss2html_EscapeLink($this->currentItem->link);
    $this->currentItem->guid = FeedForAll_rss2html_EscapeLink($this->currentItem->guid);
    $this->currentItem->creativeCommons = FeedForAll_rss2html_EscapeLink($this->currentItem->creativeCommons);
    $this->currentItem->sourceURL = FeedForAll_rss2html_EscapeLink($this->currentItem->sourceURL);
    $this->currentItem->enclosureURL = FeedForAll_rss2html_EscapeLink($this->currentItem->enclosureURL);
    $this->currentItem->comments = FeedForAll_rss2html_EscapeLink($this->currentItem->comments);
    $this->currentItem->rssMeshFeedImageUrl = FeedForAll_rss2html_EscapeLink($this->currentItem->rssMeshFeedImageUrl);
    $this->currentItem->rssMeshFeedImageLink = FeedForAll_rss2html_EscapeLink($this->currentItem->rssMeshFeedImageLink);
    }
     
    Luke Jones, Jul 8, 2007 IP
  20. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    (And the third, and final part)

    //
    if ($this->currentItem->contentEncodedUsed) {
    $this->contentEncodedUsed = 1;
    }
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
    }
    if ($this->UseItem) {
    $this->Items[] = $this->currentItem;
    if (isset($debugLevel) && ($debugLevel >= 3)) {
    echo "DIAG: adding to items, count=".count($this->Items)."<br>\n";
    }
    }
    } else {
    unset($this->currentItem);
    }
    $this->insideItem = FALSE;
    $this->level_item = 0;
    return;
    }
    elseif ($this->insideAtomAuthor && ($tagName == "AUTHOR")) {
    $this->insideAtomAuthor = FALSE;
    }
    elseif (($tagName == "IMAGE") && ($this->insideChannelImage)) {
    $this->FeedImageTitle = trim($this->FeedImageTitle);
    $this->FeedImageURL = trim($this->FeedImageURL);
    $this->FeedImageLink = trim($this->FeedImageLink);
    $this->FeedImageDescription = trim($this->FeedImageDescription);
    $this->FeedImageHeight = trim($this->FeedImageHeight);
    $this->FeedImageWidth = trim($this->FeedImageWidth);
    if ($this->operateAs == "rss2html") {
    //
    // Escape any links
    $this->FeedImageURL = FeedForAll_rss2html_EscapeLink($this->FeedImageURL);
    $this->FeedImageLink = FeedForAll_rss2html_EscapeLink($this->FeedImageLink);
    }
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
    }
    $this->insideChannelImage = FALSE;
    $this->level_channelImage = 0;
    return;
    }
    elseif ((($tagName == "CHANNEL") && ($this->feedTYPE != "FEE")) || (($tagName == "FEED") && ($this->feedTYPE == "FEE"))) {
    $this->FeedPubDate = trim($this->FeedPubDate);
    $this->FeedPubDateDC = trim($this->FeedPubDateDC);
    $this->FeedAtomUpdated = trim($this->FeedAtomUpdated);
    //
    // Get the pubDate from pubDate first and then dc:date
    if (trim($this->FeedPubDate) != "") {
    $this->FeedPubDate_t = strtotime($this->FeedPubDate);
    }
    elseif (($this->feedTYPE == "FEE") && ($this->FeedAtomUpdated != "")) {
    $this->FeedAtomUpdated = trim($this->FeedAtomUpdated);
    $this->FeedPubDate_t = FeedForAll_scripts_getRFDdate($this->FeedAtomUpdated);
    $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
    }
    elseif (trim($this->FeedPubDateDC) != "") {
    $this->FeedPubDate_t = FeedForAll_scripts_getRFDdate($this->FeedPubDateDC);
    $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
    }
    elseif (trim($this->FeedLastBuildDate) != "") {
    $this->FeedPubDate_t = strtotime($this->FeedLastBuildDate);
    $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
    } else {
    $this->FeedPubDate_t = time();
    $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
    }
    $this->FeedTitle = trim($this->FeedTitle);
    if ($this->feedTYPE == "FEE") {
    $this->FeedAtomContent = trim($this->FeedAtomContent);
    $this->FeedDescription = $this->FeedAtomContent;
    } else {
    $this->FeedDescription = $this->FeedDescription;
    }
    if (trim($this->FeedContentEncoded) == "") {
    $this->FeedContentEncoded = $this->FeedDescription;
    }
    $this->FeedLink = trim($this->FeedLink);
    if ($this->operateAs == "rss2html") {
    //
    // Escape any links
    $this->FeedLink = FeedForAll_rss2html_EscapeLink($this->FeedLink);
    $this->FeedCreativeCommons = FeedForAll_rss2html_EscapeLink($this->FeedCreativeCommons);
    }
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
    }
    $this->insideChannel = FALSE;
    $this->level_channel = 0;
    return;
    }
    elseif ($this->level == $this->level_channel) {
    if ($tagName == "TITLE") {
    $this->FeedTitle = trim($this->FeedTitle);
    }
    elseif (($tagName == "DESCRIPTION") || ($tagName == "TAGLINE")) {
    $this->FeedDescription = trim($this->FeedDescription);
    }
    elseif ($tagName == "CONTENT:ENCODED") {
    $this->FeedContentEncoded = trim($this->FeedContentEncoded);
    }
    elseif ($tagName == "LINK") {
    $this->FeedLink = trim($this->FeedLink);
    }
    }
    elseif ($tagName == "CONTENT") {
    if ($this->insideItem == TRUE) {
    // Lets look to see if the content is
    if ($this->currentItem->atomContentStartPos) {
    //
    // The the whole <content ... > string
    $pos = xml_get_current_byte_index($parser) - 2;
    if ($this->wholeString[$pos] != ">") {
    $hereToEnd = substr($this->wholeString, $pos);
    $closePos = strpos($hereToEnd, ">");
    } else {
    $closePos = 0;
    }
    $fullContentText = substr($this->wholeString, $this->currentItem->atomContentStartPos, $pos + $closePos - $this->currentItem->atomContentStartPos+1);
    // Find the end of <content
    $start = strpos($fullContentText, ">");
    $fullContentText = substr($fullContentText, $start+1);
    // Find the end of <div
    $start = strpos($fullContentText, ">");
    $fullContentText = substr($fullContentText, $start+1);
    // Find the start of </content
    $start = strrpos($fullContentText, "<");
    $fullContentText = substr($fullContentText, 0, $start-1);
    // Find the start of </div
    $start = strrpos($fullContentText, "<");
    $this->currentItem->atomContent = substr($fullContentText, 0, $start-1);
    $this->currentItem->atomContentStartPos = 0;
    }
    } else {
    // Lets look to see if the content is
    if ($this->FeedAtomContentStartPos) {
    //
    // The the whole <content ... > string
    $pos = xml_get_current_byte_index($parser) - 2;
    if ($this->wholeString[$pos] != ">") {
    $hereToEnd = substr($this->wholeString, $pos);
    $closePos = strpos($hereToEnd, ">");
    } else {
    $closePos = 0;
    }
    $fullContentText = substr($this->wholeString, $this->FeedAtomContentStartPos, $pos + $closePos - $this->FeedAtomContentStartPos+1);
    // Find the end of <content
    $start = strpos($fullContentText, ">");
    $fullContentText = substr($fullContentText, $start+1);
    // Find the end of <div
    $start = strpos($fullContentText, ">");
    $fullContentText = substr($fullContentText, $start+1);
    // Find the start of </content
    $start = strrpos($fullContentText, "<");
    $fullContentText = substr($fullContentText, 0, $start-1);
    // Find the start of </div
    $start = strrpos($fullContentText, "<");
    $this->FeedAtomContent = substr($fullContentText, 0, $start-1);
    $this->FeedAtomContentStartPos = 0;
    }
    }
    }
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
    }
    }

    function characterData($parser, $data) {
    if (($data == "") || ($data == NULL)) {
    } else {
    if (($this->insideItem) && ($this->level == $this->level_item+1)) {
    switch ($this->tag) {
    case "TITLE":
    $this->currentItem->title .= $data;
    break;

    case "DESCRIPTION":
    $this->currentItem->description .= $data;
    break;

    case "CONTENT:ENCODED":
    $this->currentItem->contentEncodedUsed = 1;
    $this->currentItem->contentEncoded .= $data;
    break;

    case "SUMMARY":
    $this->currentItem->description .= $data;
    break;

    case "LINK":
    $this->currentItem->link .= $data;
    break;

    case "PUBDATE":
    $this->currentItem->pubDate .= $data;
    break;

    case "MODIFIED":
    $this->currentItem->pubDateDC .= $data;
    break;

    case "GUID":
    $this->currentItem->guid .= $data;
    break;

    case "ID":
    case "ATOM:ID":
    $this->currentItem->atomID .= $data;
    break;

    case "AUTHOR":
    $this->currentItem->author .= $data;
    break;

    case "COMMENTS":
    $this->currentItem->comments .= $data;
    break;

    case "SOURCE":
    $this->currentItem->source .= $data;
    break;

    case "CATEGORY":
    $this->currentItem->category .= $data;
    break;

    case "CREATIVECOMMONS:LICENSE":
    $this->currentItem->creativeCommons .= $data;
    break;

    case "RSSMESH:EXTRA":
    $this->currentItem->rssMeshExtra .= $data;
    break;

    case "RSSMESH:FEEDIMAGETITLE":
    $this->currentItem->rssMeshFeedImageTitle .= $data;
    break;

    case "RSSMESH:FEEDIMAGEURL":
    $this->currentItem->rssMeshFeedImageUrl .= $data;
    break;

    case "RSSMESH:FEEDIMAGELINK":
    $this->currentItem->rssMeshFeedImageLink .= $data;
    break;

    case "RSSMESH:FEEDIMAGEDESCRIPTION":
    $this->currentItem->rssMeshFeedImageDescription .= $data;
    break;

    case "RSSMESH:FEEDIMAGEHEIGHT":
    $this->currentItem->rssMeshFeedImageHeight .= $data;
    break;

    case "RSSMESH:FEEDIMAGEWIDTH":
    $this->currentItem->rssMeshFeedImageWidth .= $data;
    break;

    case "UPDATED":
    case "ATOM:UPDATED":
    $this->currentItem->atomUpdated .= $data;
    break;

    case "CONTENT":
    case "ATOM:CONTENT":
    $this->currentItem->atomContent .= $data;
    break;

    default:
    if ($this->tag == "DC:DATE") {
    $this->currentItem->pubDateDC .= $data;
    }
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_characterData($parser, $this, $data);
    }
    }
    }
    elseif ($this->insideChannelImage) {
    switch ($this->tag) {
    case "TITLE":
    $this->FeedImageTitle .= $data;
    break;

    case "URL":
    $this->FeedImageURL .= $data;
    break;

    case "LINK":
    $this->FeedImageLink .= $data;
    break;

    case "DESCRIPTION":
    $this->FeedImageDescription .= $data;
    break;

    case "HEIGHT":
    $this->FeedImageHeight .= $data;
    break;

    case "WIDTH":
    $this->FeedImageWidth .= $data;
    break;

    default:
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_characterData($parser, $this, $data);
    }
    }
    }
    elseif (($this->insideChannel) && ($this->level == $this->level_channel+1)) {
    switch ($this->tag) {
    case "TITLE":
    $this->FeedTitle .= $data;
    break;

    case "DESCRIPTION":
    $this->FeedDescription .= $data;
    break;

    case "CONTENT:ENCODED":
    $this->FeedContentEncoded .= $data;
    break;

    case "TAGLINE":
    $this->FeedDescription .= $data;
    break;

    case "LINK":
    $this->FeedLink .= $data;
    break;

    case "PUBDATE":
    $this->FeedPubDate .= $data;
    break;

    case "MODIFIED":
    $this->FeedPubDateDC .= $data;
    break;

    case "LASTBUILDDATE":
    $this->FeedLastBuildDate .= $data;
    break;

    case "CREATIVECOMMONS:LICENSE":
    $this->FeedCreativeCommons .= $data;
    break;

    case "UPDATED":
    case "ATOM:UPDATED":
    $this->FeedAtomUpdated .= $data;
    break;

    case "CONTENT":
    case "ATOM:CONTENT":
    $this->FeedAtomContent .= $data;
    break;

    default:
    if ($this->tag == "DC:DATE") {
    $this->FeedPubDateDC .= $data;
    }
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_characterData($parser, $this, $data);
    }
    }
    }
    elseif (($this->insideAtomAuthor) && ($this->insideItem) && ($this->level == $this->level_item+2)) {
    switch ($this->tag) {
    case "EMAIL":
    case "ATOM:EMAIL":
    $this->currentItem->atomAuthorEmail .= $data;
    break;

    default:
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_characterData($parser, $this, $data);
    }
    }
    }
    elseif (($this->insideAtomAuthor) && ($this->insideChannel) && ($this->level == $this->level_channel+2)) {
    switch ($this->tag) {
    case "EMAIL":
    case "ATOM:EMAIL":
    $this->FeedAtomAuthorEmail .= $data;
    break;

    default:
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_characterData($parser, $this, $data);
    }
    }
    } else {
    if (FeedForAll_parseExtensions() === TRUE) {
    FeedForAll_parseExtensions_characterData($parser, $this, $data);
    }
    }
    }
    }
    }

    if (function_exists("FeedForAll_parseExtensions_extendParserClass")) {
    $currentBaseClassName = FeedForAll_parseExtensions_extendParserClass("rootRSSParserClass");
    } else {
    $currentBaseClassName = "rootRSSParserClass";
    }
    eval('class baseParserClassWithExtensions extends ' . $currentBaseClassName . ' {}');

    class baseParserClass extends baseParserClassWithExtensions {
    Function baseParserClass($operateAs) {
    $parentClass = get_parent_class($this);
    $this->$parentClass($operateAs);
    }
    }

    ?>
     
    Luke Jones, Jul 8, 2007 IP