Wizard 2.8.2-scripts
[autoinstalls/wordpress.git] / wp-includes / class-simplepie.php
1 <?php
2 /**
3  * SimplePie
4  *
5  * A PHP-Based RSS and Atom Feed Framework.
6  * Takes the hard work out of managing a complete RSS/Atom solution.
7  *
8  * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without modification, are
12  * permitted provided that the following conditions are met:
13  *
14  *      * Redistributions of source code must retain the above copyright notice, this list of
15  *        conditions and the following disclaimer.
16  *
17  *      * Redistributions in binary form must reproduce the above copyright notice, this list
18  *        of conditions and the following disclaimer in the documentation and/or other materials
19  *        provided with the distribution.
20  *
21  *      * Neither the name of the SimplePie Team nor the names of its contributors may be used
22  *        to endorse or promote products derived from this software without specific prior
23  *        written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
26  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
28  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * @package SimplePie
36  * @version 1.1.3
37  * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon
38  * @author Ryan Parman
39  * @author Geoffrey Sneddon
40  * @link http://simplepie.org/ SimplePie
41  * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
43  * @todo phpDoc comments
44  */
45
46 /**
47  * SimplePie Name
48  */
49 define('SIMPLEPIE_NAME', 'SimplePie');
50
51 /**
52  * SimplePie Version
53  */
54 define('SIMPLEPIE_VERSION', '1.1.3');
55
56 /**
57  * SimplePie Build
58  */
59 define('SIMPLEPIE_BUILD', 20081219);
60
61 /**
62  * SimplePie Website URL
63  */
64 define('SIMPLEPIE_URL', 'http://simplepie.org');
65
66 /**
67  * SimplePie Useragent
68  * @see SimplePie::set_useragent()
69  */
70 define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD);
71
72 /**
73  * SimplePie Linkback
74  */
75 define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');
76
77 /**
78  * No Autodiscovery
79  * @see SimplePie::set_autodiscovery_level()
80  */
81 define('SIMPLEPIE_LOCATOR_NONE', 0);
82
83 /**
84  * Feed Link Element Autodiscovery
85  * @see SimplePie::set_autodiscovery_level()
86  */
87 define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
88
89 /**
90  * Local Feed Extension Autodiscovery
91  * @see SimplePie::set_autodiscovery_level()
92  */
93 define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
94
95 /**
96  * Local Feed Body Autodiscovery
97  * @see SimplePie::set_autodiscovery_level()
98  */
99 define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
100
101 /**
102  * Remote Feed Extension Autodiscovery
103  * @see SimplePie::set_autodiscovery_level()
104  */
105 define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
106
107 /**
108  * Remote Feed Body Autodiscovery
109  * @see SimplePie::set_autodiscovery_level()
110  */
111 define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
112
113 /**
114  * All Feed Autodiscovery
115  * @see SimplePie::set_autodiscovery_level()
116  */
117 define('SIMPLEPIE_LOCATOR_ALL', 31);
118
119 /**
120  * No known feed type
121  */
122 define('SIMPLEPIE_TYPE_NONE', 0);
123
124 /**
125  * RSS 0.90
126  */
127 define('SIMPLEPIE_TYPE_RSS_090', 1);
128
129 /**
130  * RSS 0.91 (Netscape)
131  */
132 define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
133
134 /**
135  * RSS 0.91 (Userland)
136  */
137 define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
138
139 /**
140  * RSS 0.91 (both Netscape and Userland)
141  */
142 define('SIMPLEPIE_TYPE_RSS_091', 6);
143
144 /**
145  * RSS 0.92
146  */
147 define('SIMPLEPIE_TYPE_RSS_092', 8);
148
149 /**
150  * RSS 0.93
151  */
152 define('SIMPLEPIE_TYPE_RSS_093', 16);
153
154 /**
155  * RSS 0.94
156  */
157 define('SIMPLEPIE_TYPE_RSS_094', 32);
158
159 /**
160  * RSS 1.0
161  */
162 define('SIMPLEPIE_TYPE_RSS_10', 64);
163
164 /**
165  * RSS 2.0
166  */
167 define('SIMPLEPIE_TYPE_RSS_20', 128);
168
169 /**
170  * RDF-based RSS
171  */
172 define('SIMPLEPIE_TYPE_RSS_RDF', 65);
173
174 /**
175  * Non-RDF-based RSS (truly intended as syndication format)
176  */
177 define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
178
179 /**
180  * All RSS
181  */
182 define('SIMPLEPIE_TYPE_RSS_ALL', 255);
183
184 /**
185  * Atom 0.3
186  */
187 define('SIMPLEPIE_TYPE_ATOM_03', 256);
188
189 /**
190  * Atom 1.0
191  */
192 define('SIMPLEPIE_TYPE_ATOM_10', 512);
193
194 /**
195  * All Atom
196  */
197 define('SIMPLEPIE_TYPE_ATOM_ALL', 768);
198
199 /**
200  * All feed types
201  */
202 define('SIMPLEPIE_TYPE_ALL', 1023);
203
204 /**
205  * No construct
206  */
207 define('SIMPLEPIE_CONSTRUCT_NONE', 0);
208
209 /**
210  * Text construct
211  */
212 define('SIMPLEPIE_CONSTRUCT_TEXT', 1);
213
214 /**
215  * HTML construct
216  */
217 define('SIMPLEPIE_CONSTRUCT_HTML', 2);
218
219 /**
220  * XHTML construct
221  */
222 define('SIMPLEPIE_CONSTRUCT_XHTML', 4);
223
224 /**
225  * base64-encoded construct
226  */
227 define('SIMPLEPIE_CONSTRUCT_BASE64', 8);
228
229 /**
230  * IRI construct
231  */
232 define('SIMPLEPIE_CONSTRUCT_IRI', 16);
233
234 /**
235  * A construct that might be HTML
236  */
237 define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
238
239 /**
240  * All constructs
241  */
242 define('SIMPLEPIE_CONSTRUCT_ALL', 63);
243
244 /**
245  * PCRE for HTML attributes
246  */
247 define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*');
248
249 /**
250  * PCRE for XML attributes
251  */
252 define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
253
254 /**
255  * XML Namespace
256  */
257 define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace');
258
259 /**
260  * Atom 1.0 Namespace
261  */
262 define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom');
263
264 /**
265  * Atom 0.3 Namespace
266  */
267 define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#');
268
269 /**
270  * RDF Namespace
271  */
272 define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
273
274 /**
275  * RSS 0.90 Namespace
276  */
277 define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/');
278
279 /**
280  * RSS 1.0 Namespace
281  */
282 define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/');
283
284 /**
285  * RSS 1.0 Content Module Namespace
286  */
287 define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/');
288
289 /**
290  * RSS 2.0 Namespace
291  * (Stupid, I know, but I'm certain it will confuse people less with support.)
292  */
293 define('SIMPLEPIE_NAMESPACE_RSS_20', '');
294
295 /**
296  * DC 1.0 Namespace
297  */
298 define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/');
299
300 /**
301  * DC 1.1 Namespace
302  */
303 define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/');
304
305 /**
306  * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
307  */
308 define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
309
310 /**
311  * GeoRSS Namespace
312  */
313 define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss');
314
315 /**
316  * Media RSS Namespace
317  */
318 define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/');
319
320 /**
321  * Wrong Media RSS Namespace
322  */
323 define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss');
324
325 /**
326  * iTunes RSS Namespace
327  */
328 define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
329
330 /**
331  * XHTML Namespace
332  */
333 define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml');
334
335 /**
336  * IANA Link Relations Registry
337  */
338 define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/');
339
340 /**
341  * Whether we're running on PHP5
342  */
343 define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>='));
344
345 /**
346  * No file source
347  */
348 define('SIMPLEPIE_FILE_SOURCE_NONE', 0);
349
350 /**
351  * Remote file source
352  */
353 define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
354
355 /**
356  * Local file source
357  */
358 define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
359
360 /**
361  * fsockopen() file source
362  */
363 define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
364
365 /**
366  * cURL file source
367  */
368 define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
369
370 /**
371  * file_get_contents() file source
372  */
373 define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
374
375 /**
376  * SimplePie
377  *
378  * @package SimplePie
379  * @version "Razzleberry"
380  * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
381  * @author Ryan Parman
382  * @author Geoffrey Sneddon
383  * @todo Option for type of fetching (cache, not modified header, fetch, etc.)
384  */
385 class SimplePie
386 {
387         /**
388          * @var array Raw data
389          * @access private
390          */
391         var $data = array();
392
393         /**
394          * @var mixed Error string
395          * @access private
396          */
397         var $error;
398
399         /**
400          * @var object Instance of SimplePie_Sanitize (or other class)
401          * @see SimplePie::set_sanitize_class()
402          * @access private
403          */
404         var $sanitize;
405
406         /**
407          * @var string SimplePie Useragent
408          * @see SimplePie::set_useragent()
409          * @access private
410          */
411         var $useragent = SIMPLEPIE_USERAGENT;
412
413         /**
414          * @var string Feed URL
415          * @see SimplePie::set_feed_url()
416          * @access private
417          */
418         var $feed_url;
419
420         /**
421          * @var object Instance of SimplePie_File to use as a feed
422          * @see SimplePie::set_file()
423          * @access private
424          */
425         var $file;
426
427         /**
428          * @var string Raw feed data
429          * @see SimplePie::set_raw_data()
430          * @access private
431          */
432         var $raw_data;
433
434         /**
435          * @var int Timeout for fetching remote files
436          * @see SimplePie::set_timeout()
437          * @access private
438          */
439         var $timeout = 10;
440
441         /**
442          * @var bool Forces fsockopen() to be used for remote files instead
443          * of cURL, even if a new enough version is installed
444          * @see SimplePie::force_fsockopen()
445          * @access private
446          */
447         var $force_fsockopen = false;
448
449         /**
450          * @var bool Force the given data/URL to be treated as a feed no matter what
451          * it appears like
452          * @see SimplePie::force_feed()
453          * @access private
454          */
455         var $force_feed = false;
456
457         /**
458          * @var bool Enable/Disable XML dump
459          * @see SimplePie::enable_xml_dump()
460          * @access private
461          */
462         var $xml_dump = false;
463
464         /**
465          * @var bool Enable/Disable Caching
466          * @see SimplePie::enable_cache()
467          * @access private
468          */
469         var $cache = true;
470
471         /**
472          * @var int Cache duration (in seconds)
473          * @see SimplePie::set_cache_duration()
474          * @access private
475          */
476         var $cache_duration = 3600;
477
478         /**
479          * @var int Auto-discovery cache duration (in seconds)
480          * @see SimplePie::set_autodiscovery_cache_duration()
481          * @access private
482          */
483         var $autodiscovery_cache_duration = 604800; // 7 Days.
484
485         /**
486          * @var string Cache location (relative to executing script)
487          * @see SimplePie::set_cache_location()
488          * @access private
489          */
490         var $cache_location = './cache';
491
492         /**
493          * @var string Function that creates the cache filename
494          * @see SimplePie::set_cache_name_function()
495          * @access private
496          */
497         var $cache_name_function = 'md5';
498
499         /**
500          * @var bool Reorder feed by date descending
501          * @see SimplePie::enable_order_by_date()
502          * @access private
503          */
504         var $order_by_date = true;
505
506         /**
507          * @var mixed Force input encoding to be set to the follow value
508          * (false, or anything type-cast to false, disables this feature)
509          * @see SimplePie::set_input_encoding()
510          * @access private
511          */
512         var $input_encoding = false;
513
514         /**
515          * @var int Feed Autodiscovery Level
516          * @see SimplePie::set_autodiscovery_level()
517          * @access private
518          */
519         var $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
520
521         /**
522          * @var string Class used for caching feeds
523          * @see SimplePie::set_cache_class()
524          * @access private
525          */
526         var $cache_class = 'SimplePie_Cache';
527
528         /**
529          * @var string Class used for locating feeds
530          * @see SimplePie::set_locator_class()
531          * @access private
532          */
533         var $locator_class = 'SimplePie_Locator';
534
535         /**
536          * @var string Class used for parsing feeds
537          * @see SimplePie::set_parser_class()
538          * @access private
539          */
540         var $parser_class = 'SimplePie_Parser';
541
542         /**
543          * @var string Class used for fetching feeds
544          * @see SimplePie::set_file_class()
545          * @access private
546          */
547         var $file_class = 'SimplePie_File';
548
549         /**
550          * @var string Class used for items
551          * @see SimplePie::set_item_class()
552          * @access private
553          */
554         var $item_class = 'SimplePie_Item';
555
556         /**
557          * @var string Class used for authors
558          * @see SimplePie::set_author_class()
559          * @access private
560          */
561         var $author_class = 'SimplePie_Author';
562
563         /**
564          * @var string Class used for categories
565          * @see SimplePie::set_category_class()
566          * @access private
567          */
568         var $category_class = 'SimplePie_Category';
569
570         /**
571          * @var string Class used for enclosures
572          * @see SimplePie::set_enclosures_class()
573          * @access private
574          */
575         var $enclosure_class = 'SimplePie_Enclosure';
576
577         /**
578          * @var string Class used for Media RSS <media:text> captions
579          * @see SimplePie::set_caption_class()
580          * @access private
581          */
582         var $caption_class = 'SimplePie_Caption';
583
584         /**
585          * @var string Class used for Media RSS <media:copyright>
586          * @see SimplePie::set_copyright_class()
587          * @access private
588          */
589         var $copyright_class = 'SimplePie_Copyright';
590
591         /**
592          * @var string Class used for Media RSS <media:credit>
593          * @see SimplePie::set_credit_class()
594          * @access private
595          */
596         var $credit_class = 'SimplePie_Credit';
597
598         /**
599          * @var string Class used for Media RSS <media:rating>
600          * @see SimplePie::set_rating_class()
601          * @access private
602          */
603         var $rating_class = 'SimplePie_Rating';
604
605         /**
606          * @var string Class used for Media RSS <media:restriction>
607          * @see SimplePie::set_restriction_class()
608          * @access private
609          */
610         var $restriction_class = 'SimplePie_Restriction';
611
612         /**
613          * @var string Class used for content-type sniffing
614          * @see SimplePie::set_content_type_sniffer_class()
615          * @access private
616          */
617         var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
618
619         /**
620          * @var string Class used for item sources.
621          * @see SimplePie::set_source_class()
622          * @access private
623          */
624         var $source_class = 'SimplePie_Source';
625
626         /**
627          * @var mixed Set javascript query string parameter (false, or
628          * anything type-cast to false, disables this feature)
629          * @see SimplePie::set_javascript()
630          * @access private
631          */
632         var $javascript = 'js';
633
634         /**
635          * @var int Maximum number of feeds to check with autodiscovery
636          * @see SimplePie::set_max_checked_feeds()
637          * @access private
638          */
639         var $max_checked_feeds = 10;
640
641         /**
642          * @var string Web-accessible path to the handler_favicon.php file.
643          * @see SimplePie::set_favicon_handler()
644          * @access private
645          */
646         var $favicon_handler = '';
647
648         /**
649          * @var string Web-accessible path to the handler_image.php file.
650          * @see SimplePie::set_image_handler()
651          * @access private
652          */
653         var $image_handler = '';
654
655         /**
656          * @var array Stores the URLs when multiple feeds are being initialized.
657          * @see SimplePie::set_feed_url()
658          * @access private
659          */
660         var $multifeed_url = array();
661
662         /**
663          * @var array Stores SimplePie objects when multiple feeds initialized.
664          * @access private
665          */
666         var $multifeed_objects = array();
667
668         /**
669          * @var array Stores the get_object_vars() array for use with multifeeds.
670          * @see SimplePie::set_feed_url()
671          * @access private
672          */
673         var $config_settings = null;
674
675         /**
676          * @var integer Stores the number of items to return per-feed with multifeeds.
677          * @see SimplePie::set_item_limit()
678          * @access private
679          */
680         var $item_limit = 0;
681
682         /**
683          * @var array Stores the default attributes to be stripped by strip_attributes().
684          * @see SimplePie::strip_attributes()
685          * @access private
686          */
687         var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
688
689         /**
690          * @var array Stores the default tags to be stripped by strip_htmltags().
691          * @see SimplePie::strip_htmltags()
692          * @access private
693          */
694         var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
695
696         /**
697          * The SimplePie class contains feed level data and options
698          *
699          * There are two ways that you can create a new SimplePie object. The first
700          * is by passing a feed URL as a parameter to the SimplePie constructor
701          * (as well as optionally setting the cache location and cache expiry). This
702          * will initialise the whole feed with all of the default settings, and you
703          * can begin accessing methods and properties immediately.
704          *
705          * The second way is to create the SimplePie object with no parameters
706          * at all. This will enable you to set configuration options. After setting
707          * them, you must initialise the feed using $feed->init(). At that point the
708          * object's methods and properties will be available to you. This format is
709          * what is used throughout this documentation.
710          *
711          * @access public
712          * @since 1.0 Preview Release
713          * @param string $feed_url This is the URL you want to parse.
714          * @param string $cache_location This is where you want the cache to be stored.
715          * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
716          */
717         function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null)
718         {
719                 // Other objects, instances created here so we can set options on them
720                 $this->sanitize =& new SimplePie_Sanitize;
721
722                 // Set options if they're passed to the constructor
723                 if ($cache_location !== null)
724                 {
725                         $this->set_cache_location($cache_location);
726                 }
727
728                 if ($cache_duration !== null)
729                 {
730                         $this->set_cache_duration($cache_duration);
731                 }
732
733                 // Only init the script if we're passed a feed URL
734                 if ($feed_url !== null)
735                 {
736                         $this->set_feed_url($feed_url);
737                         $this->init();
738                 }
739         }
740
741         /**
742          * Used for converting object to a string
743          */
744         function __toString()
745         {
746                 return md5(serialize($this->data));
747         }
748
749         /**
750          * Remove items that link back to this before destroying this object
751          */
752         function __destruct()
753         {
754                 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
755                 {
756                         if (!empty($this->data['items']))
757                         {
758                                 foreach ($this->data['items'] as $item)
759                                 {
760                                         $item->__destruct();
761                                 }
762                                 unset($item, $this->data['items']);
763                         }
764                         if (!empty($this->data['ordered_items']))
765                         {
766                                 foreach ($this->data['ordered_items'] as $item)
767                                 {
768                                         $item->__destruct();
769                                 }
770                                 unset($item, $this->data['ordered_items']);
771                         }
772                 }
773         }
774
775         /**
776          * Force the given data/URL to be treated as a feed no matter what it
777          * appears like
778          *
779          * @access public
780          * @since 1.1
781          * @param bool $enable Force the given data/URL to be treated as a feed
782          */
783         function force_feed($enable = false)
784         {
785                 $this->force_feed = (bool) $enable;
786         }
787
788         /**
789          * This is the URL of the feed you want to parse.
790          *
791          * This allows you to enter the URL of the feed you want to parse, or the
792          * website you want to try to use auto-discovery on. This takes priority
793          * over any set raw data.
794          *
795          * You can set multiple feeds to mash together by passing an array instead
796          * of a string for the $url. Remember that with each additional feed comes
797          * additional processing and resources.
798          *
799          * @access public
800          * @since 1.0 Preview Release
801          * @param mixed $url This is the URL (or array of URLs) that you want to parse.
802          * @see SimplePie::set_raw_data()
803          */
804         function set_feed_url($url)
805         {
806                 if (is_array($url))
807                 {
808                         $this->multifeed_url = array();
809                         foreach ($url as $value)
810                         {
811                                 $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1);
812                         }
813                 }
814                 else
815                 {
816                         $this->feed_url = SimplePie_Misc::fix_protocol($url, 1);
817                 }
818         }
819
820         /**
821          * Provides an instance of SimplePie_File to use as a feed
822          *
823          * @access public
824          * @param object &$file Instance of SimplePie_File (or subclass)
825          * @return bool True on success, false on failure
826          */
827         function set_file(&$file)
828         {
829                 if (is_a($file, 'SimplePie_File'))
830                 {
831                         $this->feed_url = $file->url;
832                         $this->file =& $file;
833                         return true;
834                 }
835                 return false;
836         }
837
838         /**
839          * Allows you to use a string of RSS/Atom data instead of a remote feed.
840          *
841          * If you have a feed available as a string in PHP, you can tell SimplePie
842          * to parse that data string instead of a remote feed. Any set feed URL
843          * takes precedence.
844          *
845          * @access public
846          * @since 1.0 Beta 3
847          * @param string $data RSS or Atom data as a string.
848          * @see SimplePie::set_feed_url()
849          */
850         function set_raw_data($data)
851         {
852                 $this->raw_data = $data;
853         }
854
855         /**
856          * Allows you to override the default timeout for fetching remote feeds.
857          *
858          * This allows you to change the maximum time the feed's server to respond
859          * and send the feed back.
860          *
861          * @access public
862          * @since 1.0 Beta 3
863          * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
864          */
865         function set_timeout($timeout = 10)
866         {
867                 $this->timeout = (int) $timeout;
868         }
869
870         /**
871          * Forces SimplePie to use fsockopen() instead of the preferred cURL
872          * functions.
873          *
874          * @access public
875          * @since 1.0 Beta 3
876          * @param bool $enable Force fsockopen() to be used
877          */
878         function force_fsockopen($enable = false)
879         {
880                 $this->force_fsockopen = (bool) $enable;
881         }
882
883         /**
884          * Outputs the raw XML content of the feed, after it has gone through
885          * SimplePie's filters.
886          *
887          * Used only for debugging, this function will output the XML content as
888          * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
889          * before trying to parse it. Many parts of the feed are re-written in
890          * memory, and in the end, you have a parsable feed. XML dump shows you the
891          * actual XML that SimplePie tries to parse, which may or may not be very
892          * different from the original feed.
893          *
894          * @access public
895          * @since 1.0 Preview Release
896          * @param bool $enable Enable XML dump
897          */
898         function enable_xml_dump($enable = false)
899         {
900                 $this->xml_dump = (bool) $enable;
901         }
902
903         /**
904          * Enables/disables caching in SimplePie.
905          *
906          * This option allows you to disable caching all-together in SimplePie.
907          * However, disabling the cache can lead to longer load times.
908          *
909          * @access public
910          * @since 1.0 Preview Release
911          * @param bool $enable Enable caching
912          */
913         function enable_cache($enable = true)
914         {
915                 $this->cache = (bool) $enable;
916         }
917
918         /**
919          * Set the length of time (in seconds) that the contents of a feed
920          * will be cached.
921          *
922          * @access public
923          * @param int $seconds The feed content cache duration.
924          */
925         function set_cache_duration($seconds = 3600)
926         {
927                 $this->cache_duration = (int) $seconds;
928         }
929
930         /**
931          * Set the length of time (in seconds) that the autodiscovered feed
932          * URL will be cached.
933          *
934          * @access public
935          * @param int $seconds The autodiscovered feed URL cache duration.
936          */
937         function set_autodiscovery_cache_duration($seconds = 604800)
938         {
939                 $this->autodiscovery_cache_duration = (int) $seconds;
940         }
941
942         /**
943          * Set the file system location where the cached files should be stored.
944          *
945          * @access public
946          * @param string $location The file system location.
947          */
948         function set_cache_location($location = './cache')
949         {
950                 $this->cache_location = (string) $location;
951         }
952
953         /**
954          * Determines whether feed items should be sorted into reverse chronological order.
955          *
956          * @access public
957          * @param bool $enable Sort as reverse chronological order.
958          */
959         function enable_order_by_date($enable = true)
960         {
961                 $this->order_by_date = (bool) $enable;
962         }
963
964         /**
965          * Allows you to override the character encoding reported by the feed.
966          *
967          * @access public
968          * @param string $encoding Character encoding.
969          */
970         function set_input_encoding($encoding = false)
971         {
972                 if ($encoding)
973                 {
974                         $this->input_encoding = (string) $encoding;
975                 }
976                 else
977                 {
978                         $this->input_encoding = false;
979                 }
980         }
981
982         /**
983          * Set how much feed autodiscovery to do
984          *
985          * @access public
986          * @see SIMPLEPIE_LOCATOR_NONE
987          * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
988          * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
989          * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
990          * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
991          * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
992          * @see SIMPLEPIE_LOCATOR_ALL
993          * @param int $level Feed Autodiscovery Level (level can be a
994          * combination of the above constants, see bitwise OR operator)
995          */
996         function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL)
997         {
998                 $this->autodiscovery = (int) $level;
999         }
1000
1001         /**
1002          * Allows you to change which class SimplePie uses for caching.
1003          * Useful when you are overloading or extending SimplePie's default classes.
1004          *
1005          * @access public
1006          * @param string $class Name of custom class.
1007          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1008          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1009          */
1010         function set_cache_class($class = 'SimplePie_Cache')
1011         {
1012                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache'))
1013                 {
1014                         $this->cache_class = $class;
1015                         return true;
1016                 }
1017                 return false;
1018         }
1019
1020         /**
1021          * Allows you to change which class SimplePie uses for auto-discovery.
1022          * Useful when you are overloading or extending SimplePie's default classes.
1023          *
1024          * @access public
1025          * @param string $class Name of custom class.
1026          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1027          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1028          */
1029         function set_locator_class($class = 'SimplePie_Locator')
1030         {
1031                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator'))
1032                 {
1033                         $this->locator_class = $class;
1034                         return true;
1035                 }
1036                 return false;
1037         }
1038
1039         /**
1040          * Allows you to change which class SimplePie uses for XML parsing.
1041          * Useful when you are overloading or extending SimplePie's default classes.
1042          *
1043          * @access public
1044          * @param string $class Name of custom class.
1045          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1046          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1047          */
1048         function set_parser_class($class = 'SimplePie_Parser')
1049         {
1050                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser'))
1051                 {
1052                         $this->parser_class = $class;
1053                         return true;
1054                 }
1055                 return false;
1056         }
1057
1058         /**
1059          * Allows you to change which class SimplePie uses for remote file fetching.
1060          * Useful when you are overloading or extending SimplePie's default classes.
1061          *
1062          * @access public
1063          * @param string $class Name of custom class.
1064          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1065          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1066          */
1067         function set_file_class($class = 'SimplePie_File')
1068         {
1069                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File'))
1070                 {
1071                         $this->file_class = $class;
1072                         return true;
1073                 }
1074                 return false;
1075         }
1076
1077         /**
1078          * Allows you to change which class SimplePie uses for data sanitization.
1079          * Useful when you are overloading or extending SimplePie's default classes.
1080          *
1081          * @access public
1082          * @param string $class Name of custom class.
1083          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1084          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1085          */
1086         function set_sanitize_class($class = 'SimplePie_Sanitize')
1087         {
1088                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize'))
1089                 {
1090                         $this->sanitize =& new $class;
1091                         return true;
1092                 }
1093                 return false;
1094         }
1095
1096         /**
1097          * Allows you to change which class SimplePie uses for handling feed items.
1098          * Useful when you are overloading or extending SimplePie's default classes.
1099          *
1100          * @access public
1101          * @param string $class Name of custom class.
1102          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1103          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1104          */
1105         function set_item_class($class = 'SimplePie_Item')
1106         {
1107                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item'))
1108                 {
1109                         $this->item_class = $class;
1110                         return true;
1111                 }
1112                 return false;
1113         }
1114
1115         /**
1116          * Allows you to change which class SimplePie uses for handling author data.
1117          * Useful when you are overloading or extending SimplePie's default classes.
1118          *
1119          * @access public
1120          * @param string $class Name of custom class.
1121          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1122          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1123          */
1124         function set_author_class($class = 'SimplePie_Author')
1125         {
1126                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author'))
1127                 {
1128                         $this->author_class = $class;
1129                         return true;
1130                 }
1131                 return false;
1132         }
1133
1134         /**
1135          * Allows you to change which class SimplePie uses for handling category data.
1136          * Useful when you are overloading or extending SimplePie's default classes.
1137          *
1138          * @access public
1139          * @param string $class Name of custom class.
1140          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1141          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1142          */
1143         function set_category_class($class = 'SimplePie_Category')
1144         {
1145                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category'))
1146                 {
1147                         $this->category_class = $class;
1148                         return true;
1149                 }
1150                 return false;
1151         }
1152
1153         /**
1154          * Allows you to change which class SimplePie uses for feed enclosures.
1155          * Useful when you are overloading or extending SimplePie's default classes.
1156          *
1157          * @access public
1158          * @param string $class Name of custom class.
1159          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1160          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1161          */
1162         function set_enclosure_class($class = 'SimplePie_Enclosure')
1163         {
1164                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure'))
1165                 {
1166                         $this->enclosure_class = $class;
1167                         return true;
1168                 }
1169                 return false;
1170         }
1171
1172         /**
1173          * Allows you to change which class SimplePie uses for <media:text> captions
1174          * Useful when you are overloading or extending SimplePie's default classes.
1175          *
1176          * @access public
1177          * @param string $class Name of custom class.
1178          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1179          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1180          */
1181         function set_caption_class($class = 'SimplePie_Caption')
1182         {
1183                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption'))
1184                 {
1185                         $this->caption_class = $class;
1186                         return true;
1187                 }
1188                 return false;
1189         }
1190
1191         /**
1192          * Allows you to change which class SimplePie uses for <media:copyright>
1193          * Useful when you are overloading or extending SimplePie's default classes.
1194          *
1195          * @access public
1196          * @param string $class Name of custom class.
1197          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1198          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1199          */
1200         function set_copyright_class($class = 'SimplePie_Copyright')
1201         {
1202                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright'))
1203                 {
1204                         $this->copyright_class = $class;
1205                         return true;
1206                 }
1207                 return false;
1208         }
1209
1210         /**
1211          * Allows you to change which class SimplePie uses for <media:credit>
1212          * Useful when you are overloading or extending SimplePie's default classes.
1213          *
1214          * @access public
1215          * @param string $class Name of custom class.
1216          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1217          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1218          */
1219         function set_credit_class($class = 'SimplePie_Credit')
1220         {
1221                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit'))
1222                 {
1223                         $this->credit_class = $class;
1224                         return true;
1225                 }
1226                 return false;
1227         }
1228
1229         /**
1230          * Allows you to change which class SimplePie uses for <media:rating>
1231          * Useful when you are overloading or extending SimplePie's default classes.
1232          *
1233          * @access public
1234          * @param string $class Name of custom class.
1235          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1236          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1237          */
1238         function set_rating_class($class = 'SimplePie_Rating')
1239         {
1240                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating'))
1241                 {
1242                         $this->rating_class = $class;
1243                         return true;
1244                 }
1245                 return false;
1246         }
1247
1248         /**
1249          * Allows you to change which class SimplePie uses for <media:restriction>
1250          * Useful when you are overloading or extending SimplePie's default classes.
1251          *
1252          * @access public
1253          * @param string $class Name of custom class.
1254          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1255          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1256          */
1257         function set_restriction_class($class = 'SimplePie_Restriction')
1258         {
1259                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction'))
1260                 {
1261                         $this->restriction_class = $class;
1262                         return true;
1263                 }
1264                 return false;
1265         }
1266
1267         /**
1268          * Allows you to change which class SimplePie uses for content-type sniffing.
1269          * Useful when you are overloading or extending SimplePie's default classes.
1270          *
1271          * @access public
1272          * @param string $class Name of custom class.
1273          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1274          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1275          */
1276         function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer')
1277         {
1278                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer'))
1279                 {
1280                         $this->content_type_sniffer_class = $class;
1281                         return true;
1282                 }
1283                 return false;
1284         }
1285
1286         /**
1287          * Allows you to change which class SimplePie uses item sources.
1288          * Useful when you are overloading or extending SimplePie's default classes.
1289          *
1290          * @access public
1291          * @param string $class Name of custom class.
1292          * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1293          * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1294          */
1295         function set_source_class($class = 'SimplePie_Source')
1296         {
1297                 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source'))
1298                 {
1299                         $this->source_class = $class;
1300                         return true;
1301                 }
1302                 return false;
1303         }
1304
1305         /**
1306          * Allows you to override the default user agent string.
1307          *
1308          * @access public
1309          * @param string $ua New user agent string.
1310          */
1311         function set_useragent($ua = SIMPLEPIE_USERAGENT)
1312         {
1313                 $this->useragent = (string) $ua;
1314         }
1315
1316         /**
1317          * Set callback function to create cache filename with
1318          *
1319          * @access public
1320          * @param mixed $function Callback function
1321          */
1322         function set_cache_name_function($function = 'md5')
1323         {
1324                 if (is_callable($function))
1325                 {
1326                         $this->cache_name_function = $function;
1327                 }
1328         }
1329
1330         /**
1331          * Set javascript query string parameter
1332          *
1333          * @access public
1334          * @param mixed $get Javascript query string parameter
1335          */
1336         function set_javascript($get = 'js')
1337         {
1338                 if ($get)
1339                 {
1340                         $this->javascript = (string) $get;
1341                 }
1342                 else
1343                 {
1344                         $this->javascript = false;
1345                 }
1346         }
1347
1348         /**
1349          * Set options to make SP as fast as possible.  Forgoes a
1350          * substantial amount of data sanitization in favor of speed.
1351          *
1352          * @access public
1353          * @param bool $set Whether to set them or not
1354          */
1355         function set_stupidly_fast($set = false)
1356         {
1357                 if ($set)
1358                 {
1359                         $this->enable_order_by_date(false);
1360                         $this->remove_div(false);
1361                         $this->strip_comments(false);
1362                         $this->strip_htmltags(false);
1363                         $this->strip_attributes(false);
1364                         $this->set_image_handler(false);
1365                 }
1366         }
1367
1368         /**
1369          * Set maximum number of feeds to check with autodiscovery
1370          *
1371          * @access public
1372          * @param int $max Maximum number of feeds to check
1373          */
1374         function set_max_checked_feeds($max = 10)
1375         {
1376                 $this->max_checked_feeds = (int) $max;
1377         }
1378
1379         function remove_div($enable = true)
1380         {
1381                 $this->sanitize->remove_div($enable);
1382         }
1383
1384         function strip_htmltags($tags = '', $encode = null)
1385         {
1386                 if ($tags === '')
1387                 {
1388                         $tags = $this->strip_htmltags;
1389                 }
1390                 $this->sanitize->strip_htmltags($tags);
1391                 if ($encode !== null)
1392                 {
1393                         $this->sanitize->encode_instead_of_strip($tags);
1394                 }
1395         }
1396
1397         function encode_instead_of_strip($enable = true)
1398         {
1399                 $this->sanitize->encode_instead_of_strip($enable);
1400         }
1401
1402         function strip_attributes($attribs = '')
1403         {
1404                 if ($attribs === '')
1405                 {
1406                         $attribs = $this->strip_attributes;
1407                 }
1408                 $this->sanitize->strip_attributes($attribs);
1409         }
1410
1411         function set_output_encoding($encoding = 'UTF-8')
1412         {
1413                 $this->sanitize->set_output_encoding($encoding);
1414         }
1415
1416         function strip_comments($strip = false)
1417         {
1418                 $this->sanitize->strip_comments($strip);
1419         }
1420
1421         /**
1422          * Set element/attribute key/value pairs of HTML attributes
1423          * containing URLs that need to be resolved relative to the feed
1424          *
1425          * @access public
1426          * @since 1.0
1427          * @param array $element_attribute Element/attribute key/value pairs
1428          */
1429         function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
1430         {
1431                 $this->sanitize->set_url_replacements($element_attribute);
1432         }
1433
1434         /**
1435          * Set the handler to enable the display of cached favicons.
1436          *
1437          * @access public
1438          * @param str $page Web-accessible path to the handler_favicon.php file.
1439          * @param str $qs The query string that the value should be passed to.
1440          */
1441         function set_favicon_handler($page = false, $qs = 'i')
1442         {
1443                 if ($page != false)
1444                 {
1445                         $this->favicon_handler = $page . '?' . $qs . '=';
1446                 }
1447                 else
1448                 {
1449                         $this->favicon_handler = '';
1450                 }
1451         }
1452
1453         /**
1454          * Set the handler to enable the display of cached images.
1455          *
1456          * @access public
1457          * @param str $page Web-accessible path to the handler_image.php file.
1458          * @param str $qs The query string that the value should be passed to.
1459          */
1460         function set_image_handler($page = false, $qs = 'i')
1461         {
1462                 if ($page != false)
1463                 {
1464                         $this->sanitize->set_image_handler($page . '?' . $qs . '=');
1465                 }
1466                 else
1467                 {
1468                         $this->image_handler = '';
1469                 }
1470         }
1471
1472         /**
1473          * Set the limit for items returned per-feed with multifeeds.
1474          *
1475          * @access public
1476          * @param integer $limit The maximum number of items to return.
1477          */
1478         function set_item_limit($limit = 0)
1479         {
1480                 $this->item_limit = (int) $limit;
1481         }
1482
1483         function init()
1484         {
1485                 if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
1486                 {
1487                         return false;
1488                 }
1489                 if (isset($_GET[$this->javascript]))
1490                 {
1491                         if (function_exists('ob_gzhandler'))
1492                         {
1493                                 ob_start('ob_gzhandler');
1494                         }
1495                         header('Content-type: text/javascript; charset: UTF-8');
1496                         header('Cache-Control: must-revalidate');
1497                         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
1498                         ?>
1499 function embed_odeo(link) {
1500         document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
1501 }
1502
1503 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
1504         if (placeholder != '') {
1505                 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
1506         }
1507         else {
1508                 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
1509         }
1510 }
1511
1512 function embed_flash(bgcolor, width, height, link, loop, type) {
1513         document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
1514 }
1515
1516 function embed_flv(width, height, link, placeholder, loop, player) {
1517         document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
1518 }
1519
1520 function embed_wmedia(width, height, link) {
1521         document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
1522 }
1523                         <?php
1524                         exit;
1525                 }
1526
1527                 // Pass whatever was set with config options over to the sanitizer.
1528                 $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
1529                 $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
1530
1531                 if ($this->feed_url !== null || $this->raw_data !== null)
1532                 {
1533                         $this->data = array();
1534                         $this->multifeed_objects = array();
1535                         $cache = false;
1536
1537                         if ($this->feed_url !== null)
1538                         {
1539                                 $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
1540                                 // Decide whether to enable caching
1541                                 if ($this->cache && $parsed_feed_url['scheme'] !== '')
1542                                 {
1543                                         $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
1544                                 }
1545                                 // If it's enabled and we don't want an XML dump, use the cache
1546                                 if ($cache && !$this->xml_dump)
1547                                 {
1548                                         // Load the Cache
1549                                         $this->data = $cache->load();
1550                                         if (!empty($this->data))
1551                                         {
1552                                                 // If the cache is for an outdated build of SimplePie
1553                                                 if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD)
1554                                                 {
1555                                                         $cache->unlink();
1556                                                         $this->data = array();
1557                                                 }
1558                                                 // If we've hit a collision just rerun it with caching disabled
1559                                                 elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url)
1560                                                 {
1561                                                         $cache = false;
1562                                                         $this->data = array();
1563                                                 }
1564                                                 // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
1565                                                 elseif (isset($this->data['feed_url']))
1566                                                 {
1567                                                         // If the autodiscovery cache is still valid use it.
1568                                                         if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
1569                                                         {
1570                                                                 // Do not need to do feed autodiscovery yet.
1571                                                                 if ($this->data['feed_url'] == $this->data['url'])
1572                                                                 {
1573                                                                         $cache->unlink();
1574                                                                         $this->data = array();
1575                                                                 }
1576                                                                 else
1577                                                                 {
1578                                                                         $this->set_feed_url($this->data['feed_url']);
1579                                                                         return $this->init();
1580                                                                 }
1581                                                         }
1582                                                 }
1583                                                 // Check if the cache has been updated
1584                                                 elseif ($cache->mtime() + $this->cache_duration < time())
1585                                                 {
1586                                                         // If we have last-modified and/or etag set
1587                                                         if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
1588                                                         {
1589                                                                 $headers = array();
1590                                                                 if (isset($this->data['headers']['last-modified']))
1591                                                                 {
1592                                                                         $headers['if-modified-since'] = $this->data['headers']['last-modified'];
1593                                                                 }
1594                                                                 if (isset($this->data['headers']['etag']))
1595                                                                 {
1596                                                                         $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
1597                                                                 }
1598                                                                 $file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen);
1599                                                                 if ($file->success)
1600                                                                 {
1601                                                                         if ($file->status_code == 304)
1602                                                                         {
1603                                                                                 $cache->touch();
1604                                                                                 return true;
1605                                                                         }
1606                                                                         else
1607                                                                         {
1608                                                                                 $headers = $file->headers;
1609                                                                         }
1610                                                                 }
1611                                                                 else
1612                                                                 {
1613                                                                         unset($file);
1614                                                                 }
1615                                                         }
1616                                                 }
1617                                                 // If the cache is still valid, just return true
1618                                                 else
1619                                                 {
1620                                                         return true;
1621                                                 }
1622                                         }
1623                                         // If the cache is empty, delete it
1624                                         else
1625                                         {
1626                                                 $cache->unlink();
1627                                                 $this->data = array();
1628                                         }
1629                                 }
1630                                 // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
1631                                 if (!isset($file))
1632                                 {
1633                                         if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url)
1634                                         {
1635                                                 $file =& $this->file;
1636                                         }
1637                                         else
1638                                         {
1639                                                 $file =& new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
1640                                         }
1641                                 }
1642                                 // If the file connection has an error, set SimplePie::error to that and quit
1643                                 if (!$file->success)
1644                                 {
1645                                         $this->error = $file->error;
1646                                         if (!empty($this->data))
1647                                         {
1648                                                 return true;
1649                                         }
1650                                         else
1651                                         {
1652                                                 return false;
1653                                         }
1654                                 }
1655
1656                                 if (!$this->force_feed)
1657                                 {
1658                                         // Check if the supplied URL is a feed, if it isn't, look for it.
1659                                         $locate =& new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
1660                                         if (!$locate->is_feed($file))
1661                                         {
1662                                                 // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
1663                                                 unset($file);
1664                                                 if ($file = $locate->find($this->autodiscovery))
1665                                                 {
1666                                                         if ($cache)
1667                                                         {
1668                                                                 $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
1669                                                                 if (!$cache->save($this))
1670                                                                 {
1671                                                                         trigger_error("$cache->name is not writeable", E_USER_WARNING);
1672                                                                 }
1673                                                                 $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
1674                                                         }
1675                                                         $this->feed_url = $file->url;
1676                                                 }
1677                                                 else
1678                                                 {
1679                                                         $this->error = "A feed could not be found at $this->feed_url";
1680                                                         SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1681                                                         return false;
1682                                                 }
1683                                         }
1684                                         $locate = null;
1685                                 }
1686
1687                                 $headers = $file->headers;
1688                                 $data = $file->body;
1689                                 $sniffer =& new $this->content_type_sniffer_class($file);
1690                                 $sniffed = $sniffer->get_type();
1691                         }
1692                         else
1693                         {
1694                                 $data = $this->raw_data;
1695                         }
1696
1697                         // Set up array of possible encodings
1698                         $encodings = array();
1699
1700                         // First check to see if input has been overridden.
1701                         if ($this->input_encoding !== false)
1702                         {
1703                                 $encodings[] = $this->input_encoding;
1704                         }
1705
1706                         $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
1707                         $text_types = array('text/xml', 'text/xml-external-parsed-entity');
1708
1709                         // RFC 3023 (only applies to sniffed content)
1710                         if (isset($sniffed))
1711                         {
1712                                 if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml')
1713                                 {
1714                                         if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1715                                         {
1716                                                 $encodings[] = strtoupper($charset[1]);
1717                                         }
1718                                         $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1719                                         $encodings[] = 'UTF-8';
1720                                 }
1721                                 elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
1722                                 {
1723                                         if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1724                                         {
1725                                                 $encodings[] = $charset[1];
1726                                         }
1727                                         $encodings[] = 'US-ASCII';
1728                                 }
1729                                 // Text MIME-type default
1730                                 elseif (substr($sniffed, 0, 5) === 'text/')
1731                                 {
1732                                         $encodings[] = 'US-ASCII';
1733                                 }
1734                         }
1735
1736                         // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
1737                         $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1738                         $encodings[] = 'UTF-8';
1739                         $encodings[] = 'ISO-8859-1';
1740
1741                         // There's no point in trying an encoding twice
1742                         $encodings = array_unique($encodings);
1743
1744                         // If we want the XML, just output that with the most likely encoding and quit
1745                         if ($this->xml_dump)
1746                         {
1747                                 header('Content-type: text/xml; charset=' . $encodings[0]);
1748                                 echo $data;
1749                                 exit;
1750                         }
1751
1752                         // Loop through each possible encoding, till we return something, or run out of possibilities
1753                         foreach ($encodings as $encoding)
1754                         {
1755                                 // Change the encoding to UTF-8 (as we always use UTF-8 internally)
1756                                 if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'))
1757                                 {
1758                                         // Create new parser
1759                                         $parser =& new $this->parser_class();
1760
1761                                         // If it's parsed fine
1762                                         if ($parser->parse($utf8_data, 'UTF-8'))
1763                                         {
1764                                                 $this->data = $parser->get_data();
1765                                                 if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE)
1766                                                 {
1767                                                         if (isset($headers))
1768                                                         {
1769                                                                 $this->data['headers'] = $headers;
1770                                                         }
1771                                                         $this->data['build'] = SIMPLEPIE_BUILD;
1772
1773                                                         // Cache the file if caching is enabled
1774                                                         if ($cache && !$cache->save($this))
1775                                                         {
1776                                                                 trigger_error("$cache->name is not writeable", E_USER_WARNING);
1777                                                         }
1778                                                         return true;
1779                                                 }
1780                                                 else
1781                                                 {
1782                                                         $this->error = "A feed could not be found at $this->feed_url";
1783                                                         SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1784                                                         return false;
1785                                                 }
1786                                         }
1787                                 }
1788                         }
1789                         // We have an error, just set SimplePie::error to it and quit
1790                         $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
1791                         SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1792                         return false;
1793                 }
1794                 elseif (!empty($this->multifeed_url))
1795                 {
1796                         $i = 0;
1797                         $success = 0;
1798                         $this->multifeed_objects = array();
1799                         foreach ($this->multifeed_url as $url)
1800                         {
1801                                 if (SIMPLEPIE_PHP5)
1802                                 {
1803                                         // This keyword needs to defy coding standards for PHP4 compatibility
1804                                         $this->multifeed_objects[$i] = clone($this);
1805                                 }
1806                                 else
1807                                 {
1808                                         $this->multifeed_objects[$i] = $this;
1809                                 }
1810                                 $this->multifeed_objects[$i]->set_feed_url($url);
1811                                 $success |= $this->multifeed_objects[$i]->init();
1812                                 $i++;
1813                         }
1814                         return (bool) $success;
1815                 }
1816                 else
1817                 {
1818                         return false;
1819                 }
1820         }
1821
1822         /**
1823          * Return the error message for the occured error
1824          *
1825          * @access public
1826          * @return string Error message
1827          */
1828         function error()
1829         {
1830                 return $this->error;
1831         }
1832
1833         function get_encoding()
1834         {
1835                 return $this->sanitize->output_encoding;
1836         }
1837
1838         function handle_content_type($mime = 'text/html')
1839         {
1840                 if (!headers_sent())
1841                 {
1842                         $header = "Content-type: $mime;";
1843                         if ($this->get_encoding())
1844                         {
1845                                 $header .= ' charset=' . $this->get_encoding();
1846                         }
1847                         else
1848                         {
1849                                 $header .= ' charset=UTF-8';
1850                         }
1851                         header($header);
1852                 }
1853         }
1854
1855         function get_type()
1856         {
1857                 if (!isset($this->data['type']))
1858                 {
1859                         $this->data['type'] = SIMPLEPIE_TYPE_ALL;
1860                         if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
1861                         {
1862                                 $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10;
1863                         }
1864                         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
1865                         {
1866                                 $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03;
1867                         }
1868                         elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
1869                         {
1870                                 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
1871                                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
1872                                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
1873                                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
1874                                 {
1875                                         $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10;
1876                                 }
1877                                 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
1878                                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
1879                                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
1880                                 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
1881                                 {
1882                                         $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
1883                                 }
1884                         }
1885                         elseif (isset($this->data['child']['']['rss']))
1886                         {
1887                                 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
1888                                 if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
1889                                 {
1890                                         switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
1891                                         {
1892                                                 case '0.91':
1893                                                         $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
1894                                                         if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1895                                                         {
1896                                                                 switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1897                                                                 {
1898                                                                         case '0':
1899                                                                                 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
1900                                                                                 break;
1901
1902                                                                         case '24':
1903                                                                                 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND;
1904                                                                                 break;
1905                                                                 }
1906                                                         }
1907                                                         break;
1908
1909                                                 case '0.92':
1910                                                         $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092;
1911                                                         break;
1912
1913                                                 case '0.93':
1914                                                         $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093;
1915                                                         break;
1916
1917                                                 case '0.94':
1918                                                         $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094;
1919                                                         break;
1920
1921                                                 case '2.0':
1922                                                         $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20;
1923                                                         break;
1924                                         }
1925                                 }
1926                         }
1927                         else
1928                         {
1929                                 $this->data['type'] = SIMPLEPIE_TYPE_NONE;
1930                         }
1931                 }
1932                 return $this->data['type'];
1933         }
1934
1935         /**
1936          * Returns the URL for the favicon of the feed's website.
1937          *
1938          * @todo Cache atom:icon
1939          * @access public
1940          * @since 1.0
1941          */
1942         function get_favicon()
1943         {
1944                 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
1945                 {
1946                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1947                 }
1948                 elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url))
1949                 {
1950                         $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
1951
1952                         if ($this->cache && $this->favicon_handler)
1953                         {
1954                                 $favicon_filename = call_user_func($this->cache_name_function, $favicon);
1955                                 $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi');
1956
1957                                 if ($cache->load())
1958                                 {
1959                                         return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
1960                                 }
1961                                 else
1962                                 {
1963                                         $file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
1964
1965                                         if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
1966                                         {
1967                                                 $sniffer =& new $this->content_type_sniffer_class($file);
1968                                                 if (substr($sniffer->get_type(), 0, 6) === 'image/')
1969                                                 {
1970                                                         if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
1971                                                         {
1972                                                                 return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
1973                                                         }
1974                                                         else
1975                                                         {
1976                                                                 trigger_error("$cache->name is not writeable", E_USER_WARNING);
1977                                                                 return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
1978                                                         }
1979                                                 }
1980                                         }
1981                                 }
1982                         }
1983                         else
1984                         {
1985                                 return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
1986                         }
1987                 }
1988                 return false;
1989         }
1990
1991         /**
1992          * @todo If we have a perm redirect we should return the new URL
1993          * @todo When we make the above change, let's support <itunes:new-feed-url> as well
1994          * @todo Also, |atom:link|@rel=self
1995          */
1996         function subscribe_url()
1997         {
1998                 if ($this->feed_url !== null)
1999                 {
2000                         return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
2001                 }
2002                 else
2003                 {
2004                         return null;
2005                 }
2006         }
2007
2008         function subscribe_feed()
2009         {
2010                 if ($this->feed_url !== null)
2011                 {
2012                         return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2013                 }
2014                 else
2015                 {
2016                         return null;
2017                 }
2018         }
2019
2020         function subscribe_outlook()
2021         {
2022                 if ($this->feed_url !== null)
2023                 {
2024                         return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2025                 }
2026                 else
2027                 {
2028                         return null;
2029                 }
2030         }
2031
2032         function subscribe_podcast()
2033         {
2034                 if ($this->feed_url !== null)
2035                 {
2036                         return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI);
2037                 }
2038                 else
2039                 {
2040                         return null;
2041                 }
2042         }
2043
2044         function subscribe_itunes()
2045         {
2046                 if ($this->feed_url !== null)
2047                 {
2048                         return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI);
2049                 }
2050                 else
2051                 {
2052                         return null;
2053                 }
2054         }
2055
2056         /**
2057          * Creates the subscribe_* methods' return data
2058          *
2059          * @access private
2060          * @param string $feed_url String to prefix to the feed URL
2061          * @param string $site_url String to prefix to the site URL (and
2062          * suffix to the feed URL)
2063          * @return mixed URL if feed exists, false otherwise
2064          */
2065         function subscribe_service($feed_url, $site_url = null)
2066         {
2067                 if ($this->subscribe_url())
2068                 {
2069                         $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
2070                         if ($site_url !== null && $this->get_link() !== null)
2071                         {
2072                                 $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
2073                         }
2074                         return $return;
2075                 }
2076                 else
2077                 {
2078                         return null;
2079                 }
2080         }
2081
2082         function subscribe_aol()
2083         {
2084                 return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
2085         }
2086
2087         function subscribe_bloglines()
2088         {
2089                 return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
2090         }
2091
2092         function subscribe_eskobo()
2093         {
2094                 return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
2095         }
2096
2097         function subscribe_feedfeeds()
2098         {
2099                 return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
2100         }
2101
2102         function subscribe_feedster()
2103         {
2104                 return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
2105         }
2106
2107         function subscribe_google()
2108         {
2109                 return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
2110         }
2111
2112         function subscribe_gritwire()
2113         {
2114                 return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
2115         }
2116
2117         function subscribe_msn()
2118         {
2119                 return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru=');
2120         }
2121
2122         function subscribe_netvibes()
2123         {
2124                 return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
2125         }
2126
2127         function subscribe_newsburst()
2128         {
2129                 return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
2130         }
2131
2132         function subscribe_newsgator()
2133         {
2134                 return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
2135         }
2136
2137         function subscribe_odeo()
2138         {
2139                 return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
2140         }
2141
2142         function subscribe_podnova()
2143         {
2144                 return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
2145         }
2146
2147         function subscribe_rojo()
2148         {
2149                 return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
2150         }
2151
2152         function subscribe_yahoo()
2153         {
2154                 return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
2155         }
2156
2157         function get_feed_tags($namespace, $tag)
2158         {
2159                 $type = $this->get_type();
2160                 if ($type & SIMPLEPIE_TYPE_ATOM_10)
2161                 {
2162                         if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
2163                         {
2164                                 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
2165                         }
2166                 }
2167                 if ($type & SIMPLEPIE_TYPE_ATOM_03)
2168                 {
2169                         if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
2170                         {
2171                                 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
2172                         }
2173                 }
2174                 if ($type & SIMPLEPIE_TYPE_RSS_RDF)
2175                 {
2176                         if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
2177                         {
2178                                 return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
2179                         }
2180                 }
2181                 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2182                 {
2183                         if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
2184                         {
2185                                 return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
2186                         }
2187                 }
2188                 return null;
2189         }
2190
2191         function get_channel_tags($namespace, $tag)
2192         {
2193                 $type = $this->get_type();
2194                 if ($type & SIMPLEPIE_TYPE_ATOM_ALL)
2195                 {
2196                         if ($return = $this->get_feed_tags($namespace, $tag))
2197                         {
2198                                 return $return;
2199                         }
2200                 }
2201                 if ($type & SIMPLEPIE_TYPE_RSS_10)
2202                 {
2203                         if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel'))
2204                         {
2205                                 if (isset($channel[0]['child'][$namespace][$tag]))
2206                                 {
2207                                         return $channel[0]['child'][$namespace][$tag];
2208                                 }
2209                         }
2210                 }
2211                 if ($type & SIMPLEPIE_TYPE_RSS_090)
2212                 {
2213                         if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel'))
2214                         {
2215                                 if (isset($channel[0]['child'][$namespace][$tag]))
2216                                 {
2217                                         return $channel[0]['child'][$namespace][$tag];
2218                                 }
2219                         }
2220                 }
2221                 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2222                 {
2223                         if ($channel = $this->get_feed_tags('', 'channel'))
2224                         {
2225                                 if (isset($channel[0]['child'][$namespace][$tag]))
2226                                 {
2227                                         return $channel[0]['child'][$namespace][$tag];
2228                                 }
2229                         }
2230                 }
2231                 return null;
2232         }
2233
2234         function get_image_tags($namespace, $tag)
2235         {
2236                 $type = $this->get_type();
2237                 if ($type & SIMPLEPIE_TYPE_RSS_10)
2238                 {
2239                         if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image'))
2240                         {
2241                                 if (isset($image[0]['child'][$namespace][$tag]))
2242                                 {
2243                                         return $image[0]['child'][$namespace][$tag];
2244                                 }
2245                         }
2246                 }
2247                 if ($type & SIMPLEPIE_TYPE_RSS_090)
2248                 {
2249                         if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image'))
2250                         {
2251                                 if (isset($image[0]['child'][$namespace][$tag]))
2252                                 {
2253                                         return $image[0]['child'][$namespace][$tag];
2254                                 }
2255                         }
2256                 }
2257                 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2258                 {
2259                         if ($image = $this->get_channel_tags('', 'image'))
2260                         {
2261                                 if (isset($image[0]['child'][$namespace][$tag]))
2262                                 {
2263                                         return $image[0]['child'][$namespace][$tag];
2264                                 }
2265                         }
2266                 }
2267                 return null;
2268         }
2269
2270         function get_base($element = array())
2271         {
2272                 if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
2273                 {
2274                         return $element['xml_base'];
2275                 }
2276                 elseif ($this->get_link() !== null)
2277                 {
2278                         return $this->get_link();
2279                 }
2280                 else
2281                 {
2282                         return $this->subscribe_url();
2283                 }
2284         }
2285
2286         function sanitize($data, $type, $base = '')
2287         {
2288                 return $this->sanitize->sanitize($data, $type, $base);
2289         }
2290
2291         function get_title()
2292         {
2293                 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
2294                 {
2295                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2296                 }
2297                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
2298                 {
2299                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2300                 }
2301                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2302                 {
2303                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2304                 }
2305                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2306                 {
2307                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2308                 }
2309                 elseif ($return = $this->get_channel_tags('', 'title'))
2310                 {
2311                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2312                 }
2313                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2314                 {
2315                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2316                 }
2317                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2318                 {
2319                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2320                 }
2321                 else
2322                 {
2323                         return null;
2324                 }
2325         }
2326
2327         function get_category($key = 0)
2328         {
2329                 $categories = $this->get_categories();
2330                 if (isset($categories[$key]))
2331                 {
2332                         return $categories[$key];
2333                 }
2334                 else
2335                 {
2336                         return null;
2337                 }
2338         }
2339
2340         function get_categories()
2341         {
2342                 $categories = array();
2343
2344                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
2345                 {
2346                         $term = null;
2347                         $scheme = null;
2348                         $label = null;
2349                         if (isset($category['attribs']['']['term']))
2350                         {
2351                                 $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
2352                         }
2353                         if (isset($category['attribs']['']['scheme']))
2354                         {
2355                                 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2356                         }
2357                         if (isset($category['attribs']['']['label']))
2358                         {
2359                                 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2360                         }
2361                         $categories[] =& new $this->category_class($term, $scheme, $label);
2362                 }
2363                 foreach ((array) $this->get_channel_tags('', 'category') as $category)
2364                 {
2365                         $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2366                 }
2367                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
2368                 {
2369                         $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2370                 }
2371                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
2372                 {
2373                         $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2374                 }
2375
2376                 if (!empty($categories))
2377                 {
2378                         return SimplePie_Misc::array_unique($categories);
2379                 }
2380                 else
2381                 {
2382                         return null;
2383                 }
2384         }
2385
2386         function get_author($key = 0)
2387         {
2388                 $authors = $this->get_authors();
2389                 if (isset($authors[$key]))
2390                 {
2391                         return $authors[$key];
2392                 }
2393                 else
2394                 {
2395                         return null;
2396                 }
2397         }
2398
2399         function get_authors()
2400         {
2401                 $authors = array();
2402                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
2403                 {
2404                         $name = null;
2405                         $uri = null;
2406                         $email = null;
2407                         if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2408                         {
2409                                 $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2410                         }
2411                         if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2412                         {
2413                                 $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2414                         }
2415                         if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2416                         {
2417                                 $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2418                         }
2419                         if ($name !== null || $email !== null || $uri !== null)
2420                         {
2421                                 $authors[] =& new $this->author_class($name, $uri, $email);
2422                         }
2423                 }
2424                 if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
2425                 {
2426                         $name = null;
2427                         $url = null;
2428                         $email = null;
2429                         if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2430                         {
2431                                 $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2432                         }
2433                         if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2434                         {
2435                                 $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2436                         }
2437                         if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2438                         {
2439                                 $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2440                         }
2441                         if ($name !== null || $email !== null || $url !== null)
2442                         {
2443                                 $authors[] =& new $this->author_class($name, $url, $email);
2444                         }
2445                 }
2446                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
2447                 {
2448                         $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2449                 }
2450                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
2451                 {
2452                         $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2453                 }
2454                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
2455                 {
2456                         $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2457                 }
2458
2459                 if (!empty($authors))
2460                 {
2461                         return SimplePie_Misc::array_unique($authors);
2462                 }
2463                 else
2464                 {
2465                         return null;
2466                 }
2467         }
2468
2469         function get_contributor($key = 0)
2470         {
2471                 $contributors = $this->get_contributors();
2472                 if (isset($contributors[$key]))
2473                 {
2474                         return $contributors[$key];
2475                 }
2476                 else
2477                 {
2478                         return null;
2479                 }
2480         }
2481
2482         function get_contributors()
2483         {
2484                 $contributors = array();
2485                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
2486                 {
2487                         $name = null;
2488                         $uri = null;
2489                         $email = null;
2490                         if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2491                         {
2492                                 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2493                         }
2494                         if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2495                         {
2496                                 $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
2497                         }
2498                         if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2499                         {
2500                                 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2501                         }
2502                         if ($name !== null || $email !== null || $uri !== null)
2503                         {
2504                                 $contributors[] =& new $this->author_class($name, $uri, $email);
2505                         }
2506                 }
2507                 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
2508                 {
2509                         $name = null;
2510                         $url = null;
2511                         $email = null;
2512                         if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2513                         {
2514                                 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2515                         }
2516                         if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2517                         {
2518                                 $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
2519                         }
2520                         if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2521                         {
2522                                 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2523                         }
2524                         if ($name !== null || $email !== null || $url !== null)
2525                         {
2526                                 $contributors[] =& new $this->author_class($name, $url, $email);
2527                         }
2528                 }
2529
2530                 if (!empty($contributors))
2531                 {
2532                         return SimplePie_Misc::array_unique($contributors);
2533                 }
2534                 else
2535                 {
2536                         return null;
2537                 }
2538         }
2539
2540         function get_link($key = 0, $rel = 'alternate')
2541         {
2542                 $links = $this->get_links($rel);
2543                 if (isset($links[$key]))
2544                 {
2545                         return $links[$key];
2546                 }
2547                 else
2548                 {
2549                         return null;
2550                 }
2551         }
2552
2553         /**
2554          * Added for parity between the parent-level and the item/entry-level.
2555          */
2556         function get_permalink()
2557         {
2558                 return $this->get_link(0);
2559         }
2560
2561         function get_links($rel = 'alternate')
2562         {
2563                 if (!isset($this->data['links']))
2564                 {
2565                         $this->data['links'] = array();
2566                         if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
2567                         {
2568                                 foreach ($links as $link)
2569                                 {
2570                                         if (isset($link['attribs']['']['href']))
2571                                         {
2572                                                 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2573                                                 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2574                                         }
2575                                 }
2576                         }
2577                         if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
2578                         {
2579                                 foreach ($links as $link)
2580                                 {
2581                                         if (isset($link['attribs']['']['href']))
2582                                         {
2583                                                 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2584                                                 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2585
2586                                         }
2587                                 }
2588                         }
2589                         if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2590                         {
2591                                 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2592                         }
2593                         if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2594                         {
2595                                 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2596                         }
2597                         if ($links = $this->get_channel_tags('', 'link'))
2598                         {
2599                                 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2600                         }
2601
2602                         $keys = array_keys($this->data['links']);
2603                         foreach ($keys as $key)
2604                         {
2605                                 if (SimplePie_Misc::is_isegment_nz_nc($key))
2606                                 {
2607                                         if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
2608                                         {
2609                                                 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
2610                                                 $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
2611                                         }
2612                                         else
2613                                         {
2614                                                 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2615                                         }
2616                                 }
2617                                 elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
2618                                 {
2619                                         $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2620                                 }
2621                                 $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2622                         }
2623                 }
2624
2625                 if (isset($this->data['links'][$rel]))
2626                 {
2627                         return $this->data['links'][$rel];
2628                 }
2629                 else
2630                 {
2631                         return null;
2632                 }
2633         }
2634
2635         function get_description()
2636         {
2637                 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
2638                 {
2639                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2640                 }
2641                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
2642                 {
2643                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2644                 }
2645                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
2646                 {
2647                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2648                 }
2649                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
2650                 {
2651                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2652                 }
2653                 elseif ($return = $this->get_channel_tags('', 'description'))
2654                 {
2655                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2656                 }
2657                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
2658                 {
2659                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2660                 }
2661                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
2662                 {
2663                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2664                 }
2665                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
2666                 {
2667                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2668                 }
2669                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
2670                 {
2671                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2672                 }
2673                 else
2674                 {
2675                         return null;
2676                 }
2677         }
2678
2679         function get_copyright()
2680         {
2681                 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
2682                 {
2683                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2684                 }
2685                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
2686                 {
2687                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2688                 }
2689                 elseif ($return = $this->get_channel_tags('', 'copyright'))
2690                 {
2691                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2692                 }
2693                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
2694                 {
2695                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2696                 }
2697                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
2698                 {
2699                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2700                 }
2701                 else
2702                 {
2703                         return null;
2704                 }
2705         }
2706
2707         function get_language()
2708         {
2709                 if ($return = $this->get_channel_tags('', 'language'))
2710                 {
2711                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2712                 }
2713                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
2714                 {
2715                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2716                 }
2717                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
2718                 {
2719                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2720                 }
2721                 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
2722                 {
2723                         return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2724                 }
2725                 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
2726                 {
2727                         return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2728                 }
2729                 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
2730                 {
2731                         return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2732                 }
2733                 elseif (isset($this->data['headers']['content-language']))
2734                 {
2735                         return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT);
2736                 }
2737                 else
2738                 {
2739                         return null;
2740                 }
2741         }
2742
2743         function get_latitude()
2744         {
2745                 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
2746                 {
2747                         return (float) $return[0]['data'];
2748                 }
2749                 elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
2750                 {
2751                         return (float) $match[1];
2752                 }
2753                 else
2754                 {
2755                         return null;
2756                 }
2757         }
2758
2759         function get_longitude()
2760         {
2761                 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
2762                 {
2763                         return (float) $return[0]['data'];
2764                 }
2765                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
2766                 {
2767                         return (float) $return[0]['data'];
2768                 }
2769                 elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
2770                 {
2771                         return (float) $match[2];
2772                 }
2773                 else
2774                 {
2775                         return null;
2776                 }
2777         }
2778
2779         function get_image_title()
2780         {
2781                 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2782                 {
2783                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2784                 }
2785                 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2786                 {
2787                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2788                 }
2789                 elseif ($return = $this->get_image_tags('', 'title'))
2790                 {
2791                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2792                 }
2793                 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2794                 {
2795                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2796                 }
2797                 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2798                 {
2799                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2800                 }
2801                 else
2802                 {
2803                         return null;
2804                 }
2805         }
2806
2807         function get_image_url()
2808         {
2809                 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
2810                 {
2811                         return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
2812                 }
2813                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
2814                 {
2815                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2816                 }
2817                 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
2818                 {
2819                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2820                 }
2821                 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
2822                 {
2823                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2824                 }
2825                 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
2826                 {
2827                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2828                 }
2829                 elseif ($return = $this->get_image_tags('', 'url'))
2830                 {
2831                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2832                 }
2833                 else
2834                 {
2835                         return null;
2836                 }
2837         }
2838
2839         function get_image_link()
2840         {
2841                 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2842                 {
2843                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2844                 }
2845                 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2846                 {
2847                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2848                 }
2849                 elseif ($return = $this->get_image_tags('', 'link'))
2850                 {
2851                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2852                 }
2853                 else
2854                 {
2855                         return null;
2856                 }
2857         }
2858
2859         function get_image_width()
2860         {
2861                 if ($return = $this->get_image_tags('', 'width'))
2862                 {
2863                         return round($return[0]['data']);
2864                 }
2865                 elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
2866                 {
2867                         return 88.0;
2868                 }
2869                 else
2870                 {
2871                         return null;
2872                 }
2873         }
2874
2875         function get_image_height()
2876         {
2877                 if ($return = $this->get_image_tags('', 'height'))
2878                 {
2879                         return round($return[0]['data']);
2880                 }
2881                 elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
2882                 {
2883                         return 31.0;
2884                 }
2885                 else
2886                 {
2887                         return null;
2888                 }
2889         }
2890
2891         function get_item_quantity($max = 0)
2892         {
2893                 $qty = count($this->get_items());
2894                 if ($max == 0)
2895                 {
2896                         return $qty;
2897                 }
2898                 else
2899                 {
2900                         return ($qty > $max) ? $max : $qty;
2901                 }
2902         }
2903
2904         function get_item($key = 0)
2905         {
2906                 $items = $this->get_items();
2907                 if (isset($items[$key]))
2908                 {
2909                         return $items[$key];
2910                 }
2911                 else
2912                 {
2913                         return null;
2914                 }
2915         }
2916
2917         function get_items($start = 0, $end = 0)
2918         {
2919                 if (!empty($this->multifeed_objects))
2920                 {
2921                         return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
2922                 }
2923                 elseif (!isset($this->data['items']))
2924                 {
2925                         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
2926                         {
2927                                 $keys = array_keys($items);
2928                                 foreach ($keys as $key)
2929                                 {
2930                                         $this->data['items'][] =& new $this->item_class($this, $items[$key]);
2931                                 }
2932                         }
2933                         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
2934                         {
2935                                 $keys = array_keys($items);
2936                                 foreach ($keys as $key)
2937                                 {
2938                                         $this->data['items'][] =& new $this->item_class($this, $items[$key]);
2939                                 }
2940                         }
2941                         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
2942                         {
2943                                 $keys = array_keys($items);
2944                                 foreach ($keys as $key)
2945                                 {
2946                                         $this->data['items'][] =& new $this->item_class($this, $items[$key]);
2947                                 }
2948                         }
2949                         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
2950                         {
2951                                 $keys = array_keys($items);
2952                                 foreach ($keys as $key)
2953                                 {
2954                                         $this->data['items'][] =& new $this->item_class($this, $items[$key]);
2955                                 }
2956                         }
2957                         if ($items = $this->get_channel_tags('', 'item'))
2958                         {
2959                                 $keys = array_keys($items);
2960                                 foreach ($keys as $key)
2961                                 {
2962                                         $this->data['items'][] =& new $this->item_class($this, $items[$key]);
2963                                 }
2964                         }
2965                 }
2966
2967                 if (!empty($this->data['items']))
2968                 {
2969                         // If we want to order it by date, check if all items have a date, and then sort it
2970                         if ($this->order_by_date)
2971                         {
2972                                 if (!isset($this->data['ordered_items']))
2973                                 {
2974                                         $do_sort = true;
2975                                         foreach ($this->data['items'] as $item)
2976                                         {
2977                                                 if (!$item->get_date('U'))
2978                                                 {
2979                                                         $do_sort = false;
2980                                                         break;
2981                                                 }
2982                                         }
2983                                         $item = null;
2984                                         $this->data['ordered_items'] = $this->data['items'];
2985                                         if ($do_sort)
2986                                         {
2987                                                 usort($this->data['ordered_items'], array(&$this, 'sort_items'));
2988                                         }
2989                                 }
2990                                 $items = $this->data['ordered_items'];
2991                         }
2992                         else
2993                         {
2994                                 $items = $this->data['items'];
2995                         }
2996
2997                         // Slice the data as desired
2998                         if ($end == 0)
2999                         {
3000                                 return array_slice($items, $start);
3001                         }
3002                         else
3003                         {
3004                                 return array_slice($items, $start, $end);
3005                         }
3006                 }
3007                 else
3008                 {
3009                         return array();
3010                 }
3011         }
3012
3013         function sort_items($a, $b)
3014         {
3015                 return $a->get_date('U') <= $b->get_date('U');
3016         }
3017
3018         function merge_items($urls, $start = 0, $end = 0, $limit = 0)
3019         {
3020                 if (is_array($urls) && sizeof($urls) > 0)
3021                 {
3022                         $items = array();
3023                         foreach ($urls as $arg)
3024                         {
3025                                 if (is_a($arg, 'SimplePie'))
3026                                 {
3027                                         $items = array_merge($items, $arg->get_items(0, $limit));
3028                                 }
3029                                 else
3030                                 {
3031                                         trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
3032                                 }
3033                         }
3034
3035                         $do_sort = true;
3036                         foreach ($items as $item)
3037                         {
3038                                 if (!$item->get_date('U'))
3039                                 {
3040                                         $do_sort = false;
3041                                         break;
3042                                 }
3043                         }
3044                         $item = null;
3045                         if ($do_sort)
3046                         {
3047                                 usort($items, array('SimplePie', 'sort_items'));
3048                         }
3049
3050                         if ($end == 0)
3051                         {
3052                                 return array_slice($items, $start);
3053                         }
3054                         else
3055                         {
3056                                 return array_slice($items, $start, $end);
3057                         }
3058                 }
3059                 else
3060                 {
3061                         trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
3062                         return array();
3063                 }
3064         }
3065 }
3066
3067 class SimplePie_Item
3068 {
3069         var $feed;
3070         var $data = array();
3071
3072         function SimplePie_Item($feed, $data)
3073         {
3074                 $this->feed = $feed;
3075                 $this->data = $data;
3076         }
3077
3078         function __toString()
3079         {
3080                 return md5(serialize($this->data));
3081         }
3082
3083         /**
3084          * Remove items that link back to this before destroying this object
3085          */
3086         function __destruct()
3087         {
3088                 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
3089                 {
3090                         unset($this->feed);
3091                 }
3092         }
3093
3094         function get_item_tags($namespace, $tag)
3095         {
3096                 if (isset($this->data['child'][$namespace][$tag]))
3097                 {
3098                         return $this->data['child'][$namespace][$tag];
3099                 }
3100                 else
3101                 {
3102                         return null;
3103                 }
3104         }
3105
3106         function get_base($element = array())
3107         {
3108                 return $this->feed->get_base($element);
3109         }
3110
3111         function sanitize($data, $type, $base = '')
3112         {
3113                 return $this->feed->sanitize($data, $type, $base);
3114         }
3115
3116         function get_feed()
3117         {
3118                 return $this->feed;
3119         }
3120
3121         function get_id($hash = false)
3122         {
3123                 if (!$hash)
3124                 {
3125                         if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
3126                         {
3127                                 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3128                         }
3129                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
3130                         {
3131                                 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3132                         }
3133                         elseif ($return = $this->get_item_tags('', 'guid'))
3134                         {
3135                                 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3136                         }
3137                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
3138                         {
3139                                 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3140                         }
3141                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
3142                         {
3143                                 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3144                         }
3145                         elseif (($return = $this->get_permalink()) !== null)
3146                         {
3147                                 return $return;
3148                         }
3149                         elseif (($return = $this->get_title()) !== null)
3150                         {
3151                                 return $return;
3152                         }
3153                 }
3154                 if ($this->get_permalink() !== null || $this->get_title() !== null)
3155                 {
3156                         return md5($this->get_permalink() . $this->get_title());
3157                 }
3158                 else
3159                 {
3160                         return md5(serialize($this->data));
3161                 }
3162         }
3163
3164         function get_title()
3165         {
3166                 if (!isset($this->data['title']))
3167                 {
3168                         if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
3169                         {
3170                                 $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3171                         }
3172                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
3173                         {
3174                                 $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3175                         }
3176                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
3177                         {
3178                                 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3179                         }
3180                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
3181                         {
3182                                 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3183                         }
3184                         elseif ($return = $this->get_item_tags('', 'title'))
3185                         {
3186                                 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3187                         }
3188                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
3189                         {
3190                                 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3191                         }
3192                         elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
3193                         {
3194                                 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3195                         }
3196                         else
3197                         {
3198                                 $this->data['title'] = null;
3199                         }
3200                 }
3201                 return $this->data['title'];
3202         }
3203
3204         function get_description($description_only = false)
3205         {
3206                 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
3207                 {
3208                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3209                 }
3210                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
3211                 {
3212                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3213                 }
3214                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
3215                 {
3216                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
3217                 }
3218                 elseif ($return = $this->get_item_tags('', 'description'))
3219                 {
3220                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3221                 }
3222                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
3223                 {
3224                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3225                 }
3226                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
3227                 {
3228                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3229                 }
3230                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
3231                 {
3232                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3233                 }
3234                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
3235                 {
3236                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
3237                 }
3238                 elseif (!$description_only)
3239                 {
3240                         return $this->get_content(true);
3241                 }
3242                 else
3243                 {
3244                         return null;
3245                 }
3246         }
3247
3248         function get_content($content_only = false)
3249         {
3250                 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
3251                 {
3252                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3253                 }
3254                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
3255                 {
3256                         return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
3257                 }
3258                 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
3259                 {
3260                         return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
3261                 }
3262                 elseif (!$content_only)
3263                 {
3264                         return $this->get_description(true);
3265                 }
3266                 else
3267                 {
3268                         return null;
3269                 }
3270         }
3271
3272         function get_category($key = 0)