| [ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
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-2007, 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 "Razzleberry" 37 * @copyright 2004-2007 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.0.1'); 55 56 /** 57 * SimplePie Build 58 * @todo Hardcode for release (there's no need to have to call SimplePie_Misc::parse_date() only every load of simplepie.inc) 59 */ 60 define('SIMPLEPIE_BUILD', 20070719221955); 61 62 /** 63 * SimplePie Website URL 64 */ 65 define('SIMPLEPIE_URL', 'http://simplepie.org/'); 66 67 /** 68 * SimplePie Useragent 69 * @see SimplePie::set_useragent() 70 */ 71 define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD); 72 73 /** 74 * SimplePie Linkback 75 */ 76 define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>'); 77 78 /** 79 * No Autodiscovery 80 * @see SimplePie::set_autodiscovery_level() 81 */ 82 define('SIMPLEPIE_LOCATOR_NONE', 0); 83 84 /** 85 * Feed Link Element Autodiscovery 86 * @see SimplePie::set_autodiscovery_level() 87 */ 88 define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1); 89 90 /** 91 * Local Feed Extension Autodiscovery 92 * @see SimplePie::set_autodiscovery_level() 93 */ 94 define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2); 95 96 /** 97 * Local Feed Body Autodiscovery 98 * @see SimplePie::set_autodiscovery_level() 99 */ 100 define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4); 101 102 /** 103 * Remote Feed Extension Autodiscovery 104 * @see SimplePie::set_autodiscovery_level() 105 */ 106 define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8); 107 108 /** 109 * Remote Feed Body Autodiscovery 110 * @see SimplePie::set_autodiscovery_level() 111 */ 112 define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16); 113 114 /** 115 * All Feed Autodiscovery 116 * @see SimplePie::set_autodiscovery_level() 117 */ 118 define('SIMPLEPIE_LOCATOR_ALL', 31); 119 120 /** 121 * No known feed type 122 */ 123 define('SIMPLEPIE_TYPE_NONE', 0); 124 125 /** 126 * RSS 0.90 127 */ 128 define('SIMPLEPIE_TYPE_RSS_090', 1); 129 130 /** 131 * RSS 0.91 (Netscape) 132 */ 133 define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2); 134 135 /** 136 * RSS 0.91 (Userland) 137 */ 138 define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4); 139 140 /** 141 * RSS 0.91 (both Netscape and Userland) 142 */ 143 define('SIMPLEPIE_TYPE_RSS_091', 6); 144 145 /** 146 * RSS 0.92 147 */ 148 define('SIMPLEPIE_TYPE_RSS_092', 8); 149 150 /** 151 * RSS 0.93 152 */ 153 define('SIMPLEPIE_TYPE_RSS_093', 16); 154 155 /** 156 * RSS 0.94 157 */ 158 define('SIMPLEPIE_TYPE_RSS_094', 32); 159 160 /** 161 * RSS 1.0 162 */ 163 define('SIMPLEPIE_TYPE_RSS_10', 64); 164 165 /** 166 * RSS 2.0 167 */ 168 define('SIMPLEPIE_TYPE_RSS_20', 128); 169 170 /** 171 * RDF-based RSS 172 */ 173 define('SIMPLEPIE_TYPE_RSS_RDF', 65); 174 175 /** 176 * Non-RDF-based RSS (truly intended as syndication format) 177 */ 178 define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190); 179 180 /** 181 * All RSS 182 */ 183 define('SIMPLEPIE_TYPE_RSS_ALL', 255); 184 185 /** 186 * Atom 0.3 187 */ 188 define('SIMPLEPIE_TYPE_ATOM_03', 256); 189 190 /** 191 * Atom 1.0 192 */ 193 define('SIMPLEPIE_TYPE_ATOM_10', 512); 194 195 /** 196 * All Atom 197 */ 198 define('SIMPLEPIE_TYPE_ATOM_ALL', 768); 199 200 /** 201 * All feed types 202 */ 203 define('SIMPLEPIE_TYPE_ALL', 1023); 204 205 /** 206 * No construct 207 */ 208 define('SIMPLEPIE_CONSTRUCT_NONE', 0); 209 210 /** 211 * Text construct 212 */ 213 define('SIMPLEPIE_CONSTRUCT_TEXT', 1); 214 215 /** 216 * HTML construct 217 */ 218 define('SIMPLEPIE_CONSTRUCT_HTML', 2); 219 220 /** 221 * XHTML construct 222 */ 223 define('SIMPLEPIE_CONSTRUCT_XHTML', 4); 224 225 /** 226 * base64-encoded construct 227 */ 228 define('SIMPLEPIE_CONSTRUCT_BASE64', 8); 229 230 /** 231 * IRI construct 232 */ 233 define('SIMPLEPIE_CONSTRUCT_IRI', 16); 234 235 /** 236 * A construct that might be HTML 237 */ 238 define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32); 239 240 /** 241 * All constructs 242 */ 243 define('SIMPLEPIE_CONSTRUCT_ALL', 63); 244 245 /** 246 * PCRE for HTML attributes 247 */ 248 define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[a-z0-9\-._:]*)))?)*)\s*'); 249 250 /** 251 * PCRE for XML attributes 252 */ 253 define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*'); 254 255 /** 256 * XML Namespace 257 */ 258 define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace'); 259 260 /** 261 * Atom 1.0 Namespace 262 */ 263 define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom'); 264 265 /** 266 * Atom 0.3 Namespace 267 */ 268 define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#'); 269 270 /** 271 * RDF Namespace 272 */ 273 define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); 274 275 /** 276 * RSS 0.90 Namespace 277 */ 278 define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/'); 279 280 /** 281 * RSS 1.0 Namespace 282 */ 283 define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/'); 284 285 /** 286 * RSS 1.0 Content Module Namespace 287 */ 288 define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/'); 289 290 /** 291 * DC 1.0 Namespace 292 */ 293 define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/'); 294 295 /** 296 * DC 1.1 Namespace 297 */ 298 define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/'); 299 300 /** 301 * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace 302 */ 303 define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#'); 304 305 /** 306 * GeoRSS Namespace 307 */ 308 define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss'); 309 310 /** 311 * Media RSS Namespace 312 */ 313 define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/'); 314 315 /** 316 * iTunes RSS Namespace 317 */ 318 define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); 319 320 /** 321 * XHTML Namespace 322 */ 323 define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml'); 324 325 /** 326 * IANA Link Relations Registry 327 */ 328 define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/'); 329 330 /** 331 * Whether we're running on PHP5 332 */ 333 define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>=')); 334 335 /** 336 * SimplePie 337 * 338 * @package SimplePie 339 * @version "Razzleberry" 340 * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon 341 * @author Ryan Parman 342 * @author Geoffrey Sneddon 343 * @todo Option for type of fetching (cache, not modified header, fetch, etc.) 344 */ 345 class SimplePie 346 { 347 /** 348 * @var array Raw data 349 * @access private 350 */ 351 var $data = array(); 352 353 /** 354 * @var mixed Error string 355 * @access private 356 */ 357 var $error; 358 359 /** 360 * @var object Instance of SimplePie_Sanitize (or other class) 361 * @see SimplePie::set_sanitize_class() 362 * @access private 363 */ 364 var $sanitize; 365 366 /** 367 * @var string SimplePie Useragent 368 * @see SimplePie::set_useragent() 369 * @access private 370 */ 371 var $useragent = SIMPLEPIE_USERAGENT; 372 373 /** 374 * @var string Feed URL 375 * @see SimplePie::set_feed_url() 376 * @access private 377 */ 378 var $feed_url; 379 380 /** 381 * @var object Instance of SimplePie_File to use as a feed 382 * @see SimplePie::set_file() 383 * @access private 384 */ 385 var $file; 386 387 /** 388 * @var string Raw feed data 389 * @see SimplePie::set_raw_data() 390 * @access private 391 */ 392 var $raw_data; 393 394 /** 395 * @var int Timeout for fetching remote files 396 * @see SimplePie::set_timeout() 397 * @access private 398 */ 399 var $timeout = 10; 400 401 /** 402 * @var bool Forces fsockopen() to be used for remote files instead 403 * of cURL, even if a new enough version is installed 404 * @see SimplePie::force_fsockopen() 405 * @access private 406 */ 407 var $force_fsockopen = false; 408 409 /** 410 * @var bool Enable/Disable XML dump 411 * @see SimplePie::enable_xml_dump() 412 * @access private 413 */ 414 var $xml_dump = false; 415 416 /** 417 * @var bool Enable/Disable Caching 418 * @see SimplePie::enable_cache() 419 * @access private 420 */ 421 var $cache = true; 422 423 /** 424 * @var int Cache duration (in seconds) 425 * @see SimplePie::set_cache_duration() 426 * @access private 427 */ 428 var $cache_duration = 3600; 429 430 /** 431 * @var int Auto-discovery cache duration (in seconds) 432 * @see SimplePie::set_autodiscovery_cache_duration() 433 * @access private 434 */ 435 var $autodiscovery_cache_duration = 604800; // 7 Days. 436 437 /** 438 * @var string Cache location (relative to executing script) 439 * @see SimplePie::set_cache_location() 440 * @access private 441 */ 442 var $cache_location = './cache'; 443 444 /** 445 * @var string Function that creates the cache filename 446 * @see SimplePie::set_cache_name_function() 447 * @access private 448 */ 449 var $cache_name_function = 'md5'; 450 451 /** 452 * @var bool Reorder feed by date descending 453 * @see SimplePie::enable_order_by_date() 454 * @access private 455 */ 456 var $order_by_date = true; 457 458 /** 459 * @var mixed Force input encoding to be set to the follow value 460 * (false, or anything type-cast to false, disables this feature) 461 * @see SimplePie::set_input_encoding() 462 * @access private 463 */ 464 var $input_encoding = false; 465 466 /** 467 * @var int Feed Autodiscovery Level 468 * @see SimplePie::set_autodiscovery_level() 469 * @access private 470 */ 471 var $autodiscovery = SIMPLEPIE_LOCATOR_ALL; 472 473 /** 474 * @var string Class used for caching feeds 475 * @see SimplePie::set_cache_class() 476 * @access private 477 */ 478 var $cache_class = 'SimplePie_Cache'; 479 480 /** 481 * @var string Class used for locating feeds 482 * @see SimplePie::set_locator_class() 483 * @access private 484 */ 485 var $locator_class = 'SimplePie_Locator'; 486 487 /** 488 * @var string Class used for parsing feeds 489 * @see SimplePie::set_parser_class() 490 * @access private 491 */ 492 var $parser_class = 'SimplePie_Parser'; 493 494 /** 495 * @var string Class used for fetching feeds 496 * @see SimplePie::set_file_class() 497 * @access private 498 */ 499 var $file_class = 'SimplePie_File'; 500 501 /** 502 * @var string Class used for items 503 * @see SimplePie::set_item_class() 504 * @access private 505 */ 506 var $item_class = 'SimplePie_Item'; 507 508 /** 509 * @var string Class used for authors 510 * @see SimplePie::set_author_class() 511 * @access private 512 */ 513 var $author_class = 'SimplePie_Author'; 514 515 /** 516 * @var string Class used for categories 517 * @see SimplePie::set_category_class() 518 * @access private 519 */ 520 var $category_class = 'SimplePie_Category'; 521 522 /** 523 * @var string Class used for enclosures 524 * @see SimplePie::set_enclosures_class() 525 * @access private 526 */ 527 var $enclosure_class = 'SimplePie_Enclosure'; 528 529 /** 530 * @var string Class used for Media RSS <media:text> captions 531 * @see SimplePie::set_caption_class() 532 * @access private 533 */ 534 var $caption_class = 'SimplePie_Caption'; 535 536 /** 537 * @var string Class used for Media RSS <media:copyright> 538 * @see SimplePie::set_copyright_class() 539 * @access private 540 */ 541 var $copyright_class = 'SimplePie_Copyright'; 542 543 /** 544 * @var string Class used for Media RSS <media:credit> 545 * @see SimplePie::set_credit_class() 546 * @access private 547 */ 548 var $credit_class = 'SimplePie_Credit'; 549 550 /** 551 * @var string Class used for Media RSS <media:rating> 552 * @see SimplePie::set_rating_class() 553 * @access private 554 */ 555 var $rating_class = 'SimplePie_Rating'; 556 557 /** 558 * @var string Class used for Media RSS <media:restriction> 559 * @see SimplePie::set_restriction_class() 560 * @access private 561 */ 562 var $restriction_class = 'SimplePie_Restriction'; 563 564 /** 565 * @var mixed Set javascript query string parameter (false, or 566 * anything type-cast to false, disables this feature) 567 * @see SimplePie::set_javascript() 568 * @access private 569 */ 570 var $javascript = 'js'; 571 572 /** 573 * @var int Maximum number of feeds to check with autodiscovery 574 * @see SimplePie::set_max_checked_feeds() 575 * @access private 576 */ 577 var $max_checked_feeds = 10; 578 579 /** 580 * @var string Web-accessible path to the handler_favicon.php file. 581 * @see SimplePie::set_favicon_handler() 582 * @access private 583 */ 584 var $favicon_handler = ''; 585 586 /** 587 * @var string Web-accessible path to the handler_image.php file. 588 * @see SimplePie::set_image_handler() 589 * @access private 590 */ 591 var $image_handler = ''; 592 593 /** 594 * @var array Stores the URLs when multiple feeds are being initialized. 595 * @see SimplePie::set_feed_url() 596 * @access private 597 */ 598 var $multifeed_url = array(); 599 600 /** 601 * @var array Stores SimplePie objects when multiple feeds initialized. 602 * @access private 603 */ 604 var $multifeed_objects = array(); 605 606 /** 607 * @var array Stores the get_object_vars() array for use with multifeeds. 608 * @see SimplePie::set_feed_url() 609 * @access private 610 */ 611 var $config_settings = null; 612 613 /** 614 * @var array Stores the default attributes to be stripped by strip_attributes(). 615 * @see SimplePie::strip_attributes() 616 * @access private 617 */ 618 var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); 619 620 /** 621 * @var array Stores the default tags to be stripped by strip_htmltags(). 622 * @see SimplePie::strip_htmltags() 623 * @access private 624 */ 625 var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); 626 627 /** 628 * The SimplePie class contains feed level data and options 629 * 630 * There are two ways that you can create a new SimplePie object. The first 631 * is by passing a feed URL as a parameter to the SimplePie constructor 632 * (as well as optionally setting the cache location and cache expiry). This 633 * will initialise the whole feed with all of the default settings, and you 634 * can begin accessing methods and properties immediately. 635 * 636 * The second way is to create the SimplePie object with no parameters 637 * at all. This will enable you to set configuration options. After setting 638 * them, you must initialise the feed using $feed->init(). At that point the 639 * object's methods and properties will be available to you. This format is 640 * what is used throughout this documentation. 641 * 642 * @access public 643 * @since 1.0 Preview Release 644 * @param string $feed_url This is the URL you want to parse. 645 * @param string $cache_location This is where you want the cache to be stored. 646 * @param int $cache_duration This is the number of seconds that you want to store the cache file for. 647 */ 648 function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null) 649 { 650 // Other objects, instances created here so we can set options on them 651 $this->sanitize =& new SimplePie_Sanitize; 652 653 // Set options if they're passed to the constructor 654 if ($cache_location !== null) 655 { 656 $this->set_cache_location($cache_location); 657 } 658 659 if ($cache_duration !== null) 660 { 661 $this->set_cache_duration($cache_duration); 662 } 663 664 // Only init the script if we're passed a feed URL 665 if ($feed_url !== null) 666 { 667 $this->set_feed_url($feed_url); 668 $this->init(); 669 } 670 } 671 672 /** 673 * Used for converting object to a string 674 */ 675 function __toString() 676 { 677 return md5(serialize($this->data)); 678 } 679 680 /** 681 * This is the URL of the feed you want to parse. 682 * 683 * This allows you to enter the URL of the feed you want to parse, or the 684 * website you want to try to use auto-discovery on. This takes priority 685 * over any set raw data. 686 * 687 * You can set multiple feeds to mash together by passing an array instead 688 * of a string for the $url. Remember that with each additional feed comes 689 * additional processing and resources. 690 * 691 * @access public 692 * @since 1.0 Preview Release 693 * @param mixed $url This is the URL (or array of URLs) that you want to parse. 694 * @see SimplePie::set_raw_data() 695 */ 696 function set_feed_url($url) 697 { 698 if (is_array($url)) 699 { 700 $this->multifeed_url = array(); 701 foreach ($url as $value) 702 { 703 $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1); 704 } 705 } 706 else 707 { 708 $this->feed_url = SimplePie_Misc::fix_protocol($url, 1); 709 } 710 } 711 712 /** 713 * Provides an instance of SimplePie_File to use as a feed 714 * 715 * @access public 716 * @param object &$file Instance of SimplePie_File (or subclass) 717 * @return bool True on success, false on failure 718 */ 719 function set_file(&$file) 720 { 721 if (SimplePie_Misc::is_a($file, 'SimplePie_File')) 722 { 723 $this->feed_url = $file->url; 724 $this->file =& $file; 725 return true; 726 } 727 return false; 728 } 729 730 /** 731 * Allows you to use a string of RSS/Atom data instead of a remote feed. 732 * 733 * If you have a feed available as a string in PHP, you can tell SimplePie 734 * to parse that data string instead of a remote feed. Any set feed URL 735 * takes precedence. 736 * 737 * @access public 738 * @since 1.0 Beta 3 739 * @param string $data RSS or Atom data as a string. 740 * @see SimplePie::set_feed_url() 741 */ 742 function set_raw_data($data) 743 { 744 $this->raw_data = trim($data); 745 } 746 747 /** 748 * Allows you to override the default timeout for fetching remote feeds. 749 * 750 * This allows you to change the maximum time the feed's server to respond 751 * and send the feed back. 752 * 753 * @access public 754 * @since 1.0 Beta 3 755 * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed. 756 */ 757 function set_timeout($timeout = 10) 758 { 759 $this->timeout = (int) $timeout; 760 } 761 762 /** 763 * Forces SimplePie to use fsockopen() instead of the preferred cURL 764 * functions. 765 * 766 * @access public 767 * @since 1.0 Beta 3 768 * @param bool $enable Force fsockopen() to be used 769 */ 770 function force_fsockopen($enable = false) 771 { 772 $this->force_fsockopen = (bool) $enable; 773 } 774 775 /** 776 * Outputs the raw XML content of the feed, after it has gone through 777 * SimplePie's filters. 778 * 779 * Used only for debugging, this function will output the XML content as 780 * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up 781 * before trying to parse it. Many parts of the feed are re-written in 782 * memory, and in the end, you have a parsable feed. XML dump shows you the 783 * actual XML that SimplePie tries to parse, which may or may not be very 784 * different from the original feed. 785 * 786 * @access public 787 * @since 1.0 Preview Release 788 * @param bool $enable Enable XML dump 789 */ 790 function enable_xml_dump($enable = false) 791 { 792 $this->xml_dump = (bool) $enable; 793 } 794 795 /** 796 * Enables/disables caching in SimplePie. 797 * 798 * This option allows you to disable caching all-together in SimplePie. 799 * However, disabling the cache can lead to longer load times. 800 * 801 * @access public 802 * @since 1.0 Preview Release 803 * @param bool $enable Enable caching 804 */ 805 function enable_cache($enable = true) 806 { 807 $this->cache = (bool) $enable; 808 } 809 810 /** 811 * Set the length of time (in seconds) that the contents of a feed 812 * will be cached. 813 * 814 * @access public 815 * @param int $seconds The feed content cache duration. 816 */ 817 function set_cache_duration($seconds = 3600) 818 { 819 $this->cache_duration = (int) $seconds; 820 } 821 822 /** 823 * Set the length of time (in seconds) that the autodiscovered feed 824 * URL will be cached. 825 * 826 * @access public 827 * @param int $seconds The autodiscovered feed URL cache duration. 828 */ 829 function set_autodiscovery_cache_duration($seconds = 604800) 830 { 831 $this->autodiscovery_cache_duration = (int) $seconds; 832 } 833 834 /** 835 * Set the file system location where the cached files should be stored. 836 * 837 * @access public 838 * @param string $location The file system location. 839 */ 840 function set_cache_location($location = './cache') 841 { 842 $this->cache_location = (string) $location; 843 } 844 845 /** 846 * Determines whether feed items should be sorted into reverse chronological order. 847 * 848 * @access public 849 * @param bool $enable Sort as reverse chronological order. 850 */ 851 function enable_order_by_date($enable = true) 852 { 853 $this->order_by_date = (bool) $enable; 854 } 855 856 /** 857 * Allows you to override the character encoding reported by the feed. 858 * 859 * @access public 860 * @param string $encoding Character encoding. 861 */ 862 function set_input_encoding($encoding = false) 863 { 864 if ($encoding) 865<