48 define(
'SIMPLEPIE_NAME',
'SimplePie');
49 define(
'SIMPLEPIE_VERSION',
'1.3.1');
50 define(
'SIMPLEPIE_BUILD',
'20121030175911');
51 define(
'SIMPLEPIE_URL',
'http://simplepie.org');
54 define(
'SIMPLEPIE_LOCATOR_NONE', 0);
55 define(
'SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
56 define(
'SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
57 define(
'SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
58 define(
'SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
59 define(
'SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
60 define(
'SIMPLEPIE_LOCATOR_ALL', 31);
61 define(
'SIMPLEPIE_TYPE_NONE', 0);
62 define(
'SIMPLEPIE_TYPE_RSS_090', 1);
63 define(
'SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
64 define(
'SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
65 define(
'SIMPLEPIE_TYPE_RSS_091', 6);
66 define(
'SIMPLEPIE_TYPE_RSS_092', 8);
67 define(
'SIMPLEPIE_TYPE_RSS_093', 16);
68 define(
'SIMPLEPIE_TYPE_RSS_094', 32);
69 define(
'SIMPLEPIE_TYPE_RSS_10', 64);
70 define(
'SIMPLEPIE_TYPE_RSS_20', 128);
71 define(
'SIMPLEPIE_TYPE_RSS_RDF', 65);
72 define(
'SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
73 define(
'SIMPLEPIE_TYPE_RSS_ALL', 255);
74 define(
'SIMPLEPIE_TYPE_ATOM_03', 256);
75 define(
'SIMPLEPIE_TYPE_ATOM_10', 512);
76 define(
'SIMPLEPIE_TYPE_ATOM_ALL', 768);
77 define(
'SIMPLEPIE_TYPE_ALL', 1023);
78 define(
'SIMPLEPIE_CONSTRUCT_NONE', 0);
79 define(
'SIMPLEPIE_CONSTRUCT_TEXT', 1);
80 define(
'SIMPLEPIE_CONSTRUCT_HTML', 2);
81 define(
'SIMPLEPIE_CONSTRUCT_XHTML', 4);
82 define(
'SIMPLEPIE_CONSTRUCT_BASE64', 8);
83 define(
'SIMPLEPIE_CONSTRUCT_IRI', 16);
84 define(
'SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
85 define(
'SIMPLEPIE_CONSTRUCT_ALL', 63);
86 define(
'SIMPLEPIE_SAME_CASE', 1);
87 define(
'SIMPLEPIE_LOWERCASE', 2);
88 define(
'SIMPLEPIE_UPPERCASE', 4);
89 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]*');
90 define(
'SIMPLEPIE_PCRE_XML_ATTRIBUTE',
'((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
91 define(
'SIMPLEPIE_NAMESPACE_XML',
'http://www.w3.org/XML/1998/namespace');
92 define(
'SIMPLEPIE_NAMESPACE_ATOM_10',
'http://www.w3.org/2005/Atom');
93 define(
'SIMPLEPIE_NAMESPACE_ATOM_03',
'http://purl.org/atom/ns#');
94 define(
'SIMPLEPIE_NAMESPACE_RDF',
'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
95 define(
'SIMPLEPIE_NAMESPACE_RSS_090',
'http://my.netscape.com/rdf/simple/0.9/');
96 define(
'SIMPLEPIE_NAMESPACE_RSS_10',
'http://purl.org/rss/1.0/');
97 define(
'SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT',
'http://purl.org/rss/1.0/modules/content/');
98 define(
'SIMPLEPIE_NAMESPACE_RSS_20',
'');
99 define(
'SIMPLEPIE_NAMESPACE_DC_10',
'http://purl.org/dc/elements/1.0/');
100 define(
'SIMPLEPIE_NAMESPACE_DC_11',
'http://purl.org/dc/elements/1.1/');
101 define(
'SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO',
'http://www.w3.org/2003/01/geo/wgs84_pos#');
102 define(
'SIMPLEPIE_NAMESPACE_GEORSS',
'http://www.georss.org/georss');
103 define(
'SIMPLEPIE_NAMESPACE_MEDIARSS',
'http://search.yahoo.com/mrss/');
104 define(
'SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG',
'http://search.yahoo.com/mrss');
105 define(
'SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2',
'http://video.search.yahoo.com/mrss');
106 define(
'SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3',
'http://video.search.yahoo.com/mrss/');
107 define(
'SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4',
'http://www.rssboard.org/media-rss');
108 define(
'SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5',
'http://www.rssboard.org/media-rss/');
109 define(
'SIMPLEPIE_NAMESPACE_ITUNES',
'http://www.itunes.com/dtds/podcast-1.0.dtd');
110 define(
'SIMPLEPIE_NAMESPACE_XHTML',
'http://www.w3.org/1999/xhtml');
111 define(
'SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY',
'http://www.iana.org/assignments/relation/');
112 define(
'SIMPLEPIE_FILE_SOURCE_NONE', 0);
113 define(
'SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
114 define(
'SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
115 define(
'SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
116 define(
'SIMPLEPIE_FILE_SOURCE_CURL', 8);
117 define(
'SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
173 public $strip_attributes = array(
'bgsound',
'class',
'expr',
'id',
'style',
'onclick',
'onerror',
'onfinish',
'onmouseover',
'onmouseout',
'onfocus',
'onblur',
'lowsrc',
'dynsrc');
175 public $strip_htmltags = array(
'base',
'blink',
'body',
'doctype',
'embed',
'font',
'form',
'frame',
'frameset',
'html',
'iframe',
'input',
'marquee',
'meta',
'noscript',
'object',
'param',
'script',
'style');
179 if (version_compare(PHP_VERSION,
'5.2',
'<'))
181 trigger_error(
'PHP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2 or newer.');
187 if (func_num_args() > 0)
189 $level = defined(
'E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
190 trigger_error(
'Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly.', $level);
191 $args = func_get_args();
192 switch (count($args)) {
206 return md5(serialize($this->data));
211 if ((version_compare(PHP_VERSION,
'5.3',
'<') || !gc_enabled()) && !ini_get(
'zend.ze1_compatibility_mode'))
213 if (!empty($this->data[
'items']))
215 foreach ($this->data[
'items'] as $item)
219 unset($item, $this->data[
'items']);
221 if (!empty($this->data[
'ordered_items']))
223 foreach ($this->data[
'ordered_items'] as $item)
227 unset($item, $this->data[
'ordered_items']);
239 $this->multifeed_url = array();
242 foreach (
$url as $value)
244 $this->multifeed_url[] = $this->registry->call(
'Misc',
'fix_protocol', array($value, 1));
249 $this->feed_url = $this->registry->call(
'Misc',
'fix_protocol', array(
$url, 1));
257 $this->feed_url =
$file->url;
258 $this->file =&
$file;
266 $this->raw_data =
$data;
281 $this->cache = (bool) $enable;
286 $this->cache_duration = (int) $seconds;
291 $this->autodiscovery_cache_duration = (int) $seconds;
296 $this->cache_location = (string) $location;
301 $this->order_by_date = (bool) $enable;
308 $this->input_encoding = (string) $encoding;
312 $this->input_encoding =
false;
318 $this->autodiscovery = (int) $level;
329 return $this->registry->register(
'Cache',
$class,
true);
334 return $this->registry->register(
'Locator',
$class,
true);
339 return $this->registry->register(
'Parser',
$class,
true);
344 return $this->registry->register(
'File',
$class,
true);
349 return $this->registry->register(
'Sanitize',
$class,
true);
354 return $this->registry->register(
'Item',
$class,
true);
359 return $this->registry->register(
'Author',
$class,
true);
364 return $this->registry->register(
'Category',
$class,
true);
369 return $this->registry->register(
'Enclosure',
$class,
true);
374 return $this->registry->register(
'Caption',
$class,
true);
379 return $this->registry->register(
'Copyright',
$class,
true);
384 return $this->registry->register(
'Credit',
$class,
true);
389 return $this->registry->register(
'Rating',
$class,
true);
394 return $this->registry->register(
'Restriction',
$class,
true);
399 return $this->registry->register(
'Content_Type_Sniffer',
$class,
true);
404 return $this->registry->register(
'Source',
$class,
true);
410 $this->useragent = (string) $ua;
415 if (is_callable($function))
417 $this->cache_name_function = $function;
436 $this->max_checked_feeds = (int) $max;
440 $this->
sanitize->remove_div($enable);
448 $this->
sanitize->strip_htmltags($tags);
449 if ($encode !== null)
451 $this->
sanitize->encode_instead_of_strip($tags);
456 $this->
sanitize->encode_instead_of_strip($enable);
464 $this->
sanitize->strip_attributes($attribs);
469 $this->
sanitize->set_output_encoding($encoding);
473 $this->
sanitize->strip_comments($strip);
478 $this->
sanitize->set_url_replacements($element_attribute);
485 $this->
sanitize->set_image_handler($page .
'?' . $qs .
'=');
489 $this->image_handler =
'';
495 $this->item_limit = (int) $limit;
501 if (!extension_loaded(
'xml') || !extension_loaded(
'pcre'))
506 elseif (!extension_loaded(
'xmlreader'))
508 static $xml_is_sane = null;
509 if ($xml_is_sane === null)
511 $parser_check = xml_parser_create();
512 xml_parse_into_struct($parser_check,
'<foo>&</foo>', $values);
513 xml_parser_free($parser_check);
514 $xml_is_sane = isset($values[0][
'value']);
521 if (method_exists($this->
sanitize,
'set_registry'))
523 $this->
sanitize->set_registry($this->registry);
527 $this->
sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->registry->get_class(
'Cache'));
529 if (!empty($this->multifeed_url))
533 $this->multifeed_objects = array();
534 $this->
error = array();
535 foreach ($this->multifeed_url as
$url)
537 $this->multifeed_objects[
$i] = clone $this;
538 $this->multifeed_objects[
$i]->set_feed_url($url);
539 $single_success = $this->multifeed_objects[
$i]->init();
540 $success |= $single_success;
541 if (!$single_success)
543 $this->
error[
$i] = $this->multifeed_objects[
$i]->error();
547 return (
bool) $success;
549 elseif ($this->feed_url === null && $this->raw_data === null)
554 $this->data = array();
555 $this->multifeed_objects = array();
557 if ($this->feed_url !== null)
559 $parsed_feed_url = $this->registry->call(
'Misc',
'parse_url', array($this->feed_url));
561 if ($this->cache && $parsed_feed_url[
'scheme'] !==
'')
563 $cache = $this->registry->call(
'Cache',
'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url),
'spc'));
570 elseif ($fetched ===
false) {
573 list($headers, $sniffed) = $fetched;
576 $encodings = array();
578 if ($this->input_encoding !==
false)
582 $application_types = array(
'application/xml',
'application/xml-dtd',
'application/xml-external-parsed-entity');
583 $text_types = array(
'text/xml',
'text/xml-external-parsed-entity');
587 if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) ===
'application/' && substr($sniffed, -4) ===
'+xml')
589 if (isset($headers[
'content-type']) && preg_match(
'/;\x20?charset=([^;]*)/i', $headers[
'content-type'], $charset))
591 $encodings[] = strtoupper($charset[1]);
593 $encodings = array_merge($encodings, $this->registry->call(
'Misc',
'xml_encoding', array($this->raw_data, &$this->registry)));
594 $encodings[] =
'UTF-8';
596 elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) ===
'text/' && substr($sniffed, -4) ===
'+xml')
598 if (isset($headers[
'content-type']) && preg_match(
'/;\x20?charset=([^;]*)/i', $headers[
'content-type'], $charset))
600 $encodings[] = $charset[1];
602 $encodings[] =
'US-ASCII';
605 elseif (substr($sniffed, 0, 5) ===
'text/')
607 $encodings[] =
'US-ASCII';
611 $encodings = array_merge($encodings, $this->registry->call(
'Misc',
'xml_encoding', array($this->raw_data, &$this->registry)));
612 $encodings[] =
'UTF-8';
613 $encodings[] =
'ISO-8859-1';
615 $encodings = array_unique($encodings);
617 foreach ($encodings as $encoding)
620 if ($utf8_data = $this->registry->call(
'Misc',
'change_encoding', array($this->raw_data, $encoding,
'UTF-8')))
623 $parser = $this->registry->create(
'Parser');
625 if ($parser->parse($utf8_data,
'UTF-8'))
627 $this->data = $parser->get_data();
630 $this->
error =
"A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";
631 $this->registry->call(
'Misc',
'error', array($this->
error, E_USER_NOTICE, __FILE__, __LINE__));
636 $this->data[
'headers'] = $headers;
642 trigger_error(
"$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
651 $this->
error = sprintf(
'This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
655 $this->
error =
'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.';
657 $this->registry->call(
'Misc',
'error', array($this->
error, E_USER_NOTICE, __FILE__, __LINE__));
667 $this->data =
$cache->load();
668 if (!empty($this->data))
671 if (!isset($this->data[
'build']) || $this->data[
'build'] !==
SIMPLEPIE_BUILD)
674 $this->data = array();
677 elseif (isset($this->data[
'url']) && $this->data[
'url'] !== $this->feed_url)
680 $this->data = array();
683 elseif (isset($this->data[
'feed_url']))
686 if (
$cache->mtime() + $this->autodiscovery_cache_duration > time())
689 if ($this->data[
'feed_url'] !== $this->data[
'url'])
692 return $this->
init();
695 $this->data = array();
699 elseif (
$cache->mtime() + $this->cache_duration < time())
702 if (isset($this->data[
'headers'][
'last-modified']) || isset($this->data[
'headers'][
'etag']))
705 'Accept' =>
'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
707 if (isset($this->data[
'headers'][
'last-modified']))
709 $headers[
'if-modified-since'] = $this->data[
'headers'][
'last-modified'];
711 if (isset($this->data[
'headers'][
'etag']))
713 $headers[
'if-none-match'] = $this->data[
'headers'][
'etag'];
715 $file = $this->registry->create(
'File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->
force_fsockopen));
718 if (
$file->status_code === 304)
733 $this->raw_data =
false;
741 $this->data = array();
747 if ($this->file instanceof
SimplePie_File && $this->file->url === $this->feed_url)
754 'Accept' =>
'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
756 $file = $this->registry->create(
'File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->
force_fsockopen));
763 return !empty($this->data);
768 $locate = $this->registry->create(
'Locator', array(&
$file, $this->timeout, $this->useragent, $this->max_checked_feeds));
769 if (!$locate->is_feed(
$file))
775 if (!(
$file = $locate->find($this->autodiscovery, $this->all_discovered_feeds)))
777 $this->
error =
"A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " .
SIMPLEPIE_NAME .
" was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed.";
778 $this->registry->call(
'Misc',
'error', array($this->
error, E_USER_NOTICE, __FILE__, __LINE__));
785 $this->
error = $e->getMessage();
786 $this->registry->call(
'Misc',
'error', array($this->
error, E_USER_NOTICE, $e->getFile(), $e->getLine()));
791 $this->data = array(
'url' => $this->feed_url,
'feed_url' =>
$file->url,
'build' =>
SIMPLEPIE_BUILD);
794 trigger_error(
"$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
796 $cache = $this->registry->call(
'Cache',
'get_handler', array($this->cache_location, call_user_func($this->cache_name_function,
$file->url),
'spc'));
798 $this->feed_url =
$file->url;
802 $this->raw_data =
$file->body;
803 $headers =
$file->headers;
804 $sniffer = $this->registry->create(
'Content_Type_Sniffer', array(&
$file));
805 $sniffed = $sniffer->get_type();
806 return array($headers, $sniffed);
821 return $this->
sanitize->output_encoding;
828 $header =
"Content-type: $mime;";
835 $header .=
' charset=UTF-8';
843 if (!isset($this->data[
'type']))
857 || isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RDF][
'RDF'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_10][
'image'])
858 || isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RDF][
'RDF'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_10][
'item'])
859 || isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RDF][
'RDF'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_10][
'textinput']))
864 || isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RDF][
'RDF'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_090][
'image'])
865 || isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RDF][
'RDF'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_090][
'item'])
866 || isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RDF][
'RDF'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_090][
'textinput']))
874 if (isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'rss'][0][
'attribs'][
''][
'version']))
876 switch (trim($this->data[
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'rss'][0][
'attribs'][
''][
'version']))
880 if (isset($this->data[
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'rss'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'skiphours'][
'hour'][0][
'data']))
882 switch (trim($this->data[
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'rss'][0][
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'skiphours'][
'hour'][0][
'data']))
913 return $this->data[
'type'];
918 if ($this->feed_url !== null)
976 if (isset($channel[0][
'child'][$namespace][$tag]))
978 return $channel[0][
'child'][$namespace][$tag];
986 if (isset($channel[0][
'child'][$namespace][$tag]))
988 return $channel[0][
'child'][$namespace][$tag];
996 if (isset($channel[0][
'child'][$namespace][$tag]))
998 return $channel[0][
'child'][$namespace][$tag];
1012 if (isset($image[0][
'child'][$namespace][$tag]))
1014 return $image[0][
'child'][$namespace][$tag];
1022 if (isset($image[0][
'child'][$namespace][$tag]))
1024 return $image[0][
'child'][$namespace][$tag];
1032 if (isset($image[0][
'child'][$namespace][$tag]))
1034 return $image[0][
'child'][$namespace][$tag];
1045 return $element[
'xml_base'];
1066 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
1070 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
1101 if (isset($categories[$key]))
1103 return $categories[$key];
1113 $categories = array();
1119 if (isset($category[
'attribs'][
''][
'term']))
1123 if (isset($category[
'attribs'][
''][
'scheme']))
1127 if (isset($category[
'attribs'][
''][
'label']))
1131 $categories[] = $this->registry->create(
'Category', array($term, $scheme, $label));
1138 if (isset($category[
'attribs'][
''][
'domain']))
1146 $categories[] = $this->registry->create(
'Category', array($term, $scheme, null));
1156 if (!empty($categories))
1158 return array_unique($categories);
1169 if (isset($authors[$key]))
1171 return $authors[$key];
1191 if (isset($author[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'uri'][0][
'data']))
1195 if (isset($author[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'email'][0][
'data']))
1199 if ($name !== null || $email !== null || $uri !== null)
1201 $authors[] = $this->registry->create(
'Author', array($name, $uri, $email));
1213 if (isset($author[0][
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'url'][0][
'data']))
1217 if (isset($author[0][
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'email'][0][
'data']))
1221 if ($name !== null || $email !== null ||
$url !== null)
1223 $authors[] = $this->registry->create(
'Author', array($name,
$url, $email));
1238 if (!empty($authors))
1240 return array_unique($authors);
1251 if (isset($contributors[$key]))
1253 return $contributors[$key];
1263 $contributors = array();
1273 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'uri'][0][
'data']))
1275 $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]));
1277 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'email'][0][
'data']))
1281 if ($name !== null || $email !== null || $uri !== null)
1283 $contributors[] = $this->registry->create(
'Author', array($name, $uri, $email));
1295 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'url'][0][
'data']))
1299 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'email'][0][
'data']))
1303 if ($name !== null || $email !== null ||
$url !== null)
1305 $contributors[] = $this->registry->create(
'Author', array($name,
$url, $email));
1308 if (!empty($contributors))
1310 return array_unique($contributors);
1321 if (isset($links[$key]))
1323 return $links[$key];
1338 if (!isset($this->data[
'links']))
1340 $this->data[
'links'] = array();
1343 foreach ($links as $link)
1345 if (isset($link[
'attribs'][
''][
'href']))
1347 $link_rel = (isset($link[
'attribs'][
''][
'rel'])) ? $link[
'attribs'][
''][
'rel'] :
'alternate';
1354 foreach ($links as $link)
1356 if (isset($link[
'attribs'][
''][
'href']))
1358 $link_rel = (isset($link[
'attribs'][
''][
'rel'])) ? $link[
'attribs'][
''][
'rel'] :
'alternate';
1375 $keys = array_keys($this->data[
'links']);
1376 foreach ($keys as $key)
1378 if ($this->registry->call(
'Misc',
'is_isegment_nz_nc', array($key)))
1392 $this->data[
'links'][substr($key, 41)] =& $this->data[
'links'][$key];
1394 $this->data[
'links'][$key] = array_unique($this->data[
'links'][$key]);
1397 if (isset($this->data[
'links'][$rel]))
1399 return $this->data[
'links'][$rel];
1415 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
1419 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
1459 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
1463 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
1509 elseif (isset($this->data[
'headers'][
'content-language']))
1523 return (
float) $return[0][
'data'];
1527 return (
float)
$match[1];
1539 return (
float) $return[0][
'data'];
1543 return (
float) $return[0][
'data'];
1547 return (
float)
$match[2];
1639 return round($return[0][
'data']);
1655 return round($return[0][
'data']);
1677 return ($qty > $max) ? $max : $qty;
1684 if (isset($items[$key]))
1686 return $items[$key];
1696 if (!isset($this->data[
'items']))
1698 if (!empty($this->multifeed_objects))
1704 $this->data[
'items'] = array();
1707 $keys = array_keys($items);
1708 foreach ($keys as $key)
1710 $this->data[
'items'][] = $this->registry->create(
'Item', array($this, $items[$key]));
1715 $keys = array_keys($items);
1716 foreach ($keys as $key)
1718 $this->data[
'items'][] = $this->registry->create(
'Item', array($this, $items[$key]));
1723 $keys = array_keys($items);
1724 foreach ($keys as $key)
1726 $this->data[
'items'][] = $this->registry->create(
'Item', array($this, $items[$key]));
1731 $keys = array_keys($items);
1732 foreach ($keys as $key)
1734 $this->data[
'items'][] = $this->registry->create(
'Item', array($this, $items[$key]));
1739 $keys = array_keys($items);
1740 foreach ($keys as $key)
1742 $this->data[
'items'][] = $this->registry->create(
'Item', array($this, $items[$key]));
1747 if (!empty($this->data[
'items']))
1750 if ($this->order_by_date && empty($this->multifeed_objects))
1752 if (!isset($this->data[
'ordered_items']))
1755 foreach ($this->data[
'items'] as $item)
1757 if (!$item->get_date(
'U'))
1764 $this->data[
'ordered_items'] = $this->data[
'items'];
1767 usort($this->data[
'ordered_items'], array(get_class($this),
'sort_items'));
1770 $items = $this->data[
'ordered_items'];
1774 $items = $this->data[
'items'];
1779 return array_slice($items,
$start);
1783 return array_slice($items,
$start, $end);
1794 $level = defined(
'E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
1795 trigger_error(
'Favicon handling has been removed, please use your own handling', $level);
1801 $level = defined(
'E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
1802 trigger_error(
'Favicon handling has been removed, please use your own handling', $level);
1805 return 'http://g.etfv.co/' . urlencode(
$url);
1812 if (strpos($method,
'subscribe_') === 0)
1814 $level = defined(
'E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
1815 trigger_error(
'subscribe_*() has been deprecated, implement the callback yourself', $level);
1818 if ($method ===
'enable_xml_dump')
1820 $level = defined(
'E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
1821 trigger_error(
'enable_xml_dump() has been deprecated, use get_raw_data() instead', $level);
1824 $class = get_class($this);
1825 $trace = debug_backtrace();
1826 $file = $trace[0][
'file'];
1827 $line = $trace[0][
'line'];
1828 trigger_error(
"Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR);
1833 return $a->get_date(
'U') <= $b->get_date(
'U');
1838 if (is_array($urls) &&
sizeof($urls) > 0)
1841 foreach ($urls as $arg)
1845 $items = array_merge($items, $arg->get_items(0, $limit));
1849 trigger_error(
'Arguments must be SimplePie objects', E_USER_WARNING);
1853 foreach ($items as $item)
1855 if (!$item->get_date(
'U'))
1864 usort($items, array(get_class($urls[0]),
'sort_items'));
1868 return array_slice($items,
$start);
1872 return array_slice($items,
$start, $end);
1877 trigger_error(
'Cannot merge zero SimplePie objects', E_USER_WARNING);
1891 public function __construct($name = null, $link = null, $email = null)
1893 $this->name =
$name;
1894 $this->link =
$link;
1901 return md5(serialize($this));
1906 if ($this->name !== null)
1918 if ($this->link !== null)
1930 if ($this->email !== null)
1947 public function __construct($location, $name, $type);
1951 public function load();
1953 public function mtime();
1955 public function touch();
1957 public function unlink();
1964 $items =
$data->get_items();
1965 $items_by_id = array();
1968 foreach ($items as $item)
1970 $items_by_id[$item->get_id()] = $item;
1972 if (count($items_by_id) !== count($items))
1974 $items_by_id = array();
1975 foreach ($items as $item)
1977 $items_by_id[$item->get_id(
true)] = $item;
2000 if ($channel !== null)
2004 unset($channel[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'entry']);
2008 unset($channel[
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'entry']);
2012 unset($channel[
'child'][SIMPLEPIE_NAMESPACE_RSS_10][
'item']);
2016 unset($channel[
'child'][SIMPLEPIE_NAMESPACE_RSS_090][
'item']);
2018 if (isset($channel[
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'item']))
2020 unset($channel[
'child'][SIMPLEPIE_NAMESPACE_RSS_20][
'item']);
2023 if (isset(
$data->data[
'items']))
2025 unset(
$data->data[
'items']);
2027 if (isset(
$data->data[
'ordered_items']))
2029 unset(
$data->data[
'ordered_items']);
2032 return array(serialize(
$data->data), $items_by_id);
2049 $this->filename =
$name;
2050 $this->extension = $type;
2051 $this->name =
"$this->location/$this->filename.$this->extension";
2056 if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location))
2063 return (
bool) file_put_contents($this->name,
$data);
2070 if (file_exists($this->name) && is_readable($this->name))
2072 return unserialize(file_get_contents($this->name));
2079 if (file_exists($this->name))
2081 return filemtime($this->name);
2088 if (file_exists($this->name))
2090 return touch($this->name);
2097 if (file_exists($this->name))
2099 return unlink($this->name);
2115 $this->options = array(
2116 'host' =>
'127.0.0.1',
2120 'prefix' =>
'simplepie_',
2124 $this->options[
'host'] = empty($parsed[
'host']) ? $this->options[
'host'] : $parsed[
'host'];
2125 $this->options[
'port'] = empty($parsed[
'port']) ? $this->options[
'port'] : $parsed[
'port'];
2126 $this->options[
'extras'] = array_merge($this->options[
'extras'], $parsed[
'extras']);
2127 $this->name = $this->options[
'extras'][
'prefix'] . md5(
"$name:$type");
2128 $this->cache =
new Memcache();
2129 $this->cache->addServer($this->options[
'host'], (
int) $this->options[
'port']);
2138 return $this->cache->set($this->name, serialize(
$data), MEMCACHE_COMPRESSED, (
int) $this->options[
'extras'][
'timeout']);
2143 $data = $this->cache->get($this->name);
2144 if (
$data !==
false)
2146 return unserialize(
$data);
2153 $data = $this->cache->get($this->name);
2154 if (
$data !==
false)
2164 $data = $this->cache->get($this->name);
2165 if (
$data !==
false)
2167 return $this->cache->set($this->name,
$data, MEMCACHE_COMPRESSED, (
int) $this->duration);
2174 return $this->cache->delete($this->name, 0);
2188 $this->options = array(
2191 'host' =>
'127.0.0.1',
2200 $this->options[
'dbname'] = substr($this->options[
'path'], 1);
2203 $this->mysql =
new PDO(
"mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}", $this->options[
'user'], $this->options[
'pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND =>
'SET NAMES utf8'));
2205 catch (PDOException $e)
2207 $this->mysql = null;
2210 $this->
id = $name . $type;
2211 if (!
$query = $this->mysql->query(
'SHOW TABLES'))
2213 $this->mysql = null;
2217 while ($row =
$query->fetchColumn())
2221 if (!in_array($this->options[
'extras'][
'prefix'] .
'cache_data', $db))
2223 $query = $this->mysql->exec(
'CREATE TABLE `' . $this->options[
'extras'][
'prefix'] .
'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))');
2226 $this->mysql = null;
2229 if (!in_array($this->options[
'extras'][
'prefix'] .
'items', $db))
2231 $query = $this->mysql->exec(
'CREATE TABLE `' . $this->options[
'extras'][
'prefix'] .
'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');
2234 $this->mysql = null;
2241 if ($this->mysql === null)
2248 $prepared = self::prepare_simplepie_object_for_cache($data);
2249 $query = $this->mysql->prepare(
'SELECT COUNT(*) FROM `' . $this->options[
'extras'][
'prefix'] .
'cache_data` WHERE `id` = :feed');
2250 $query->bindValue(
':feed', $this->
id);
2253 if (
$query->fetchColumn() > 0)
2255 $items = count($prepared[1]);
2258 $sql =
'UPDATE `' . $this->options[
'extras'][
'prefix'] .
'cache_data` SET `items` = :items, `data` = :data, `mtime` = :time WHERE `id` = :feed';
2260 $query->bindValue(
':items', $items);
2264 $sql =
'UPDATE `' . $this->options[
'extras'][
'prefix'] .
'cache_data` SET `data` = :data, `mtime` = :time WHERE `id` = :feed';
2267 $query->bindValue(
':data', $prepared[0]);
2268 $query->bindValue(
':time', time());
2269 $query->bindValue(
':feed', $this->
id);
2277 $query = $this->mysql->prepare(
'INSERT INTO `' . $this->options[
'extras'][
'prefix'] .
'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:feed, :count, :data, :time)');
2278 $query->bindValue(
':feed', $this->
id);
2279 $query->bindValue(
':count', count($prepared[1]));
2280 $query->bindValue(
':data', $prepared[0]);
2281 $query->bindValue(
':time', time());
2287 $ids = array_keys($prepared[1]);
2290 foreach ($ids as
$id)
2292 $database_ids[] = $this->mysql->quote($id);
2294 $query = $this->mysql->prepare(
'SELECT `id` FROM `' . $this->options[
'extras'][
'prefix'] .
'items` WHERE `id` = ' . implode(
' OR `id` = ', $database_ids) .
' AND `feed_id` = :feed');
2295 $query->bindValue(
':feed', $this->
id);
2298 $existing_ids = array();
2299 while ($row =
$query->fetchColumn())
2301 $existing_ids[] = $row;
2303 $new_ids = array_diff($ids, $existing_ids);
2304 foreach ($new_ids as $new_id)
2306 if (!($date = $prepared[1][$new_id]->get_date(
'U')))
2310 $query = $this->mysql->prepare(
'INSERT INTO `' . $this->options[
'extras'][
'prefix'] .
'items` (`feed_id`, `id`, `data`, `posted`) VALUES(:feed, :id, :data, :date)');
2311 $query->bindValue(
':feed', $this->
id);
2312 $query->bindValue(
':id', $new_id);
2313 $query->bindValue(
':data', serialize($prepared[1][$new_id]->data));
2314 $query->bindValue(
':date', $date);
2331 $query = $this->mysql->prepare(
'SELECT `id` FROM `' . $this->options[
'extras'][
'prefix'] .
'cache_data` WHERE `id` = :feed');
2332 $query->bindValue(
':feed', $this->
id);
2335 if (
$query->rowCount() > 0)
2337 $query = $this->mysql->prepare(
'UPDATE `' . $this->options[
'extras'][
'prefix'] .
'cache_data` SET `items` = 0, `data` = :data, `mtime` = :time WHERE `id` = :feed');
2339 $query->bindValue(
':time', time());
2340 $query->bindValue(
':feed', $this->
id);
2341 if ($this->execute())
2348 $query = $this->mysql->prepare(
'INSERT INTO `' . $this->options[
'extras'][
'prefix'] .
'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:id, 0, :data, :time)');
2349 $query->bindValue(
':id', $this->
id);
2351 $query->bindValue(
':time', time());
2364 if ($this->mysql === null)
2368 $query = $this->mysql->prepare(
'SELECT `items`, `data` FROM `' . $this->options[
'extras'][
'prefix'] .
'cache_data` WHERE `id` = :id');
2369 $query->bindValue(
':id', $this->
id);
2372 $data = unserialize($row[1]);
2373 if (isset($this->options[
'items'][0]))
2375 $items = (int) $this->options[
'items'][0];
2379 $items = (int) $row[0];
2405 $sql =
'SELECT `data` FROM `' . $this->options[
'extras'][
'prefix'] .
'items` WHERE `feed_id` = :feed ORDER BY `posted` DESC';
2408 $sql .=
' LIMIT ' . $items;
2411 $query->bindValue(
':feed', $this->
id);
2414 while ($row =
$query->fetchColumn())
2432 if ($this->mysql === null)
2436 $query = $this->mysql->prepare(
'SELECT `mtime` FROM `' . $this->options[
'extras'][
'prefix'] .
'cache_data` WHERE `id` = :id');
2437 $query->bindValue(
':id', $this->
id);
2438 if (
$query->execute() && ($time =
$query->fetchColumn()))
2450 if ($this->mysql === null)
2454 $query = $this->mysql->prepare(
'UPDATE `' . $this->options[
'extras'][
'prefix'] .
'cache_data` SET `mtime` = :time WHERE `id` = :id');
2455 $query->bindValue(
':time', time());
2456 $query->bindValue(
':id', $this->
id);
2469 if ($this->mysql === null)
2473 $query = $this->mysql->prepare(
'DELETE FROM `' . $this->options[
'extras'][
'prefix'] .
'cache_data` WHERE `id` = :id');
2474 $query->bindValue(
':id', $this->
id);
2475 $query2 = $this->mysql->prepare(
'DELETE FROM `' . $this->options[
'extras'][
'prefix'] .
'items` WHERE `feed_id` = :id');
2476 $query2->bindValue(
':id', $this->
id);
2477 if (
$query->execute() && $query2->execute())
2491 'mysql' =>
'SimplePie_Cache_MySQL',
2492 'memcache' =>
'SimplePie_Cache_Memcache',
2495 private function __construct() { }
2499 $type = explode(
':', $location, 2);
2501 if (!empty(self::$handlers[$type]))
2503 $class = self::$handlers[$type];
2511 trigger_error(
'Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
2515 public static function register($type,
$class)
2517 self::$handlers[$type] =
$class;
2522 $params = parse_url(
$url);
2523 $params[
'extras'] = array();
2524 if (isset($params[
'query']))
2526 parse_str($params[
'query'], $params[
'extras']);
2544 public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
2546 $this->type =
$type;
2547 $this->lang =
$lang;
2550 $this->text =
$text;
2556 return md5(serialize($this));
2561 if ($this->endTime !== null)
2573 if ($this->lang !== null)
2585 if ($this->startTime !== null)
2597 if ($this->text !== null)
2609 if ($this->type !== null)
2628 public function __construct($term = null, $scheme = null, $label = null)
2630 $this->term =
$term;
2638 return md5(serialize($this));
2643 if ($this->term !== null)
2655 if ($this->scheme !== null)
2667 if ($this->label !== null)
2684 $this->file =
$file;
2689 if (isset($this->file->headers[
'content-type']))
2691 if (!isset($this->file->headers[
'content-encoding'])
2692 && ($this->file->headers[
'content-type'] ===
'text/plain'
2693 || $this->file->headers[
'content-type'] ===
'text/plain; charset=ISO-8859-1'
2694 || $this->file->headers[
'content-type'] ===
'text/plain; charset=iso-8859-1'
2695 || $this->file->headers[
'content-type'] ===
'text/plain; charset=UTF-8'))
2699 if (($pos = strpos($this->file->headers[
'content-type'],
';')) !==
false)
2701 $official = substr($this->file->headers[
'content-type'], 0, $pos);
2705 $official = $this->file->headers[
'content-type'];
2707 $official = trim(strtolower($official));
2708 if ($official ===
'unknown/unknown'
2709 || $official ===
'application/unknown')
2713 elseif (substr($official, -4) ===
'+xml'
2714 || $official ===
'text/xml'
2715 || $official ===
'application/xml')
2719 elseif (substr($official, 0, 6) ===
'image/')
2721 if ($return = $this->
image())
2730 elseif ($official ===
'text/html')
2747 if (substr($this->file->body, 0, 2) ===
"\xFE\xFF"
2748 || substr($this->file->body, 0, 2) ===
"\xFF\xFE"
2749 || substr($this->file->body, 0, 4) ===
"\x00\x00\xFE\xFF"
2750 || substr($this->file->body, 0, 3) ===
"\xEF\xBB\xBF")
2752 return 'text/plain';
2754 elseif (preg_match(
'/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body))
2756 return 'application/octect-stream';
2760 return 'text/plain';
2766 $ws = strspn($this->file->body,
"\x09\x0A\x0B\x0C\x0D\x20");
2767 if (strtolower(substr($this->file->body, $ws, 14)) ===
'<!doctype html'
2768 || strtolower(substr($this->file->body, $ws, 5)) ===
'<html'
2769 || strtolower(substr($this->file->body, $ws, 7)) ===
'<script')
2773 elseif (substr($this->file->body, 0, 5) ===
'%PDF-')
2775 return 'application/pdf';
2777 elseif (substr($this->file->body, 0, 11) ===
'%!PS-Adobe-')
2779 return 'application/postscript';
2781 elseif (substr($this->file->body, 0, 6) ===
'GIF87a'
2782 || substr($this->file->body, 0, 6) ===
'GIF89a')
2786 elseif (substr($this->file->body, 0, 8) ===
"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
2790 elseif (substr($this->file->body, 0, 3) ===
"\xFF\xD8\xFF")
2792 return 'image/jpeg';
2794 elseif (substr($this->file->body, 0, 2) ===
"\x42\x4D")
2798 elseif (substr($this->file->body, 0, 4) ===
"\x00\x00\x01\x00")
2800 return 'image/vnd.microsoft.icon';
2810 if (substr($this->file->body, 0, 6) ===
'GIF87a'
2811 || substr($this->file->body, 0, 6) ===
'GIF89a')
2815 elseif (substr($this->file->body, 0, 8) ===
"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
2819 elseif (substr($this->file->body, 0, 3) ===
"\xFF\xD8\xFF")
2821 return 'image/jpeg';
2823 elseif (substr($this->file->body, 0, 2) ===
"\x42\x4D")
2827 elseif (substr($this->file->body, 0, 4) ===
"\x00\x00\x01\x00")
2829 return 'image/vnd.microsoft.icon';
2839 $len = strlen($this->file->body);
2840 $pos = strspn($this->file->body,
"\x09\x0A\x0D\x20");
2843 switch ($this->file->body[$pos])
2849 $pos += strspn($this->file->body,
"\x09\x0A\x0D\x20", $pos);
2857 if (substr($this->file->body, $pos, 3) ===
'!--')
2860 if ($pos < $len && ($pos = strpos($this->file->body,
'-->', $pos)) !==
false)
2869 elseif (substr($this->file->body, $pos, 1) ===
'!')
2871 if ($pos < $len && ($pos = strpos($this->file->body,
'>', $pos)) !==
false)
2880 elseif (substr($this->file->body, $pos, 1) ===
'?')
2882 if ($pos < $len && ($pos = strpos($this->file->body,
'?>', $pos)) !==
false)
2891 elseif (substr($this->file->body, $pos, 3) ===
'rss'
2892 || substr($this->file->body, $pos, 7) ===
'rdf:RDF')
2894 return 'application/rss+xml';
2896 elseif (substr($this->file->body, $pos, 4) ===
'feed')
2898 return 'application/atom+xml';
2924 return md5(serialize($this));
2929 if ($this->url !== null)
2941 if ($this->label !== null)
2963 public function __construct($role = null, $scheme = null, $name = null)
2965 $this->role =
$role;
2967 $this->name =
$name;
2973 return md5(serialize($this));
2978 if ($this->role !== null)
2990 if ($this->scheme !== null)
3002 if ($this->name !== null)
3023 $this->data =
$data;
3028 while (($this->position = strpos($this->data,
'&', $this->position)) !==
false)
3032 $this->consumed =
'';
3039 if (isset($this->data[$this->position]))
3042 return $this->data[$this->position++];
3052 if ($len = strspn($this->data, $chars, $this->position))
3054 $data = substr($this->data, $this->position, $len);
3055 $this->consumed .=
$data;
3056 $this->position += $len;
3067 $this->consumed = substr($this->consumed, 0, -1);
3090 $range =
'0123456789ABCDEFabcdef';
3094 $range =
'0123456789';
3101 static $windows_1252_specials = array(0x0D =>
"\x0A", 0x80 =>
"\xE2\x82\xAC", 0x81 =>
"\xEF\xBF\xBD", 0x82 =>
"\xE2\x80\x9A", 0x83 =>
"\xC6\x92", 0x84 =>
"\xE2\x80\x9E", 0x85 =>
"\xE2\x80\xA6", 0x86 =>
"\xE2\x80\xA0", 0x87 =>
"\xE2\x80\xA1", 0x88 =>
"\xCB\x86", 0x89 =>
"\xE2\x80\xB0", 0x8A =>
"\xC5\xA0", 0x8B =>
"\xE2\x80\xB9", 0x8C =>
"\xC5\x92", 0x8D =>
"\xEF\xBF\xBD", 0x8E =>
"\xC5\xBD", 0x8F =>
"\xEF\xBF\xBD", 0x90 =>
"\xEF\xBF\xBD", 0x91 =>
"\xE2\x80\x98", 0x92 =>
"\xE2\x80\x99", 0x93 =>
"\xE2\x80\x9C", 0x94 =>
"\xE2\x80\x9D", 0x95 =>
"\xE2\x80\xA2", 0x96 =>
"\xE2\x80\x93", 0x97 =>
"\xE2\x80\x94", 0x98 =>
"\xCB\x9C", 0x99 =>
"\xE2\x84\xA2", 0x9A =>
"\xC5\xA1", 0x9B =>
"\xE2\x80\xBA", 0x9C =>
"\xC5\x93", 0x9D =>
"\xEF\xBF\xBD", 0x9E =>
"\xC5\xBE", 0x9F =>
"\xC5\xB8");
3104 $codepoint = hexdec($codepoint);
3108 $codepoint = intval($codepoint);
3110 if (isset($windows_1252_specials[$codepoint]))
3112 $replacement = $windows_1252_specials[$codepoint];
3118 if (!in_array($this->
consume(), array(
';',
false),
true))
3122 $consumed_length = strlen($this->consumed);
3123 $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
3124 $this->position += strlen($replacement) - $consumed_length;
3128 static $entities = array(
3129 'Aacute' =>
"\xC3\x81",
3130 'aacute' =>
"\xC3\xA1",
3131 'Aacute;' =>
"\xC3\x81",
3132 'aacute;' =>
"\xC3\xA1",
3133 'Acirc' =>
"\xC3\x82",
3134 'acirc' =>
"\xC3\xA2",
3135 'Acirc;' =>
"\xC3\x82",
3136 'acirc;' =>
"\xC3\xA2",
3137 'acute' =>
"\xC2\xB4",
3138 'acute;' =>
"\xC2\xB4",
3139 'AElig' =>
"\xC3\x86",
3140 'aelig' =>
"\xC3\xA6",
3141 'AElig;' =>
"\xC3\x86",
3142 'aelig;' =>
"\xC3\xA6",
3143 'Agrave' =>
"\xC3\x80",
3144 'agrave' =>
"\xC3\xA0",
3145 'Agrave;' =>
"\xC3\x80",
3146 'agrave;' =>
"\xC3\xA0",
3147 'alefsym;' =>
"\xE2\x84\xB5",
3148 'Alpha;' =>
"\xCE\x91",
3149 'alpha;' =>
"\xCE\xB1",
3154 'and;' =>
"\xE2\x88\xA7",
3155 'ang;' =>
"\xE2\x88\xA0",
3157 'Aring' =>
"\xC3\x85",
3158 'aring' =>
"\xC3\xA5",
3159 'Aring;' =>
"\xC3\x85",
3160 'aring;' =>
"\xC3\xA5",
3161 'asymp;' =>
"\xE2\x89\x88",
3162 'Atilde' =>
"\xC3\x83",
3163 'atilde' =>
"\xC3\xA3",
3164 'Atilde;' =>
"\xC3\x83",
3165 'atilde;' =>
"\xC3\xA3",
3166 'Auml' =>
"\xC3\x84",
3167 'auml' =>
"\xC3\xA4",
3168 'Auml;' =>
"\xC3\x84",
3169 'auml;' =>
"\xC3\xA4",
3170 'bdquo;' =>
"\xE2\x80\x9E",
3171 'Beta;' =>
"\xCE\x92",
3172 'beta;' =>
"\xCE\xB2",
3173 'brvbar' =>
"\xC2\xA6",
3174 'brvbar;' =>
"\xC2\xA6",
3175 'bull;' =>
"\xE2\x80\xA2",
3176 'cap;' =>
"\xE2\x88\xA9",
3177 'Ccedil' =>
"\xC3\x87",
3178 'ccedil' =>
"\xC3\xA7",
3179 'Ccedil;' =>
"\xC3\x87",
3180 'ccedil;' =>
"\xC3\xA7",
3181 'cedil' =>
"\xC2\xB8",
3182 'cedil;' =>
"\xC2\xB8",
3183 'cent' =>
"\xC2\xA2",
3184 'cent;' =>
"\xC2\xA2",
3185 'Chi;' =>
"\xCE\xA7",
3186 'chi;' =>
"\xCF\x87",
3187 'circ;' =>
"\xCB\x86",
3188 'clubs;' =>
"\xE2\x99\xA3",
3189 'cong;' =>
"\xE2\x89\x85",
3190 'COPY' =>
"\xC2\xA9",
3191 'copy' =>
"\xC2\xA9",
3192 'COPY;' =>
"\xC2\xA9",
3193 'copy;' =>
"\xC2\xA9",
3194 'crarr;' =>
"\xE2\x86\xB5",
3195 'cup;' =>
"\xE2\x88\xAA",
3196 'curren' =>
"\xC2\xA4",
3197 'curren;' =>
"\xC2\xA4",
3198 'Dagger;' =>
"\xE2\x80\xA1",
3199 'dagger;' =>
"\xE2\x80\xA0",
3200 'dArr;' =>
"\xE2\x87\x93",
3201 'darr;' =>
"\xE2\x86\x93",
3202 'deg' =>
"\xC2\xB0",
3203 'deg;' =>
"\xC2\xB0",
3204 'Delta;' =>
"\xCE\x94",
3205 'delta;' =>
"\xCE\xB4",
3206 'diams;' =>
"\xE2\x99\xA6",
3207 'divide' =>
"\xC3\xB7",
3208 'divide;' =>
"\xC3\xB7",
3209 'Eacute' =>
"\xC3\x89",
3210 'eacute' =>
"\xC3\xA9",
3211 'Eacute;' =>
"\xC3\x89",
3212 'eacute;' =>
"\xC3\xA9",
3213 'Ecirc' =>
"\xC3\x8A",
3214 'ecirc' =>
"\xC3\xAA",
3215 'Ecirc;' =>
"\xC3\x8A",
3216 'ecirc;' =>
"\xC3\xAA",
3217 'Egrave' =>
"\xC3\x88",
3218 'egrave' =>
"\xC3\xA8",
3219 'Egrave;' =>
"\xC3\x88",
3220 'egrave;' =>
"\xC3\xA8",
3221 'empty;' =>
"\xE2\x88\x85",
3222 'emsp;' =>
"\xE2\x80\x83",
3223 'ensp;' =>
"\xE2\x80\x82",
3224 'Epsilon;' =>
"\xCE\x95",
3225 'epsilon;' =>
"\xCE\xB5",
3226 'equiv;' =>
"\xE2\x89\xA1",
3227 'Eta;' =>
"\xCE\x97",
3228 'eta;' =>
"\xCE\xB7",
3229 'ETH' =>
"\xC3\x90",
3230 'eth' =>
"\xC3\xB0",
3231 'ETH;' =>
"\xC3\x90",
3232 'eth;' =>
"\xC3\xB0",
3233 'Euml' =>
"\xC3\x8B",
3234 'euml' =>
"\xC3\xAB",
3235 'Euml;' =>
"\xC3\x8B",
3236 'euml;' =>
"\xC3\xAB",
3237 'euro;' =>
"\xE2\x82\xAC",
3238 'exist;' =>
"\xE2\x88\x83",
3239 'fnof;' =>
"\xC6\x92",
3240 'forall;' =>
"\xE2\x88\x80",
3241 'frac12' =>
"\xC2\xBD",
3242 'frac12;' =>
"\xC2\xBD",
3243 'frac14' =>
"\xC2\xBC",
3244 'frac14;' =>
"\xC2\xBC",
3245 'frac34' =>
"\xC2\xBE",
3246 'frac34;' =>
"\xC2\xBE",
3247 'frasl;' =>
"\xE2\x81\x84",
3248 'Gamma;' =>
"\xCE\x93",
3249 'gamma;' =>
"\xCE\xB3",
3250 'ge;' =>
"\xE2\x89\xA5",
3255 'hArr;' =>
"\xE2\x87\x94",
3256 'harr;' =>
"\xE2\x86\x94",
3257 'hearts;' =>
"\xE2\x99\xA5",
3258 'hellip;' =>
"\xE2\x80\xA6",
3259 'Iacute' =>
"\xC3\x8D",
3260 'iacute' =>
"\xC3\xAD",
3261 'Iacute;' =>
"\xC3\x8D",
3262 'iacute;' =>
"\xC3\xAD",
3263 'Icirc' =>
"\xC3\x8E",
3264 'icirc' =>
"\xC3\xAE",
3265 'Icirc;' =>
"\xC3\x8E",
3266 'icirc;' =>
"\xC3\xAE",
3267 'iexcl' =>
"\xC2\xA1",
3268 'iexcl;' =>
"\xC2\xA1",
3269 'Igrave' =>
"\xC3\x8C",
3270 'igrave' =>
"\xC3\xAC",
3271 'Igrave;' =>
"\xC3\x8C",
3272 'igrave;' =>
"\xC3\xAC",
3273 'image;' =>
"\xE2\x84\x91",
3274 'infin;' =>
"\xE2\x88\x9E",
3275 'int;' =>
"\xE2\x88\xAB",
3276 'Iota;' =>
"\xCE\x99",
3277 'iota;' =>
"\xCE\xB9",
3278 'iquest' =>
"\xC2\xBF",
3279 'iquest;' =>
"\xC2\xBF",
3280 'isin;' =>
"\xE2\x88\x88",
3281 'Iuml' =>
"\xC3\x8F",
3282 'iuml' =>
"\xC3\xAF",
3283 'Iuml;' =>
"\xC3\x8F",
3284 'iuml;' =>
"\xC3\xAF",
3285 'Kappa;' =>
"\xCE\x9A",
3286 'kappa;' =>
"\xCE\xBA",
3287 'Lambda;' =>
"\xCE\x9B",
3288 'lambda;' =>
"\xCE\xBB",
3289 'lang;' =>
"\xE3\x80\x88",
3290 'laquo' =>
"\xC2\xAB",
3291 'laquo;' =>
"\xC2\xAB",
3292 'lArr;' =>
"\xE2\x87\x90",
3293 'larr;' =>
"\xE2\x86\x90",
3294 'lceil;' =>
"\xE2\x8C\x88",
3295 'ldquo;' =>
"\xE2\x80\x9C",
3296 'le;' =>
"\xE2\x89\xA4",
3297 'lfloor;' =>
"\xE2\x8C\x8A",
3298 'lowast;' =>
"\xE2\x88\x97",
3299 'loz;' =>
"\xE2\x97\x8A",
3300 'lrm;' =>
"\xE2\x80\x8E",
3301 'lsaquo;' =>
"\xE2\x80\xB9",
3302 'lsquo;' =>
"\xE2\x80\x98",
3307 'macr' =>
"\xC2\xAF",
3308 'macr;' =>
"\xC2\xAF",
3309 'mdash;' =>
"\xE2\x80\x94",
3310 'micro' =>
"\xC2\xB5",
3311 'micro;' =>
"\xC2\xB5",
3312 'middot' =>
"\xC2\xB7",
3313 'middot;' =>
"\xC2\xB7",
3314 'minus;' =>
"\xE2\x88\x92",
3315 'Mu;' =>
"\xCE\x9C",
3316 'mu;' =>
"\xCE\xBC",
3317 'nabla;' =>
"\xE2\x88\x87",
3318 'nbsp' =>
"\xC2\xA0",
3319 'nbsp;' =>
"\xC2\xA0",
3320 'ndash;' =>
"\xE2\x80\x93",
3321 'ne;' =>
"\xE2\x89\xA0",
3322 'ni;' =>
"\xE2\x88\x8B",
3323 'not' =>
"\xC2\xAC",
3324 'not;' =>
"\xC2\xAC",
3325 'notin;' =>
"\xE2\x88\x89",
3326 'nsub;' =>
"\xE2\x8A\x84",
3327 'Ntilde' =>
"\xC3\x91",
3328 'ntilde' =>
"\xC3\xB1",
3329 'Ntilde;' =>
"\xC3\x91",
3330 'ntilde;' =>
"\xC3\xB1",
3331 'Nu;' =>
"\xCE\x9D",
3332 'nu;' =>
"\xCE\xBD",
3333 'Oacute' =>
"\xC3\x93",
3334 'oacute' =>
"\xC3\xB3",
3335 'Oacute;' =>
"\xC3\x93",
3336 'oacute;' =>
"\xC3\xB3",
3337 'Ocirc' =>
"\xC3\x94",
3338 'ocirc' =>
"\xC3\xB4",
3339 'Ocirc;' =>
"\xC3\x94",
3340 'ocirc;' =>
"\xC3\xB4",
3341 'OElig;' =>
"\xC5\x92",
3342 'oelig;' =>
"\xC5\x93",
3343 'Ograve' =>
"\xC3\x92",
3344 'ograve' =>
"\xC3\xB2",
3345 'Ograve;' =>
"\xC3\x92",
3346 'ograve;' =>
"\xC3\xB2",
3347 'oline;' =>
"\xE2\x80\xBE",
3348 'Omega;' =>
"\xCE\xA9",
3349 'omega;' =>
"\xCF\x89",
3350 'Omicron;' =>
"\xCE\x9F",
3351 'omicron;' =>
"\xCE\xBF",
3352 'oplus;' =>
"\xE2\x8A\x95",
3353 'or;' =>
"\xE2\x88\xA8",
3354 'ordf' =>
"\xC2\xAA",
3355 'ordf;' =>
"\xC2\xAA",
3356 'ordm' =>
"\xC2\xBA",
3357 'ordm;' =>
"\xC2\xBA",
3358 'Oslash' =>
"\xC3\x98",
3359 'oslash' =>
"\xC3\xB8",
3360 'Oslash;' =>
"\xC3\x98",
3361 'oslash;' =>
"\xC3\xB8",
3362 'Otilde' =>
"\xC3\x95",
3363 'otilde' =>
"\xC3\xB5",
3364 'Otilde;' =>
"\xC3\x95",
3365 'otilde;' =>
"\xC3\xB5",
3366 'otimes;' =>
"\xE2\x8A\x97",
3367 'Ouml' =>
"\xC3\x96",
3368 'ouml' =>
"\xC3\xB6",
3369 'Ouml;' =>
"\xC3\x96",
3370 'ouml;' =>
"\xC3\xB6",
3371 'para' =>
"\xC2\xB6",
3372 'para;' =>
"\xC2\xB6",
3373 'part;' =>
"\xE2\x88\x82",
3374 'permil;' =>
"\xE2\x80\xB0",
3375 'perp;' =>
"\xE2\x8A\xA5",
3376 'Phi;' =>
"\xCE\xA6",
3377 'phi;' =>
"\xCF\x86",
3378 'Pi;' =>
"\xCE\xA0",
3379 'pi;' =>
"\xCF\x80",
3380 'piv;' =>
"\xCF\x96",
3381 'plusmn' =>
"\xC2\xB1",
3382 'plusmn;' =>
"\xC2\xB1",
3383 'pound' =>
"\xC2\xA3",
3384 'pound;' =>
"\xC2\xA3",
3385 'Prime;' =>
"\xE2\x80\xB3",
3386 'prime;' =>
"\xE2\x80\xB2",
3387 'prod;' =>
"\xE2\x88\x8F",
3388 'prop;' =>
"\xE2\x88\x9D",
3389 'Psi;' =>
"\xCE\xA8",
3390 'psi;' =>
"\xCF\x88",
3395 'radic;' =>
"\xE2\x88\x9A",
3396 'rang;' =>
"\xE3\x80\x89",
3397 'raquo' =>
"\xC2\xBB",
3398 'raquo;' =>
"\xC2\xBB",
3399 'rArr;' =>
"\xE2\x87\x92",
3400 'rarr;' =>
"\xE2\x86\x92",
3401 'rceil;' =>
"\xE2\x8C\x89",
3402 'rdquo;' =>
"\xE2\x80\x9D",
3403 'real;' =>
"\xE2\x84\x9C",
3404 'REG' =>
"\xC2\xAE",
3405 'reg' =>
"\xC2\xAE",
3406 'REG;' =>
"\xC2\xAE",
3407 'reg;' =>
"\xC2\xAE",
3408 'rfloor;' =>
"\xE2\x8C\x8B",
3409 'Rho;' =>
"\xCE\xA1",
3410 'rho;' =>
"\xCF\x81",
3411 'rlm;' =>
"\xE2\x80\x8F",
3412 'rsaquo;' =>
"\xE2\x80\xBA",
3413 'rsquo;' =>
"\xE2\x80\x99",
3414 'sbquo;' =>
"\xE2\x80\x9A",
3415 'Scaron;' =>
"\xC5\xA0",
3416 'scaron;' =>
"\xC5\xA1",
3417 'sdot;' =>
"\xE2\x8B\x85",
3418 'sect' =>
"\xC2\xA7",
3419 'sect;' =>
"\xC2\xA7",
3420 'shy' =>
"\xC2\xAD",
3421 'shy;' =>
"\xC2\xAD",
3422 'Sigma;' =>
"\xCE\xA3",
3423 'sigma;' =>
"\xCF\x83",
3424 'sigmaf;' =>
"\xCF\x82",
3425 'sim;' =>
"\xE2\x88\xBC",
3426 'spades;' =>
"\xE2\x99\xA0",
3427 'sub;' =>
"\xE2\x8A\x82",
3428 'sube;' =>
"\xE2\x8A\x86",
3429 'sum;' =>
"\xE2\x88\x91",
3430 'sup;' =>
"\xE2\x8A\x83",
3431 'sup1' =>
"\xC2\xB9",
3432 'sup1;' =>
"\xC2\xB9",
3433 'sup2' =>
"\xC2\xB2",
3434 'sup2;' =>
"\xC2\xB2",
3435 'sup3' =>
"\xC2\xB3",
3436 'sup3;' =>
"\xC2\xB3",
3437 'supe;' =>
"\xE2\x8A\x87",
3438 'szlig' =>
"\xC3\x9F",
3439 'szlig;' =>
"\xC3\x9F",
3440 'Tau;' =>
"\xCE\xA4",
3441 'tau;' =>
"\xCF\x84",
3442 'there4;' =>
"\xE2\x88\xB4",
3443 'Theta;' =>
"\xCE\x98",
3444 'theta;' =>
"\xCE\xB8",
3445 'thetasym;' =>
"\xCF\x91",
3446 'thinsp;' =>
"\xE2\x80\x89",
3447 'THORN' =>
"\xC3\x9E",
3448 'thorn' =>
"\xC3\xBE",
3449 'THORN;' =>
"\xC3\x9E",
3450 'thorn;' =>
"\xC3\xBE",
3451 'tilde;' =>
"\xCB\x9C",
3452 'times' =>
"\xC3\x97",
3453 'times;' =>
"\xC3\x97",
3454 'TRADE;' =>
"\xE2\x84\xA2",
3455 'trade;' =>
"\xE2\x84\xA2",
3456 'Uacute' =>
"\xC3\x9A",
3457 'uacute' =>
"\xC3\xBA",
3458 'Uacute;' =>
"\xC3\x9A",
3459 'uacute;' =>
"\xC3\xBA",
3460 'uArr;' =>
"\xE2\x87\x91",
3461 'uarr;' =>
"\xE2\x86\x91",
3462 'Ucirc' =>
"\xC3\x9B",
3463 'ucirc' =>
"\xC3\xBB",
3464 'Ucirc;' =>
"\xC3\x9B",
3465 'ucirc;' =>
"\xC3\xBB",
3466 'Ugrave' =>
"\xC3\x99",
3467 'ugrave' =>
"\xC3\xB9",
3468 'Ugrave;' =>
"\xC3\x99",
3469 'ugrave;' =>
"\xC3\xB9",
3470 'uml' =>
"\xC2\xA8",
3471 'uml;' =>
"\xC2\xA8",
3472 'upsih;' =>
"\xCF\x92",
3473 'Upsilon;' =>
"\xCE\xA5",
3474 'upsilon;' =>
"\xCF\x85",
3475 'Uuml' =>
"\xC3\x9C",
3476 'uuml' =>
"\xC3\xBC",
3477 'Uuml;' =>
"\xC3\x9C",
3478 'uuml;' =>
"\xC3\xBC",
3479 'weierp;' =>
"\xE2\x84\x98",
3480 'Xi;' =>
"\xCE\x9E",
3481 'xi;' =>
"\xCE\xBE",
3482 'Yacute' =>
"\xC3\x9D",
3483 'yacute' =>
"\xC3\xBD",
3484 'Yacute;' =>
"\xC3\x9D",
3485 'yacute;' =>
"\xC3\xBD",
3486 'yen' =>
"\xC2\xA5",
3487 'yen;' =>
"\xC2\xA5",
3488 'yuml' =>
"\xC3\xBF",
3489 'Yuml;' =>
"\xC5\xB8",
3490 'yuml;' =>
"\xC3\xBF",
3491 'Zeta;' =>
"\xCE\x96",
3492 'zeta;' =>
"\xCE\xB6",
3493 'zwj;' =>
"\xE2\x80\x8D",
3494 'zwnj;' =>
"\xE2\x80\x8C"
3498 $consumed = substr($this->consumed, 1);
3499 if (isset($entities[$consumed]))
3506 $this->data = substr_replace($this->data, $entities[
$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
3507 $this->position += strlen($entities[$match]) - strlen($consumed) - 1;
3570 public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
3585 $this->lang =
$lang;
3587 $this->link =
$link;
3595 $this->type =
$type;
3597 if (class_exists(
'idna_convert'))
3599 $idn =
new idna_convert();
3609 return md5(serialize($this));
3614 if ($this->bitrate !== null)
3627 if (isset($captions[$key]))
3629 return $captions[$key];
3639 if ($this->captions !== null)
3652 if (isset($categories[$key]))
3654 return $categories[$key];
3664 if ($this->categories !== null)
3676 if ($this->channels !== null)
3688 if ($this->copyright !== null)
3701 if (isset($credits[$key]))
3703 return $credits[$key];
3713 if ($this->credits !== null)
3725 if ($this->description !== null)
3737 if ($this->duration !== null)
3757 if ($this->expression !== null)
3769 if ($this->link !== null)
3772 if (
$url[
'path'] !==
'')
3774 return pathinfo(
$url[
'path'], PATHINFO_EXTENSION);
3782 if ($this->framerate !== null)
3800 if (isset($hashes[$key]))
3802 return $hashes[$key];
3812 if ($this->hashes !== null)
3824 if ($this->height !== null)
3836 if ($this->lang !== null)
3849 if (isset($keywords[$key]))
3851 return $keywords[$key];
3861 if ($this->keywords !== null)
3873 if ($this->length !== null)
3885 if ($this->link !== null)
3887 return urldecode($this->link);
3897 if ($this->medium !== null)
3909 if ($this->player !== null)
3922 if (isset($ratings[$key]))
3924 return $ratings[$key];
3934 if ($this->ratings !== null)
3947 if (isset($restrictions[$key]))
3949 return $restrictions[$key];
3959 if ($this->restrictions !== null)
3971 if ($this->samplingrate !== null)
3984 if ($length !== null)
3986 return round($length/1048576, 2);
3997 if (isset($thumbnails[$key]))
3999 return $thumbnails[$key];
4009 if ($this->thumbnails !== null)
4021 if ($this->title !== null)
4033 if ($this->type !== null)
4045 if ($this->width !== null)
4057 return $this->
embed($options,
true);
4060 public function embed($options =
'', $native =
false)
4070 $bgcolor =
'#ffffff';
4072 $widescreen =
false;
4076 if (is_array($options))
4082 $options = explode(
',', $options);
4083 foreach($options as $option)
4085 $opt = explode(
':', $option, 2);
4086 if (isset($opt[0], $opt[1]))
4088 $opt[0] = trim($opt[0]);
4089 $opt[1] = trim($opt[1]);
4102 $altclass = $opt[1];
4117 $mediaplayer = $opt[1];
4120 $widescreen = $opt[1];
4126 $mime = explode(
'/', $type, 2);
4129 if ($width ===
'auto')
4131 if ($mime ===
'video')
4133 if ($height ===
'auto')
4139 $width = round((intval($height)/9)*16);
4143 $width = round((intval($height)/3)*4);
4151 if ($height ===
'auto')
4153 if ($mime ===
'audio')
4157 elseif ($mime ===
'video')
4159 if ($width ===
'auto')
4172 $height = round((intval($width)/16)*9);
4176 $height = round((intval($width)/4)*3);
4184 elseif ($mime ===
'audio')
4189 if ($mime ===
'audio')
4191 $placeholder = $audio;
4193 elseif ($mime ===
'video')
4195 $placeholder = $video;
4199 if ($handler ===
'flash')
4203 $embed .=
"<embed src=\"" . $this->
get_link() .
"\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
4207 $embed .=
"<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->
get_link() .
"', '$loop', '$type');</script>";
4212 elseif ($handler ===
'fmedia' || ($handler ===
'mp3' && $mediaplayer !==
''))
4217 $embed .=
"<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->
get_link().
'?file_extension=.'.$this->
get_extension()) .
"&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";
4221 $embed .=
"<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->
get_link().
'?file_extension=.'.$this->
get_extension()) .
"', '$placeholder', '$loop', '$mediaplayer');</script>";
4226 elseif ($handler ===
'quicktime' || ($handler ===
'mp3' && $mediaplayer ===
''))
4231 if ($placeholder !==
'')
4233 $embed .=
"<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->
get_link() .
"\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
4237 $embed .=
"<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->
get_link() .
"\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
4242 $embed .=
"<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->
get_link() .
"', '$placeholder', '$loop');</script>";
4246 elseif ($handler ===
'wmedia')
4251 $embed .=
"<embed type=\"application/x-mplayer2\" src=\"" . $this->
get_link() .
"\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>";
4255 $embed .=
"<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->
get_link() .
"');</script>";
4259 else $embed .=
'<a href="' . $this->
get_link() .
'" class="' . $altclass .
'">' . $alt .
'</a>';
4266 $types_flash = array(
'application/x-shockwave-flash',
'application/futuresplash');
4267 $types_fmedia = array(
'video/flv',
'video/x-flv',
'flv-application/octet-stream');
4268 $types_quicktime = array(
'audio/3gpp',
'audio/3gpp2',
'audio/aac',
'audio/x-aac',
'audio/aiff',
'audio/x-aiff',
'audio/mid',
'audio/midi',
'audio/x-midi',
'audio/mp4',
'audio/m4a',
'audio/x-m4a',
'audio/wav',
'audio/x-wav',
'video/3gpp',
'video/3gpp2',
'video/m4v',
'video/x-m4v',
'video/mp4',
'video/mpeg',
'video/x-mpeg',
'video/quicktime',
'video/sd-video');
4269 $types_wmedia = array(
'application/asx',
'application/x-mplayer2',
'audio/x-ms-wma',
'audio/x-ms-wax',
'video/x-ms-asf-plugin',
'video/x-ms-asf',
'video/x-ms-wm',
'video/x-ms-wmv',
'video/x-ms-wvx');
4270 $types_mp3 = array(
'audio/mp3',
'audio/x-mp3',
'audio/mpeg',
'audio/x-mpeg');
4273 $type = strtolower($this->type);
4280 if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
4287 $type =
'audio/acc';
4293 $type =
'audio/aiff';
4296 $type =
'audio/wav';
4302 $type =
'audio/midi';
4305 $type =
'audio/x-m4a';
4309 $type =
'audio/mp3';
4312 $type =
'audio/wav';
4315 $type =
'audio/x-ms-wax';
4318 $type =
'audio/x-ms-wma';
4323 $type =
'video/3gpp';
4327 $type =
'video/3gpp2';
4330 $type =
'video/x-ms-asf';
4333 $type =
'video/x-flv';
4346 $type =
'video/mpeg';
4349 $type =
'video/x-m4v';
4353 $type =
'video/quicktime';
4357 $type =
'video/mp4';
4360 $type =
'video/sd-video';
4363 $type =
'video/x-ms-wm';
4366 $type =
'video/x-ms-wmv';
4369 $type =
'video/x-ms-wvx';
4373 $type =
'application/futuresplash';
4376 $type =
'application/x-shockwave-flash';
4382 if (in_array($type, $types_flash))
4386 elseif (in_array($type, $types_fmedia))
4390 elseif (in_array($type, $types_quicktime))
4394 elseif (in_array($type, $types_wmedia))
4398 elseif (in_array($type, $types_mp3))
4427 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen =
false)
4429 if (class_exists(
'idna_convert'))
4431 $idn =
new idna_convert();
4437 if (preg_match(
'/^http(s)?:\/\//i', $url))
4439 if ($useragent === null)
4441 $useragent = ini_get(
'user_agent');
4444 if (!is_array($headers))
4448 if (!$force_fsockopen && function_exists(
'curl_exec'))
4452 $headers2 = array();
4453 foreach ($headers as $key => $value)
4455 $headers2[] =
"$key: $value";
4459 curl_setopt(
$fp, CURLOPT_ENCODING,
'');
4461 curl_setopt(
$fp, CURLOPT_URL, $url);
4462 curl_setopt(
$fp, CURLOPT_HEADER, 1);
4463 curl_setopt(
$fp, CURLOPT_RETURNTRANSFER, 1);
4464 curl_setopt(
$fp, CURLOPT_TIMEOUT, $timeout);
4465 curl_setopt(
$fp, CURLOPT_CONNECTTIMEOUT, $timeout);
4466 curl_setopt(
$fp, CURLOPT_REFERER, $url);
4467 curl_setopt(
$fp, CURLOPT_USERAGENT, $useragent);
4468 curl_setopt(
$fp, CURLOPT_HTTPHEADER, $headers2);
4471 curl_setopt(
$fp, CURLOPT_FOLLOWLOCATION, 1);
4472 curl_setopt(
$fp, CURLOPT_MAXREDIRS, $redirects);
4474 $this->headers = curl_exec(
$fp);
4475 if (curl_errno(
$fp) === 23 || curl_errno(
$fp) === 61)
4477 curl_setopt(
$fp, CURLOPT_ENCODING,
'none');
4478 $this->headers = curl_exec(
$fp);
4480 if (curl_errno(
$fp))
4482 $this->error =
'cURL error ' . curl_errno(
$fp) .
': ' . curl_error(
$fp);
4483 $this->success =
false;
4487 $info = curl_getinfo(
$fp);
4489 $this->headers = explode(
"\r\n\r\n", $this->headers, $info[
'redirect_count'] + 1);
4490 $this->headers = array_pop($this->headers);
4492 if ($parser->parse())
4494 $this->headers = $parser->headers;
4495 $this->body = $parser->body;
4496 $this->status_code = $parser->status_code;
4497 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers[
'location']) && $this->redirects <
$redirects)
4501 return $this->
__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
4509 $url_parts = parse_url($url);
4510 $socket_host = $url_parts[
'host'];
4511 if (isset($url_parts[
'scheme']) && strtolower($url_parts[
'scheme']) ===
'https')
4513 $socket_host =
"ssl://$url_parts[host]";
4514 $url_parts[
'port'] = 443;
4516 if (!isset($url_parts[
'port']))
4518 $url_parts[
'port'] = 80;
4520 $fp = @fsockopen($socket_host, $url_parts[
'port'], $errno, $errstr, $timeout);
4523 $this->error =
'fsockopen error: ' . $errstr;
4524 $this->success =
false;
4528 stream_set_timeout(
$fp, $timeout);
4529 if (isset($url_parts[
'path']))
4531 if (isset($url_parts[
'query']))
4533 $get =
"$url_parts[path]?$url_parts[query]";
4537 $get = $url_parts[
'path'];
4544 $out =
"GET $get HTTP/1.1\r\n";
4545 $out .=
"Host: $url_parts[host]\r\n";
4546 $out .=
"User-Agent: $useragent\r\n";
4547 if (extension_loaded(
'zlib'))
4549 $out .=
"Accept-Encoding: x-gzip,gzip,deflate\r\n";
4551 if (isset($url_parts[
'user']) && isset($url_parts[
'pass']))
4553 $out .=
"Authorization: Basic " . base64_encode(
"$url_parts[user]:$url_parts[pass]") .
"\r\n";
4555 foreach ($headers as $key => $value)
4557 $out .=
"$key: $value\r\n";
4559 $out .=
"Connection: Close\r\n\r\n";
4561 $info = stream_get_meta_data(
$fp);
4562 $this->headers =
'';
4563 while (!$info[
'eof'] && !$info[
'timed_out'])
4565 $this->headers .= fread(
$fp, 1160);
4566 $info = stream_get_meta_data(
$fp);
4568 if (!$info[
'timed_out'])
4571 if ($parser->parse())
4573 $this->headers = $parser->headers;
4574 $this->body = $parser->body;
4575 $this->status_code = $parser->status_code;
4576 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers[
'location']) && $this->redirects <
$redirects)
4580 return $this->
__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
4582 if (isset($this->headers[
'content-encoding']))
4585 switch (strtolower(trim($this->headers[
'content-encoding'],
"\x09\x0A\x0D\x20")))
4590 if (!$decoder->parse())
4592 $this->error =
'Unable to decode HTTP "gzip" stream';
4593 $this->success =
false;
4597 $this->body = $decoder->data;
4601 if (($decompressed = gzinflate($this->body)) !==
false)
4603 $this->body = $decompressed;
4605 else if (($decompressed = gzuncompress($this->body)) !==
false)
4607 $this->body = $decompressed;
4609 else if (function_exists(
'gzdecode') && ($decompressed = gzdecode($this->body)) !==
false)
4611 $this->body = $decompressed;
4615 $this->error =
'Unable to decode HTTP "deflate" stream';
4616 $this->success =
false;
4620 $this->error =
'Unknown content coding';
4621 $this->success =
false;
4628 $this->error =
'fsocket timed out';
4629 $this->success =
false;
4638 if (!$this->body = file_get_contents($url))
4640 $this->error =
'file_get_contents could not read the file';
4641 $this->success =
false;
4679 trigger_error(
"Cannot write property $name", E_USER_ERROR);
4684 $this->compressed_data =
$data;
4685 $this->compressed_size = strlen($data);
4690 if ($this->compressed_size >= $this->min_compressed_size)
4693 if (substr($this->compressed_data, 0, 3) !==
"\x1F\x8B\x08")
4698 $this->flags = ord($this->compressed_data[3]);
4700 if ($this->flags > 0x1F)
4705 $this->position += 4;
4707 $mtime = substr($this->compressed_data, $this->position, 4);
4709 if (current(unpack(
'S',
"\x00\x01")) === 1)
4711 $mtime = strrev($mtime);
4713 $this->MTIME = current(unpack(
'l', $mtime));
4714 $this->position += 4;
4716 $this->XFL = ord($this->compressed_data[$this->position++]);
4718 $this->OS = ord($this->compressed_data[$this->position++]);
4720 if ($this->flags & 4)
4723 $this->SI1 = $this->compressed_data[$this->position++];
4724 $this->SI2 = $this->compressed_data[$this->position++];
4726 if ($this->SI2 ===
"\x00")
4731 $len = current(unpack(
'v', substr($this->compressed_data, $this->position, 2)));
4732 $this->position += 2;
4734 $this->min_compressed_size += $len + 4;
4735 if ($this->compressed_size >= $this->min_compressed_size)
4738 $this->extra_field = substr($this->compressed_data, $this->position, $len);
4739 $this->position += $len;
4747 if ($this->flags & 8)
4750 $len = strcspn($this->compressed_data,
"\x00", $this->position);
4752 $this->min_compressed_size += $len + 1;
4753 if ($this->compressed_size >= $this->min_compressed_size)
4756 $this->filename = substr($this->compressed_data, $this->position, $len);
4757 $this->position += $len + 1;
4765 if ($this->flags & 16)
4768 $len = strcspn($this->compressed_data,
"\x00", $this->position);
4770 $this->min_compressed_size += $len + 1;
4771 if ($this->compressed_size >= $this->min_compressed_size)
4774 $this->comment = substr($this->compressed_data, $this->position, $len);
4775 $this->position += $len + 1;
4783 if ($this->flags & 2)
4786 $this->min_compressed_size += $len + 2;
4787 if ($this->compressed_size >= $this->min_compressed_size)
4790 $crc = current(unpack(
'v', substr($this->compressed_data, $this->position, 2)));
4792 if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc)
4794 $this->position += 2;
4807 if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) ===
false)
4813 $this->position = $this->compressed_size - 8;
4816 $crc = current(unpack(
'V', substr($this->compressed_data, $this->position, 4)));
4817 $this->position += 4;
4823 $isize = current(unpack(
'V', substr($this->compressed_data, $this->position, 4)));
4824 $this->position += 4;
4825 if (sprintf(
'%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf(
'%u', $isize))
4865 $this->data =
$data;
4866 $this->data_length = strlen($this->data);
4871 while ($this->state && $this->state !==
'emit' && $this->
has_data())
4877 if ($this->state ===
'emit' || $this->state ===
'body')
4884 $this->status_code =
'';
4886 $this->headers = array();
4902 && isset($this->data[$this->position + 1])
4903 && ($this->data[$this->position + 1] ===
"\x09" || $this->data[$this->position + 1] ===
"\x20")));
4908 if (strpos($this->data,
"\x0A") !==
false && strtoupper(substr($this->data, 0, 5)) ===
'HTTP/')
4910 $len = strspn($this->data,
'0123456789.', 5);
4912 $this->position += 5 + $len;
4916 $this->position += strspn($this->data,
"\x09\x20", $this->position);
4917 $this->state =
'status';
4921 $this->state =
false;
4926 $this->state =
false;
4932 if ($len = strspn($this->data,
'0123456789', $this->position))
4934 $this->status_code = (int) substr($this->data, $this->position, $len);
4935 $this->position += $len;
4936 $this->state =
'reason';
4940 $this->state =
false;
4946 $len = strcspn($this->data,
"\x0A", $this->position);
4947 $this->
reason = trim(substr($this->data, $this->position, $len),
"\x09\x0D\x20");
4948 $this->position += $len + 1;
4949 $this->state =
'new_line';
4954 $this->
value = trim($this->
value,
"\x0D\x20");
4955 if ($this->
name !==
'' && $this->
value !==
'')
4957 $this->
name = strtolower($this->
name);
4959 if (isset($this->headers[$this->
name]) && $this->name !==
'content-type')
4970 if (substr($this->data[$this->position], 0, 2) ===
"\x0D\x0A")
4972 $this->position += 2;
4973 $this->state =
'body';
4975 elseif ($this->data[$this->position] ===
"\x0A")
4978 $this->state =
'body';
4982 $this->state =
'name';
4988 $len = strcspn($this->data,
"\x0A:", $this->position);
4989 if (isset($this->data[$this->position + $len]))
4991 if ($this->data[$this->position + $len] ===
"\x0A")
4993 $this->position += $len;
4994 $this->state =
'new_line';
4998 $this->
name = substr($this->data, $this->position, $len);
4999 $this->position += $len + 1;
5000 $this->state =
'value';
5005 $this->state =
false;
5013 if (substr($this->data, $this->position, 2) ===
"\x0D\x0A")
5015 $this->position += 2;
5017 elseif ($this->data[$this->position] ===
"\x0A")
5021 $this->position += strspn($this->data,
"\x09\x20", $this->position);
5023 $this->
value .=
"\x20";
5034 switch ($this->data[$this->position])
5039 if (strtolower($this->
name) ===
'etag')
5041 $this->
value .=
'"';
5043 $this->state =
'value_char';
5047 $this->state =
'quote';
5051 $this->state =
'new_line';
5054 $this->state =
'value_char';
5062 $len = strcspn($this->data,
"\x09\x20\x0A\"", $this->position);
5063 $this->
value .= substr($this->data, $this->position, $len);
5064 $this->position += $len;
5065 $this->state =
'value';
5076 switch ($this->data[$this->position])
5080 $this->state =
'value';
5084 $this->state =
'new_line';
5088 $this->state =
'quote_escaped';
5091 $this->state =
'quote_char';
5099 $len = strcspn($this->data,
"\x09\x20\x0A\"\\", $this->position);
5100 $this->
value .= substr($this->data, $this->position, $len);
5101 $this->position += $len;
5102 $this->state =
'value';
5109 $this->state =
'quote';
5114 $this->
body = substr($this->data, $this->position);
5115 if (!empty($this->headers[
'transfer-encoding']))
5117 unset($this->headers[
'transfer-encoding']);
5118 $this->state =
'chunked';
5122 $this->state =
'emit';
5128 if (!preg_match(
'/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($this->
body)))
5130 $this->state =
'emit';
5137 $is_chunked = (bool) preg_match(
'/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches );
5141 $this->state =
'emit';
5144 $length = hexdec(trim($matches[1]));
5148 $this->state =
'emit';
5149 $this->
body = $decoded;
5152 $chunk_length = strlen($matches[0]);
5153 $decoded .= $part = substr($encoded, $chunk_length, $length);
5154 $encoded = substr($encoded, $chunk_length + $length + 2);
5155 if (trim($encoded) ===
'0' || empty($encoded))
5157 $this->state =
'emit';
5158 $this->
body = $decoded;
5189 'ihost' =>
'localhost'
5208 if (method_exists($this,
'set_' . $name))
5210 call_user_func(array($this,
'set_' . $name), $value);
5213 $name ===
'iauthority'
5214 || $name ===
'iuserinfo'
5215 || $name ===
'ihost'
5216 || $name ===
'ipath'
5217 || $name ===
'iquery'
5218 || $name ===
'ifragment'
5221 call_user_func(array($this,
'set_' . substr($name, 1)), $value);
5229 $props = get_object_vars($this);
5233 $name ===
'iauthority' ||
5234 $name ===
'authority'
5237 $return = $this->{
"get_$name"}();
5239 elseif (array_key_exists($name, $props))
5241 $return = $this->$name;
5244 elseif (($prop =
'i' . $name) && array_key_exists($prop, $props))
5247 $return = $this->$prop;
5250 elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props))
5253 $return = $this->$prop;
5257 trigger_error(
'Undefined property: ' . get_class($this) .
'::' . $name, E_USER_NOTICE);
5260 if ($return === null && isset($this->normalization[$this->scheme][$name]))
5272 if (method_exists($this,
'get_' . $name) || isset($this->$name))
5284 if (method_exists($this,
'set_' . $name))
5286 call_user_func(array($this,
'set_' . $name),
'');
5299 $relative =
new SimplePie_IRI($relative);
5301 if (!$relative->is_valid())
5305 elseif ($relative->scheme !== null)
5307 return clone $relative;
5311 if (!($base instanceof SimplePie_IRI))
5313 $base =
new SimplePie_IRI($base);
5315 if ($base->scheme !== null && $base->is_valid())
5317 if ($relative->get_iri() !==
'')
5319 if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null)
5321 $target = clone $relative;
5322 $target->scheme = $base->scheme;
5326 $target =
new SimplePie_IRI;
5327 $target->scheme = $base->scheme;
5328 $target->iuserinfo = $base->iuserinfo;
5329 $target->ihost = $base->ihost;
5330 $target->port = $base->port;
5331 if ($relative->ipath !==
'')
5333 if ($relative->ipath[0] ===
'/')
5335 $target->ipath = $relative->ipath;
5337 elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath ===
'')
5339 $target->ipath =
'/' . $relative->ipath;
5341 elseif (($last_segment = strrpos($base->ipath,
'/')) !==
false)
5343 $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath;
5347 $target->ipath = $relative->ipath;
5349 $target->ipath = $target->remove_dot_segments($target->ipath);
5350 $target->iquery = $relative->iquery;
5354 $target->ipath = $base->ipath;
5355 if ($relative->iquery !== null)
5357 $target->iquery = $relative->iquery;
5359 elseif ($base->iquery !== null)
5361 $target->iquery = $base->iquery;
5364 $target->ifragment = $relative->ifragment;
5369 $target = clone $base;
5370 $target->ifragment = null;
5372 $target->scheme_normalization();
5384 $iri = trim($iri,
"\x20\x09\x0A\x0C\x0D");
5385 if (preg_match(
'/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri,
$match))
5393 $match[
'authority'] = null;
5405 $match[
'fragment'] = null;
5419 while (strpos($input,
'./') !==
false || strpos($input,
'/.') !==
false || $input ===
'.' || $input ===
'..')
5422 if (strpos($input,
'../') === 0)
5424 $input = substr($input, 3);
5426 elseif (strpos($input,
'./') === 0)
5428 $input = substr($input, 2);
5431 elseif (strpos($input,
'/./') === 0)
5433 $input = substr($input, 2);
5440 elseif (strpos($input,
'/../') === 0)
5442 $input = substr($input, 3);
5445 elseif ($input ===
'/..')
5451 elseif ($input ===
'.' || $input ===
'..')
5456 elseif (($pos = strpos($input,
'/', 1)) !==
false)
5458 $output .= substr($input, 0, $pos);
5459 $input = substr_replace($input,
'', 0, $pos);
5473 $string = preg_replace_callback(
'/(?:%[A-Fa-f0-9]{2})+/', array($this,
'remove_iunreserved_percent_encoded'), $string);
5475 $string = preg_replace(
'/%(?![A-Fa-f0-9]{2})/',
'%25', $string);
5478 $extra_chars .=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%';
5481 $strlen = strlen($string);
5482 while (($position += strspn($string, $extra_chars, $position)) < $strlen)
5484 $value = ord($string[$position]);
5491 if (($value & 0xE0) === 0xC0)
5493 $character = ($value & 0x1F) << 6;
5498 elseif (($value & 0xF0) === 0xE0)
5500 $character = ($value & 0x0F) << 12;
5505 elseif (($value & 0xF8) === 0xF0)
5507 $character = ($value & 0x07) << 18;
5520 if ($position + $length <= $strlen)
5522 for ($position++; $remaining; $position++)
5524 $value = ord($string[$position]);
5526 if (($value & 0xC0) === 0x80)
5528 $character |= ($value & 0x3F) << (--$remaining * 6);
5541 $position = $strlen - 1;
5550 || $length > 1 && $character <= 0x7F
5551 || $length > 2 && $character <= 0x7FF
5552 || $length > 3 && $character <= 0xFFFF
5555 || ($character & 0xFFFE) === 0xFFFE
5556 || $character >= 0xFDD0 && $character <= 0xFDEF
5559 $character > 0xD7FF && $character < 0xF900
5560 || $character < 0xA0
5561 || $character > 0xEFFFD
5566 || $character < 0xE000
5567 || $character > 0x10FFFD
5574 for ($j =
$start; $j <= $position; $j++)
5576 $string = substr_replace($string, sprintf(
'%%%02X', ord($string[$j])), $j, 1);
5590 $bytes = explode(
'%',
$match[0]);
5597 for (
$i = 1, $len = count($bytes);
$i < $len;
$i++)
5599 $value = hexdec($bytes[
$i]);
5610 $character = $value;
5614 elseif (($value & 0xE0) === 0xC0)
5616 $character = ($value & 0x1F) << 6;
5621 elseif (($value & 0xF0) === 0xE0)
5623 $character = ($value & 0x0F) << 12;
5628 elseif (($value & 0xF8) === 0xF0)
5630 $character = ($value & 0x07) << 18;
5645 if (($value & 0xC0) === 0x80)
5648 $character |= ($value & 0x3F) << ($remaining * 6);
5666 || $length > 1 && $character <= 0x7F
5667 || $length > 2 && $character <= 0x7FF
5668 || $length > 3 && $character <= 0xFFFF
5670 || $character < 0x2D
5671 || $character > 0xEFFFD
5673 || ($character & 0xFFFE) === 0xFFFE
5674 || $character >= 0xFDD0 && $character <= 0xFDEF
5676 || $character === 0x2F
5677 || $character > 0x39 && $character < 0x41
5678 || $character > 0x5A && $character < 0x61
5679 || $character > 0x7A && $character < 0x7E
5680 || $character > 0x7E && $character < 0xA0
5681 || $character > 0xD7FF && $character < 0xF900
5686 $string .=
'%' . strtoupper($bytes[$j]);
5693 $string .= chr(hexdec($bytes[$j]));
5702 for ($j =
$start; $j < $len; $j++)
5704 $string .=
'%' . strtoupper($bytes[$j]);
5711 if (isset($this->normalization[$this->scheme][
'iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme][
'iuserinfo'])
5713 $this->iuserinfo = null;
5715 if (isset($this->normalization[$this->scheme][
'ihost']) && $this->ihost === $this->normalization[$this->scheme][
'ihost'])
5717 $this->ihost = null;
5719 if (isset($this->normalization[$this->scheme][
'port']) && $this->port === $this->normalization[$this->scheme][
'port'])
5723 if (isset($this->normalization[$this->scheme][
'ipath']) && $this->ipath === $this->normalization[$this->scheme][
'ipath'])
5727 if (isset($this->normalization[$this->scheme][
'iquery']) && $this->iquery === $this->normalization[$this->scheme][
'iquery'])
5729 $this->iquery = null;
5731 if (isset($this->normalization[$this->scheme][
'ifragment']) && $this->ifragment === $this->normalization[$this->scheme][
'ifragment'])
5733 $this->ifragment = null;
5739 $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null;
5740 if ($this->ipath !==
'' &&
5743 $this->ipath[0] !==
'/' ||
5744 substr($this->ipath, 0, 2) ===
'//'
5747 $this->scheme === null &&
5749 strpos($this->ipath,
':') !==
false &&
5750 (strpos($this->ipath,
'/') ===
false ?
true : strpos($this->ipath,
':') < strpos($this->ipath,
'/'))
5771 elseif (isset($cache[$iri]))
5780 $return) = $cache[$iri];
5785 $parsed = $this->
parse_iri((
string) $iri);
5790 $return = $this->
set_scheme($parsed[
'scheme'])
5792 && $this->
set_path($parsed[
'path'])
5795 $cache[$iri] = array($this->scheme,
5811 $this->scheme = null;
5813 elseif (!preg_match(
'/^[A-Za-z][0-9A-Za-z+\-.]*$/',
$scheme))
5815 $this->scheme = null;
5820 $this->scheme = strtolower(
$scheme);
5830 if ($authority === null)
5832 $this->iuserinfo = null;
5833 $this->ihost = null;
5837 elseif (isset($cache[$authority]))
5839 list($this->iuserinfo,
5842 $return) = $cache[$authority];
5847 $remaining = $authority;
5848 if (($iuserinfo_end = strrpos($remaining,
'@')) !==
false)
5850 $iuserinfo = substr($remaining, 0, $iuserinfo_end);
5851 $remaining = substr($remaining, $iuserinfo_end + 1);
5857 if (($port_start = strpos($remaining,
':', strpos($remaining,
']'))) !==
false)
5859 if ((
$port = substr($remaining, $port_start + 1)) ===
false)
5863 $remaining = substr($remaining, 0, $port_start);
5872 $cache[$authority] = array($this->iuserinfo,
5884 $this->iuserinfo = null;
5898 $this->ihost = null;
5909 $this->ihost = null;
5920 $strlen = strlen(
$ihost);
5921 while (($position += strcspn(
$ihost,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen)
5923 if (
$ihost[$position] ===
'%')
5948 $this->port = (int)
$port;
5967 if (isset($cache[
$ipath]))
5969 $this->ipath = $cache[
$ipath][(int) ($this->scheme !== null)];
5975 $cache[
$ipath] = array($valid, $removed);
5976 $this->ipath = ($this->scheme !== null) ? $removed : $valid;
5986 $this->iquery = null;
6000 $this->ifragment = null;
6015 $non_ascii = implode(
'', range(
"\x80",
"\xFF"));
6018 $strlen = strlen($string);
6019 while (($position += strcspn($string, $non_ascii, $position)) < $strlen)
6021 $string = substr_replace($string, sprintf(
'%%%02X', ord($string[$position])), $position, 1);
6035 if ($this->scheme !== null)
6037 $iri .= $this->scheme .
':';
6041 $iri .=
'//' . $iauthority;
6043 if ($this->ipath !==
'')
6047 elseif (!empty($this->normalization[$this->scheme][
'ipath']) && $iauthority !== null && $iauthority !==
'')
6051 if ($this->iquery !== null)
6055 if ($this->ifragment !== null)
6069 if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null)
6072 if ($this->iuserinfo !== null)
6074 $iauthority .= $this->iuserinfo .
'@';
6076 if ($this->ihost !== null)
6080 if ($this->port !== null)
6095 if (is_string($iauthority))
6096 return $this->
to_uri($iauthority);
6112 $this->feed =
$feed;
6113 $this->data =
$data;
6123 return md5(serialize($this->data));
6128 if ((version_compare(PHP_VERSION,
'5.3',
'<') || !gc_enabled()) && !ini_get(
'zend.ze1_compatibility_mode'))
6136 if (isset($this->data[
'child'][$namespace][$tag]))
6138 return $this->data[
'child'][$namespace][$tag];
6148 return $this->feed->get_base($element);
6153 return $this->feed->sanitize($data, $type, $base);
6204 return md5(serialize($this->data));
6210 if (!isset($this->data[
'title']))
6214 $this->data[
'title'] = $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
6218 $this->data[
'title'] = $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
6242 $this->data[
'title'] = null;
6245 return $this->data[
'title'];
6252 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
6256 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
6286 elseif (!$description_only)
6300 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_content_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
6304 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
6323 if (isset($categories[$key]))
6325 return $categories[$key];
6335 $categories = array();
6341 if (isset($category[
'attribs'][
''][
'term']))
6345 if (isset($category[
'attribs'][
''][
'scheme']))
6349 if (isset($category[
'attribs'][
''][
'label']))
6353 $categories[] = $this->registry->create(
'Category', array($term, $scheme, $label));
6360 if (isset($category[
'attribs'][
''][
'domain']))
6368 $categories[] = $this->registry->create(
'Category', array($term, $scheme, null));
6378 if (!empty($categories))
6380 return array_unique($categories);
6391 if (isset($authors[$key]))
6393 return $authors[$key];
6404 if (isset($contributors[$key]))
6406 return $contributors[$key];
6416 $contributors = array();
6426 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'uri'][0][
'data']))
6428 $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]));
6430 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'email'][0][
'data']))
6434 if ($name !== null || $email !== null || $uri !== null)
6436 $contributors[] = $this->registry->create(
'Author', array($name, $uri, $email));
6448 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'url'][0][
'data']))
6452 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'email'][0][
'data']))
6456 if ($name !== null || $email !== null ||
$url !== null)
6458 $contributors[] = $this->registry->create(
'Author', array($name,
$url, $email));
6461 if (!empty($contributors))
6463 return array_unique($contributors);
6483 if (isset($author[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'uri'][0][
'data']))
6487 if (isset($author[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'email'][0][
'data']))
6491 if ($name !== null || $email !== null || $uri !== null)
6493 $authors[] = $this->registry->create(
'Author', array($name, $uri, $email));
6505 if (isset($author[0][
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'url'][0][
'data']))
6509 if (isset($author[0][
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'email'][0][
'data']))
6513 if ($name !== null || $email !== null ||
$url !== null)
6515 $authors[] = $this->registry->create(
'Author', array($name,
$url, $email));
6534 if (!empty($authors))
6536 return array_unique($authors);
6538 elseif (($source = $this->
get_source()) && ($authors = $source->get_authors()))
6542 elseif ($authors = $this->feed->get_authors())
6556 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
6572 public function get_date($date_format =
'j F Y, g:i a')
6574 if (!isset($this->data[
'date']))
6578 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6582 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6586 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6590 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6594 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6598 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6602 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6606 $this->data[
'date'][
'raw'] = $return[0][
'data'];
6608 if (!empty($this->data[
'date'][
'raw']))
6610 $parser = $this->registry->call(
'Parse_Date',
'get');
6611 $this->data[
'date'][
'parsed'] = $parser->parse($this->data[
'date'][
'raw']);
6615 $this->data[
'date'] = null;
6618 if ($this->data[
'date'])
6620 $date_format = (string) $date_format;
6621 switch ($date_format)
6626 return $this->data[
'date'][
'parsed'];
6628 return date($date_format, $this->data[
'date'][
'parsed']);
6639 if (!isset($this->data[
'updated']))
6643 $this->data[
'updated'][
'raw'] = $return[0][
'data'];
6645 if (!empty($this->data[
'updated'][
'raw']))
6647 $parser = $this->registry->call(
'Parse_Date',
'get');
6648 $this->data[
'updated'][
'parsed'] = $parser->parse($this->data[
'date'][
'raw']);
6652 $this->data[
'updated'] = null;
6655 if ($this->data[
'updated'])
6657 $date_format = (string) $date_format;
6658 switch ($date_format)
6663 return $this->data[
'updated'][
'parsed'];
6665 return date($date_format, $this->data[
'updated'][
'parsed']);
6680 elseif (($date = $this->
get_date(
'U')) !== null && $date !==
false)
6682 return strftime($date_format, $date);
6697 return gmdate($date_format, $date);
6707 return gmdate($date_format, $date);
6718 elseif ($enclosure !== null)
6720 return $enclosure->get_link();
6731 if ($links[$key] !== null)
6733 return $links[$key];
6743 if (!isset($this->data[
'links']))
6745 $this->data[
'links'] = array();
6748 if (isset($link[
'attribs'][
''][
'href']))
6750 $link_rel = (isset($link[
'attribs'][
''][
'rel'])) ? $link[
'attribs'][
''][
'rel'] :
'alternate';
6756 if (isset($link[
'attribs'][
''][
'href']))
6758 $link_rel = (isset($link[
'attribs'][
''][
'rel'])) ? $link[
'attribs'][
''][
'rel'] :
'alternate';
6776 if (!isset($links[0][
'attribs'][
''][
'isPermaLink']) || strtolower(trim($links[0][
'attribs'][
''][
'isPermaLink'])) ===
'true')
6781 $keys = array_keys($this->data[
'links']);
6782 foreach ($keys as $key)
6784 if ($this->registry->call(
'Misc',
'is_isegment_nz_nc', array($key)))
6798 $this->data[
'links'][substr($key, 41)] =& $this->data[
'links'][$key];
6800 $this->data[
'links'][$key] = array_unique($this->data[
'links'][$key]);
6803 if (isset($this->data[
'links'][$rel]))
6805 return $this->data[
'links'][$rel];
6816 if (isset($enclosures[$key]))
6818 return $enclosures[$key];
6828 if (!isset($this->data[
'enclosures']))
6830 $this->data[
'enclosures'] = array();
6832 $captions_parent = null;
6833 $categories_parent = null;
6834 $copyrights_parent = null;
6835 $credits_parent = null;
6836 $description_parent = null;
6837 $duration_parent = null;
6838 $hashes_parent = null;
6839 $keywords_parent = null;
6840 $player_parent = null;
6841 $ratings_parent = null;
6842 $restrictions_parent = null;
6843 $thumbnails_parent = null;
6844 $title_parent = null;
6850 foreach ($captions as $caption)
6852 $caption_type = null;
6853 $caption_lang = null;
6854 $caption_startTime = null;
6855 $caption_endTime = null;
6856 $caption_text = null;
6857 if (isset($caption[
'attribs'][
''][
'type']))
6861 if (isset($caption[
'attribs'][
''][
'lang']))
6865 if (isset($caption[
'attribs'][
''][
'start']))
6869 if (isset($caption[
'attribs'][
''][
'end']))
6873 if (isset($caption[
'data']))
6877 $captions_parent[] = $this->registry->create(
'Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
6882 foreach ($captions as $caption)
6884 $caption_type = null;
6885 $caption_lang = null;
6886 $caption_startTime = null;
6887 $caption_endTime = null;
6888 $caption_text = null;
6889 if (isset($caption[
'attribs'][
''][
'type']))
6893 if (isset($caption[
'attribs'][
''][
'lang']))
6897 if (isset($caption[
'attribs'][
''][
'start']))
6901 if (isset($caption[
'attribs'][
''][
'end']))
6905 if (isset($caption[
'data']))
6909 $captions_parent[] = $this->registry->create(
'Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
6912 if (is_array($captions_parent))
6914 $captions_parent = array_values(array_unique($captions_parent));
6922 if (isset($category[
'data']))
6926 if (isset($category[
'attribs'][
''][
'scheme']))
6932 $scheme =
'http://search.yahoo.com/mrss/category_schema';
6934 if (isset($category[
'attribs'][
''][
'label']))
6938 $categories_parent[] = $this->registry->create(
'Category', array($term, $scheme, $label));
6945 if (isset($category[
'data']))
6949 if (isset($category[
'attribs'][
''][
'scheme']))
6955 $scheme =
'http://search.yahoo.com/mrss/category_schema';
6957 if (isset($category[
'attribs'][
''][
'label']))
6961 $categories_parent[] = $this->registry->create(
'Category', array($term, $scheme, $label));
6966 $scheme =
'http://www.itunes.com/dtds/podcast-1.0.dtd';
6968 if (isset($category[
'attribs'][
''][
'text']))
6972 $categories_parent[] = $this->registry->create(
'Category', array($term, $scheme, $label));
6975 foreach ((array) $category[
'child'][SIMPLEPIE_NAMESPACE_ITUNES][
'category'] as $subcategory)
6977 if (isset($subcategory[
'attribs'][
''][
'text']))
6981 $categories_parent[] = $this->registry->create(
'Category', array($term, $scheme, $label));
6985 if (is_array($categories_parent))
6987 $categories_parent = array_values(array_unique($categories_parent));
6992 $copyright_url = null;
6993 $copyright_label = null;
6994 if (isset($copyright[0][
'attribs'][
''][
'url']))
6998 if (isset($copyright[0][
'data']))
7002 $copyrights_parent = $this->registry->create(
'Copyright', array($copyright_url, $copyright_label));
7006 $copyright_url = null;
7007 $copyright_label = null;
7008 if (isset($copyright[0][
'attribs'][
''][
'url']))
7012 if (isset($copyright[0][
'data']))
7016 $copyrights_parent = $this->registry->create(
'Copyright', array($copyright_url, $copyright_label));
7021 foreach ($credits as $credit)
7023 $credit_role = null;
7024 $credit_scheme = null;
7025 $credit_name = null;
7026 if (isset($credit[
'attribs'][
''][
'role']))
7030 if (isset($credit[
'attribs'][
''][
'scheme']))
7036 $credit_scheme =
'urn:ebu';
7038 if (isset($credit[
'data']))
7042 $credits_parent[] = $this->registry->create(
'Credit', array($credit_role, $credit_scheme, $credit_name));
7047 foreach ($credits as $credit)
7049 $credit_role = null;
7050 $credit_scheme = null;
7051 $credit_name = null;
7052 if (isset($credit[
'attribs'][
''][
'role']))
7056 if (isset($credit[
'attribs'][
''][
'scheme']))
7062 $credit_scheme =
'urn:ebu';
7064 if (isset($credit[
'data']))
7068 $credits_parent[] = $this->registry->create(
'Credit', array($credit_role, $credit_scheme, $credit_name));
7071 if (is_array($credits_parent))
7073 $credits_parent = array_values(array_unique($credits_parent));
7078 if (isset($description_parent[0][
'data']))
7085 if (isset($description_parent[0][
'data']))
7096 if (isset($duration_parent[0][
'data']))
7099 if (
sizeof($temp) > 0)
7101 $seconds = (int) array_pop($temp);
7103 if (
sizeof($temp) > 0)
7105 $minutes = (int) array_pop($temp);
7106 $seconds += $minutes * 60;
7108 if (
sizeof($temp) > 0)
7110 $hours = (int) array_pop($temp);
7111 $seconds += $hours * 3600;
7114 $duration_parent = $seconds;
7120 foreach ($hashes_iterator as $hash)
7124 if (isset($hash[
'data']))
7128 if (isset($hash[
'attribs'][
''][
'algo']))
7136 $hashes_parent[] = $algo.
':'.$value;
7141 foreach ($hashes_iterator as $hash)
7145 if (isset($hash[
'data']))
7149 if (isset($hash[
'attribs'][
''][
'algo']))
7157 $hashes_parent[] = $algo.
':'.$value;
7160 if (is_array($hashes_parent))
7162 $hashes_parent = array_values(array_unique($hashes_parent));
7167 if (isset($keywords[0][
'data']))
7170 foreach ($temp as $word)
7172 $keywords_parent[] = trim($word);
7179 if (isset($keywords[0][
'data']))
7182 foreach ($temp as $word)
7184 $keywords_parent[] = trim($word);
7191 if (isset($keywords[0][
'data']))
7194 foreach ($temp as $word)
7196 $keywords_parent[] = trim($word);
7203 if (isset($keywords[0][
'data']))
7206 foreach ($temp as $word)
7208 $keywords_parent[] = trim($word);
7213 if (is_array($keywords_parent))
7215 $keywords_parent = array_values(array_unique($keywords_parent));
7220 if (isset($player_parent[0][
'attribs'][
''][
'url']))
7227 if (isset($player_parent[0][
'attribs'][
''][
'url']))
7235 foreach ($ratings as $rating)
7237 $rating_scheme = null;
7238 $rating_value = null;
7239 if (isset($rating[
'attribs'][
''][
'scheme']))
7245 $rating_scheme =
'urn:simple';
7247 if (isset($rating[
'data']))
7251 $ratings_parent[] = $this->registry->create(
'Rating', array($rating_scheme, $rating_value));
7256 foreach ($ratings as $rating)
7258 $rating_scheme =
'urn:itunes';
7259 $rating_value = null;
7260 if (isset($rating[
'data']))
7264 $ratings_parent[] = $this->registry->create(
'Rating', array($rating_scheme, $rating_value));
7269 foreach ($ratings as $rating)
7271 $rating_scheme = null;
7272 $rating_value = null;
7273 if (isset($rating[
'attribs'][
''][
'scheme']))
7279 $rating_scheme =
'urn:simple';
7281 if (isset($rating[
'data']))
7285 $ratings_parent[] = $this->registry->create(
'Rating', array($rating_scheme, $rating_value));
7290 foreach ($ratings as $rating)
7292 $rating_scheme =
'urn:itunes';
7293 $rating_value = null;
7294 if (isset($rating[
'data']))
7298 $ratings_parent[] = $this->registry->create(
'Rating', array($rating_scheme, $rating_value));
7301 if (is_array($ratings_parent))
7303 $ratings_parent = array_values(array_unique($ratings_parent));
7308 foreach ($restrictions as $restriction)
7310 $restriction_relationship = null;
7311 $restriction_type = null;
7312 $restriction_value = null;
7313 if (isset($restriction[
'attribs'][
''][
'relationship']))
7317 if (isset($restriction[
'attribs'][
''][
'type']))
7321 if (isset($restriction[
'data']))
7325 $restrictions_parent[] = $this->registry->create(
'Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
7330 foreach ($restrictions as $restriction)
7332 $restriction_relationship =
'allow';
7333 $restriction_type = null;
7334 $restriction_value =
'itunes';
7335 if (isset($restriction[
'data']) && strtolower($restriction[
'data']) ===
'yes')
7337 $restriction_relationship =
'deny';
7339 $restrictions_parent[] = $this->registry->create(
'Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
7344 foreach ($restrictions as $restriction)
7346 $restriction_relationship = null;
7347 $restriction_type = null;
7348 $restriction_value = null;
7349 if (isset($restriction[
'attribs'][
''][
'relationship']))
7353 if (isset($restriction[
'attribs'][
''][
'type']))
7357 if (isset($restriction[
'data']))
7361 $restrictions_parent[] = $this->registry->create(
'Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
7366 foreach ($restrictions as $restriction)
7368 $restriction_relationship =
'allow';
7369 $restriction_type = null;
7370 $restriction_value =
'itunes';
7371 if (isset($restriction[
'data']) && strtolower($restriction[
'data']) ===
'yes')
7373 $restriction_relationship =
'deny';
7375 $restrictions_parent[] = $this->registry->create(
'Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
7378 if (is_array($restrictions_parent))
7380 $restrictions_parent = array_values(array_unique($restrictions_parent));
7389 foreach ($thumbnails as $thumbnail)
7391 if (isset($thumbnail[
'attribs'][
''][
'url']))
7399 foreach ($thumbnails as $thumbnail)
7401 if (isset($thumbnail[
'attribs'][
''][
'url']))
7410 if (isset($title_parent[0][
'data']))
7417 if (isset($title_parent[0][
'data']))
7435 $samplingrate = null;
7444 $description = null;
7449 $restrictions = null;
7458 foreach ((array) $group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'content'] as $content)
7460 if (isset($content[
'attribs'][
''][
'url']))
7473 $samplingrate = null;
7482 $description = null;
7487 $restrictions = null;
7491 if (isset($content[
'attribs'][
''][
'bitrate']))
7495 if (isset($content[
'attribs'][
''][
'channels']))
7499 if (isset($content[
'attribs'][
''][
'duration']))
7505 $duration = $duration_parent;
7507 if (isset($content[
'attribs'][
''][
'expression']))
7511 if (isset($content[
'attribs'][
''][
'framerate']))
7515 if (isset($content[
'attribs'][
''][
'height']))
7519 if (isset($content[
'attribs'][
''][
'lang']))
7523 if (isset($content[
'attribs'][
''][
'fileSize']))
7525 $length = ceil($content[
'attribs'][
''][
'fileSize']);
7527 if (isset($content[
'attribs'][
''][
'medium']))
7531 if (isset($content[
'attribs'][
''][
'samplingrate']))
7535 if (isset($content[
'attribs'][
''][
'type']))
7539 if (isset($content[
'attribs'][
''][
'width']))
7546 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'text']))
7548 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'text'] as $caption)
7550 $caption_type = null;
7551 $caption_lang = null;
7552 $caption_startTime = null;
7553 $caption_endTime = null;
7554 $caption_text = null;
7555 if (isset($caption[
'attribs'][
''][
'type']))
7559 if (isset($caption[
'attribs'][
''][
'lang']))
7563 if (isset($caption[
'attribs'][
''][
'start']))
7567 if (isset($caption[
'attribs'][
''][
'end']))
7571 if (isset($caption[
'data']))
7575 $captions[] = $this->registry->create(
'Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
7577 if (is_array($captions))
7579 $captions = array_values(array_unique($captions));
7582 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'text']))
7584 foreach ($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'text'] as $caption)
7586 $caption_type = null;
7587 $caption_lang = null;
7588 $caption_startTime = null;
7589 $caption_endTime = null;
7590 $caption_text = null;
7591 if (isset($caption[
'attribs'][
''][
'type']))
7595 if (isset($caption[
'attribs'][
''][
'lang']))
7599 if (isset($caption[
'attribs'][
''][
'start']))
7603 if (isset($caption[
'attribs'][
''][
'end']))
7607 if (isset($caption[
'data']))
7611 $captions[] = $this->registry->create(
'Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
7613 if (is_array($captions))
7615 $captions = array_values(array_unique($captions));
7620 $captions = $captions_parent;
7623 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'category']))
7625 foreach ((array) $content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'category'] as $category)
7630 if (isset($category[
'data']))
7634 if (isset($category[
'attribs'][
''][
'scheme']))
7640 $scheme =
'http://search.yahoo.com/mrss/category_schema';
7642 if (isset($category[
'attribs'][
''][
'label']))
7646 $categories[] = $this->registry->create(
'Category', array($term, $scheme, $label));
7649 if (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'category']))
7651 foreach ((array) $group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'category'] as $category)
7656 if (isset($category[
'data']))
7660 if (isset($category[
'attribs'][
''][
'scheme']))
7666 $scheme =
'http://search.yahoo.com/mrss/category_schema';
7668 if (isset($category[
'attribs'][
''][
'label']))
7672 $categories[] = $this->registry->create(
'Category', array($term, $scheme, $label));
7675 if (is_array($categories) && is_array($categories_parent))
7677 $categories = array_values(array_unique(array_merge($categories, $categories_parent)));
7679 elseif (is_array($categories))
7681 $categories = array_values(array_unique($categories));
7683 elseif (is_array($categories_parent))
7685 $categories = array_values(array_unique($categories_parent));
7688 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright']))
7690 $copyright_url = null;
7691 $copyright_label = null;
7692 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright'][0][
'attribs'][
''][
'url']))
7696 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright'][0][
'data']))
7700 $copyrights = $this->registry->create(
'Copyright', array($copyright_url, $copyright_label));
7702 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright']))
7704 $copyright_url = null;
7705 $copyright_label = null;
7706 if (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright'][0][
'attribs'][
''][
'url']))
7710 if (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright'][0][
'data']))
7714 $copyrights = $this->registry->create(
'Copyright', array($copyright_url, $copyright_label));
7718 $copyrights = $copyrights_parent;
7721 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'credit']))
7723 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'credit'] as $credit)
7725 $credit_role = null;
7726 $credit_scheme = null;
7727 $credit_name = null;
7728 if (isset($credit[
'attribs'][
''][
'role']))
7732 if (isset($credit[
'attribs'][
''][
'scheme']))
7738 $credit_scheme =
'urn:ebu';
7740 if (isset($credit[
'data']))
7744 $credits[] = $this->registry->create(
'Credit', array($credit_role, $credit_scheme, $credit_name));
7746 if (is_array($credits))
7748 $credits = array_values(array_unique($credits));
7751 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'credit']))
7753 foreach ($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'credit'] as $credit)
7755 $credit_role = null;
7756 $credit_scheme = null;
7757 $credit_name = null;
7758 if (isset($credit[
'attribs'][
''][
'role']))
7762 if (isset($credit[
'attribs'][
''][
'scheme']))
7768 $credit_scheme =
'urn:ebu';
7770 if (isset($credit[
'data']))
7774 $credits[] = $this->registry->create(
'Credit', array($credit_role, $credit_scheme, $credit_name));
7776 if (is_array($credits))
7778 $credits = array_values(array_unique($credits));
7783 $credits = $credits_parent;
7786 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'description']))
7790 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'description']))
7796 $description = $description_parent;
7799 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'hash']))
7801 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'hash'] as $hash)
7805 if (isset($hash[
'data']))
7809 if (isset($hash[
'attribs'][
''][
'algo']))
7817 $hashes[] = $algo.
':'.$value;
7819 if (is_array($hashes))
7821 $hashes = array_values(array_unique($hashes));
7824 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'hash']))
7826 foreach ($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'hash'] as $hash)
7830 if (isset($hash[
'data']))
7834 if (isset($hash[
'attribs'][
''][
'algo']))
7842 $hashes[] = $algo.
':'.$value;
7844 if (is_array($hashes))
7846 $hashes = array_values(array_unique($hashes));
7851 $hashes = $hashes_parent;
7854 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'keywords']))
7856 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'keywords'][0][
'data']))
7859 foreach ($temp as $word)
7861 $keywords[] = trim($word);
7865 if (is_array($keywords))
7867 $keywords = array_values(array_unique($keywords));
7870 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'keywords']))
7872 if (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'keywords'][0][
'data']))
7875 foreach ($temp as $word)
7877 $keywords[] = trim($word);
7881 if (is_array($keywords))
7883 $keywords = array_values(array_unique($keywords));
7888 $keywords = $keywords_parent;
7891 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'player']))
7895 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'player']))
7901 $player = $player_parent;
7904 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'rating']))
7906 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'rating'] as $rating)
7908 $rating_scheme = null;
7909 $rating_value = null;
7910 if (isset($rating[
'attribs'][
''][
'scheme']))
7916 $rating_scheme =
'urn:simple';
7918 if (isset($rating[
'data']))
7922 $ratings[] = $this->registry->create(
'Rating', array($rating_scheme, $rating_value));
7924 if (is_array($ratings))
7926 $ratings = array_values(array_unique($ratings));
7929 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'rating']))
7931 foreach ($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'rating'] as $rating)
7933 $rating_scheme = null;
7934 $rating_value = null;
7935 if (isset($rating[
'attribs'][
''][
'scheme']))
7941 $rating_scheme =
'urn:simple';
7943 if (isset($rating[
'data']))
7947 $ratings[] = $this->registry->create(
'Rating', array($rating_scheme, $rating_value));
7949 if (is_array($ratings))
7951 $ratings = array_values(array_unique($ratings));
7956 $ratings = $ratings_parent;
7959 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'restriction']))
7961 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'restriction'] as $restriction)
7963 $restriction_relationship = null;
7964 $restriction_type = null;
7965 $restriction_value = null;
7966 if (isset($restriction[
'attribs'][
''][
'relationship']))
7970 if (isset($restriction[
'attribs'][
''][
'type']))
7974 if (isset($restriction[
'data']))
7978 $restrictions[] = $this->registry->create(
'Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
7980 if (is_array($restrictions))
7982 $restrictions = array_values(array_unique($restrictions));
7985 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'restriction']))
7987 foreach ($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'restriction'] as $restriction)
7989 $restriction_relationship = null;
7990 $restriction_type = null;
7991 $restriction_value = null;
7992 if (isset($restriction[
'attribs'][
''][
'relationship']))
7996 if (isset($restriction[
'attribs'][
''][
'type']))
8000 if (isset($restriction[
'data']))
8004 $restrictions[] = $this->registry->create(
'Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
8006 if (is_array($restrictions))
8008 $restrictions = array_values(array_unique($restrictions));
8013 $restrictions = $restrictions_parent;
8016 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'thumbnail']))
8018 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'thumbnail'] as $thumbnail)
8022 if (is_array($thumbnails))
8024 $thumbnails = array_values(array_unique($thumbnails));
8027 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'thumbnail']))
8029 foreach ($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'thumbnail'] as $thumbnail)
8033 if (is_array($thumbnails))
8035 $thumbnails = array_values(array_unique($thumbnails));
8040 $thumbnails = $thumbnails_parent;
8043 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'title']))
8047 elseif (isset($group[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'title']))
8053 $title = $title_parent;
8055 $this->data[
'enclosures'][] = $this->registry->create(
'Enclosure', array(
$url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords,
$lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width));
8063 foreach ((array) $this->data[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'content'] as $content)
8065 if (isset($content[
'attribs'][
''][
'url']) || isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'player']))
8078 $samplingrate = null;
8087 $description = null;
8092 $restrictions = null;
8096 if (isset($content[
'attribs'][
''][
'bitrate']))
8100 if (isset($content[
'attribs'][
''][
'channels']))
8104 if (isset($content[
'attribs'][
''][
'duration']))
8110 $duration = $duration_parent;
8112 if (isset($content[
'attribs'][
''][
'expression']))
8116 if (isset($content[
'attribs'][
''][
'framerate']))
8120 if (isset($content[
'attribs'][
''][
'height']))
8124 if (isset($content[
'attribs'][
''][
'lang']))
8128 if (isset($content[
'attribs'][
''][
'fileSize']))
8130 $length = ceil($content[
'attribs'][
''][
'fileSize']);
8132 if (isset($content[
'attribs'][
''][
'medium']))
8136 if (isset($content[
'attribs'][
''][
'samplingrate']))
8140 if (isset($content[
'attribs'][
''][
'type']))
8144 if (isset($content[
'attribs'][
''][
'width']))
8148 if (isset($content[
'attribs'][
''][
'url']))
8154 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'text']))
8156 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'text'] as $caption)
8158 $caption_type = null;
8159 $caption_lang = null;
8160 $caption_startTime = null;
8161 $caption_endTime = null;
8162 $caption_text = null;
8163 if (isset($caption[
'attribs'][
''][
'type']))
8167 if (isset($caption[
'attribs'][
''][
'lang']))
8171 if (isset($caption[
'attribs'][
''][
'start']))
8175 if (isset($caption[
'attribs'][
''][
'end']))
8179 if (isset($caption[
'data']))
8183 $captions[] = $this->registry->create(
'Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
8185 if (is_array($captions))
8187 $captions = array_values(array_unique($captions));
8192 $captions = $captions_parent;
8195 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'category']))
8197 foreach ((array) $content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'category'] as $category)
8202 if (isset($category[
'data']))
8206 if (isset($category[
'attribs'][
''][
'scheme']))
8212 $scheme =
'http://search.yahoo.com/mrss/category_schema';
8214 if (isset($category[
'attribs'][
''][
'label']))
8218 $categories[] = $this->registry->create(
'Category', array($term, $scheme, $label));
8221 if (is_array($categories) && is_array($categories_parent))
8223 $categories = array_values(array_unique(array_merge($categories, $categories_parent)));
8225 elseif (is_array($categories))
8227 $categories = array_values(array_unique($categories));
8229 elseif (is_array($categories_parent))
8231 $categories = array_values(array_unique($categories_parent));
8238 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright']))
8240 $copyright_url = null;
8241 $copyright_label = null;
8242 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright'][0][
'attribs'][
''][
'url']))
8246 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'copyright'][0][
'data']))
8250 $copyrights = $this->registry->create(
'Copyright', array($copyright_url, $copyright_label));
8254 $copyrights = $copyrights_parent;
8257 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'credit']))
8259 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'credit'] as $credit)
8261 $credit_role = null;
8262 $credit_scheme = null;
8263 $credit_name = null;
8264 if (isset($credit[
'attribs'][
''][
'role']))
8268 if (isset($credit[
'attribs'][
''][
'scheme']))
8274 $credit_scheme =
'urn:ebu';
8276 if (isset($credit[
'data']))
8280 $credits[] = $this->registry->create(
'Credit', array($credit_role, $credit_scheme, $credit_name));
8282 if (is_array($credits))
8284 $credits = array_values(array_unique($credits));
8289 $credits = $credits_parent;
8292 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'description']))
8298 $description = $description_parent;
8301 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'hash']))
8303 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'hash'] as $hash)
8307 if (isset($hash[
'data']))
8311 if (isset($hash[
'attribs'][
''][
'algo']))
8319 $hashes[] = $algo.
':'.$value;
8321 if (is_array($hashes))
8323 $hashes = array_values(array_unique($hashes));
8328 $hashes = $hashes_parent;
8331 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'keywords']))
8333 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'keywords'][0][
'data']))
8336 foreach ($temp as $word)
8338 $keywords[] = trim($word);
8342 if (is_array($keywords))
8344 $keywords = array_values(array_unique($keywords));
8349 $keywords = $keywords_parent;
8352 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'player']))
8358 $player = $player_parent;
8361 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'rating']))
8363 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'rating'] as $rating)
8365 $rating_scheme = null;
8366 $rating_value = null;
8367 if (isset($rating[
'attribs'][
''][
'scheme']))
8373 $rating_scheme =
'urn:simple';
8375 if (isset($rating[
'data']))
8379 $ratings[] = $this->registry->create(
'Rating', array($rating_scheme, $rating_value));
8381 if (is_array($ratings))
8383 $ratings = array_values(array_unique($ratings));
8388 $ratings = $ratings_parent;
8391 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'restriction']))
8393 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'restriction'] as $restriction)
8395 $restriction_relationship = null;
8396 $restriction_type = null;
8397 $restriction_value = null;
8398 if (isset($restriction[
'attribs'][
''][
'relationship']))
8402 if (isset($restriction[
'attribs'][
''][
'type']))
8406 if (isset($restriction[
'data']))
8410 $restrictions[] = $this->registry->create(
'Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
8412 if (is_array($restrictions))
8414 $restrictions = array_values(array_unique($restrictions));
8419 $restrictions = $restrictions_parent;
8422 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'thumbnail']))
8424 foreach ($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'thumbnail'] as $thumbnail)
8428 if (is_array($thumbnails))
8430 $thumbnails = array_values(array_unique($thumbnails));
8435 $thumbnails = $thumbnails_parent;
8438 if (isset($content[
'child'][SIMPLEPIE_NAMESPACE_MEDIARSS][
'title']))
8444 $title = $title_parent;
8446 $this->data[
'enclosures'][] = $this->registry->create(
'Enclosure', array(
$url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords,
$lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width));
8452 if (isset($link[
'attribs'][
''][
'href']) && !empty($link[
'attribs'][
''][
'rel']) && $link[
'attribs'][
''][
'rel'] ===
'enclosure')
8465 $samplingrate = null;
8470 if (isset($link[
'attribs'][
''][
'type']))
8474 if (isset($link[
'attribs'][
''][
'length']))
8476 $length = ceil($link[
'attribs'][
''][
'length']);
8479 $this->data[
'enclosures'][] = $this->registry->create(
'Enclosure', array(
$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent,
$lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
8484 if (isset($link[
'attribs'][
''][
'href']) && !empty($link[
'attribs'][
''][
'rel']) && $link[
'attribs'][
''][
'rel'] ===
'enclosure')
8497 $samplingrate = null;
8502 if (isset($link[
'attribs'][
''][
'type']))
8506 if (isset($link[
'attribs'][
''][
'length']))
8508 $length = ceil($link[
'attribs'][
''][
'length']);
8511 $this->data[
'enclosures'][] = $this->registry->create(
'Enclosure', array(
$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent,
$lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
8516 if (isset($enclosure[0][
'attribs'][
''][
'url']))
8529 $samplingrate = null;
8534 if (isset($enclosure[0][
'attribs'][
''][
'type']))
8538 if (isset($enclosure[0][
'attribs'][
''][
'length']))
8540 $length = ceil($enclosure[0][
'attribs'][
''][
'length']);
8543 $this->data[
'enclosures'][] = $this->registry->create(
'Enclosure', array(
$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent,
$lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
8546 if (
sizeof($this->data[
'enclosures']) === 0 && (
$url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent ||
$lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
8549 $this->data[
'enclosures'][] = $this->registry->create(
'Enclosure', array(
$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent,
$lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
8551 $this->data[
'enclosures'] = array_values(array_unique($this->data[
'enclosures']));
8553 if (!empty($this->data[
'enclosures']))
8555 return $this->data[
'enclosures'];
8567 return (
float) $return[0][
'data'];
8571 return (
float)
$match[1];
8583 return (
float) $return[0][
'data'];
8587 return (
float) $return[0][
'data'];
8591 return (
float)
$match[2];
8603 return $this->registry->create(
'Source', array($this, $return[0]));
8627 $this->file =
$file;
8631 if (class_exists(
'DOMDocument'))
8633 $this->dom =
new DOMDocument();
8634 set_error_handler(array(
'SimplePie_Misc',
'silence_errors'));
8635 $this->dom->loadHTML($this->file->body);
8636 restore_error_handler();
8649 if ($this->
is_feed($this->file))
8655 $sniffer = $this->registry->create(
'Content_Type_Sniffer', array($this->file));
8656 if ($sniffer->get_type() !==
'text/html')
8694 $sniffer = $this->registry->create(
'Content_Type_Sniffer', array($file));
8695 $sniffed = $sniffer->get_type();
8696 if (in_array($sniffed, array(
'application/rss+xml',
'application/rdf+xml',
'text/rdf',
'application/atom+xml',
'text/xml',
'application/xml')))
8716 if ($this->dom === null)
8720 $this->http_base = $this->file->url;
8722 $elements = $this->dom->getElementsByTagName(
'base');
8723 foreach ($elements as $element)
8725 if ($element->hasAttribute(
'href'))
8727 $base = $this->registry->call(
'Misc',
'absolutize_url', array(trim($element->getAttribute(
'href')), $this->http_base));
8728 if ($base ===
false)
8732 $this->base =
$base;
8733 $this->base_location = method_exists($element,
'getLineNo') ? $element->getLineNo() : 0;
8747 return array_values($feeds);
8756 if ($this->dom === null)
8760 $links = $this->dom->getElementsByTagName($name);
8761 foreach ($links as $link)
8763 if ($this->checked_feeds === $this->max_checked_feeds)
8767 if ($link->hasAttribute(
'href') && $link->hasAttribute(
'rel'))
8769 $rel = array_unique($this->registry->call(
'Misc',
'space_seperated_tokens', array(strtolower($link->getAttribute(
'rel')))));
8770 $line = method_exists($link,
'getLineNo') ? $link->getLineNo() : 1;
8771 if ($this->base_location < $line)
8773 $href = $this->registry->call(
'Misc',
'absolutize_url', array(trim($link->getAttribute(
'href')), $this->base));
8777 $href = $this->registry->call(
'Misc',
'absolutize_url', array(trim($link->getAttribute(
'href')), $this->http_base));
8779 if ($href ===
false)
8783 if (!in_array($href, $done) && in_array(
'feed', $rel) || (in_array(
'alternate', $rel) && !in_array(
'stylesheet', $rel) && $link->hasAttribute(
'type') && in_array(strtolower($this->registry->call(
'Misc',
'parse_mime', array($link->getAttribute(
'type')))), array(
'application/rss+xml',
'application/atom+xml'))) && !isset($feeds[$href]))
8785 $this->checked_feeds++;
8787 'Accept' =>
'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
8789 $feed = $this->registry->create(
'File', array($href, $this->timeout, 5, $headers, $this->useragent));
8790 if ($feed->success && ($feed->method &
SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
8792 $feeds[$href] = $feed;
8802 if ($this->dom === null)
8806 $links = $this->dom->getElementsByTagName(
'a');
8807 foreach ($links as $link)
8809 if ($link->hasAttribute(
'href'))
8811 $href = trim($link->getAttribute(
'href'));
8812 $parsed = $this->registry->call(
'Misc',
'parse_url', array($href));
8813 if ($parsed[
'scheme'] ===
'' || preg_match(
'/^(http(s)|feed)?$/i', $parsed[
'scheme']))
8815 if ($this->base_location < $link->getLineNo())
8817 $href = $this->registry->call(
'Misc',
'absolutize_url', array(trim($link->getAttribute(
'href')), $this->base));
8821 $href = $this->registry->call(
'Misc',
'absolutize_url', array(trim($link->getAttribute(
'href')), $this->http_base));
8823 if ($href ===
false)
8827 $current = $this->registry->call(
'Misc',
'parse_url', array($this->file->url));
8828 if ($parsed[
'authority'] ===
'' || $parsed[
'authority'] === $current[
'authority'])
8830 $this->local[] = $href;
8834 $this->elsewhere[] = $href;
8839 $this->local = array_unique($this->local);
8840 $this->elsewhere = array_unique($this->elsewhere);
8841 if (!empty($this->local) || !empty($this->elsewhere))
8849 foreach ($array as $key => $value)
8851 if ($this->checked_feeds === $this->max_checked_feeds)
8855 if (in_array(strtolower(strrchr($value,
'.')), array(
'.rss',
'.rdf',
'.atom',
'.xml')))
8857 $this->checked_feeds++;
8859 'Accept' =>
'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
8861 $feed = $this->registry->create(
'File', array($value, $this->timeout, 5, $headers, $this->useragent));
8862 if ($feed->success && ($feed->method &
SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
8868 unset($array[$key]);
8876 foreach ($array as $key => $value)
8878 if ($this->checked_feeds === $this->max_checked_feeds)
8882 if (preg_match(
'/(rss|rdf|atom|xml)/i', $value))
8884 $this->checked_feeds++;
8886 'Accept' =>
'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
8888 $feed = $this->registry->create(
'File', array($value, $this->timeout, 5, null, $this->useragent));
8889 if ($feed->success && ($feed->method &
SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
8895 unset($array[$key]);
8907 $hours = floor($seconds / 3600);
8908 $remainder = $seconds % 3600;
8911 $time .= $hours.
':';
8913 $minutes = floor($remainder / 60);
8914 $seconds = $remainder % 60;
8915 if ($minutes < 10 && $hours > 0)
8917 $minutes =
'0' . $minutes;
8921 $seconds =
'0' . $seconds;
8923 $time .= $minutes.
':';
8934 return $iri->get_uri();
8940 $name = preg_quote($realname,
'/');
8941 if (preg_match_all(
"/<($name)" .
SIMPLEPIE_PCRE_HTML_ATTRIBUTE .
"(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
8943 for (
$i = 0, $total_matches = count($matches);
$i < $total_matches;
$i++)
8945 $return[
$i][
'tag'] = $realname;
8946 $return[
$i][
'full'] = $matches[
$i][0][0];
8947 $return[
$i][
'offset'] = $matches[
$i][0][1];
8948 if (strlen($matches[
$i][3][0]) <= 2)
8950 $return[
$i][
'self_closing'] =
true;
8954 $return[
$i][
'self_closing'] =
false;
8955 $return[
$i][
'content'] = $matches[
$i][4][0];
8957 $return[
$i][
'attribs'] = array();
8958 if (isset($matches[$i][2][0]) && preg_match_all(
'/[\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]*)?))?/',
' ' . $matches[$i][2][0] .
' ', $attribs, PREG_SET_ORDER))
8960 for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
8962 if (count($attribs[$j]) === 2)
8964 $attribs[$j][2] = $attribs[$j][1];
8975 $full =
"<$element[tag]";
8976 foreach ($element[
'attribs'] as $key => $value)
8978 $key = strtolower($key);
8979 $full .=
" $key=\"" . htmlspecialchars($value[
'data']) .
'"';
8981 if ($element[
'self_closing'])
8987 $full .=
">$element[content]</$element[tag]>";
8991 public static function error($message, $level, $file, $line)
8993 if ((ini_get(
'error_reporting') & $level) > 0)
8998 $note =
'PHP Error';
9000 case E_USER_WARNING:
9001 $note =
'PHP Warning';
9004 $note =
'PHP Notice';
9007 $note =
'Unknown Error';
9011 if (!function_exists(
'error_log'))
9015 $log_file = @ini_get(
'error_log');
9016 if (!empty($log_file) && (
'syslog' !== $log_file) && !@is_writable($log_file))
9022 @error_log(
"$note: $message in $file on line $line", 0);
9031 if ($parsed[
'scheme'] !==
'' && $parsed[
'scheme'] !==
'http' && $parsed[
'scheme'] !==
'https')
9035 if ($parsed[
'scheme'] ===
'' && $parsed[
'authority'] ===
'' && !file_exists(
$url))
9039 if ($http === 2 && $parsed[
'scheme'] !==
'')
9043 elseif ($http === 3 && strtolower($parsed[
'scheme']) ===
'http')
9045 return substr_replace(
$url,
'podcast', 0, 4);
9047 elseif ($http === 4 && strtolower($parsed[
'scheme']) ===
'http')
9049 return substr_replace(
$url,
'itpc', 0, 4);
9060 'scheme' => (
string) $iri->scheme,
9061 'authority' => (
string) $iri->authority,
9062 'path' => (
string) $iri->path,
9063 'query' => (
string) $iri->query,
9064 'fragment' => (
string) $iri->fragment
9070 $iri->scheme = $scheme;
9071 $iri->authority = $authority;
9074 $iri->fragment = $fragment;
9075 return $iri->get_uri();
9080 return $iri->get_uri();
9084 $integer = hexdec(
$match[1]);
9085 if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
9087 return chr($integer);
9091 return strtoupper(
$match[0]);
9097 static $convert_table = array(
"\x80" =>
"\xE2\x82\xAC",
"\x81" =>
"\xEF\xBF\xBD",
"\x82" =>
"\xE2\x80\x9A",
"\x83" =>
"\xC6\x92",
"\x84" =>
"\xE2\x80\x9E",
"\x85" =>
"\xE2\x80\xA6",
"\x86" =>
"\xE2\x80\xA0",
"\x87" =>
"\xE2\x80\xA1",
"\x88" =>
"\xCB\x86",
"\x89" =>
"\xE2\x80\xB0",
"\x8A" =>
"\xC5\xA0",
"\x8B" =>
"\xE2\x80\xB9",
"\x8C" =>
"\xC5\x92",
"\x8D" =>
"\xEF\xBF\xBD",
"\x8E" =>
"\xC5\xBD",
"\x8F" =>
"\xEF\xBF\xBD",
"\x90" =>
"\xEF\xBF\xBD",
"\x91" =>
"\xE2\x80\x98",
"\x92" =>
"\xE2\x80\x99",
"\x93" =>
"\xE2\x80\x9C",
"\x94" =>
"\xE2\x80\x9D",
"\x95" =>
"\xE2\x80\xA2",
"\x96" =>
"\xE2\x80\x93",
"\x97" =>
"\xE2\x80\x94",
"\x98" =>
"\xCB\x9C",
"\x99" =>
"\xE2\x84\xA2",
"\x9A" =>
"\xC5\xA1",
"\x9B" =>
"\xE2\x80\xBA",
"\x9C" =>
"\xC5\x93",
"\x9D" =>
"\xEF\xBF\xBD",
"\x9E" =>
"\xC5\xBE",
"\x9F" =>
"\xC5\xB8",
"\xA0" =>
"\xC2\xA0",
"\xA1" =>
"\xC2\xA1",
"\xA2" =>
"\xC2\xA2",
"\xA3" =>
"\xC2\xA3",
"\xA4" =>
"\xC2\xA4",
"\xA5" =>
"\xC2\xA5",
"\xA6" =>
"\xC2\xA6",
"\xA7" =>
"\xC2\xA7",
"\xA8" =>
"\xC2\xA8",
"\xA9" =>
"\xC2\xA9",
"\xAA" =>
"\xC2\xAA",
"\xAB" =>
"\xC2\xAB",
"\xAC" =>
"\xC2\xAC",
"\xAD" =>
"\xC2\xAD",
"\xAE" =>
"\xC2\xAE",
"\xAF" =>
"\xC2\xAF",
"\xB0" =>
"\xC2\xB0",
"\xB1" =>
"\xC2\xB1",
"\xB2" =>
"\xC2\xB2",
"\xB3" =>
"\xC2\xB3",
"\xB4" =>
"\xC2\xB4",
"\xB5" =>
"\xC2\xB5",
"\xB6" =>
"\xC2\xB6",
"\xB7" =>
"\xC2\xB7",
"\xB8" =>
"\xC2\xB8",
"\xB9" =>
"\xC2\xB9",
"\xBA" =>
"\xC2\xBA",
"\xBB" =>
"\xC2\xBB",
"\xBC" =>
"\xC2\xBC",
"\xBD" =>
"\xC2\xBD",
"\xBE" =>
"\xC2\xBE",
"\xBF" =>
"\xC2\xBF",
"\xC0" =>
"\xC3\x80",
"\xC1" =>
"\xC3\x81",
"\xC2" =>
"\xC3\x82",
"\xC3" =>
"\xC3\x83",
"\xC4" =>
"\xC3\x84",
"\xC5" =>
"\xC3\x85",
"\xC6" =>
"\xC3\x86",
"\xC7" =>
"\xC3\x87",
"\xC8" =>
"\xC3\x88",
"\xC9" =>
"\xC3\x89",
"\xCA" =>
"\xC3\x8A",
"\xCB" =>
"\xC3\x8B",
"\xCC" =>
"\xC3\x8C",
"\xCD" =>
"\xC3\x8D",
"\xCE" =>
"\xC3\x8E",
"\xCF" =>
"\xC3\x8F",
"\xD0" =>
"\xC3\x90",
"\xD1" =>
"\xC3\x91",
"\xD2" =>
"\xC3\x92",
"\xD3" =>
"\xC3\x93",
"\xD4" =>
"\xC3\x94",
"\xD5" =>
"\xC3\x95",
"\xD6" =>
"\xC3\x96",
"\xD7" =>
"\xC3\x97",
"\xD8" =>
"\xC3\x98",
"\xD9" =>
"\xC3\x99",
"\xDA" =>
"\xC3\x9A",
"\xDB" =>
"\xC3\x9B",
"\xDC" =>
"\xC3\x9C",
"\xDD" =>
"\xC3\x9D",
"\xDE" =>
"\xC3\x9E",
"\xDF" =>
"\xC3\x9F",
"\xE0" =>
"\xC3\xA0",
"\xE1" =>
"\xC3\xA1",
"\xE2" =>
"\xC3\xA2",
"\xE3" =>
"\xC3\xA3",
"\xE4" =>
"\xC3\xA4",
"\xE5" =>
"\xC3\xA5",
"\xE6" =>
"\xC3\xA6",
"\xE7" =>
"\xC3\xA7",
"\xE8" =>
"\xC3\xA8",
"\xE9" =>
"\xC3\xA9",
"\xEA" =>
"\xC3\xAA",
"\xEB" =>
"\xC3\xAB",
"\xEC" =>
"\xC3\xAC",
"\xED" =>
"\xC3\xAD",
"\xEE" =>
"\xC3\xAE",
"\xEF" =>
"\xC3\xAF",
"\xF0" =>
"\xC3\xB0",
"\xF1" =>
"\xC3\xB1",
"\xF2" =>
"\xC3\xB2",
"\xF3" =>
"\xC3\xB3",
"\xF4" =>
"\xC3\xB4",
"\xF5" =>
"\xC3\xB5",
"\xF6" =>
"\xC3\xB6",
"\xF7" =>
"\xC3\xB7",
"\xF8" =>
"\xC3\xB8",
"\xF9" =>
"\xC3\xB9",
"\xFA" =>
"\xC3\xBA",
"\xFB" =>
"\xC3\xBB",
"\xFC" =>
"\xC3\xBC",
"\xFD" =>
"\xC3\xBD",
"\xFE" =>
"\xC3\xBE",
"\xFF" =>
"\xC3\xBF");
9098 return strtr($string, $convert_table);
9106 if ($input ===
'US-ASCII')
9108 static $non_ascii_octects =
'';
9109 if (!$non_ascii_octects)
9111 for (
$i = 0x80;
$i <= 0xFF;
$i++)
9113 $non_ascii_octects .= chr(
$i);
9116 $data = substr($data, 0, strcspn($data, $non_ascii_octects));
9119 if ($input ===
'windows-1252' &&
$output ===
'UTF-8')
9141 if ($input ===
'windows-949')
9145 if (
$output ===
'windows-949')
9149 if ($input ===
'Windows-31J')
9153 if (
$output ===
'Windows-31J')
9158 if (@mb_convert_encoding(
"\x80",
'UTF-16BE', $input) ===
"\x00\x80")
9162 if (!in_array($input, mb_list_encodings()))
9167 if ($return = @mb_convert_encoding($data,
$output, $input))
9175 return @iconv($input,
$output, $data);
9181 switch (strtolower(preg_replace(
'/(?:[^a-zA-Z0-9]+|([^0-9])0+)/',
'\1', $charset)))
9183 case 'adobestandardencoding':
9184 case 'csadobestandardencoding':
9185 return 'Adobe-Standard-Encoding';
9186 case 'adobesymbolencoding':
9188 return 'Adobe-Symbol-Encoding';
9191 return 'Amiga-1251';
9192 case 'ansix31101983':
9194 case 'csiso99naplps':
9197 return 'ANSI_X3.110-1983';
9200 case 'csiso89asmo449':
9208 return 'Big5-HKSCS';
9216 case 'csiso4unitedkingdom':
9223 case 'csiso47bsviewdata':
9225 return 'BS_viewdata';
9231 case 'csaz243419851':
9232 case 'csiso121canadian1':
9235 return 'CSA_Z243.4-1985-1';
9237 case 'csaz243419852':
9238 case 'csiso122canadian2':
9241 return 'CSA_Z243.4-1985-2';
9242 case 'csaz24341985gr':
9243 case 'csiso123csaz24341985gr':
9245 return 'CSA_Z243.4-1985-gr';
9246 case 'csiso139csn369103':
9249 return 'CSN_369103';
9254 case 'csiso21german':
9263 case 'csiso646danish':
9268 case 'csibmebcdicatde':
9270 return 'EBCDIC-AT-DE';
9271 case 'csebcdicatdea':
9273 return 'EBCDIC-AT-DE-A';
9274 case 'csebcdiccafr':
9276 return 'EBCDIC-CA-FR';
9277 case 'csebcdicdkno':
9279 return 'EBCDIC-DK-NO';
9280 case 'csebcdicdknoa':
9282 return 'EBCDIC-DK-NO-A';
9288 return 'EBCDIC-ES-A';
9291 return 'EBCDIC-ES-S';
9292 case 'csebcdicfise':
9294 return 'EBCDIC-FI-SE';
9295 case 'csebcdicfisea':
9297 return 'EBCDIC-FI-SE-A';
9313 case 'csiso111ecmacyrillic':
9314 case 'ecmacyrillic':
9317 return 'ECMA-cyrillic';
9318 case 'csiso17spanish':
9323 case 'csiso85spanish2':
9328 case 'cseucpkdfmtjapanese':
9330 case 'extendedunixcodepackedformatforjapanese':
9332 case 'cseucfixwidjapanese':
9333 case 'extendedunixcodefixedwidthforjapanese':
9334 return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
9340 case 'csiso58gb231280':
9349 case 'csiso57gb1988':
9353 return 'GB_1988-80';
9354 case 'csiso153gost1976874':
9358 return 'GOST_19768-74';
9360 case 'csiso150greekccitt':
9363 return 'greek-ccitt';
9364 case 'csiso88greek7':
9368 case 'csiso18greek7old':
9371 return 'greek7-old';
9374 return 'HP-DeskTop';
9383 return 'HP-Pi-font';
9390 return 'HZ-GB-2312';
9391 case 'csibmsymbols':
9393 return 'IBM-Symbols';
9457 case 'ebcdicjpkana':
9482 case 'cspc8codepage437':
9492 case 'cspc775baltic':
9497 case 'cspc850multilingual':
9523 case 'pcmultilingual850euro':
9538 case 'cspc862latinhebrew':
9573 case 'ebcdiccproece':
9584 case 'ebcdiccyrillic':
9612 case 'ebcdiclatin9euro':
9623 case 'ebcdicus37euro':
9628 case 'ebcdicde273euro':
9633 case 'ebcdicdk277euro':
9634 case 'ebcdicno277euro':
9639 case 'ebcdicfi278euro':
9640 case 'ebcdicse278euro':
9645 case 'ebcdicit280euro':
9650 case 'ebcdices284euro':
9655 case 'ebcdicgb285euro':
9660 case 'ebcdicfr297euro':
9665 case 'ebcdicinternational500euro':
9670 case 'ebcdicis871euro':
9673 case 'csiso143iecp271':
9681 case 'csiso50inis8':
9685 case 'csiso51iniscyrillic':
9686 case 'iniscyrillic':
9688 return 'INIS-cyrillic';
9693 return 'ISO-2022-CN';
9694 case 'iso2022cnext':
9695 return 'ISO-2022-CN-EXT';
9698 return 'ISO-2022-JP';
9699 case 'csiso2022jp2':
9701 return 'ISO-2022-JP-2';
9704 return 'ISO-2022-KR';
9705 case 'cswindows30latin1':
9706 case 'iso88591windows30latin1':
9707 return 'ISO-8859-1-Windows-3.0-Latin-1';
9708 case 'cswindows31latin1':
9709 case 'iso88591windows31latin1':
9710 return 'ISO-8859-1-Windows-3.1-Latin-1';
9713 case 'iso885921987':
9717 return 'ISO-8859-2';
9718 case 'cswindows31latin2':
9719 case 'iso88592windowslatin2':
9720 return 'ISO-8859-2-Windows-Latin-2';
9723 case 'iso885931988':
9727 return 'ISO-8859-3';
9730 case 'iso885941988':
9734 return 'ISO-8859-4';
9735 case 'csisolatincyrillic':
9738 case 'iso885951988':
9740 return 'ISO-8859-5';
9743 case 'csisolatinarabic':
9746 case 'iso885961987':
9748 return 'ISO-8859-6';
9751 return 'ISO-8859-6-E';
9754 return 'ISO-8859-6-I';
9755 case 'csisolatingreek':
9761 case 'iso885971987':
9763 return 'ISO-8859-7';
9764 case 'csisolatinhebrew':
9767 case 'iso885981988':
9769 return 'ISO-8859-8';
9772 return 'ISO-8859-8-E';
9775 return 'ISO-8859-8-I';
9776 case 'cswindows31latin5':
9777 case 'iso88599windowslatin5':
9778 return 'ISO-8859-9-Windows-Latin-5';
9781 case 'iso8859101992':
9785 return 'ISO-8859-10';
9787 return 'ISO-8859-13';
9789 case 'iso8859141998':
9794 return 'ISO-8859-14';
9797 return 'ISO-8859-15';
9799 case 'iso8859162001':
9803 return 'ISO-8859-16';
9805 return 'ISO-10646-J-1';
9807 case 'iso10646ucs2':
9808 return 'ISO-10646-UCS-2';
9810 case 'iso10646ucs4':
9811 return 'ISO-10646-UCS-4';
9812 case 'csunicodeascii':
9813 case 'iso10646ucsbasic':
9814 return 'ISO-10646-UCS-Basic';
9815 case 'csunicodelatin1':
9817 case 'iso10646unicodelatin1':
9818 return 'ISO-10646-Unicode-Latin1';
9819 case 'csiso10646utf1':
9820 case 'iso10646utf1':
9821 return 'ISO-10646-UTF-1';
9825 return 'ISO-11548-1';
9829 case 'csunicodeibm1261':
9830 case 'isounicodeibm1261':
9831 return 'ISO-Unicode-IBM-1261';
9832 case 'csunicodeibm1264':
9833 case 'isounicodeibm1264':
9834 return 'ISO-Unicode-IBM-1264';
9835 case 'csunicodeibm1265':
9836 case 'isounicodeibm1265':
9837 return 'ISO-Unicode-IBM-1265';
9838 case 'csunicodeibm1268':
9839 case 'isounicodeibm1268':
9840 return 'ISO-Unicode-IBM-1268';
9841 case 'csunicodeibm1276':
9842 case 'isounicodeibm1276':
9843 return 'ISO-Unicode-IBM-1276';
9844 case 'csiso646basic1983':
9845 case 'iso646basic1983':
9847 return 'ISO_646.basic:1983';
9848 case 'csiso2intlrefversion':
9850 case 'iso646irv1983':
9852 return 'ISO_646.irv:1983';
9857 return 'ISO_2033-1983';
9858 case 'csiso5427cyrillic':
9862 case 'iso5427cyrillic1981':
9865 return 'ISO_5427:1981';
9866 case 'csiso5428greek':
9869 return 'ISO_5428:1980';
9870 case 'csiso6937add':
9873 return 'ISO_6937-2-25';
9874 case 'csisotextcomm':
9877 return 'ISO_6937-2-add';
9878 case 'csiso8859supp':
9882 return 'ISO_8859-supp';
9883 case 'csiso10367box':
9886 return 'ISO_10367-box';
9887 case 'csiso15italian':
9892 case 'csiso13jisc6220jp':
9894 case 'jisc62201969':
9895 case 'jisc62201969jp':
9898 return 'JIS_C6220-1969-jp';
9899 case 'csiso14jisc6220ro':
9902 case 'jisc62201969ro':
9904 return 'JIS_C6220-1969-ro';
9905 case 'csiso42jisc62261978':
9907 case 'jisc62261978':
9908 return 'JIS_C6226-1978';
9909 case 'csiso87jisx208':
9911 case 'jisc62261983':
9914 return 'JIS_C6226-1983';
9915 case 'csiso91jisc62291984a':
9917 case 'jisc62291984a':
9919 return 'JIS_C6229-1984-a';
9920 case 'csiso92jisc62991984b':
9921 case 'iso646jpocrb':
9923 case 'jisc62291984b':
9925 return 'JIS_C6229-1984-b';
9926 case 'csiso93jis62291984badd':
9928 case 'jisc62291984badd':
9930 return 'JIS_C6229-1984-b-add';
9931 case 'csiso94jis62291984hand':
9933 case 'jisc62291984hand':
9935 return 'JIS_C6229-1984-hand';
9936 case 'csiso95jis62291984handadd':
9938 case 'jisc62291984handadd':
9939 case 'jpocrhandadd':
9940 return 'JIS_C6229-1984-hand-add';
9941 case 'csiso96jisc62291984kana':
9943 case 'jisc62291984kana':
9944 return 'JIS_C6229-1984-kana';
9945 case 'csjisencoding':
9947 return 'JIS_Encoding';
9948 case 'cshalfwidthkatakana':
9952 case 'csiso159jisx2121990':
9956 return 'JIS_X0212-1990';
9957 case 'csiso141jusib1002':
9963 return 'JUS_I.B1.002';
9964 case 'csiso147macedonian':
9966 case 'jusib1003mac':
9968 return 'JUS_I.B1.003-mac';
9969 case 'csiso146serbian':
9971 case 'jusib1003serb':
9973 return 'JUS_I.B1.003-serb';
9974 case 'koi7switched':
9975 return 'KOI7-switched';
9988 case 'strk10482002':
9990 case 'csiso19latingreek':
9993 return 'latin-greek';
9994 case 'csiso27latingreek1':
9997 return 'Latin-greek-1';
10002 return 'latin-lap';
10003 case 'csmacintosh':
10006 return 'macintosh';
10007 case 'csmicrosoftpublishing':
10008 case 'microsoftpublishing':
10009 return 'Microsoft-Publishing';
10016 case 'csiso86hungarian':
10021 return 'MSZ_7795.3';
10025 return 'NATS-DANO';
10026 case 'csnatsdanoadd':
10028 case 'natsdanoadd':
10029 return 'NATS-DANO-ADD';
10033 return 'NATS-SEFI';
10034 case 'csnatssefiadd':
10036 case 'natssefiadd':
10037 return 'NATS-SEFI-ADD';
10038 case 'csiso151cuba':
10043 return 'NC_NC00-10:81';
10044 case 'csiso69french':
10049 return 'NF_Z_62-010';
10050 case 'csiso25french':
10053 case 'nfz620101973':
10054 return 'NF_Z_62-010_(1973)';
10055 case 'csiso60danishnorwegian':
10056 case 'csiso60norwegian1':
10061 return 'NS_4551-1';
10062 case 'csiso61norwegian2':
10067 return 'NS_4551-2';
10068 case 'osdebcdicdf3irv':
10069 return 'OSD_EBCDIC_DF03_IRV';
10070 case 'osdebcdicdf41':
10071 return 'OSD_EBCDIC_DF04_1';
10072 case 'osdebcdicdf415':
10073 return 'OSD_EBCDIC_DF04_15';
10074 case 'cspc8danishnorwegian':
10075 case 'pc8danishnorwegian':
10076 return 'PC8-Danish-Norwegian';
10077 case 'cspc8turkish':
10079 return 'PC8-Turkish';
10080 case 'csiso16portuguese':
10085 case 'csiso84portuguese2':
10092 case 'cyrillicasian':
10098 case 'csiso10swedish':
10105 return 'SEN_850200_B';
10106 case 'csiso11swedishfornames':
10111 return 'SEN_850200_C';
10112 case 'csiso102t617bit':
10115 return 'T.61-7bit';
10116 case 'csiso103t618bit':
10120 return 'T.61-8bit';
10121 case 'csiso128t101g2':
10128 case 'csunicode11':
10130 return 'UNICODE-1-1';
10131 case 'csunicode11utf7':
10132 case 'unicode11utf7':
10133 return 'UNICODE-1-1-UTF-7';
10134 case 'csunknown8bit':
10135 case 'unknown8bit':
10136 return 'UNKNOWN-8BIT';
10137 case 'ansix341968':
10138 case 'ansix341986':
10143 case 'iso646irv1991':
10168 case 'csventurainternational':
10169 case 'venturainternational':
10170 return 'Ventura-International';
10171 case 'csventuramath':
10172 case 'venturamath':
10173 return 'Ventura-Math';
10174 case 'csventuraus':
10176 return 'Ventura-US';
10177 case 'csiso70videotexsupp1':
10179 case 'videotexsuppl':
10180 return 'videotex-suppl';
10188 case 'cswindows31j':
10192 return 'Windows-31J';
10195 return 'windows-874';
10197 case 'csksc56011987':
10202 case 'ksc56011987':
10203 case 'ksc56011989':
10205 return 'windows-949';
10206 case 'windows1250':
10207 return 'windows-1250';
10208 case 'windows1251':
10209 return 'windows-1251';
10211 case 'csisolatin1':
10214 case 'iso885911987':
10218 case 'windows1252':
10219 return 'windows-1252';
10220 case 'windows1253':
10221 return 'windows-1253';
10222 case 'csisolatin5':
10224 case 'iso885991989':
10228 case 'windows1254':
10229 return 'windows-1254';
10230 case 'windows1255':
10231 return 'windows-1255';
10232 case 'windows1256':
10233 return 'windows-1256';
10234 case 'windows1257':
10235 return 'windows-1257';
10236 case 'windows1258':
10237 return 'windows-1258';
10244 if (is_array($curl = curl_version()))
10246 $curl = $curl[
'version'];
10248 elseif (substr($curl, 0, 5) ===
'curl/')
10250 $curl = substr($curl, 5, strcspn($curl,
"\x09\x0A\x0B\x0C\x0D", 5));
10252 elseif (substr($curl, 0, 8) ===
'libcurl/')
10254 $curl = substr($curl, 8, strcspn($curl,
"\x09\x0A\x0B\x0C\x0D", 8));
10266 while ((
$start = strpos($data,
'<!--')) !==
false)
10269 if (($end = strpos($data,
'-->',
$start)) !==
false)
10271 $data = substr_replace($data,
'', 0, $end + 3);
10283 return $parser->parse($dt);
10289 return $decoder->parse();
10294 $string = (string) $string;
10296 $length = strlen($string);
10299 while ($position < $length && ($pos = strpos($string,
'(', $position)) !==
false)
10301 $output .= substr($string, $position, $pos - $position);
10302 $position = $pos + 1;
10303 if ($string[$pos - 1] !==
'\\')
10306 while ($depth && $position < $length)
10308 $position += strcspn($string,
'()', $position);
10309 if ($string[$position - 1] ===
'\\')
10314 elseif (isset($string[$position]))
10316 switch ($string[$position])
10338 $output .= substr($string, $position);
10343 if (($pos = strpos($mime,
';')) ===
false)
10345 return trim($mime);
10349 return trim(substr($mime, 0, $pos));
10354 if (isset($attribs[
''][
'mode']) && strtolower(trim($attribs[
''][
'mode']) ===
'base64'))
10362 if (isset($attribs[
''][
'type']))
10364 switch (strtolower(trim($attribs[
''][
'type'])))
10373 case 'application/xhtml+xml':
10386 if (isset($attribs[
''][
'type']))
10388 switch (strtolower(trim($attribs[
''][
'type'])))
10404 if (isset($attribs[
''][
'type']))
10406 $type = strtolower(trim($attribs[
''][
'type']));
10416 if (in_array(substr($type, -4), array(
'+xml',
'/xml')) || substr($type, 0, 5) ===
'text/')
10432 return (
bool) preg_match(
'/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
10436 $space_characters =
"\x20\x09\x0A\x0B\x0C\x0D";
10437 $string_length = strlen($string);
10438 $position = strspn($string, $space_characters);
10440 while ($position < $string_length)
10442 $len = strcspn($string, $space_characters, $position);
10443 $tokens[] = substr($string, $position, $len);
10445 $position += strspn($string, $space_characters, $position);
10452 $codepoint = (int) $codepoint;
10453 if ($codepoint < 0)
10457 else if ($codepoint <= 0x7f)
10459 return chr($codepoint);
10461 else if ($codepoint <= 0x7ff)
10463 return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
10465 else if ($codepoint <= 0xffff)
10467 return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
10469 else if ($codepoint <= 0x10ffff)
10471 return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
10476 return "\xEF\xBF\xBD";
10483 $str = explode(
'&', $str);
10484 foreach ($str as $section)
10486 if (strpos($section,
'=') !==
false)
10488 list($name, $value) = explode(
'=', $section, 2);
10489 $return[urldecode($name)][] = urldecode($value);
10493 $return[urldecode($section)][] = null;
10502 if (substr($data, 0, 4) ===
"\x00\x00\xFE\xFF")
10504 $encoding[] =
'UTF-32BE';
10507 elseif (substr($data, 0, 4) ===
"\xFF\xFE\x00\x00")
10509 $encoding[] =
'UTF-32LE';
10512 elseif (substr($data, 0, 2) ===
"\xFE\xFF")
10514 $encoding[] =
'UTF-16BE';
10517 elseif (substr($data, 0, 2) ===
"\xFF\xFE")
10519 $encoding[] =
'UTF-16LE';
10522 elseif (substr($data, 0, 3) ===
"\xEF\xBB\xBF")
10524 $encoding[] =
'UTF-8';
10527 elseif (substr($data, 0, 20) ===
"\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
10529 if ($pos = strpos($data,
"\x00\x00\x00\x3F\x00\x00\x00\x3E"))
10532 if ($parser->parse())
10534 $encoding[] = $parser->encoding;
10537 $encoding[] =
'UTF-32BE';
10540 elseif (substr($data, 0, 20) ===
"\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
10542 if ($pos = strpos($data,
"\x3F\x00\x00\x00\x3E\x00\x00\x00"))
10545 if ($parser->parse())
10547 $encoding[] = $parser->encoding;
10550 $encoding[] =
'UTF-32LE';
10553 elseif (substr($data, 0, 10) ===
"\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
10555 if ($pos = strpos($data,
"\x00\x3F\x00\x3E"))
10558 if ($parser->parse())
10560 $encoding[] = $parser->encoding;
10563 $encoding[] =
'UTF-16BE';
10566 elseif (substr($data, 0, 10) ===
"\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
10568 if ($pos = strpos($data,
"\x3F\x00\x3E\x00"))
10571 if ($parser->parse())
10573 $encoding[] = $parser->encoding;
10576 $encoding[] =
'UTF-16LE';
10579 elseif (substr($data, 0, 5) ===
"\x3C\x3F\x78\x6D\x6C")
10581 if ($pos = strpos($data,
"\x3F\x3E"))
10583 $parser = $registry->create(
'XML_Declaration_Parser', array(substr($data, 5, $pos - 5)));
10584 if ($parser->parse())
10586 $encoding[] = $parser->encoding;
10589 $encoding[] =
'UTF-8';
10594 $encoding[] =
'UTF-8';
10600 if (function_exists(
'ob_gzhandler'))
10602 ob_start(
'ob_gzhandler');
10604 header(
'Content-type: text/javascript; charset: UTF-8');
10605 header(
'Cache-Control: must-revalidate');
10606 header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', time() + 604800) .
' GMT');
10608 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
10609 if (placeholder !=
'') {
10610 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>');
10613 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>');
10616 function embed_flash(bgcolor, width, height, link, loop, type) {
10617 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>');
10619 function embed_flv(width, height, link, placeholder, loop, player) {
10620 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>');
10622 function embed_wmedia(width, height, link) {
10623 document.writeln(
'<embed type="application/x-mplayer2" src="'+link+
'" autosize="1" width="'+width+
'" height="'+height+
'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
10630 $root = dirname(dirname(__FILE__));
10631 if (file_exists($root .
'/.git/index'))
10633 return filemtime($root .
'/.git/index');
10635 elseif (file_exists($root .
'/SimplePie'))
10638 foreach (glob($root .
'/SimplePie/*.php') as $file)
10640 if (($mtime = filemtime($file)) > $time)
10647 elseif (file_exists(dirname(__FILE__) .
'/Core.php'))
10649 return filemtime(dirname(__FILE__) .
'/Core.php');
10653 return filemtime(__FILE__);
10660 $info .=
'PHP ' . PHP_VERSION .
"\n";
10661 if ($sp->error() !== null)
10663 $info .=
'Error occurred: ' . $sp->error() .
"\n";
10667 $info .=
"No error found.\n";
10669 $info .=
"Extensions:\n";
10670 $extensions = array(
'pcre',
'curl',
'zlib',
'mbstring',
'iconv',
'xmlreader',
'xml');
10671 foreach ($extensions as $ext)
10673 if (extension_loaded($ext))
10675 $info .=
" $ext loaded\n";
10679 $info .=
' Version ' . PCRE_VERSION .
"\n";
10682 $version = curl_version();
10683 $info .=
' Version ' . $version[
'version'] .
"\n";
10686 $info .=
' Overloading: ' . mb_get_info(
'func_overload') .
"\n";
10689 $info .=
' Version ' . ICONV_VERSION .
"\n";
10692 $info .=
' Version ' . LIBXML_DOTTED_VERSION .
"\n";
10698 $info .=
" $ext not loaded\n";
10715 if (substr_count($ip,
'::') === 1)
10717 list($ip1, $ip2) = explode(
'::', $ip);
10724 $c1 = substr_count($ip1,
':');
10732 $c2 = substr_count($ip2,
':');
10734 if (strpos($ip2,
'.') !==
false)
10739 if ($c1 === -1 && $c2 === -1)
10741 $ip =
'0:0:0:0:0:0:0:0';
10744 else if ($c1 === -1)
10746 $fill = str_repeat(
'0:', 7 - $c2);
10747 $ip = str_replace(
'::', $fill, $ip);
10750 else if ($c2 === -1)
10752 $fill = str_repeat(
':0', 7 - $c1);
10753 $ip = str_replace(
'::', $fill, $ip);
10758 $fill =
':' . str_repeat(
'0:', 6 - $c2 - $c1);
10759 $ip = str_replace(
'::', $fill, $ip);
10768 $ip = self::uncompress($ip);
10769 $ip_parts = self::split_v6_v4($ip);
10771 $ip_parts[0] = preg_replace(
'/(^|:)0+([0-9])/',
'\1\2', $ip_parts[0]);
10773 if (preg_match_all(
'/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE))
10777 foreach ($matches[0] as
$match)
10779 if (strlen($match[0]) > $max)
10781 $max = strlen($match[0]);
10785 $ip_parts[0] = substr_replace($ip_parts[0],
'::', $pos, $max);
10787 if ($ip_parts[1] !==
'')
10789 return implode(
':', $ip_parts);
10793 return $ip_parts[0];
10797 private static function split_v6_v4($ip)
10799 if (strpos($ip,
'.') !==
false)
10801 $pos = strrpos($ip,
':');
10802 $ipv6_part = substr($ip, 0, $pos);
10803 $ipv4_part = substr($ip, $pos + 1);
10804 return array($ipv6_part, $ipv4_part);
10808 return array($ip,
'');
10814 $ip = self::uncompress($ip);
10815 list($ipv6, $ipv4) = self::split_v6_v4($ip);
10816 $ipv6 = explode(
':', $ipv6);
10817 $ipv4 = explode(
'.', $ipv4);
10818 if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4)
10820 foreach ($ipv6 as $ipv6_part)
10823 if ($ipv6_part ===
'')
10826 if (strlen($ipv6_part) > 4)
10829 $ipv6_part = ltrim($ipv6_part,
'0');
10830 if ($ipv6_part ===
'')
10833 $value = hexdec($ipv6_part);
10834 if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF)
10837 if (count($ipv4) === 4)
10839 foreach ($ipv4 as $ipv4_part)
10841 $value = (int) $ipv4_part;
10842 if ((
string) $value !== $ipv4_part || $value < 0 || $value > 0xFF)
10856 return self::check_ipv6($ip);
10924 'keskiviikko' => 3,
11298 $this->day_pcre =
'(' . implode(array_keys($this->day),
'|') .
')';
11299 $this->month_pcre =
'(' . implode(array_keys($this->month),
'|') .
')';
11301 if (!isset($cache[get_class($this)]))
11303 $all_methods = get_class_methods($this);
11304 foreach ($all_methods as $method)
11306 if (strtolower(substr($method, 0, 5)) ===
'date_')
11308 $cache[get_class($this)][] = $method;
11312 foreach ($cache[get_class($this)] as $method)
11314 $this->built_in[] = $method;
11318 public static function get()
11330 foreach ($this->user as $method)
11332 if (($returned = call_user_func($method, $date)) !==
false)
11337 foreach ($this->built_in as $method)
11339 if (($returned = call_user_func(array($this, $method), $date)) !==
false)
11349 if (is_callable($callback))
11351 $this->user[] = $callback;
11355 trigger_error(
'User-supplied function must be a valid callback', E_USER_WARNING);
11364 $year =
'([0-9]{4})';
11365 $month = $day = $hour = $minute = $second =
'([0-9]{2})';
11366 $decimal =
'([0-9]*)';
11367 $zone =
'(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
11368 $pcre =
'/^' . $year .
'(?:-?' . $month .
'(?:-?' . $day .
'(?:[Tt\x09\x20]+' . $hour .
'(?::?' . $minute .
'(?::?' . $second .
'(?:.' . $decimal .
')?)?)?' . $zone .
')?)?)?$/';
11370 if (preg_match($pcre, $date,
$match))
11398 $timezone =
$match[10] * 3600;
11399 $timezone +=
$match[11] * 60;
11421 $string = (string) $string;
11423 $length = strlen($string);
11426 while ($position < $length && ($pos = strpos($string,
'(', $position)) !==
false)
11428 $output .= substr($string, $position, $pos - $position);
11429 $position = $pos + 1;
11430 if ($string[$pos - 1] !==
'\\')
11433 while ($depth && $position < $length)
11435 $position += strcspn($string,
'()', $position);
11436 if ($string[$position - 1] ===
'\\')
11441 elseif (isset($string[$position]))
11443 switch ($string[$position])
11465 $output .= substr($string, $position);
11474 $wsp =
'[\x09\x20]';
11475 $fws =
'(?:' . $wsp .
'+|' . $wsp .
'*(?:\x0D\x0A' . $wsp .
'+)+)';
11476 $optional_fws = $fws .
'?';
11479 $day =
'([0-9]{1,2})';
11480 $hour = $minute = $second =
'([0-9]{2})';
11481 $year =
'([0-9]{2,4})';
11482 $num_zone =
'([+\-])([0-9]{2})([0-9]{2})';
11483 $character_zone =
'([A-Z]{1,5})';
11484 $zone =
'(?:' . $num_zone .
'|' . $character_zone .
')';
11485 $pcre =
'/(?:' . $optional_fws . $day_name . $optional_fws .
',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws .
':' . $optional_fws . $minute .
'(?:' . $optional_fws .
':' . $optional_fws . $second .
')?' . $fws . $zone .
'/i';
11504 $month = $this->month[strtolower(
$match[3])];
11508 $timezone =
$match[9] * 3600;
11509 $timezone +=
$match[10] * 60;
11516 elseif (isset($this->timezone[strtoupper(
$match[11])]))
11518 $timezone = $this->timezone[strtoupper(
$match[11])];
11556 $space =
'[\x09\x20]+';
11559 $day =
'([0-9]{1,2})';
11560 $year = $hour = $minute = $second =
'([0-9]{2})';
11561 $zone =
'([A-Z]{1,5})';
11562 $pcre =
'/^' . $day_name .
',' . $space . $day .
'-' . $month .
'-' . $year . $space . $hour .
':' . $minute .
':' . $second . $space . $zone .
'$/i';
11564 if (preg_match($pcre, $date,
$match))
11578 $month = $this->month[strtolower(
$match[3])];
11580 if (isset($this->timezone[strtoupper(
$match[8])]))
11582 $timezone = $this->timezone[strtoupper(
$match[8])];
11611 $space =
'[\x09\x20]+';
11614 $day =
'([0-9]{1,2})';
11615 $hour = $sec = $min =
'([0-9]{2})';
11616 $year =
'([0-9]{4})';
11617 $terminator =
'\x0A?\x00?';
11618 $pcre =
'/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour .
':' . $min .
':' . $sec . $space . $year . $terminator .
'$/i';
11620 if (preg_match($pcre, $date,
$match))
11632 $month = $this->month[strtolower(
$match[2])];
11643 $strtotime = strtotime($date);
11644 if ($strtotime === -1 || $strtotime ===
false)
11667 var $data = array();
11679 if (strtoupper($encoding) ===
'US-ASCII')
11681 $this->encoding =
'UTF-8';
11689 if (substr($data, 0, 4) ===
"\x00\x00\xFE\xFF")
11691 $data = substr($data, 4);
11694 elseif (substr($data, 0, 4) ===
"\xFF\xFE\x00\x00")
11696 $data = substr($data, 4);
11699 elseif (substr($data, 0, 2) ===
"\xFE\xFF")
11701 $data = substr($data, 2);
11704 elseif (substr($data, 0, 2) ===
"\xFF\xFE")
11706 $data = substr($data, 2);
11709 elseif (substr($data, 0, 3) ===
"\xEF\xBB\xBF")
11711 $data = substr($data, 3);
11713 if (substr($data, 0, 5) ===
'<?xml' && strspn(substr($data, 5, 1),
"\x09\x0A\x0D\x20") && ($pos = strpos($data,
'?>')) !==
false)
11715 $declaration = $this->registry->create(
'XML_Declaration_Parser', array(substr($data, 5, $pos - 5)));
11716 if ($declaration->parse())
11718 $data = substr($data, $pos + 2);
11719 $data =
'<?xml version="' . $declaration->version .
'" encoding="' . $encoding .
'" standalone="' . (($declaration->standalone) ?
'yes' :
'no') .
'"?>' .
$data;
11723 $this->error_string =
'SimplePie bug! Please report this!';
11728 static $xml_is_sane = null;
11729 if ($xml_is_sane === null)
11731 $parser_check = xml_parser_create();
11732 xml_parse_into_struct($parser_check,
'<foo>&</foo>', $values);
11733 xml_parser_free($parser_check);
11734 $xml_is_sane = isset($values[0][
'value']);
11739 $xml = xml_parser_create_ns($this->encoding, $this->separator);
11740 xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
11741 xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
11742 xml_set_object($xml, $this);
11743 xml_set_character_data_handler($xml,
'cdata');
11744 xml_set_element_handler($xml,
'tag_open',
'tag_close');
11746 if (!xml_parse($xml, $data,
true))
11748 $this->error_code = xml_get_error_code($xml);
11749 $this->error_string = xml_error_string($this->error_code);
11752 $this->current_line = xml_get_current_line_number($xml);
11753 $this->current_column = xml_get_current_column_number($xml);
11754 $this->current_byte = xml_get_current_byte_index($xml);
11755 xml_parser_free($xml);
11760 libxml_clear_errors();
11761 $xml =
new XMLReader();
11763 while (@$xml->read())
11765 switch ($xml->nodeType)
11767 case constant(
'XMLReader::END_ELEMENT'):
11768 if ($xml->namespaceURI !==
'')
11770 $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
11774 $tagName = $xml->localName;
11778 case constant(
'XMLReader::ELEMENT'):
11779 $empty = $xml->isEmptyElement;
11780 if ($xml->namespaceURI !==
'')
11782 $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
11786 $tagName = $xml->localName;
11788 $attributes = array();
11789 while ($xml->moveToNextAttribute())
11791 if ($xml->namespaceURI !==
'')
11793 $attrName = $xml->namespaceURI . $this->separator . $xml->localName;
11797 $attrName = $xml->localName;
11799 $attributes[$attrName] = $xml->value;
11801 $this->
tag_open(null, $tagName, $attributes);
11807 case constant(
'XMLReader::TEXT'):
11808 case constant(
'XMLReader::CDATA'):
11809 $this->
cdata(null, $xml->value);
11813 if (
$error = libxml_get_last_error())
11815 $this->error_code =
$error->code;
11816 $this->error_string =
$error->message;
11817 $this->current_line =
$error->line;
11818 $this->current_column =
$error->column;
11853 list($this->
namespace[], $this->element[]) = $this->
split_ns($tag);
11854 $attribs = array();
11855 foreach ($attributes as $name => $value)
11857 list($attrib_namespace, $attribute) = $this->
split_ns($name);
11858 $attribs[$attrib_namespace][$attribute] = $value;
11862 $base = $this->registry->call(
'Misc',
'absolutize_url', array($attribs[SIMPLEPIE_NAMESPACE_XML][
'base'], end($this->xml_base)));
11863 if ($base !==
false)
11865 $this->xml_base[] = $base;
11866 $this->xml_base_explicit[] =
true;
11871 $this->xml_base[] = end($this->xml_base);
11872 $this->xml_base_explicit[] = end($this->xml_base_explicit);
11874 if (isset($attribs[SIMPLEPIE_NAMESPACE_XML][
'lang']))
11880 $this->xml_lang[] = end($this->xml_lang);
11882 if ($this->current_xhtml_construct >= 0)
11884 $this->current_xhtml_construct++;
11887 $this->data[
'data'] .=
'<' . end($this->element);
11888 if (isset($attribs[
'']))
11890 foreach ($attribs[
''] as $name => $value)
11892 $this->data[
'data'] .=
' ' . $name .
'="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) .
'"';
11895 $this->data[
'data'] .=
'>';
11901 $this->data =& $this->data[
'child'][end($this->
namespace)][end($this->element)][];
11902 $this->data = array(
'data' =>
'',
'attribs' => $attribs,
'xml_base' => end($this->xml_base),
'xml_base_explicit' => end($this->xml_base_explicit),
'xml_lang' => end($this->xml_lang));
11903 if ((end($this->
namespace) ===
SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array(
'title',
'tagline',
'copyright',
'info',
'summary',
'content')) && isset($attribs[
''][
'mode']) && $attribs[
''][
'mode'] ===
'xml')
11904 || (end($this->
namespace) ===
SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array(
'rights',
'subtitle',
'summary',
'info',
'title',
'content')) && isset($attribs[
''][
'type']) && $attribs[
''][
'type'] ===
'xhtml')
11909 $this->current_xhtml_construct = 0;
11915 if ($this->current_xhtml_construct >= 0)
11917 $this->data[
'data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
11921 $this->data[
'data'] .= $cdata;
11926 if ($this->current_xhtml_construct >= 0)
11928 $this->current_xhtml_construct--;
11929 if (end($this->
namespace) ===
SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array(
'area',
'base',
'basefont',
'br',
'col',
'frame',
'hr',
'img',
'input',
'isindex',
'link',
'meta',
'param')))
11931 $this->data[
'data'] .=
'</' . end($this->element) .
'>';
11934 if ($this->current_xhtml_construct === -1)
11936 $this->data =& $this->datas[count($this->datas) - 1];
11937 array_pop($this->datas);
11939 array_pop($this->element);
11940 array_pop($this->
namespace);
11941 array_pop($this->xml_base);
11942 array_pop($this->xml_base_explicit);
11943 array_pop($this->xml_lang);
11947 static $cache = array();
11948 if (!isset($cache[$string]))
11950 if ($pos = strpos($string, $this->separator))
11952 static $separator_length;
11953 if (!$separator_length)
11955 $separator_length = strlen($this->separator);
11957 $namespace = substr($string, 0, $pos);
11958 $local_name = substr($string, $pos + $separator_length);
11972 $cache[$string] = array($namespace, $local_name);
11976 $cache[$string] = array(
'', $string);
11979 return $cache[$string];
11998 return md5(serialize($this));
12003 if ($this->scheme !== null)
12015 if ($this->value !== null)
12029 'Cache' =>
'SimplePie_Cache',
12030 'Locator' =>
'SimplePie_Locator',
12031 'Parser' =>
'SimplePie_Parser',
12032 'File' =>
'SimplePie_File',
12033 'Sanitize' =>
'SimplePie_Sanitize',
12034 'Item' =>
'SimplePie_Item',
12035 'Author' =>
'SimplePie_Author',
12036 'Category' =>
'SimplePie_Category',
12037 'Enclosure' =>
'SimplePie_Enclosure',
12038 'Caption' =>
'SimplePie_Caption',
12039 'Copyright' =>
'SimplePie_Copyright',
12040 'Credit' =>
'SimplePie_Credit',
12041 'Rating' =>
'SimplePie_Rating',
12042 'Restriction' =>
'SimplePie_Restriction',
12043 'Content_Type_Sniffer' =>
'SimplePie_Content_Type_Sniffer',
12044 'Source' =>
'SimplePie_Source',
12045 'Misc' =>
'SimplePie_Misc',
12046 'XML_Declaration_Parser' =>
'SimplePie_XML_Declaration_Parser',
12047 'Parse_Date' =>
'SimplePie_Parse_Date',
12058 if (!is_subclass_of($class, $this->
default[$type]))
12062 $this->classes[$type] =
$class;
12065 $this->legacy[] =
$class;
12072 if (!empty($this->classes[$type]))
12074 return $this->classes[$type];
12076 if (!empty($this->
default[$type]))
12078 return $this->
default[$type];
12083 public function &
create($type, $parameters = array())
12086 if (in_array($class, $this->legacy))
12093 $replacement = array($this->
get_class(
'file'), $parameters[3], $this->
get_class(
'content_type_sniffer'));
12094 array_splice($parameters, 3, 1, $replacement);
12098 if (!method_exists($class,
'__construct'))
12104 $reflector =
new ReflectionClass($class);
12105 $instance = $reflector->newInstanceArgs($parameters);
12107 if (method_exists($instance,
'set_registry'))
12109 $instance->set_registry($this);
12114 public function &
call($type, $method, $parameters = array())
12117 if (in_array($class, $this->legacy))
12124 if ($method ===
'get_handler')
12126 $result = @call_user_func_array(array($class,
'create'), $parameters);
12132 $result = call_user_func_array(array($class, $method), $parameters);
12145 public function __construct($relationship = null, $type = null, $value = null)
12148 $this->type =
$type;
12155 return md5(serialize($this));
12160 if ($this->relationship !== null)
12172 if ($this->type !== null)
12184 if ($this->value !== null)
12201 var
$strip_htmltags = array(
'base',
'blink',
'body',
'doctype',
'embed',
'font',
'form',
'frame',
'frameset',
'html',
'iframe',
'input',
'marquee',
'meta',
'noscript',
'object',
'param',
'script',
'style');
12203 var
$strip_attributes = array(
'bgsound',
'class',
'expr',
'id',
'style',
'onclick',
'onerror',
'onfinish',
'onmouseover',
'onmouseout',
'onfocus',
'onblur',
'lowsrc',
'dynsrc');
12226 $this->image_handler = (string) $page;
12230 $this->image_handler =
false;
12235 $this->registry = $registry;
12237 public function pass_cache_data($enable_cache =
true, $cache_location =
'./cache', $cache_name_function =
'md5', $cache_class =
'SimplePie_Cache')
12239 if (isset($enable_cache))
12241 $this->enable_cache = (bool) $enable_cache;
12243 if ($cache_location)
12245 $this->cache_location = (string) $cache_location;
12247 if ($cache_name_function)
12249 $this->cache_name_function = (string) $cache_name_function;
12252 public function pass_file_data($file_class =
'SimplePie_File', $timeout = 10, $useragent =
'', $force_fsockopen =
false)
12256 $this->timeout = (string) $timeout;
12260 $this->useragent = (string) $useragent;
12262 if ($force_fsockopen)
12264 $this->force_fsockopen = (string) $force_fsockopen;
12267 public function strip_htmltags($tags = array(
'base',
'blink',
'body',
'doctype',
'embed',
'font',
'form',
'frame',
'frameset',
'html',
'iframe',
'input',
'marquee',
'meta',
'noscript',
'object',
'param',
'script',
'style'))
12271 if (is_array($tags))
12289 public function strip_attributes($attribs = array(
'bgsound',
'class',
'expr',
'id',
'style',
'onclick',
'onerror',
'onfinish',
'onmouseover',
'onmouseout',
'onfocus',
'onblur',
'lowsrc',
'dynsrc'))
12293 if (is_array($attribs))
12313 $this->output_encoding = (string) $encoding;
12318 if ($element_attribute === null)
12320 $element_attribute = array(
12323 'blockquote' =>
'cite',
12325 'form' =>
'action',
12335 $this->replace_url_attributes = (array) $element_attribute;
12339 $data = trim($data);
12344 if (preg_match(
'/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' .
SIMPLEPIE_PCRE_HTML_ATTRIBUTE .
'>)/', $data))
12355 $data = base64_decode($data);
12359 $document =
new DOMDocument();
12360 $document->encoding =
'UTF-8';
12362 set_error_handler(array(
'SimplePie_Misc',
'silence_errors'));
12363 $document->loadHTML($data);
12364 restore_error_handler();
12368 $xpath =
new DOMXPath($document);
12369 $comments = $xpath->query(
'//comment()');
12370 foreach ($comments as $comment)
12372 $comment->parentNode->removeChild($comment);
12382 $this->
strip_tag($tag, $document, $type);
12393 $this->base =
$base;
12394 foreach ($this->replace_url_attributes as $element => $attributes)
12396 $this->
replace_urls($document, $element, $attributes);
12399 if (isset($this->image_handler) && ((
string) $this->image_handler) !==
'' && $this->enable_cache)
12401 $images = $document->getElementsByTagName(
'img');
12402 foreach ($images as $img)
12404 if ($img->hasAttribute(
'src'))
12406 $image_url = call_user_func($this->cache_name_function, $img->getAttribute(
'src'));
12407 $cache = $this->registry->call(
'Cache',
'get_handler', array($this->cache_location, $image_url,
'spi'));
12408 if ($cache->load())
12410 $img->setAttribute(
'src', $this->image_handler . $image_url);
12414 $file = $this->registry->create(
'File', array($img[
'attribs'][
'src'][
'data'], $this->timeout, 5, array(
'X-FORWARDED-FOR' => $_SERVER[
'REMOTE_ADDR']), $this->useragent, $this->force_fsockopen));
12415 $headers = $file->headers;
12416 if ($file->success && ($file->method &
SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
12418 if ($cache->save(array(
'headers' => $file->headers,
'body' => $file->body)))
12420 $img->setAttribute(
'src', $this->image_handler . $image_url);
12424 trigger_error(
"$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
12433 if ($document->firstChild instanceof DOMDocumentType)
12435 $document->removeChild($document->firstChild);
12438 $real_body = $document->getElementsByTagName(
'body')->item(0)->childNodes->item(0);
12439 $document->replaceChild($real_body, $document->firstChild);
12441 $data = trim($document->saveHTML());
12445 $data = preg_replace(
'/<\/div>$/',
'', $data);
12452 if ($type & SIMPLEPIE_CONSTRUCT_IRI)
12454 $absolute = $this->registry->call(
'Misc',
'absolutize_url', array($data, $base));
12455 if ($absolute !==
false)
12462 $data = htmlspecialchars($data, ENT_COMPAT,
'UTF-8');
12464 if ($this->output_encoding !==
'UTF-8')
12466 $data = $this->registry->call(
'Misc',
'change_encoding', array($data,
'UTF-8', $this->output_encoding));
12478 $html =
'<div>' . $html .
'</div>';
12479 $ret .=
'<!DOCTYPE html>';
12480 $content_type =
'text/html';
12484 $ret .=
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
12485 $content_type =
'application/xhtml+xml';
12487 $ret .=
'<html><head>';
12488 $ret .=
'<meta http-equiv="Content-Type" content="' . $content_type .
'; charset=utf-8" />';
12489 $ret .=
'</head><body>' . $html .
'</body></html>';
12494 if (!is_array($attributes))
12496 $attributes = array($attributes);
12500 $elements = $document->getElementsByTagName($tag);
12501 foreach ($elements as $element)
12503 foreach ($attributes as $attribute)
12505 if ($element->hasAttribute($attribute))
12507 $value = $this->registry->call(
'Misc',
'absolutize_url', array($element->getAttribute($attribute),
$this->base));
12508 if ($value !==
false)
12510 $element->setAttribute($attribute, $value);
12521 if (isset(
$match[4]) && !in_array(strtolower(
$match[1]), array(
'script',
'style')))
12523 $match[1] = htmlspecialchars(
$match[1], ENT_COMPAT,
'UTF-8');
12524 $match[2] = htmlspecialchars(
$match[2], ENT_COMPAT,
'UTF-8');
12525 return "<$match[1]$match[2]>$match[3]</$match[1]>";
12529 return htmlspecialchars(
$match[0], ENT_COMPAT,
'UTF-8');
12532 elseif (isset(
$match[4]) && !in_array(strtolower(
$match[1]), array(
'script',
'style')))
12543 $xpath =
new DOMXPath($document);
12544 $elements = $xpath->query(
'body//' . $tag);
12547 foreach ($elements as $element)
12549 $fragment = $document->createDocumentFragment();
12551 if (!in_array($tag, array(
'script',
'style')))
12553 $text =
'<' . $tag;
12554 if ($element->hasAttributes())
12557 foreach ($element->attributes as $name => $attr)
12559 $value = $attr->value;
12572 $attrs[] = $name .
'="' . $attr->value .
'"';
12574 $text .=
' ' . implode(
' ', $attrs);
12577 $fragment->appendChild(
new DOMText($text));
12579 $number = $element->childNodes->length;
12580 for (
$i = $number;
$i > 0;
$i--)
12582 $child = $element->childNodes->item(0);
12583 $fragment->appendChild($child);
12585 if (!in_array($tag, array(
'script',
'style')))
12587 $fragment->appendChild(
new DOMText(
'</' . $tag .
'>'));
12589 $element->parentNode->replaceChild($fragment, $element);
12593 elseif (in_array($tag, array(
'script',
'style')))
12595 foreach ($elements as $element)
12597 $element->parentNode->removeChild($element);
12603 foreach ($elements as $element)
12605 $fragment = $document->createDocumentFragment();
12606 $number = $element->childNodes->length;
12607 for (
$i = $number;
$i > 0;
$i--)
12609 $child = $element->childNodes->item(0);
12610 $fragment->appendChild($child);
12612 $element->parentNode->replaceChild($fragment, $element);
12618 $xpath =
new DOMXPath($document);
12619 $elements = $xpath->query(
'//*[@' . $attrib .
']');
12620 foreach ($elements as $element)
12622 $element->removeAttribute($attrib);
12629 var $data = array();
12633 $this->item =
$item;
12634 $this->data =
$data;
12642 return md5(serialize($this->data));
12646 if (isset($this->data[
'child'][$namespace][$tag]))
12648 return $this->data[
'child'][$namespace][$tag];
12657 return $this->item->get_base($element);
12661 return $this->item->sanitize($data, $type, $base);
12671 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
12675 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
12705 if (isset($categories[$key]))
12707 return $categories[$key];
12716 $categories = array();
12722 if (isset($category[
'attribs'][
''][
'term']))
12726 if (isset($category[
'attribs'][
''][
'scheme']))
12730 if (isset($category[
'attribs'][
''][
'label']))
12734 $categories[] = $this->registry->create(
'Category', array($term, $scheme, $label));
12741 if (isset($category[
'attribs'][
''][
'domain']))
12749 $categories[] = $this->registry->create(
'Category', array($term, $scheme, null));
12759 if (!empty($categories))
12761 return array_unique($categories);
12771 if (isset($authors[$key]))
12773 return $authors[$key];
12782 $authors = array();
12792 if (isset($author[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'uri'][0][
'data']))
12796 if (isset($author[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'email'][0][
'data']))
12800 if ($name !== null || $email !== null || $uri !== null)
12802 $authors[] = $this->registry->create(
'Author', array($name, $uri, $email));
12814 if (isset($author[0][
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'url'][0][
'data']))
12818 if (isset($author[0][
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'email'][0][
'data']))
12822 if ($name !== null || $email !== null ||
$url !== null)
12824 $authors[] = $this->registry->create(
'Author', array($name,
$url, $email));
12839 if (!empty($authors))
12841 return array_unique($authors);
12851 if (isset($contributors[$key]))
12853 return $contributors[$key];
12862 $contributors = array();
12872 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'uri'][0][
'data']))
12874 $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]));
12876 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_10][
'email'][0][
'data']))
12880 if ($name !== null || $email !== null || $uri !== null)
12882 $contributors[] = $this->registry->create(
'Author', array($name, $uri, $email));
12894 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'url'][0][
'data']))
12898 if (isset($contributor[
'child'][SIMPLEPIE_NAMESPACE_ATOM_03][
'email'][0][
'data']))
12902 if ($name !== null || $email !== null ||
$url !== null)
12904 $contributors[] = $this->registry->create(
'Author', array($name,
$url, $email));
12907 if (!empty($contributors))
12909 return array_unique($contributors);
12919 if (isset($links[$key]))
12921 return $links[$key];
12935 if (!isset($this->data[
'links']))
12937 $this->data[
'links'] = array();
12940 foreach ($links as $link)
12942 if (isset($link[
'attribs'][
''][
'href']))
12944 $link_rel = (isset($link[
'attribs'][
''][
'rel'])) ? $link[
'attribs'][
''][
'rel'] :
'alternate';
12951 foreach ($links as $link)
12953 if (isset($link[
'attribs'][
''][
'href']))
12955 $link_rel = (isset($link[
'attribs'][
''][
'rel'])) ? $link[
'attribs'][
''][
'rel'] :
'alternate';
12972 $keys = array_keys($this->data[
'links']);
12973 foreach ($keys as $key)
12975 if ($this->registry->call(
'Misc',
'is_isegment_nz_nc', array($key)))
12989 $this->data[
'links'][substr($key, 41)] =& $this->data[
'links'][$key];
12991 $this->data[
'links'][$key] = array_unique($this->data[
'links'][$key]);
12994 if (isset($this->data[
'links'][$rel]))
12996 return $this->data[
'links'][$rel];
13007 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
13011 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
13050 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_10_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
13054 return $this->
sanitize($return[0][
'data'], $this->registry->call(
'Misc',
'atom_03_construct_type', array($return[0][
'attribs'])), $this->
get_base($return[0]));
13087 elseif (isset($this->data[
'xml_lang']))
13100 return (
float) $return[0][
'data'];
13104 return (
float)
$match[1];
13115 return (
float) $return[0][
'data'];
13119 return (
float) $return[0][
'data'];
13123 return (
float)
$match[2];
13169 $this->data =
$data;
13170 $this->data_length = strlen($this->data);
13175 while ($this->state && $this->state !==
'emit' && $this->
has_data())
13181 if ($this->state ===
'emit')
13187 $this->version =
'';
13188 $this->encoding =
'';
13189 $this->standalone =
'';
13201 $whitespace = strspn($this->data,
"\x09\x0A\x0D\x20", $this->position);
13202 $this->position += $whitespace;
13203 return $whitespace;
13208 $quote = substr($this->data, $this->position, 1);
13209 if ($quote ===
'"' || $quote ===
"'")
13212 $len = strcspn($this->data, $quote, $this->position);
13215 $value = substr($this->data, $this->position, $len);
13216 $this->position += $len + 1;
13226 $this->state =
'version_name';
13230 $this->state =
false;
13235 if (substr($this->data, $this->position, 7) ===
'version')
13237 $this->position += 7;
13239 $this->state =
'version_equals';
13243 $this->state =
false;
13248 if (substr($this->data, $this->position, 1) ===
'=')
13252 $this->state =
'version_value';
13256 $this->state =
false;
13261 if ($this->version = $this->
get_value())
13266 $this->state =
'encoding_name';
13270 $this->state =
'emit';
13275 $this->state =
false;
13280 if (substr($this->data, $this->position, 8) ===
'encoding')
13282 $this->position += 8;
13284 $this->state =
'encoding_equals';
13288 $this->state =
'standalone_name';
13293 if (substr($this->data, $this->position, 1) ===
'=')
13297 $this->state =
'encoding_value';
13301 $this->state =
false;
13306 if ($this->encoding = $this->
get_value())
13311 $this->state =
'standalone_name';
13315 $this->state =
'emit';
13320 $this->state =
false;
13325 if (substr($this->data, $this->position, 10) ===
'standalone')
13327 $this->position += 10;
13329 $this->state =
'standalone_equals';
13333 $this->state =
false;
13338 if (substr($this->data, $this->position, 1) ===
'=')
13342 $this->state =
'standalone_value';
13346 $this->state =
false;
13353 switch ($standalone)
13356 $this->standalone =
true;
13359 $this->standalone =
false;
13362 $this->state =
false;
13368 $this->state =
false;
13372 $this->state =
'emit';
13377 $this->state =
false;
const SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO
set_cache_location($location= './cache')
set_copyright_class($class= 'SimplePie_Copyright')
get_source_tags($namespace, $tag)
foreach(array('date1', 'date2', 'type', 'renewals', 'width') as $item) $data
const SIMPLEPIE_CONSTRUCT_NONE
const SIMPLEPIE_FILE_SOURCE_FSOCKOPEN
get_base($element=array())
set_caption_class($class= 'SimplePie_Caption')
tag_open($parser, $tag, $attributes)
set_registry(SimplePie_Registry $registry)
set_url_replacements($element_attribute=null)
strip_comments($strip=false)
static silence_errors($num, $str)
const SIMPLEPIE_NAMESPACE_MEDIARSS
strip_htmltags($tags=array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'))
static fix_protocol($url, $http=1)
const SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
remove_dot_segments($input)
const SIMPLEPIE_NAMESPACE_RSS_10
static sort_items($a, $b)
const SIMPLEPIE_CONSTRUCT_BASE64
get_content($content_only=false)
const SIMPLEPIE_TYPE_RSS_092
get_item_tags($namespace, $tag)
get_base($element=array())
const SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3
static atom_03_construct_type($attribs)
sanitize($data, $type, $base= '')
const SIMPLEPIE_NAMESPACE_DC_11
get_link($key=0, $rel= 'alternate')
set_authority($authority)
static get_element($realname, $string)
strip_attributes($attribs= '')
& create($type, $parameters=array())
__construct($location, $name, $type)
get_links($rel= 'alternate')
__construct($name=null, $link=null, $email=null)
const SIMPLEPIE_LOCATOR_ALL
const SIMPLEPIE_LOCATOR_AUTODISCOVERY
static absolutize_url($relative, $base)
get_local_date($date_format= '%c')
if($rub=fetch_assoc($rub_query)) if(check_if_module_active('url_rewriting')) $class
encode_instead_of_strip($enable=true)
const SIMPLEPIE_NAMESPACE_RSS_090
set_registry(SimplePie_Registry $registry)
__construct($item, $data)
const SIMPLEPIE_NAMESPACE_RSS_20
set_item_class($class= 'SimplePie_Item')
set_output_encoding($encoding= 'UTF-8')
const SIMPLEPIE_TYPE_RSS_10
static change_encoding_mbstring($data, $input, $output)
set_cache_duration($seconds=3600)
set_url_replacements($element_attribute=null)
$autodiscovery_cache_duration
static entities_decode($data)
if(!select_db($_SESSION['session_install_choixbase'], $GLOBALS['database_object'], true)) $error
__construct($type=null, $lang=null, $startTime=null, $endTime=null, $text=null)
get_links($rel= 'alternate')
get_link($key=0, $rel= 'alternate')
const SIMPLEPIE_TYPE_ATOM_10
set_max_checked_feeds($max=10)
get_link($key=0, $rel= 'alternate')
pass_cache_data($enable_cache=true, $cache_location= './cache', $cache_name_function= 'md5', $cache_class= 'SimplePie_Cache')
get_item_quantity($max=0)
const SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS
sanitize($data, $type, $base= '')
set_input_encoding($encoding=false)
const SIMPLEPIE_TYPE_RSS_SYNDICATION
set_output_encoding($encoding= 'UTF-8')
set_registry(SimplePie_Registry $registry)
const SIMPLEPIE_LOCATOR_NONE
const SIMPLEPIE_TYPE_RSS_093
static percent_encoding_normalization($match)
static compress_parse_url($scheme= '', $authority= '', $path= '', $query= '', $fragment= '')
search_elements_by_tag($name, &$done, $feeds)
remove_iunreserved_percent_encoded($match)
set_image_handler($page=false, $qs= 'i')
set_source_class($class= 'SimplePie_Source')
static uncomment_rfc822($string)
set_autodiscovery_cache_duration($seconds=604800)
set_registry(SimplePie_Registry $registry)
static space_seperated_tokens($string)
create($location, $filename, $extension)
const SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5
set_locator_class($class= 'SimplePie_Locator')
const SIMPLEPIE_TYPE_NONE
native_embed($options='')
encode_instead_of_strip($encode=false)
const SIMPLEPIE_PCRE_XML_ATTRIBUTE
const SIMPLEPIE_FILE_SOURCE_NONE
get_date($date_format= 'j F Y, g:i a')
set_restriction_class($class= 'SimplePie_Restriction')
const SIMPLEPIE_TYPE_RSS_090
const SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG
const SIMPLEPIE_FILE_SOURCE_REMOTE
static time_hms($seconds)
__construct($url, $timeout=10, $redirects=5, $headers=null, $useragent=null, $force_fsockopen=false)
set_cache_class($class= 'SimplePie_Cache')
static error($message, $level, $file, $line)
static absolutize($base, $relative)
const SIMPLEPIE_CONSTRUCT_TEXT
find($type=SIMPLEPIE_LOCATOR_ALL, &$working)
const SIMPLEPIE_TYPE_ATOM_ALL
const SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
static normalize_url($url)
get_links($rel= 'alternate')
set_autodiscovery_level($level=SIMPLEPIE_LOCATOR_ALL)
force_fsockopen($enable=false)
__construct($location, $name, $type)
const SIMPLEPIE_CONSTRUCT_MAYBE_HTML
strip_tag($tag, $document, $type)
enable_order_by_date($enable=true)
replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate=false)
__construct($location, $name, $type)
get_real_type($find_handler=false)
static atom_10_construct_type($attribs)
get_description($description_only=false)
const SIMPLEPIE_TYPE_RSS_20
const SIMPLEPIE_LOCATOR_REMOTE_BODY
const SIMPLEPIE_NAMESPACE_RDF
const SIMPLEPIE_FILE_SOURCE_CURL
set_enclosure_class($class= 'SimplePie_Enclosure')
const SIMPLEPIE_NAMESPACE_ATOM_03
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
enable_cache($enable=true)
get_base($element=array())
handle_content_type($mime= 'text/html')
static get_curl_version()
static encoding($charset)
set_favicon_handler($page=false, $qs= 'i')
const SIMPLEPIE_FILE_SOURCE_LOCAL
static merge_items($urls, $start=0, $end=0, $limit=0)
static get_handler($location, $filename, $extension)
get_items($start=0, $end=0)
get_image_tags($namespace, $tag)
__construct(SimplePie_File $file, $timeout=10, $useragent=null, $max_checked_feeds=10)
const SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY
__construct($role=null, $scheme=null, $name=null)
do_strip_htmltags($match)
set_parser_class($class= 'SimplePie_Parser')
strip_attr($attrib, $document)
static xml_encoding($data, $registry)
const SIMPLEPIE_CONSTRUCT_IRI
const SIMPLEPIE_TYPE_RSS_091
set_credit_class($class= 'SimplePie_Credit')
strip_htmltags($tags= '', $encode=null)
pass_file_data($file_class= 'SimplePie_File', $timeout=10, $useragent= '', $force_fsockopen=false)
__construct($relationship=null, $type=null, $value=null)
__construct($scheme=null, $value=null)
set_image_handler($page=false)
__construct($link=null, $type=null, $length=null, $javascript=null, $bitrate=null, $captions=null, $categories=null, $channels=null, $copyright=null, $credits=null, $description=null, $duration=null, $expression=null, $framerate=null, $hashes=null, $height=null, $keywords=null, $lang=null, $medium=null, $player=null, $ratings=null, $restrictions=null, $samplingrate=null, $thumbnails=null, $title=null, $width=null)
replace_urls($document, $tag, $attributes)
__construct($term=null, $scheme=null, $label=null)
const SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2
const SIMPLEPIE_LOCATOR_LOCAL_BODY
const SIMPLEPIE_TYPE_ATOM_03
const SIMPLEPIE_PCRE_HTML_ATTRIBUTE
const SIMPLEPIE_TYPE_RSS_091_NETSCAPE
const SIMPLEPIE_NAMESPACE_XHTML
__construct($feed, $data)
const SIMPLEPIE_NAMESPACE_ATOM_10
& call($type, $method, $parameters=array())
const SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4
set_file_class($class= 'SimplePie_File')
static change_encoding_iconv($data, $input, $output)
const SIMPLEPIE_USERAGENT
const SIMPLEPIE_CONSTRUCT_HTML
get_channel_tags($namespace, $tag)
const SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT
static atom_10_content_construct_type($attribs)
get_feed_tags($namespace, $tag)
static change_encoding($data, $input, $output)
set_useragent($ua=SIMPLEPIE_USERAGENT)
strip_attributes($attribs=array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
get_gmdate($date_format= 'j F Y, g:i a')
static prepare_simplepie_object_for_cache($data)
set_registry(SimplePie_Registry $registry)
get_updated_gmdate($date_format= 'j F Y, g:i a')
set_sanitize_class($class= 'SimplePie_Sanitize')
const SIMPLEPIE_TYPE_RSS_RDF
sanitize($data, $type, $base= '')
__construct($url=null, $label=null)
get_duration($convert=false)
const SIMPLEPIE_CONSTRUCT_XHTML
set_category_class($class= 'SimplePie_Category')
embed($options= '', $native=false)
remove_rfc2822_comments($string)
set_stupidly_fast($set=false)
get_updated_date($date_format= 'j F Y, g:i a')
static strip_comments($data)
get_all_discovered_feeds()
force_feed($enable=false)
static element_implode($element)
const SIMPLEPIE_TYPE_RSS_091_USERLAND
set_author_class($class= 'SimplePie_Author')
set_rating_class($class= 'SimplePie_Rating')
set_content_type_sniffer_class($class= 'SimplePie_Content_Type_Sniffer')
strip_comments($strip=false)
sanitize($data, $type, $base= '')
static windows_1252_to_utf8($string)
get_enclosure($key=0, $prefer=null)
set_cache_name_function($function= 'md5')
const SIMPLEPIE_NAMESPACE_XML
const SIMPLEPIE_TYPE_RSS_ALL
const SIMPLEPIE_TYPE_RSS_094
__construct($location, $name, $type)
static output_javascript()
static codepoint_to_utf8($codepoint)
const SIMPLEPIE_NAMESPACE_DC_10
static is_isegment_nz_nc($string)
const SIMPLEPIE_NAMESPACE_ITUNES
const SIMPLEPIE_NAMESPACE_GEORSS