home *** CD-ROM | disk | FTP | other *** search
/ notepage.net / notepage.net.tar / notepage.net / dev / temp / FeedForAll_XMLParser.inc.php < prev    next >
PHP Script  |  2015-09-23  |  66KB  |  1,728 lines

  1. <?php
  2. //
  3. // rssFilter.php Filter RSS feeds
  4. //
  5. // Copyright 2007 NotePage, Inc.
  6. // http://www.feedforall.com
  7. //
  8. // NotePage, Inc. grants registerd users of our FeedForAll and/or
  9. // FeedForAll Mac product(s) the right to install and use the
  10. // rssFilter.php script free of charge.
  11. // Please refer to the EULA included in the download for full license
  12. // terms and conditions.
  13. //
  14. // $Id: FeedForAll_XMLParser.inc.php,v 3.25 2014/10/22 22:31:38 housley Exp $
  15. //
  16. // $Log: FeedForAll_XMLParser.inc.php,v $
  17. // Revision 3.25  2014/10/22 22:31:38  housley
  18. // Added default timezone
  19. //
  20. // Revision 3.24  2010/03/16 22:31:38  housley
  21. // Fix for PHP 5.3
  22. //
  23. // Revision 3.23  2010/03/06 02:26:06  housley
  24. // Change needed to make PHP 5.3.x work with the initializer
  25. //
  26. // Revision 3.22  2009/11/23 02:05:12  housley
  27. // Switch to explode() since PHP 5.3.0 made split() decrepit
  28. //
  29. // Revision 3.21  2009/08/04 23:17:11  housley
  30. // Fix error related to using a string as a function
  31. //
  32. // Revision 3.20  2009/02/22 20:50:39  housley
  33. // Try an prevent any content encoding
  34. //
  35. // Revision 3.19  2008/10/18 12:52:36  housley
  36. // Update useragent so feedburner won't detect and change functionality
  37. // for us
  38. //
  39. // Revision 3.18  2008/10/10 00:34:33  housley
  40. // Set the encoding that is accepted
  41. //
  42. // Revision 3.17  2008/01/26 13:12:20  housley
  43. // Hide warning/error messages from the system that shouldn't have
  44. // been displayed
  45. //
  46. // Revision 3.16  2007/10/07 11:51:58  housley
  47. // In processing Atom 1.0 allow atom:summary to be used to populate item
  48. // description.
  49. //
  50. // Revision 3.15  2007/08/02 20:01:48  housley
  51. // Fix finding the bottom sections in Atom and RDF feed types
  52. //
  53. // Revision 3.14  2007/07/23 14:20:05  housley
  54. // In FeedForAll_fopen():
  55. // * Actually read the headers
  56. // * Check the return code
  57. // * return the result
  58. //
  59. // Revision 3.13  2007/07/23 13:24:40  housley
  60. // Check that the returned page is not an error page
  61. //
  62. // Revision 3.12  2007/07/19 15:29:32  housley
  63. // Fix a possible problem with FeedForAll_fopen()
  64. //
  65. // Revision 3.11  2007/07/17 12:29:39  housley
  66. // Initialize a class variable
  67. //
  68. // Revision 3.10  2007/07/12 12:49:51  housley
  69. // Be pickier on the Atom 1.0 link usage, since Blogger has started using a
  70. // link type that is not in the spec.
  71. //
  72. // Revision 3.9  2007/07/08 13:42:39  housley
  73. // Create my own version of fopen() to try and get files when cURL is not
  74. // available.  FeedForAll_fopen() is based on just connecting to the server
  75. // and reading the results.
  76. //
  77. // Revision 3.8  2007/06/21 12:25:04  housley
  78. // Fix the parsing to find the last element when using the expat library, PHP4
  79. //
  80. // Revision 3.7  2007/05/30 19:04:02  housley
  81. // Add the ability to have 3 more extra fields in RSSMesh
  82. //
  83. // Revision 3.6  2007/05/27 14:31:17  housley
  84. // Add debug statements to the non-cached version of FeedForAll_scripts_readFile()
  85. //
  86. // Revision 3.5  2007/05/25 10:22:51  housley
  87. // In rssMesh.php, fix the count comparison.  It was adding one too many items.
  88. //
  89. // Revision 3.4  2007/05/04 11:54:19  housley
  90. // When checking for caching, check a function only in the caching module
  91. //
  92. // Revision 3.3  2007/05/03 18:53:16  housley
  93. // Different versions of PHP accept "today at noon" or "noon today", but don't
  94. // accept the other.  Create the value of noon at startup and use that
  95. // always.
  96. //
  97. // Revision 3.2  2007/05/03 16:13:13  housley
  98. // It seems the XML parser doesn't like most of the HTML entities
  99. //
  100. // Revision 3.1  2007/04/25 12:33:47  housley
  101. // Some feeds use <dc:date> with dates in a completely wrong format,
  102. // try and get a date from the value.
  103. //
  104. // Revision 3.0  2007/04/16 14:23:03  housley
  105. // Release version 3.0 of the scripts
  106. //
  107. // Revision 2.30  2007/04/13 18:30:10  housley
  108. // * Atom:content might need whole string so always make it available
  109. // * atom:content of type xhtml is in a div that needs to be stripped and
  110. //   then used as is.
  111. //
  112. // Revision 2.29  2007/04/11 12:11:11  housley
  113. // * Add more debug messages
  114. // * Reorder the add item code some
  115. //
  116. // Revision 2.28  2007/04/11 10:40:38  housley
  117. // Add some debug messages
  118. //
  119. // Revision 2.27  2007/04/06 11:18:03  housley
  120. // Since <dc:creator> isn't specified to be an email, we can't move it to
  121. // <author>
  122. //
  123. // Revision 2.26  2007/04/06 11:08:58  housley
  124. // Add support for the Dublin Core (dc) namespace
  125. //
  126. // Revision 2.25  2007/04/05 11:37:05  housley
  127. // Rename DcCreator so it can't interfer with a DublinCore extension
  128. //
  129. // Revision 2.24  2007/04/04 20:55:46  housley
  130. // Add the ability to set CURLOPT_CONNECTTIMEOUT
  131. //
  132. // Revision 2.23  2007/04/04 18:43:26  housley
  133. // * Update rssMesh to properly pass content:encoded through
  134. // * Make sure <description> is always populated
  135. // * Don't populate content:encoded from description in rssMesh
  136. //
  137. // Revision 2.22  2007/03/30 13:14:00  housley
  138. // Move where pubDate_t and pubDate are manipulated to the beging of the
  139. // code that processes an item.  This removes redundant caculations of
  140. // pubDate_t
  141. //
  142. // Revision 2.21  2007/03/30 01:35:16  housley
  143. // Use pubDate_t for the pubDateAsNumber since it already there
  144. //
  145. // Revision 2.20  2007/03/30 01:34:12  housley
  146. // Move the very specific rssFilter code to rssFilter.php
  147. //
  148. // Revision 2.19  2007/03/28 23:23:11  housley
  149. // Add support for Atom <author><email> into RSS 2.0 <author>
  150. //
  151. // Revision 2.18  2007/03/28 13:26:30  housley
  152. // Support atom:content, at least in a basic form
  153. //
  154. // Revision 2.17  2007/03/27 23:49:02  housley
  155. // For non-RSS 2.0 formats create a valid pubDate from the appropiate date
  156. //
  157. // Revision 2.16  2007/03/27 23:16:31  housley
  158. // Add support for Atom 1.0 atom:updated date field
  159. //
  160. // Revision 2.15  2007/03/25 11:24:21  housley
  161. // Only to the replace on the one array value that we care about
  162. //
  163. // Revision 2.14  2007/03/19 14:13:24  housley
  164. // Fix some small bugs in the new code, and test
  165. //
  166. // Revision 2.13  2007/03/15 18:37:32  housley
  167. // Fix filter ordering
  168. //
  169. // Revision 2.12  2007/03/15 13:50:34  housley
  170. // * Clear the current tag, in endElement()
  171. // * Trim the feed level items at end of channel
  172. //
  173. // Revision 2.11  2007/03/15 01:21:24  housley
  174. // Changes needed for when there extra parsing files aren't included
  175. //
  176. // Revision 2.10  2007/03/14 17:55:05  housley
  177. // Support atom's id as guid
  178. //
  179. // Revision 2.9  2007/03/07 00:23:12  housley
  180. // Add isEmpty, notEmpty, alphaBefore and alphaAfter
  181. //
  182. // Revision 2.8  2007/03/06 13:31:05  housley
  183. // Change from ignoreCase to matchCase
  184. //
  185. // Revision 2.7  2007/03/05 21:13:11  housley
  186. // * Add support for working with pubDate as a date or time
  187. // * Show which items will and won't be used
  188. //
  189. // Revision 2.6  2007/03/05 15:10:07  housley
  190. // Add "Ends With"
  191. //
  192. // Revision 2.5  2007/03/05 01:12:16  housley
  193. // Move FeedForAll_scripts_convertEncoding and FeedForAll_scripts_readFile
  194. // into FeedForAll_XMLParser.inc.php, because they are used in every file
  195. //
  196. // Revision 2.4  2007/03/04 22:54:03  housley
  197. // Add methods to get the filter capabilities
  198. //
  199. // Revision 2.3  2007/03/04 13:41:53  housley
  200. // * Pass the parsing mode to the item class
  201. // * Cleanup the feed level processing
  202. // * rss2html uses the separate parser too
  203. //
  204. // Revision 2.2  2007/03/04 12:13:52  housley
  205. // If the feed is atom, check the link type if any
  206. //
  207. // Revision 2.1  2007/03/04 02:10:08  housley
  208. // Move the parser used by the paid scripts into its own file.
  209. //
  210. //
  211. //
  212.  
  213.  
  214. // ==========================================================================
  215. // Below this point of the file there are no user editable options.  Your
  216. // are welcome to make any modifications that you wish to any of the code
  217. // below, but that is not necessary for normal use.
  218. // ==========================================================================
  219.  
  220. $ReadErrorString = "";
  221.  
  222. date_default_timezone_set('America/New_York');
  223.  
  224. if (function_exists("FeedForAll_scripts_getRFDdate") === FALSE) {
  225.   Function FeedForAll_scripts_getRFDdate($datestring) {
  226.     if ($datestring[10] != "T") {
  227.       // Might be a RFC 822 date
  228.       if (($retVal = strtotime($datestring)) != -1) {
  229.         return $retVal;
  230.       }
  231.     }
  232.  
  233.     $startTZ = 19;
  234.     
  235.     $year = substr($datestring, 0, 4);
  236.     $month = substr($datestring, 5, 2);
  237.     $day = substr($datestring, 8, 2);
  238.     $hour = substr($datestring, 11, 2);
  239.     $minute = substr($datestring, 14, 2);
  240.     $second = substr($datestring, 17, 2);
  241.     if ($datestring[$startTZ] == ".") {
  242.       $curChar = $datestring[$startTZ];
  243.       while (($startTZ < strlen($datestring)) && ($curChar != "Z") && ($curChar != "+") && ($curChar != "-")) {
  244.         $startTZ++;
  245.         $curChar = $datestring[$startTZ];
  246.       }
  247.     }
  248.     if ($datestring[$startTZ] == "Z") {
  249.       $offset_hour = 0;
  250.       $offset_minute = 0;
  251.     } else {
  252.       if (substr($datestring, $startTZ, 1) == "-") {
  253.         $offset_hour = substr($datestring, $startTZ+1, 2);
  254.         $offset_minute = substr($datestring, $startTZ+4, 2);
  255.       } else {
  256.         $offset_hour = -1*substr($datestring, $startTZ+1, 2);
  257.         $offset_minute = -1*substr($datestring, $startTZ+4, 2);
  258.       }
  259.     }
  260.     return gmmktime((int)($hour+$offset_hour), (int)($minute+$offset_minute), (int)$second, (int)$month, (int)$day, (int)$year);
  261.   }
  262. }
  263.  
  264. if (function_exists("FeedForAll_scripts_convertEncoding") === FALSE) {
  265.   Function FeedForAll_scripts_convertEncoding($XMLstring, $missingEncodingDefault="ISO-8859-1", $destinationEncoding="UTF-8") {
  266.     $results = NULL;
  267.     $inputEncoding = $missingEncodingDefault;
  268.     $workString = $XMLstring;
  269.  
  270.     if (function_exists("mb_convert_encoding") !== FALSE) {
  271.  
  272.       if (preg_match("/<\?xml(.*)\?>/", $XMLstring, $results) === FALSE) return FALSE;
  273.  
  274.       if (count($results) == 0) return FALSE;
  275.  
  276.       $initialXMLHeader = $results[0];
  277.       $results[0] = str_replace("'", "\"", str_replace(" ", "", $results[0]));
  278.  
  279.       if (($location = stristr($results[0], "encoding=")) !== FALSE) {
  280.         $parts = explode("\"", $location);
  281.  
  282.         if (strcasecmp($parts[1], $destinationEncoding) == 0) {
  283.           return $XMLstring;
  284.         }
  285.         $inputEncoding = $parts[1];
  286.         $modifiedXMLHeader = str_replace($inputEncoding, $destinationEncoding, $initialXMLHeader);
  287.       } else {
  288.         $modifiedXMLHeader = str_replace("?>", " encoding=\"$destinationEncoding\" ?>", $initialXMLHeader);
  289.       }
  290.       $workString = str_replace($initialXMLHeader, $modifiedXMLHeader, $workString);
  291.  
  292.       if (($newResult = mb_convert_encoding($workString, $destinationEncoding, $inputEncoding)) !== FALSE) {
  293.         return $newResult;
  294.       }
  295.     }
  296.     if (function_exists("iconv") !== FALSE) {
  297.  
  298.       if (preg_match("/<\?xml(.*)\?>/", $XMLstring, $results) === FALSE) return FALSE;
  299.  
  300.       if (count($results) == 0) return FALSE;
  301.  
  302.       $initialXMLHeader = $results[0];
  303.       $results = str_replace(" ", "", $results);
  304.       $results = str_replace("'", "\"", $results);
  305.  
  306.       if (($location = stristr($results[0], "encoding=")) !== FALSE) {
  307.         $parts = explode("\"", $location);
  308.  
  309.         if (strcasecmp($parts[1], $destinationEncoding) == 0) {
  310.           return $XMLstring;
  311.         }
  312.         $inputEncoding = $parts[1];
  313.         $modifiedXMLHeader = str_replace($inputEncoding, $destinationEncoding, $initialXMLHeader);
  314.       } else {
  315.         $modifiedXMLHeader = str_replace("?>", " encoding=\"$destinationEncoding\" ?>", $initialXMLHeader);
  316.       }
  317.       $workString = str_replace($initialXMLHeader, $modifiedXMLHeader, $workString);
  318.  
  319.       if (($newResult = iconv($inputEncoding, "$destinationEncoding//TRANSLIT", $workString)) !== FALSE) {
  320.         return $newResult;
  321.       }
  322.     }
  323.     return FALSE;
  324.   }
  325. }
  326.  
  327. if (function_exists("FeedForAll_preProcessXML") === FALSE) {
  328.   Function FeedForAll_preProcessXML($XMLString) {
  329.     //
  330.     // It seems that the PHP XML processor doesn't like a lot of the entities
  331.     $XMLString = str_replace("¡", "¡", $XMLString);
  332.     $XMLString = str_replace("¢", "¢", $XMLString);
  333.     $XMLString = str_replace("£", "£", $XMLString);
  334.     $XMLString = str_replace("¤", "¤", $XMLString);
  335.     $XMLString = str_replace("¥", "¥", $XMLString);
  336.     $XMLString = str_replace("¦", "¦", $XMLString);
  337.     $XMLString = str_replace("§", "§", $XMLString);
  338.     $XMLString = str_replace("¨", "¨", $XMLString);
  339.     $XMLString = str_replace("©", "©", $XMLString);
  340.     $XMLString = str_replace("ª", "ª", $XMLString);
  341.     $XMLString = str_replace("«", "«", $XMLString);
  342.     $XMLString = str_replace("¬", "¬", $XMLString);
  343.     $XMLString = str_replace("­", "­", $XMLString);
  344.     $XMLString = str_replace("®", "®", $XMLString);
  345.     $XMLString = str_replace("¯", "¯", $XMLString);
  346.     $XMLString = str_replace("°", "°", $XMLString);
  347.     $XMLString = str_replace("±", "±", $XMLString);
  348.     $XMLString = str_replace("²", "²", $XMLString);
  349.     $XMLString = str_replace("³", "³", $XMLString);
  350.     $XMLString = str_replace("´", "´", $XMLString);
  351.     $XMLString = str_replace("µ", "µ", $XMLString);
  352.     $XMLString = str_replace("¶", "¶", $XMLString);
  353.     $XMLString = str_replace("·", "·", $XMLString);
  354.     $XMLString = str_replace("¸", "¸", $XMLString);
  355.     $XMLString = str_replace("¹", "¹", $XMLString);
  356.     $XMLString = str_replace("º", "º", $XMLString);
  357.     $XMLString = str_replace("»", "»", $XMLString);
  358.     $XMLString = str_replace("¼", "¼", $XMLString);
  359.     $XMLString = str_replace("½", "½", $XMLString);
  360.     $XMLString = str_replace("¾", "¾", $XMLString);
  361.     $XMLString = str_replace("¿", "¿", $XMLString);
  362.     $XMLString = str_replace("À", "À", $XMLString);
  363.     $XMLString = str_replace("Á", "Á", $XMLString);
  364.     $XMLString = str_replace("Â", "Â", $XMLString);
  365.     $XMLString = str_replace("Ã", "Ã", $XMLString);
  366.     $XMLString = str_replace("Ä", "Ä", $XMLString);
  367.     $XMLString = str_replace("Å", "Å", $XMLString);
  368.     $XMLString = str_replace("Æ", "Æ", $XMLString);
  369.     $XMLString = str_replace("Ç", "Ç", $XMLString);
  370.     $XMLString = str_replace("È", "È", $XMLString);
  371.     $XMLString = str_replace("É", "É", $XMLString);
  372.     $XMLString = str_replace("Ê", "Ê", $XMLString);
  373.     $XMLString = str_replace("Ë", "Ë", $XMLString);
  374.     $XMLString = str_replace("Ì", "Ì", $XMLString);
  375.     $XMLString = str_replace("Í", "Í", $XMLString);
  376.     $XMLString = str_replace("Î", "Î", $XMLString);
  377.     $XMLString = str_replace("Ï", "Ï", $XMLString);
  378.     $XMLString = str_replace("Ð", "Ð", $XMLString);
  379.     $XMLString = str_replace("Ñ", "Ñ", $XMLString);
  380.     $XMLString = str_replace("Ò", "Ò", $XMLString);
  381.     $XMLString = str_replace("Ó", "Ó", $XMLString);
  382.     $XMLString = str_replace("Ô", "Ô", $XMLString);
  383.     $XMLString = str_replace("Õ", "Õ", $XMLString);
  384.     $XMLString = str_replace("Ö", "Ö", $XMLString);
  385.     $XMLString = str_replace("×", "×", $XMLString);
  386.     $XMLString = str_replace("Ø", "Ø", $XMLString);
  387.     $XMLString = str_replace("Ù", "Ù", $XMLString);
  388.     $XMLString = str_replace("Ú", "Ú", $XMLString);
  389.     $XMLString = str_replace("Û", "Û", $XMLString);
  390.     $XMLString = str_replace("Ü", "Ü", $XMLString);
  391.     $XMLString = str_replace("Ý", "Ý", $XMLString);
  392.     $XMLString = str_replace("Þ", "Þ", $XMLString);
  393.     $XMLString = str_replace("ß", "ß", $XMLString);
  394.     $XMLString = str_replace("à", "à", $XMLString);
  395.     $XMLString = str_replace("á", "á", $XMLString);
  396.     $XMLString = str_replace("â", "â", $XMLString);
  397.     $XMLString = str_replace("ã", "ã", $XMLString);
  398.     $XMLString = str_replace("ä", "ä", $XMLString);
  399.     $XMLString = str_replace("å", "å", $XMLString);
  400.     $XMLString = str_replace("æ", "æ", $XMLString);
  401.     $XMLString = str_replace("ç", "ç", $XMLString);
  402.     $XMLString = str_replace("è", "è", $XMLString);
  403.     $XMLString = str_replace("é", "é", $XMLString);
  404.     $XMLString = str_replace("ê", "ê", $XMLString);
  405.     $XMLString = str_replace("ë", "ë", $XMLString);
  406.     $XMLString = str_replace("ì", "ì", $XMLString);
  407.     $XMLString = str_replace("í", "í", $XMLString);
  408.     $XMLString = str_replace("î", "î", $XMLString);
  409.     $XMLString = str_replace("ï", "ï", $XMLString);
  410.     $XMLString = str_replace("ð", "ð", $XMLString);
  411.     $XMLString = str_replace("ñ", "ñ", $XMLString);
  412.     $XMLString = str_replace("ò", "ò", $XMLString);
  413.     $XMLString = str_replace("ó", "ó", $XMLString);
  414.     $XMLString = str_replace("ô", "ô", $XMLString);
  415.     $XMLString = str_replace("õ", "õ", $XMLString);
  416.     $XMLString = str_replace("ö", "ö", $XMLString);
  417.     $XMLString = str_replace("÷", "÷", $XMLString);
  418.     $XMLString = str_replace("ø", "ø", $XMLString);
  419.     $XMLString = str_replace("ù", "ù", $XMLString);
  420.     $XMLString = str_replace("ú", "ú", $XMLString);
  421.     $XMLString = str_replace("û", "û", $XMLString);
  422.     $XMLString = str_replace("ü", "ü", $XMLString);
  423.     $XMLString = str_replace("ý", "ý", $XMLString);
  424.     $XMLString = str_replace("þ", "þ", $XMLString);
  425.     $XMLString = str_replace("ÿ", "ÿ", $XMLString);
  426.     $XMLString = str_replace(" ", " ", $XMLString);
  427.     $XMLString = str_replace(" ", " ", $XMLString);
  428.     $XMLString = str_replace(" ", " ", $XMLString);
  429.     $XMLString = str_replace("‌", "‌", $XMLString);
  430.     $XMLString = str_replace("‍", "‍", $XMLString);
  431.     $XMLString = str_replace("‎", "‎", $XMLString);
  432.     $XMLString = str_replace("‏", "‏", $XMLString);
  433.     $XMLString = str_replace("–", "–", $XMLString);
  434.     $XMLString = str_replace("—", "—", $XMLString);
  435.     $XMLString = str_replace("‘", "‘", $XMLString);
  436.     $XMLString = str_replace("’", "’", $XMLString);
  437.     $XMLString = str_replace("‚", "‚", $XMLString);
  438.     $XMLString = str_replace("“", "“", $XMLString);
  439.     $XMLString = str_replace("”", "”", $XMLString);
  440.     $XMLString = str_replace("„", "„", $XMLString);
  441.     $XMLString = str_replace("†", "†", $XMLString);
  442.     $XMLString = str_replace("‡", "‡", $XMLString);
  443.     $XMLString = str_replace("•", "•", $XMLString);
  444.     $XMLString = str_replace("&hellep;", "…", $XMLString);
  445.     $XMLString = str_replace("‰", "‰", $XMLString);
  446.     $XMLString = str_replace("′", "′", $XMLString);
  447.     $XMLString = str_replace("″", "″", $XMLString);
  448.     $XMLString = str_replace("‹", "‹", $XMLString);
  449.     $XMLString = str_replace("›", "›", $XMLString);
  450.     $XMLString = str_replace("‾", "‾", $XMLString);
  451.     $XMLString = str_replace("⁄", "⁄", $XMLString);
  452.     $XMLString = str_replace("€", "⁈", $XMLString);
  453.     return $XMLString;
  454.   }
  455. }
  456.  
  457. if (function_exists("FeedForAll_fopen") === FALSE) {
  458.   Function FeedForAll_fopen($url) {
  459.     //
  460.     // The internal "hidden function is to do some initialization
  461.     if (function_exists("h_FeedForAll_fopen") === FALSE) {
  462.       Function h_FeedForAll_fopen($url, $RedirectHistory) {
  463.         GLOBAL $connectTimeoutLimit;
  464.         GLOBAL $ReadErrorString;
  465.  
  466.         //
  467.         // Divide the URL into parts so we can work with it
  468.         $parts = parse_url($url);
  469.         $thepath = $parts["path"];
  470.         if (isset($parts["query"])) {
  471.           $thepath .= "?$parts[query]";
  472.         }
  473.         $domain = $parts["host"];
  474.         if (isset($parts["port"])) {
  475.           $port = $parts["port"];
  476.         } else {
  477.           $port = 80;
  478.         }
  479.  
  480.         $errno = "";
  481.         $errstr = "";
  482.         if (isset($connectTimeoutLimit) && $connectTimeoutLimit != 0) {
  483.           $fd = @fsockopen($domain, $port, $errno, $errstr, $connectTimeoutLimit);
  484.         } else {
  485.           $fd = @fsockopen($domain, $port, $errno, $errstr);
  486.         }
  487.         if ($fd !== FALSE) {
  488.           $request = "GET $thepath HTTP/1.0\r\n";
  489.           $request .= "Host: $domain\r\n";
  490.           $request .= "Content-Encoding: identity\r\n";
  491.           $request .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1;) Gecko/2008070208 Firefox/3.0.1\r\n\r\n";
  492.           @fputs($fd, $request);
  493.           
  494.           $headerLine = 0;
  495.  
  496.           do {
  497.             if (@feof($fd) !== FALSE) {
  498.               // End of file
  499.               break;
  500.             }
  501.             $header = @fgets($fd, 1024);
  502.             if (($header[0] == "\n") || ($header[0] == "\r")) {
  503.               // End of the headers
  504.               break;
  505.             }
  506.             if ($headerLine == 0) {
  507.               $firstHeaderLine = $header;
  508.             }
  509.             $headerLine++;
  510.             if (substr($header, 0, 9) == "Location:") {
  511.               //
  512.               // We got a location header, try to fetch from the new location
  513.               @fclose($fd);
  514.               if (count($RedirectHistory) < 10) {
  515.                 $loc = trim(substr($header, 9));
  516.                 //
  517.                 // Check if the redirect is relative or absolute
  518.                 if (substr($loc, 0, 7) != "http://") {
  519.                   if ($loc[0] == "/") {
  520.                     if ($port == 80) {
  521.                       $loc = "http://$domain$loc";
  522.                     } else {
  523.                       $loc = "http://$domain:$port$loc";
  524.                     }
  525.                   } else {
  526.                     //
  527.                     // The path is relative so we need the existing path
  528.                     $path = dirname($parts["path"])."/$loc";
  529.                     if ($port == 80) {
  530.                       $loc = "http://$domain$path";
  531.                     } else {
  532.                       $loc = "http://$domain:$port$path";
  533.                     }
  534.                   }
  535.                 }
  536.                 for ($x = count($RedirectHistory)-1; $x >= 0; $x--) {
  537.                   if (!strcmp($loc, $RedirectHistory[$x])) {
  538.                     $ReadErrorString = "Redirection loop detected";
  539.                     return FALSE;
  540.                   }
  541.                 }
  542.                 $RedirectHistory[count($RedirectHistory)] = $loc;
  543.                 return h_FeedForAll_fopen($loc, $RedirectHistory);
  544.               } else {
  545.                 $ReadErrorString = "Too many redirects";
  546.                 return FALSE;
  547.               }
  548.             }
  549.           } while (1);
  550.         } else {
  551.           $ReadErrorString = $errstr;
  552.           return FALSE;
  553.         }
  554.         //
  555.         // Get the result code
  556.         $parts = explode(" ", $firstHeaderLine);
  557.         if (($parts[1] < 200) || (300 <= $parts[1])) {
  558.           $ReadErrorString = "HTTP ERROR: ".$parts[1];
  559.           @fclose($fd);
  560.           return FALSE;
  561.         }
  562.         
  563.         $result = "";
  564.         while (($data = fread($fd, 4096)) != "") {
  565.           $result .= $data;
  566.         }
  567.         @fclose($fd);
  568.         return $result;
  569.       }
  570.     }
  571.  
  572.     $RedirectHistory = Array();
  573.  
  574.     return h_FeedForAll_fopen($url, $RedirectHistory);
  575.   }
  576. }
  577.  
  578. if (function_exists("FeedForAll_scripts_readFile") === FALSE) {
  579.   Function FeedForAll_scripts_readFile($filename, $useFopenURL, $useCaching = 0) {
  580.     GLOBAL $connectTimeoutLimit;
  581.     GLOBAL $ReadErrorString;
  582.     GLOBAL $debugLevel;
  583.  
  584.     if ($useCaching);
  585.  
  586.     if (isset($debugLevel) && ($debugLevel >= 1)) {
  587.       echo "DIAG: FeedForAll_scripts_readFile($filename, $useFopenURL, $useCaching <= 0)<br>\n";
  588.     }
  589.     
  590.     $ReadErrorString = "";
  591.     $result = "";
  592.     if (stristr($filename, "://")) {
  593.       if ($useFopenURL == 1) {
  594.         if (($fd = @fopen($filename, "rb")) === FALSE) {
  595.           if (isset($debugLevel) && ($debugLevel >= 1)) {
  596.             echo "DIAG: FeedForAll_scripts_readFile(): fopen() failed<br>\n";
  597.           }
  598.           return FALSE;
  599.         }
  600.         while (($data = @fread($fd, 4096)) != "") {
  601.           $result .= $data;
  602.         }
  603.         @fclose($fd);
  604.       }
  605.       elseif ($useFopenURL == -1) {
  606.         $result = FeedForAll_fopen($filename);
  607.       } else {
  608.         FeedForAll_fopen($filename);
  609.         // This is a URL so use CURL
  610.         $curlHandle = curl_init();
  611.         curl_setopt($curlHandle, CURLOPT_URL, $filename);
  612.         curl_setopt($curlHandle, CURLOPT_HEADER, 0);
  613.         curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
  614.         curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1;) Gecko/2008070208 Firefox/3.0.1");
  615.         //    curl_setopt($curlHandle, CURLOPT_AUTOREFERER, 1);
  616.         curl_setopt($curlHandle, CURLOPT_REFERER, $filename);
  617.         if (!(ini_get("safe_mode") || ini_get("open_basedir"))) {
  618.           curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, 1);
  619.         }
  620.         if (isset($connectTimeoutLimit) && $connectTimeoutLimit != 0) {
  621.           curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, $connectTimeoutLimit);
  622.         }
  623.         curl_setopt($curlHandle, CURLOPT_MAXREDIRS, 10);
  624.         curl_setopt($curlHandle, CURLOPT_ENCODING, 'identity');
  625.         $result = curl_exec($curlHandle);
  626.         if (curl_errno($curlHandle)) {
  627.           $ReadErrorString = curl_error($curlHandle);
  628.           curl_close($curlHandle);
  629.           return FALSE;
  630.         }
  631.         $http_response = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
  632.         if (($http_response < 200) || (300 <= $http_response)) {
  633.           $ReadErrorString = "HTTP ERROR: $http_response";
  634.           curl_close($curlHandle);
  635.           return FALSE;
  636.         }
  637.         curl_close($curlHandle);
  638.       }
  639.     } else {
  640.       // This is a local file, so use fopen
  641.       if (($fd = @fopen($filename, "rb")) === FALSE) {
  642.         if (isset($debugLevel) && ($debugLevel >= 1)) {
  643.           echo "DIAG: FeedForAll_scripts_readFile(): fopen(): failed<br>\n";
  644.         }
  645.         return FALSE;
  646.       }
  647.       while (($data = @fread($fd, 4096)) != "") {
  648.         $result .= $data;
  649.       }
  650.       @fclose($fd);
  651.       if (isset($debugLevel) && ($debugLevel >= 1)) {
  652.         echo "DIAG: FeedForAll_scripts_readFile(): flock() successeded<br>\n";
  653.       }
  654.     }
  655.     return $result;
  656.   }
  657. }
  658.  
  659. class rootItemClass {
  660.   var $operateAs;
  661.   var $title;
  662.   var $description;
  663.   var $contentEncoded;
  664.   var $link;
  665.   var $pubDate;
  666.   var $pubDate_t;
  667.   var $pubDateDC;
  668.   var $enclosureURL;
  669.   var $enclosureLength;
  670.   var $enclosureType;
  671.   var $categoryArray;
  672.   var $category;
  673.   var $categoryDomain;
  674.   var $guid;
  675.   var $guidIsPermaLink;
  676.   var $author;
  677.   var $comments;
  678.   var $source;
  679.   var $sourceURL;
  680.   var $creativeCommons;
  681.   var $rssMeshExtra;
  682.   var $rssMeshExtra1;
  683.   var $rssMeshExtra2;
  684.   var $rssMeshExtra3;
  685.   var $rssMeshFeedImageTitle;
  686.   var $rssMeshFeedImageUrl;
  687.   var $rssMeshFeedImageLink;
  688.   var $rssMeshFeedImageDescription;
  689.   var $rssMeshFeedImageHeight;
  690.   var $rssMeshFeedImageWidth;
  691.   var $atomID;
  692.   var $atomUpdated;
  693.   var $atomContent;
  694.   var $atomContentStartPos;
  695.   var $atomAuthorEmail;
  696.   
  697.   var $contentEncodedUsed;
  698.  
  699.   var $itemStartPos;
  700.   var $itemFullText;
  701.  
  702.   // Constructor
  703.   Function rootItemClass($operateAs) {
  704.     $this->operateAs = $operateAs;
  705.     $this->title = "";
  706.     $this->description = "";
  707.     $this->contentEncoded = "";
  708.     $this->link = "";
  709.     $this->pubDate = "";
  710.     $this->pubDate_t = 0;
  711.     $this->pubDateDC = "";
  712.     $this->enclosureURL = "";
  713.     $this->enclosureLength = "";
  714.     $this->enclosureType = "";
  715.     $this->categoryArray = Array();
  716.     $this->category = "";
  717.     $this->categoryDomain = "";
  718.     $this->guid = "";
  719.     $this->guidIsPermaLink = "";
  720.     $this->author = "";
  721.     $this->comments = "";
  722.     $this->source = "";
  723.     $this->sourceURL = "";
  724.     $this->creativeCommons = "";
  725.     $this->rssMeshExtra = "";
  726.     $this->rssMeshExtra1 = "";
  727.     $this->rssMeshExtra2 = "";
  728.     $this->rssMeshExtra3 = "";
  729.     $this->rssMeshFeedImageTitle = "";
  730.     $this->rssMeshFeedImageUrl = "";
  731.     $this->rssMeshFeedImageLink = "";
  732.     $this->rssMeshFeedImageDescription = "";
  733.     $this->rssMeshFeedImageHeight = "";
  734.     $this->rssMeshFeedImageWidth = "";
  735.     $this->atomID = "";
  736.     $this->atomUpdated = "";
  737.     $this->atomContent = "";
  738.     $this->atomContentStartPos = 0;
  739.     $this->atomAuthorEmail = "";
  740.     
  741.     $this->contentEncodedUsed = 0;
  742.  
  743.     $this->itemStartPos = 0;
  744.     $this->itemFullText = "";
  745.   }
  746.  
  747.   Function getValueOf($elementName) {
  748.     if ($elementName == "~~~ItemTitle~~~") {
  749.       return $this->title;
  750.     }
  751.     elseif ($elementName == "~~~ItemDescription~~~") {
  752.       return $this->description;
  753.     }
  754.     elseif ($elementName == "~~~ItemContentEncoded~~~") {
  755.       return $this->contentEncoded;
  756.     }
  757.     elseif ($elementName == "~~~ItemLink~~~") {
  758.       return $this->link;
  759.     }
  760.     elseif ($elementName == "~~~ItemPubDate~~~") {
  761.       return $this->pubDate;
  762.     }
  763.     elseif ($elementName == "~~~ItemPubDateAsNumber~~~") {
  764.       return $this->pubDate_t;
  765.     }
  766.     elseif ($elementName == "~~~ItemEnclosureUrl~~~") {
  767.       return $this->enclosureURL;
  768.     }
  769.     elseif ($elementName == "~~~ItemEnclosureType~~~") {
  770.       return $this->enclosureType;
  771.     }
  772.     elseif ($elementName == "~~~ItemEnclosureLength~~~") {
  773.       return $this->enclosureLength;
  774.     }
  775.     elseif ($elementName == "~~~ItemGuid~~~") {
  776.       return $this->guid;
  777.     }
  778.     elseif ($elementName == "~~~ItemAuthor~~~") {
  779.       return $this->author;
  780.     }
  781.     elseif ($elementName == "~~~ItemComments~~~") {
  782.       return $this->comments;
  783.     }
  784.     elseif ($elementName == "~~~ItemSource~~~") {
  785.       return $this->source;
  786.     }
  787.     elseif ($elementName == "~~~ItemSourceUrl~~~") {
  788.       return $this->sourceURL;
  789.     }
  790.     elseif ($elementName == "~~~ItemCategory~~~") {
  791.       if (count($this->categoryArray)) {
  792.         return $this->categoryArray[0]["Category"];
  793.       }
  794.     }
  795.     elseif ($elementName == "~~~ItemCategoryDomain~~~") {
  796.       if (count($this->categoryArray)) {
  797.         return $this->categoryArray[0]["Domain"];
  798.       }
  799.     }
  800.     elseif ($elementName == "~~~ItemCreativeCommons~~~") {
  801.       return $this->creativeCommons;
  802.     }
  803.     elseif ($elementName == "~~~ItemRssMeshExtra~~~") {
  804.       return $this->rssMeshExtra;
  805.     }
  806.     elseif ($elementName == "~~~ItemRssMeshExtra1~~~") {
  807.       return $this->rssMeshExtra1;
  808.     }
  809.     elseif ($elementName == "~~~ItemRssMeshExtra2~~~") {
  810.       return $this->rssMeshExtra2;
  811.     }
  812.     elseif ($elementName == "~~~ItemRssMeshExtra3~~~") {
  813.       return $this->rssMeshExtra3;
  814.     }
  815.     elseif ($elementName == "~~~ItemRssMeshFeedImageTitle~~~") {
  816.       return $this->rssMeshFeedImageTitle;
  817.     }
  818.     elseif ($elementName == "~~~ItemRssMeshFeedImageUrl~~~") {
  819.       return $this->rssMeshFeedImageUrl;
  820.     }
  821.     elseif ($elementName == "~~~ItemRssMeshFeedImageLink~~~") {
  822.       return $this->rssMeshFeedImageLink;
  823.     }
  824.     elseif ($elementName == "~~~ItemRssMeshFeedImageDescription~~~") {
  825.       return $this->rssMeshFeedImageDescription;
  826.     }
  827.     elseif ($elementName == "~~~ItemRssMeshFeedImageHeight~~~") {
  828.       return $this->rssMeshFeedImageHeight;
  829.     }
  830.     elseif ($elementName == "~~~ItemRssMeshFeedImageWidth~~~") {
  831.       return $this->rssMeshFeedImageWidth;
  832.     }
  833.     return NULL;
  834.   }
  835.  
  836.   Function getArrayOfFields() {
  837.     $result = Array();
  838.  
  839.     $result[] = "~~~ItemTitle~~~";
  840.     $result[] = "~~~ItemDescription~~~";
  841.     $result[] = "~~~ItemContentEncoded~~~";
  842.     $result[] = "~~~ItemLink~~~";
  843.     $result[] = "~~~ItemPubDate~~~";
  844.     $result[] = "~~~ItemPubDateAsNumber~~~";
  845.     $result[] = "~~~ItemEnclosureUrl~~~";
  846.     $result[] = "~~~ItemEnclosureType~~~";
  847.     $result[] = "~~~ItemEnclosureLength~~~";
  848.     $result[] = "~~~ItemGuid~~~";
  849.     $result[] = "~~~ItemAuthor~~~";
  850.     $result[] = "~~~ItemComments~~~";
  851.     $result[] = "~~~ItemSource~~~";
  852.     $result[] = "~~~ItemSourceUrl~~~";
  853.     $result[] = "~~~ItemCategory~~~";
  854.     $result[] = "~~~ItemCategoryDomain~~~";
  855.     $result[] = "~~~ItemCreativeCommons~~~";
  856.     $result[] = "~~~ItemRssMeshExtra~~~";
  857.     $result[] = "~~~ItemRssMeshExtra1~~~";
  858.     $result[] = "~~~ItemRssMeshExtra2~~~";
  859.     $result[] = "~~~ItemRssMeshExtra3~~~";
  860.     $result[] = "~~~ItemRssMeshFeedImageTitle~~~";
  861.     $result[] = "~~~ItemRssMeshFeedImageUrl~~~";
  862.     $result[] = "~~~ItemRssMeshFeedImageLink~~~";
  863.     $result[] = "~~~ItemRssMeshFeedImageDescription~~~";
  864.     $result[] = "~~~ItemRssMeshFeedImageHeight~~~";
  865.     $result[] = "~~~ItemRssMeshFeedImageWidth~~~";
  866.     
  867.     return $result;
  868.   }
  869.   
  870. }
  871.  
  872. $startingClassName = "rootItemClass";
  873. if (function_exists("rssFilter_extendClass")) {
  874.   $startingClassName = rssFilter_extendClass($startingClassName);
  875. }
  876.  
  877. if (function_exists("FeedForAll_parseExtensions_extendClass")) {
  878.   $currentBaseClassName = FeedForAll_parseExtensions_extendClass($startingClassName);
  879. } else {
  880.   $currentBaseClassName = $startingClassName;
  881. }
  882. eval('class baseItemClassWithExtensions extends ' . $currentBaseClassName . ' {
  883.   Function baseItemClassWithExtensions($operateAs) {
  884.     $this->' . $currentBaseClassName . '($operateAs);
  885.   }
  886. }');
  887.  
  888. class baseItemClass extends baseItemClassWithExtensions {
  889.   Function baseItemClass($operateAs) {
  890.     $parentClass = get_parent_class($this);
  891.     $this->$parentClass($operateAs);
  892.   }
  893. }
  894.  
  895. class rootRSSParserClass {
  896.   var $operateAs;
  897.   var $gotROOT;
  898.   var $feedTYPE;
  899.   var $wholeString;
  900.   var $level;
  901.   var $tag;
  902.   var $noFutureItems;
  903.   
  904.   var $currentItem;
  905.  
  906.   var $FeedTitle;
  907.   var $FeedDescription;
  908.   var $FeedContentEncoded;
  909.   var $FeedLink;
  910.   var $FeedPubDate;
  911.   var $FeedPubDateDC;
  912.   var $FeedPubDate_t;
  913.   var $FeedLastBuildDate;
  914.   var $FeedImageURL;
  915.   var $FeedImageTitle;
  916.   var $FeedImageLink;
  917.   var $FeedImageDescription;
  918.   var $FeedImageHeight;
  919.   var $FeedImageWidth;
  920.   var $FeedCreativeCommons;
  921.   var $FeedAtomUpdated;
  922.   var $FeedAtomContent;
  923.   var $FeedAtomContentStartPos;
  924.   var $FeedAtomAuthorEmail;
  925.   
  926.   var $contentEncodedUsed;
  927.   
  928.   var $noon_t;
  929.  
  930.   var $Items;
  931.  
  932.   //
  933.   var $insideChannel = FALSE;
  934.   var $level_channel;
  935.   var $insideChannelImage = FALSE;
  936.   var $level_channelImage;
  937.   var $insideItem = FALSE;
  938.   var $level_item;
  939.   var $insideAtomAuthor = FALSE;
  940.  
  941.   Function rootRSSParserClass($operateAs) {
  942.     $this->operateAs = $operateAs;
  943.     $this->gotROOT = 0;
  944.     $this->feedTYPE = "RSS";
  945.     $this->wholeString = "";
  946.     $this->level = 0;
  947.     $this->tag = "";
  948.     $this->noFutureItems = 0;;
  949.   
  950.     $this->FeedImageURL = "";
  951.     $this->FeedImageTitle = "";
  952.     $this->FeedImageLink = "";
  953.     $this->FeedImageDescription = "";
  954.     $this->FeedImageHeight = "";
  955.     $this->FeedImageWidth = "";
  956.     $this->currentItem = NULL;
  957.  
  958.     $this->FeedTitle = "";
  959.     $this->FeedDescription = "";
  960.     $this->FeedContentEncoded = "";
  961.     $this->FeedLink = "";
  962.     $this->FeedPubDate = "";
  963.     $this->FeedPubDateDC = "";
  964.     $this->FeedPubDate_t = 0;
  965.     $this->FeedLastBuildDate = "";
  966.     $this->FeedImageURL = "";
  967.     $this->FeedImageTitle = "";
  968.     $this->FeedImageLink = "";
  969.     $this->FeedImageDescription = "";
  970.     $this->FeedImageHeight = "";
  971.     $this->FeedImageWidth = "";
  972.     $this->FeedCreativeCommons = "";
  973.     $this->FeedAtomUpdated = "";
  974.     $this->FeedAtomContent = "";
  975.     $this->FeedAtomContentStartPos = 0;
  976.     $this->FeedAtomAuthorEmail = "";
  977.  
  978.     $this->contentEncodedUsed = 0;
  979.     
  980.     $this->noon_t = mktime(12, 0, 0, date("m"), date("d"), date("Y"));
  981.     
  982.     $this->Items = Array();
  983.  
  984.     //
  985.     $this->insideChannel = FALSE;
  986.     $this->level_channel = 0;
  987.     $this->insideChannelImage = FALSE;
  988.     $this->level_channelImage = 0;
  989.     $this->insideItem = FALSE;
  990.     $this->level_item = 0;
  991.   }
  992.  
  993.   function startElement($parser, $tagName, $attrs) {
  994.     GLOBAL $debugLevel;
  995.     
  996.     $this->level++;
  997.     $this->tag = $tagName;
  998.     if ($this->gotROOT == 0) {
  999.       $this->gotROOT = 1;
  1000.       if (strstr($tagName, "RSS")) {
  1001.         $this->feedTYPE = "RSS";
  1002.       }
  1003.       elseif (strstr($tagName, "RDF")) {
  1004.         $this->feedTYPE = "RDF";
  1005.       }
  1006.       elseif (strstr($tagName, "FEE")) {
  1007.         $this->feedTYPE = "FEE";
  1008.         $this->insideChannel = TRUE;
  1009.         $this->level_channel = 1;
  1010.       }
  1011.     }
  1012.     elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) {
  1013.       if (isset($debugLevel) && ($debugLevel >= 2)) {
  1014.         echo "DIAG: startElement(\$parser, $tagName, \$attrs)<br>\n";
  1015.       }
  1016.       
  1017.       $this->insideItem = TRUE;
  1018.       $this->level_item = $this->level;
  1019.       $this->currentItem = new baseItemClass($this->operateAs);
  1020.  
  1021.       //
  1022.       // Find the start of the <item> or <entry>
  1023.       $this->currentItem->ItemStartPos = xml_get_current_byte_index($parser);
  1024.       if ($this->wholeString[$this->currentItem->ItemStartPos] != "<") {
  1025.         $startToHere = substr($this->wholeString, 0, $this->currentItem->ItemStartPos);
  1026.         $this->currentItem->ItemStartPos = strrpos($startToHere, "<");
  1027.       }
  1028.     }
  1029.     elseif ($this->insideChannel && (($tagName == "AUTHOR") && ($this->feedTYPE == "FEE"))) {
  1030.       $this->insideAtomAuthor = TRUE;
  1031.     }
  1032.     elseif ($this->insideItem && (($tagName == "AUTHOR") && ($this->feedTYPE == "FEE"))) {
  1033.       $this->insideAtomAuthor = TRUE;
  1034.     }
  1035.     elseif (($this->insideItem) && ($tagName == "ENCLOSURE")) {
  1036.       if (isset($attrs["URL"])) {
  1037.         $this->currentItem->enclosureURL = $attrs["URL"];
  1038.       }
  1039.       if (isset($attrs["TYPE"])) {
  1040.         $this->currentItem->enclosureType = $attrs["TYPE"];
  1041.       }
  1042.       if (isset($attrs["LENGTH"])) {
  1043.         $this->currentItem->enclosureLength = $attrs["LENGTH"];
  1044.       }
  1045.     }
  1046.     elseif (($this->insideItem) && ($tagName == "SOURCE")) {
  1047.       if (isset($attrs["URL"])) {
  1048.         $this->currentItem->sourceURL = $attrs["URL"];
  1049.       }
  1050.     }
  1051.     elseif (($this->insideItem) && ($tagName == "CATEGORY")) {
  1052.       if (isset($attrs["DOMAIN"])) {
  1053.         $this->currentItem->categoryDomain = $attrs["DOMAIN"];
  1054.       }
  1055.     }
  1056.     elseif (($this->insideItem) && ($tagName == "GUID")) {
  1057.       if (isset($attrs["ISPERMALINK"])) {
  1058.         $this->currentItem->guidIsPermaLink = $attrs["ISPERMALINK"];
  1059.       }
  1060.     }
  1061.     elseif (($tagName == "LINK") && ($this->feedTYPE == "FEE")) {
  1062.       if ($this->insideItem) {
  1063.         if (isset($attrs["REL"]) && ($attrs["REL"] == "enclosure")) {
  1064.           $this->currentItem->enclosureURL = $attrs["HREF"];
  1065.           $this->currentItem->enclosureType = $attrs["TYPE"];
  1066.           $this->currentItem->enclosureLength = $attrs["LENGTH"];
  1067.         }
  1068.         elseif (isset($attrs["HREF"]) && ((isset($attrs["TYPE"]) && ($attrs["TYPE"] == "text/html") && ((isset($attrs["REL"]) && ($attrs["REL"] == "alternate")) || !isset($attrs["REL"]))) || !isset($attrs["TYPE"]))) {
  1069.           $this->currentItem->link = $attrs["HREF"];
  1070.         }
  1071.       } else {
  1072.         if (isset($attrs["HREF"]) && ((isset($attrs["TYPE"]) && ($attrs["TYPE"] == "text/html") && ((isset($attrs["REL"]) && ($attrs["REL"] == "alternate")) || !isset($attrs["REL"]))) || !isset($attrs["TYPE"]))) {
  1073.           $this->FeedLink = $attrs["HREF"];
  1074.         }
  1075.       }
  1076.     }
  1077.     elseif ($tagName == "CHANNEL") {
  1078.       $this->insideChannel = TRUE;
  1079.       $this->level_channel = $this->level;
  1080.     }
  1081.     elseif (($tagName == "IMAGE") && ($this->insideChannel == TRUE)) {
  1082.       $this->insideChannelImage = TRUE;
  1083.       $this->level_channelImage = $this->level;
  1084.     }
  1085.     elseif ($tagName == "CONTENT") {
  1086.       if ($this->insideItem == TRUE) {
  1087.         if (isset($attrs["TYPE"]) && ($attrs["TYPE"] == "xhtml")) {
  1088.           //
  1089.           // Find the start of the <content ... >
  1090.           $this->currentItem->atomContentStartPos = xml_get_current_byte_index($parser);
  1091.           if ($this->wholeString[$this->currentItem->atomContentStartPos] != "<") {
  1092.             $startToHere = substr($this->wholeString, 0, $this->currentItem->atomContentStartPos);
  1093.             $this->currentItem->atomContentStartPos = strrpos($startToHere, "<");
  1094.           }
  1095.         }
  1096.       } else {
  1097.         if (isset($attrs["TYPE"]) && ($attrs["TYPE"] == "xhtml")) {
  1098.           //
  1099.           // Find the start of the <content ... >
  1100.           $this->FeedAtomContentStartPos = xml_get_current_byte_index($parser);
  1101.           if ($this->wholeString[$this->FeedAtomContentStartPos] != "<") {
  1102.             $startToHere = substr($this->wholeString, 0, $this->FeedAtomContentStartPos);
  1103.             $this->FeedAtomContentStartPos = strrpos($startToHere, "<");
  1104.           }
  1105.         }
  1106.       }
  1107.     }
  1108.     if (FeedForAll_parseExtensions() === TRUE) {
  1109.       FeedForAll_parseExtensions_startElemend($parser, $this, $tagName, $attrs);
  1110.     }
  1111.   }
  1112.  
  1113.   function endElement($parser, $tagName) {
  1114.     GLOBAL $debugLevel;
  1115.  
  1116.     $this->tag = "";
  1117.     $this->level--;
  1118.     if (($this->insideItem) && ($tagName == "CATEGORY")) {
  1119.       $this->currentItem->categoryArray[] = Array("Category" => $this->currentItem->category, "Domain" => $this->currentItem->categoryDomain);
  1120.       $this->currentItem->category = "";
  1121.       $this->currentItem->categoryDomain = "";
  1122.     }
  1123.     elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) {
  1124.       if (isset($debugLevel) && ($debugLevel >= 2)) {
  1125.         echo "DIAG: endElement(\$parser, $tagName)<br>\n";
  1126.       }
  1127.       
  1128.       $this->UseItem = TRUE;
  1129.  
  1130.       //
  1131.       // Do any special processing to convert ATOM to RSS 2.0
  1132.       if ($this->feedTYPE == "FEE") {
  1133.         if ($this->currentItem->guid == "") {
  1134.           // There was no GUID, use ID
  1135.           $this->currentItem->guid = $this->currentItem->atomID;
  1136.           $this->currentItem->guidIsPermaLink = "false";
  1137.         }
  1138.       }
  1139.       
  1140.       //
  1141.       // The the whole item string
  1142.       $pos = xml_get_current_byte_index($parser);
  1143.       //
  1144.       // Find the element that opened this all up.
  1145.       $endingString = '</'.substr($this->wholeString, $this->currentItem->ItemStartPos+1, 4);
  1146.       if ($endingString == substr($this->wholeString, $pos, 6)) {
  1147.         // We are good just where we are
  1148.       } else {
  1149.         for (;$pos > 0; $pos--) {
  1150.           /* Look for a closing angle */
  1151.           if ($endingString == substr($this->wholeString, $pos, 6)) break;
  1152.         }
  1153.       }
  1154.       $pos++;
  1155.       $hereToEnd = substr($this->wholeString, $pos);
  1156.       $closePos = strpos($hereToEnd, '>');
  1157.       $this->currentItem->itemFullText = substr($this->wholeString, $this->currentItem->ItemStartPos, $pos + $closePos - $this->currentItem->ItemStartPos+1);
  1158.  
  1159.       //
  1160.       // Get the pubDate from pubDate first and then dc:date
  1161.       if (trim($this->currentItem->pubDate) != "") {
  1162.         $this->currentItem->pubDate = trim($this->currentItem->pubDate);
  1163.         $this->currentItem->pubDate_t = strtotime($this->currentItem->pubDate);
  1164.       }
  1165.       elseif (($this->feedTYPE == "FEE") && (trim($this->currentItem->atomUpdated) != "")) {
  1166.         $this->currentItem->atomUpdated = trim($this->currentItem->atomUpdated);
  1167.         $this->currentItem->pubDate_t = FeedForAll_scripts_getRFDdate($this->currentItem->atomUpdated);
  1168.         $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t);
  1169.       }
  1170.       elseif (trim($this->currentItem->pubDateDC) != "") {
  1171.         $this->currentItem->pubDate_t = FeedForAll_scripts_getRFDdate($this->currentItem->pubDateDC);
  1172.         $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t);
  1173.       } else {
  1174.         $this->currentItem->pubDate_t = time();
  1175.         $this->currentItem->pubDate = date("D, d M Y H:i:s O", $this->currentItem->pubDate_t);
  1176.       }
  1177.  
  1178.       if (($this->operateAs == "rssFilter") && function_exists("rssFilter_useItem")) {
  1179.         GLOBAL $_REQUEST;
  1180.  
  1181.         $this->UseItem = rssFilter_useItem($this->currentItem);
  1182.  
  1183.         if (isset($_REQUEST["testScript"])) {
  1184.           if ($this->UseItem) {
  1185.             echo "USING Item: ".htmlentities($this->currentItem->title)."<br>\n";
  1186.           } else {
  1187.             echo "NOT Using: ".htmlentities($this->currentItem->title)."<br>\n";
  1188.           }
  1189.         }
  1190.       }
  1191.  
  1192.       if ($this->operateAs == "rssMesh") {
  1193.         if (($this->itemLimit >= 0) && (count($this->Items) >= $this->itemLimit)) {
  1194.           $this->UseItem = FALSE;
  1195.         }
  1196.       }
  1197.       elseif ($this->operateAs == "rss2html") {
  1198.         if (($useUniq = FeedForAll_rss2html_UseUniqueLink($this->currentItem->title, $this->currentItem->description, $this->currentItem->link, $this->currentItem->guid)) != -1) {
  1199.           if ($useUniq == 0) {
  1200.             if (isset($debugLevel) && ($debugLevel >= 2)) {
  1201.               echo "DIAG: FeedForAll_rss2html_UseUniqueLink() => 0, Not using<br>\n";
  1202.             }
  1203.  
  1204.             $this->UseItem = FALSE;
  1205.           }
  1206.         }
  1207.         if ($this->noFutureItems) {
  1208.           if (($this->currentItem->pubDate_t - $this->noon_t) > 43200) {
  1209.             if (isset($debugLevel) && ($debugLevel >= 2)) {
  1210.               echo "DIAG: future pubdate, Not using<br>\n";
  1211.             }
  1212.             $this->UseItem = FALSE;
  1213.           }
  1214.         }
  1215.       }
  1216.  
  1217.       if ($this->UseItem) {
  1218.         if (isset($debugLevel) && ($debugLevel >= 2)) {
  1219.           echo "DIAG: Using item \"".$this->currentItem->title."\"<br>\n";
  1220.         }
  1221.         
  1222.         //
  1223.         // Clean up some of the values
  1224.         $this->currentItem->title = trim($this->currentItem->title);
  1225.         $this->currentItem->description = trim($this->currentItem->description);
  1226.         if ($this->feedTYPE == "FEE") {
  1227.           $this->currentItem->atomContent = trim($this->currentItem->atomContent);
  1228.           if ($this->currentItem->atomContent != "") {
  1229.             $this->currentItem->description = $this->currentItem->atomContent;
  1230.           } else {
  1231.             $this->currentItem->description = trim($this->currentItem->description);
  1232.           }
  1233.         } else {
  1234.           $this->currentItem->description = $this->currentItem->description;
  1235.         }
  1236.         if (trim($this->currentItem->contentEncoded) == "") {
  1237.           if  ($this->operateAs != "rssMesh") {
  1238.             $this->currentItem->contentEncoded = $this->currentItem->description;
  1239.           }
  1240.         } else {
  1241.           $this->currentItem->contentEncoded = trim($this->currentItem->contentEncoded);
  1242.         }
  1243.         if (trim($this->currentItem->description) == "") {
  1244.           $this->currentItem->description = trim($this->currentItem->contentEncoded);
  1245.         }
  1246.         $this->currentItem->link = trim($this->currentItem->link);
  1247.         $this->currentItem->guid = trim($this->currentItem->guid);
  1248.         $this->currentItem->guidIsPermaLink = trim($this->currentItem->guidIsPermaLink);
  1249.         if ($this->feedTYPE == "FEE") {
  1250.           $this->currentItem->atomAuthorEmail = trim($this->currentItem->atomAuthorEmail);
  1251.           $this->currentItem->author = trim($this->currentItem->atomAuthorEmail);
  1252.         }
  1253.         $this->currentItem->author = trim($this->currentItem->author);
  1254.         if ($this->currentItem->creativeCommons == "") {
  1255.           $this->currentItem->creativeCommons = trim($this->FeedCreativeCommons);
  1256.         } else {
  1257.           $this->currentItem->creativeCommons = trim($this->currentItem->creativeCommons);
  1258.         }
  1259.         if ($this->operateAs == "rss2sql") {
  1260.           if (($this->currentItem->source == "") && ($this->sourceFeedURL != "")) {
  1261.             $this->currentItem->source = $this->FeedTitle;
  1262.             $this->currentItem->sourceURL = $this->sourceFeedURL;
  1263.           }
  1264.         }
  1265.         $this->currentItem->source = trim($this->currentItem->source);
  1266.         $this->currentItem->sourceURL = trim($this->currentItem->sourceURL);
  1267.         $this->currentItem->enclosureURL = trim($this->currentItem->enclosureURL);
  1268.         $this->currentItem->enclosureLength = trim($this->currentItem->enclosureLength);
  1269.         $this->currentItem->enclosureType = trim($this->currentItem->enclosureType);
  1270.         $this->currentItem->comments = trim($this->currentItem->comments);
  1271.         $this->currentItem->rssMeshExtra = trim($this->currentItem->rssMeshExtra);
  1272.         $this->currentItem->rssMeshExtra1 = trim($this->currentItem->rssMeshExtra1);
  1273.         $this->currentItem->rssMeshExtra2 = trim($this->currentItem->rssMeshExtra2);
  1274.         $this->currentItem->rssMeshExtra3 = trim($this->currentItem->rssMeshExtra3);
  1275.         $this->currentItem->rssMeshFeedImageTitle = trim($this->currentItem->rssMeshFeedImageTitle);
  1276.         $this->currentItem->rssMeshFeedImageUrl = trim($this->currentItem->rssMeshFeedImageUrl);
  1277.         $this->currentItem->rssMeshFeedImageLink = trim($this->currentItem->rssMeshFeedImageLink);
  1278.         $this->currentItem->rssMeshFeedImageDescription = trim($this->currentItem->rssMeshFeedImageDescription);
  1279.         $this->currentItem->rssMeshFeedImageHeight = trim($this->currentItem->rssMeshFeedImageHeight);
  1280.         $this->currentItem->rssMeshFeedImageWidth = trim($this->currentItem->rssMeshFeedImageWidth);
  1281.         if ($this->operateAs == "rss2html") {
  1282.           //
  1283.           // Escape any links
  1284.           $this->currentItem->link = FeedForAll_rss2html_EscapeLink($this->currentItem->link);
  1285.           $this->currentItem->guid = FeedForAll_rss2html_EscapeLink($this->currentItem->guid);
  1286.           $this->currentItem->creativeCommons = FeedForAll_rss2html_EscapeLink($this->currentItem->creativeCommons);
  1287.           $this->currentItem->sourceURL = FeedForAll_rss2html_EscapeLink($this->currentItem->sourceURL);
  1288.           $this->currentItem->enclosureURL = FeedForAll_rss2html_EscapeLink($this->currentItem->enclosureURL);
  1289.           $this->currentItem->comments = FeedForAll_rss2html_EscapeLink($this->currentItem->comments);
  1290.           $this->currentItem->rssMeshFeedImageUrl = FeedForAll_rss2html_EscapeLink($this->currentItem->rssMeshFeedImageUrl);
  1291.           $this->currentItem->rssMeshFeedImageLink = FeedForAll_rss2html_EscapeLink($this->currentItem->rssMeshFeedImageLink);
  1292.         }
  1293.         
  1294.         //
  1295.         if ($this->currentItem->contentEncodedUsed) {
  1296.           $this->contentEncodedUsed = 1;
  1297.         }
  1298.         if (FeedForAll_parseExtensions() === TRUE) {
  1299.           FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
  1300.         }
  1301.         if ($this->UseItem) {
  1302.           $this->Items[] = $this->currentItem;
  1303.           if (isset($debugLevel) && ($debugLevel >= 3)) {
  1304.             echo "DIAG: adding to items, count=".count($this->Items)."<br>\n";
  1305.           }
  1306.         }
  1307.       } else {
  1308.         unset($this->currentItem);
  1309.       }
  1310.       $this->insideItem = FALSE;
  1311.       $this->level_item = 0;
  1312.       return;
  1313.     }
  1314.     elseif ($this->insideAtomAuthor && ($tagName == "AUTHOR")) {
  1315.       $this->insideAtomAuthor = FALSE;
  1316.     }
  1317.     elseif (($tagName == "IMAGE") && ($this->insideChannelImage)) {
  1318.       $this->FeedImageTitle = trim($this->FeedImageTitle);
  1319.       $this->FeedImageURL = trim($this->FeedImageURL);
  1320.       $this->FeedImageLink = trim($this->FeedImageLink);
  1321.       $this->FeedImageDescription = trim($this->FeedImageDescription);
  1322.       $this->FeedImageHeight = trim($this->FeedImageHeight);
  1323.       $this->FeedImageWidth = trim($this->FeedImageWidth);
  1324.       if ($this->operateAs == "rss2html") {
  1325.         //
  1326.         // Escape any links
  1327.         $this->FeedImageURL = FeedForAll_rss2html_EscapeLink($this->FeedImageURL);
  1328.         $this->FeedImageLink = FeedForAll_rss2html_EscapeLink($this->FeedImageLink);
  1329.       }
  1330.       if (FeedForAll_parseExtensions() === TRUE) {
  1331.         FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
  1332.       }
  1333.       $this->insideChannelImage = FALSE;
  1334.       $this->level_channelImage = 0;
  1335.       return;
  1336.     }
  1337.     elseif ((($tagName == "CHANNEL") && ($this->feedTYPE != "FEE")) || (($tagName == "FEED") && ($this->feedTYPE == "FEE"))) {
  1338.       $this->FeedPubDate = trim($this->FeedPubDate);
  1339.       $this->FeedPubDateDC = trim($this->FeedPubDateDC);
  1340.       $this->FeedAtomUpdated = trim($this->FeedAtomUpdated);
  1341.       //
  1342.       // Get the pubDate from pubDate first and then dc:date
  1343.       if (trim($this->FeedPubDate) != "") {
  1344.         $this->FeedPubDate_t = strtotime($this->FeedPubDate);
  1345.       }
  1346.       elseif (($this->feedTYPE == "FEE") && ($this->FeedAtomUpdated != "")) {
  1347.         $this->FeedAtomUpdated = trim($this->FeedAtomUpdated);
  1348.         $this->FeedPubDate_t = FeedForAll_scripts_getRFDdate($this->FeedAtomUpdated);
  1349.         $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
  1350.       }
  1351.       elseif (trim($this->FeedPubDateDC) != "") {
  1352.         $this->FeedPubDate_t = FeedForAll_scripts_getRFDdate($this->FeedPubDateDC);
  1353.         $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
  1354.       }
  1355.       elseif (trim($this->FeedLastBuildDate) != "") {
  1356.         $this->FeedPubDate_t = strtotime($this->FeedLastBuildDate);
  1357.         $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
  1358.       } else {
  1359.         $this->FeedPubDate_t = time();
  1360.         $this->FeedPubDate = date("D, d M Y H:i:s O", $this->FeedPubDate_t);
  1361.       }
  1362.       $this->FeedTitle = trim($this->FeedTitle);
  1363.       if ($this->feedTYPE == "FEE") {
  1364.         $this->FeedAtomContent = trim($this->FeedAtomContent);
  1365.         $this->FeedDescription = $this->FeedAtomContent;
  1366.       } else {
  1367.         $this->FeedDescription = $this->FeedDescription;
  1368.       }
  1369.       if (trim($this->FeedContentEncoded) == "") {
  1370.         $this->FeedContentEncoded = $this->FeedDescription;
  1371.       }
  1372.       $this->FeedLink = trim($this->FeedLink);
  1373.       if ($this->operateAs == "rss2html") {
  1374.         //
  1375.         // Escape any links
  1376.         $this->FeedLink = FeedForAll_rss2html_EscapeLink($this->FeedLink);
  1377.         $this->FeedCreativeCommons = FeedForAll_rss2html_EscapeLink($this->FeedCreativeCommons);
  1378.       }
  1379.       if (FeedForAll_parseExtensions() === TRUE) {
  1380.         FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
  1381.       }
  1382.       $this->insideChannel = FALSE;
  1383.       $this->level_channel = 0;
  1384.       return;
  1385.     }
  1386.     elseif ($this->level == $this->level_channel) {
  1387.       if ($tagName == "TITLE") {
  1388.         $this->FeedTitle = trim($this->FeedTitle);
  1389.       }
  1390.       elseif (($tagName == "DESCRIPTION") || ($tagName == "TAGLINE")) {
  1391.         $this->FeedDescription = trim($this->FeedDescription);
  1392.       }
  1393.       elseif ($tagName == "CONTENT:ENCODED") {
  1394.         $this->FeedContentEncoded = trim($this->FeedContentEncoded);
  1395.       }
  1396.       elseif ($tagName == "LINK") {
  1397.         $this->FeedLink = trim($this->FeedLink);
  1398.       }
  1399.     }
  1400.     elseif ($tagName == "CONTENT") {
  1401.       if ($this->insideItem == TRUE) {
  1402.         // Lets look to see if the content is
  1403.         if ($this->currentItem->atomContentStartPos) {
  1404.           //
  1405.           // The the whole <content ... > string
  1406.           $pos = xml_get_current_byte_index($parser);
  1407.           for (;$pos > 0; $pos--) {
  1408.             /* Look for a closing angle */
  1409.             if ($this->wholeString[$pos] == ">") break;
  1410.           }
  1411.           $pos++;
  1412.           $hereToEnd = substr($this->wholeString, $pos);
  1413.           $closePos = strpos($hereToEnd, ">");
  1414.           $fullContentText = substr($this->wholeString, $this->currentItem->atomContentStartPos, $pos + $closePos - $this->currentItem->atomContentStartPos+1);
  1415.           // Find the end of <content
  1416.           $start = strpos($fullContentText, ">");
  1417.           $fullContentText = substr($fullContentText, $start+1);
  1418.           // Find the end of <div
  1419.           $start = strpos($fullContentText, ">");
  1420.           $fullContentText = substr($fullContentText, $start+1);
  1421.           // Find the start of </content
  1422.           $start = strrpos($fullContentText, "<");
  1423.           $fullContentText = substr($fullContentText, 0, $start-1);
  1424.           // Find the start of </div
  1425.           $start = strrpos($fullContentText, "<");
  1426.           $this->currentItem->atomContent = substr($fullContentText, 0, $start-1);
  1427.           $this->currentItem->atomContentStartPos = 0;
  1428.         }
  1429.       } else {
  1430.         // Lets look to see if the content is
  1431.         if ($this->FeedAtomContentStartPos) {
  1432.           //
  1433.           // The the whole <content ... > string
  1434.           $pos = xml_get_current_byte_index($parser);
  1435.           for (;$pos > 0; $pos--) {
  1436.             /* Look for a closing angle */
  1437.             if ($this->wholeString[$pos] == ">") break;
  1438.           }
  1439.           $pos++;
  1440.           $hereToEnd = substr($this->wholeString, $pos);
  1441.           $closePos = strpos($hereToEnd, ">");
  1442.           $fullContentText = substr($this->wholeString, $this->FeedAtomContentStartPos, $pos + $closePos - $this->FeedAtomContentStartPos+1);
  1443.           // Find the end of <content
  1444.           $start = strpos($fullContentText, ">");
  1445.           $fullContentText = substr($fullContentText, $start+1);
  1446.           // Find the end of <div
  1447.           $start = strpos($fullContentText, ">");
  1448.           $fullContentText = substr($fullContentText, $start+1);
  1449.           // Find the start of </content
  1450.           $start = strrpos($fullContentText, "<");
  1451.           $fullContentText = substr($fullContentText, 0, $start-1);
  1452.           // Find the start of </div
  1453.           $start = strrpos($fullContentText, "<");
  1454.           $this->FeedAtomContent = substr($fullContentText, 0, $start-1);
  1455.           $this->FeedAtomContentStartPos = 0;
  1456.         }
  1457.       }
  1458.     }
  1459.     if (FeedForAll_parseExtensions() === TRUE) {
  1460.       FeedForAll_parseExtensions_endElemend($parser, $this, $tagName);
  1461.     }
  1462.   }
  1463.  
  1464.   function characterData($parser, $data) {
  1465.     if (($data == "") || ($data == NULL)) {
  1466.     } else {
  1467.       if (($this->insideItem) && ($this->level == $this->level_item+1)) {
  1468.         switch ($this->tag) {
  1469.           case "TITLE":
  1470.           $this->currentItem->title .= $data;
  1471.           break;
  1472.  
  1473.           case "DESCRIPTION":
  1474.           $this->currentItem->description .= $data;
  1475.           break;
  1476.  
  1477.           case "CONTENT:ENCODED":
  1478.           $this->currentItem->contentEncodedUsed = 1;
  1479.           $this->currentItem->contentEncoded .= $data;
  1480.           break;
  1481.  
  1482.           case "SUMMARY":
  1483.           $this->currentItem->description .= $data;
  1484.           break;
  1485.  
  1486.           case "LINK":
  1487.           $this->currentItem->link .= $data;
  1488.           break;
  1489.  
  1490.           case "PUBDATE":
  1491.           $this->currentItem->pubDate .= $data;
  1492.           break;
  1493.  
  1494.           case "MODIFIED":
  1495.           $this->currentItem->pubDateDC .= $data;
  1496.           break;
  1497.  
  1498.           case "GUID":
  1499.           $this->currentItem->guid .= $data;
  1500.           break;
  1501.           
  1502.           case "ID":
  1503.           case "ATOM:ID":
  1504.           $this->currentItem->atomID .= $data;
  1505.           break;
  1506.  
  1507.           case "AUTHOR":
  1508.           $this->currentItem->author .= $data;
  1509.           break;
  1510.  
  1511.           case "COMMENTS":
  1512.           $this->currentItem->comments .= $data;
  1513.           break;
  1514.  
  1515.           case "SOURCE":
  1516.           $this->currentItem->source .= $data;
  1517.           break;
  1518.  
  1519.           case "CATEGORY":
  1520.           $this->currentItem->category .= $data;
  1521.           break;
  1522.  
  1523.           case "CREATIVECOMMONS:LICENSE":
  1524.           $this->currentItem->creativeCommons .= $data;
  1525.           break;
  1526.  
  1527.           case "RSSMESH:EXTRA":
  1528.           $this->currentItem->rssMeshExtra .= $data;
  1529.           break;
  1530.  
  1531.           case "RSSMESH:EXTRA1":
  1532.           $this->currentItem->rssMeshExtra1 .= $data;
  1533.           break;
  1534.  
  1535.           case "RSSMESH:EXTRA2":
  1536.           $this->currentItem->rssMeshExtra2 .= $data;
  1537.           break;
  1538.  
  1539.           case "RSSMESH:EXTRA3":
  1540.           $this->currentItem->rssMeshExtra3 .= $data;
  1541.           break;
  1542.  
  1543.           case "RSSMESH:FEEDIMAGETITLE":
  1544.           $this->currentItem->rssMeshFeedImageTitle .= $data;
  1545.           break;
  1546.  
  1547.           case "RSSMESH:FEEDIMAGEURL":
  1548.           $this->currentItem->rssMeshFeedImageUrl .= $data;
  1549.           break;
  1550.  
  1551.           case "RSSMESH:FEEDIMAGELINK":
  1552.           $this->currentItem->rssMeshFeedImageLink .= $data;
  1553.           break;
  1554.  
  1555.           case "RSSMESH:FEEDIMAGEDESCRIPTION":
  1556.           $this->currentItem->rssMeshFeedImageDescription .= $data;
  1557.           break;
  1558.  
  1559.           case "RSSMESH:FEEDIMAGEHEIGHT":
  1560.           $this->currentItem->rssMeshFeedImageHeight .= $data;
  1561.           break;
  1562.  
  1563.           case "RSSMESH:FEEDIMAGEWIDTH":
  1564.           $this->currentItem->rssMeshFeedImageWidth .= $data;
  1565.           break;
  1566.  
  1567.           case "UPDATED":
  1568.           case "ATOM:UPDATED":
  1569.           $this->currentItem->atomUpdated .= $data;
  1570.           break;
  1571.           
  1572.           case "CONTENT":
  1573.           case "ATOM:CONTENT":
  1574.           $this->currentItem->atomContent .= $data;
  1575.           break;
  1576.           
  1577.           default:
  1578.           if ($this->tag == "DC:DATE") {
  1579.             $this->currentItem->pubDateDC .= $data;
  1580.           }
  1581.           if (FeedForAll_parseExtensions() === TRUE) {
  1582.             FeedForAll_parseExtensions_characterData($parser, $this, $data);
  1583.           }
  1584.         }
  1585.       }
  1586.       elseif ($this->insideChannelImage) {
  1587.         switch ($this->tag) {
  1588.           case "TITLE":
  1589.           $this->FeedImageTitle .= $data;
  1590.           break;
  1591.  
  1592.           case "URL":
  1593.           $this->FeedImageURL .= $data;
  1594.           break;
  1595.  
  1596.           case "LINK":
  1597.           $this->FeedImageLink .= $data;
  1598.           break;
  1599.  
  1600.           case "DESCRIPTION":
  1601.           $this->FeedImageDescription .= $data;
  1602.           break;
  1603.  
  1604.           case "HEIGHT":
  1605.           $this->FeedImageHeight .= $data;
  1606.           break;
  1607.  
  1608.           case "WIDTH":
  1609.           $this->FeedImageWidth .= $data;
  1610.           break;
  1611.  
  1612.           default:
  1613.           if (FeedForAll_parseExtensions() === TRUE) {
  1614.             FeedForAll_parseExtensions_characterData($parser, $this, $data);
  1615.           }
  1616.         }
  1617.       }
  1618.       elseif (($this->insideChannel) && ($this->level == $this->level_channel+1)) {
  1619.         switch ($this->tag) {
  1620.           case "TITLE":
  1621.           $this->FeedTitle .= $data;
  1622.           break;
  1623.  
  1624.           case "DESCRIPTION":
  1625.           $this->FeedDescription .= $data;
  1626.           break;
  1627.  
  1628.           case "CONTENT:ENCODED":
  1629.           $this->FeedContentEncoded .= $data;
  1630.           break;
  1631.  
  1632.           case "TAGLINE":
  1633.           $this->FeedDescription .= $data;
  1634.           break;
  1635.  
  1636.           case "LINK":
  1637.           $this->FeedLink .= $data;
  1638.           break;
  1639.  
  1640.           case "PUBDATE":
  1641.           $this->FeedPubDate .= $data;
  1642.           break;
  1643.  
  1644.           case "MODIFIED":
  1645.           $this->FeedPubDateDC .= $data;
  1646.           break;
  1647.  
  1648.           case "LASTBUILDDATE":
  1649.           $this->FeedLastBuildDate .= $data;
  1650.           break;
  1651.  
  1652.           case "CREATIVECOMMONS:LICENSE":
  1653.           $this->FeedCreativeCommons .= $data;
  1654.           break;
  1655.  
  1656.           case "UPDATED":
  1657.           case "ATOM:UPDATED":
  1658.           $this->FeedAtomUpdated .= $data;
  1659.           break;
  1660.           
  1661.           case "CONTENT":
  1662.           case "ATOM:CONTENT":
  1663.           $this->FeedAtomContent .= $data;
  1664.           break;
  1665.           
  1666.           default:
  1667.           if ($this->tag == "DC:DATE") {
  1668.             $this->FeedPubDateDC .= $data;
  1669.           }
  1670.           if (FeedForAll_parseExtensions() === TRUE) {
  1671.             FeedForAll_parseExtensions_characterData($parser, $this, $data);
  1672.           }
  1673.         }
  1674.       }
  1675.       elseif (($this->insideAtomAuthor) && ($this->insideItem) && ($this->level == $this->level_item+2)) {
  1676.         switch ($this->tag) {
  1677.           case "EMAIL":
  1678.           case "ATOM:EMAIL":
  1679.           $this->currentItem->atomAuthorEmail .= $data;
  1680.           break;
  1681.           
  1682.           default:
  1683.           if (FeedForAll_parseExtensions() === TRUE) {
  1684.             FeedForAll_parseExtensions_characterData($parser, $this, $data);
  1685.           }
  1686.         }
  1687.       }
  1688.       elseif (($this->insideAtomAuthor) && ($this->insideChannel) && ($this->level == $this->level_channel+2)) {
  1689.         switch ($this->tag) {
  1690.           case "EMAIL":
  1691.           case "ATOM:EMAIL":
  1692.           $this->FeedAtomAuthorEmail .= $data;
  1693.           break;
  1694.           
  1695.           default:
  1696.           if (FeedForAll_parseExtensions() === TRUE) {
  1697.             FeedForAll_parseExtensions_characterData($parser, $this, $data);
  1698.           }
  1699.         }
  1700.       } else {
  1701.         if (FeedForAll_parseExtensions() === TRUE) {
  1702.           FeedForAll_parseExtensions_characterData($parser, $this, $data);
  1703.         }
  1704.       }
  1705.     }
  1706.   }
  1707. }
  1708.  
  1709. if (function_exists("FeedForAll_parseExtensions_extendParserClass")) {
  1710.   $currentBaseClassName = FeedForAll_parseExtensions_extendParserClass("rootRSSParserClass");
  1711. } else {
  1712.   $currentBaseClassName = "rootRSSParserClass";
  1713. }
  1714. eval('class baseParserClassWithExtensions extends ' . $currentBaseClassName . ' {
  1715.   Function baseParserClassWithExtensions($operateAs) {
  1716.     $this->' . $currentBaseClassName . '($operateAs);
  1717.   }
  1718. }');
  1719.  
  1720. class baseParserClass extends baseParserClassWithExtensions {
  1721.   Function baseParserClass($operateAs) {
  1722.     $parentClass = get_parent_class($this);
  1723.     $this->$parentClass($operateAs);
  1724.   }
  1725. }
  1726.  
  1727. ?>
  1728.