Ticket #36669: SimplePie-1.5.2.diff
File SimplePie-1.5.2.diff, 120.1 KB (added by , 6 years ago) |
---|
-
SimplePie/Author.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 114 113 { 115 114 return $this->name; 116 115 } 117 else 118 { 119 return null; 120 } 116 117 return null; 121 118 } 122 119 123 120 /** … … 131 128 { 132 129 return $this->link; 133 130 } 134 else 135 { 136 return null; 137 } 131 132 return null; 138 133 } 139 134 140 135 /** … … 148 143 { 149 144 return $this->email; 150 145 } 151 else 152 { 153 return null; 154 } 146 147 return null; 155 148 } 156 149 } 157 -
SimplePie/Cache/Base.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue -
SimplePie/Cache/DB.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue -
SimplePie/Cache/File.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 136 135 */ 137 136 public function mtime() 138 137 { 139 if (file_exists($this->name)) 140 { 141 return filemtime($this->name); 142 } 143 return false; 138 return @filemtime($this->name); 144 139 } 145 140 146 141 /** … … 150 145 */ 151 146 public function touch() 152 147 { 153 if (file_exists($this->name)) 154 { 155 return touch($this->name); 156 } 157 return false; 148 return @touch($this->name); 158 149 } 159 150 160 151 /** -
SimplePie/Cache/Memcache.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 95 94 'prefix' => 'simplepie_', 96 95 ), 97 96 ); 98 $parsed = SimplePie_Cache::parse_URL($location); 99 $this->options['host'] = empty($parsed['host']) ? $this->options['host'] : $parsed['host']; 100 $this->options['port'] = empty($parsed['port']) ? $this->options['port'] : $parsed['port']; 101 $this->options['extras'] = array_merge($this->options['extras'], $parsed['extras']); 97 $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); 98 102 99 $this->name = $this->options['extras']['prefix'] . md5("$name:$type"); 103 100 104 101 $this->cache = new Memcache(); … … 147 144 148 145 if ($data !== false) 149 146 { 150 // essentially ignore the mtime because Memcache expires on it 's own147 // essentially ignore the mtime because Memcache expires on its own 151 148 return time(); 152 149 } 153 150 … … 165 162 166 163 if ($data !== false) 167 164 { 168 return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this-> duration);165 return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this->options['extras']['timeout']); 169 166 } 170 167 171 168 return false; -
SimplePie/Cache/MySQL.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 94 93 'path' => '', 95 94 'extras' => array( 96 95 'prefix' => '', 96 'cache_purge_time' => 2592000 97 97 ), 98 98 ); 99 $this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));100 99 100 $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); 101 101 102 // Path is prefixed with a "/" 102 103 $this->options['dbname'] = substr($this->options['path'], 1); 103 104 … … 130 131 $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)))'); 131 132 if ($query === false) 132 133 { 134 trigger_error("Can't create " . $this->options['extras']['prefix'] . "cache_data table, check permissions", E_USER_WARNING); 133 135 $this->mysql = null; 136 return; 134 137 } 135 138 } 136 139 137 140 if (!in_array($this->options['extras']['prefix'] . 'items', $db)) 138 141 { 139 $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 utf8NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');142 $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` MEDIUMBLOB NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'); 140 143 if ($query === false) 141 144 { 145 trigger_error("Can't create " . $this->options['extras']['prefix'] . "items table, check permissions", E_USER_WARNING); 142 146 $this->mysql = null; 147 return; 143 148 } 144 149 } 145 150 } … … 157 162 return false; 158 163 } 159 164 165 $query = $this->mysql->prepare('DELETE i, cd FROM `' . $this->options['extras']['prefix'] . 'cache_data` cd, ' . 166 '`' . $this->options['extras']['prefix'] . 'items` i ' . 167 'WHERE cd.id = i.feed_id ' . 168 'AND cd.mtime < (unix_timestamp() - :purge_time)'); 169 $query->bindValue(':purge_time', $this->options['extras']['cache_purge_time']); 170 171 if (!$query->execute()) 172 { 173 return false; 174 } 175 160 176 if ($data instanceof SimplePie) 161 177 { 162 178 $data = clone $data; … … 379 395 { 380 396 return $time; 381 397 } 382 else 383 { 384 return false; 385 } 398 399 return false; 386 400 } 387 401 388 402 /** … … 400 414 $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `mtime` = :time WHERE `id` = :id'); 401 415 $query->bindValue(':time', time()); 402 416 $query->bindValue(':id', $this->id); 403 if ($query->execute() && $query->rowCount() > 0) 404 { 405 return true; 406 } 407 else 408 { 409 return false; 410 } 417 418 return $query->execute() && $query->rowCount() > 0; 411 419 } 412 420 413 421 /** … … 426 434 $query->bindValue(':id', $this->id); 427 435 $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id'); 428 436 $query2->bindValue(':id', $this->id); 429 if ($query->execute() && $query2->execute()) 430 { 431 return true; 432 } 433 else 434 { 435 return false; 436 } 437 438 return $query->execute() && $query2->execute(); 437 439 } 438 440 } -
SimplePie/Cache.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 62 61 * @var array 63 62 */ 64 63 protected static $handlers = array( 65 'mysql' => 'SimplePie_Cache_MySQL', 66 'memcache' => 'SimplePie_Cache_Memcache', 64 'mysql' => 'SimplePie_Cache_MySQL', 65 'memcache' => 'SimplePie_Cache_Memcache', 66 'memcached' => 'SimplePie_Cache_Memcached', 67 'redis' => 'SimplePie_Cache_Redis' 67 68 ); 68 69 69 70 /** -
SimplePie/Caption.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 132 131 { 133 132 return $this->endTime; 134 133 } 135 else 136 { 137 return null; 138 } 134 135 return null; 139 136 } 140 137 141 138 /** … … 150 147 { 151 148 return $this->lang; 152 149 } 153 else 154 { 155 return null; 156 } 150 151 return null; 157 152 } 158 153 159 154 /** … … 167 162 { 168 163 return $this->startTime; 169 164 } 170 else 171 { 172 return null; 173 } 165 166 return null; 174 167 } 175 168 176 169 /** … … 184 177 { 185 178 return $this->text; 186 179 } 187 else 188 { 189 return null; 190 } 180 181 return null; 191 182 } 192 183 193 184 /** … … 201 192 { 202 193 return $this->type; 203 194 } 204 else 205 { 206 return null; 207 } 195 196 return null; 208 197 } 209 198 } 210 -
SimplePie/Category.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 57 56 /** 58 57 * Category identifier 59 58 * 60 * @var string 59 * @var string|null 61 60 * @see get_term 62 61 */ 63 62 var $term; … … 65 64 /** 66 65 * Categorization scheme identifier 67 66 * 68 * @var string 67 * @var string|null 69 68 * @see get_scheme() 70 69 */ 71 70 var $scheme; … … 73 72 /** 74 73 * Human readable label 75 74 * 76 * @var string 75 * @var string|null 77 76 * @see get_label() 78 77 */ 79 78 var $label; 80 79 81 80 /** 81 * Category type 82 * 83 * category for <category> 84 * subject for <dc:subject> 85 * 86 * @var string|null 87 * @see get_type() 88 */ 89 var $type; 90 91 /** 82 92 * Constructor, used to input the data 83 93 * 84 * @param string $term 85 * @param string $scheme 86 * @param string $label 94 * @param string|null $term 95 * @param string|null $scheme 96 * @param string|null $label 97 * @param string|null $type 87 98 */ 88 public function __construct($term = null, $scheme = null, $label = null )99 public function __construct($term = null, $scheme = null, $label = null, $type = null) 89 100 { 90 101 $this->term = $term; 91 102 $this->scheme = $scheme; 92 103 $this->label = $label; 104 $this->type = $type; 93 105 } 94 106 95 107 /** … … 110 122 */ 111 123 public function get_term() 112 124 { 113 if ($this->term !== null) 114 { 115 return $this->term; 116 } 117 else 118 { 119 return null; 120 } 125 return $this->term; 121 126 } 122 127 123 128 /** … … 127 132 */ 128 133 public function get_scheme() 129 134 { 130 if ($this->scheme !== null) 131 { 132 return $this->scheme; 133 } 134 else 135 { 136 return null; 137 } 135 return $this->scheme; 138 136 } 139 137 140 138 /** 141 139 * Get the human readable label 142 140 * 141 * @param bool $strict 143 142 * @return string|null 144 143 */ 145 public function get_label( )144 public function get_label($strict = false) 146 145 { 147 if ($this->label !== null)146 if ($this->label === null && $strict !== true) 148 147 { 149 return $this->label;150 }151 else152 {153 148 return $this->get_term(); 154 149 } 150 return $this->label; 155 151 } 152 153 /** 154 * Get the category type 155 * 156 * @return string|null 157 */ 158 public function get_type() 159 { 160 return $this->type; 161 } 156 162 } 157 163 -
SimplePie/Content/Type/Sniffer.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 121 120 { 122 121 return $return; 123 122 } 124 else 125 { 126 return $official; 127 } 123 124 return $official; 128 125 } 129 126 elseif ($official === 'text/html') 130 127 { 131 128 return $this->feed_or_html(); 132 129 } 133 else 134 { 135 return $official; 136 } 130 131 return $official; 137 132 } 138 else 139 { 140 return $this->unknown(); 141 } 133 134 return $this->unknown(); 142 135 } 143 136 144 137 /** … … 159 152 { 160 153 return 'application/octect-stream'; 161 154 } 162 else 163 { 164 return 'text/plain'; 165 } 155 156 return 'text/plain'; 166 157 } 167 158 168 159 /** … … 208 199 { 209 200 return 'image/vnd.microsoft.icon'; 210 201 } 211 else 212 { 213 return $this->text_or_binary(); 214 } 202 203 return $this->text_or_binary(); 215 204 } 216 205 217 206 /** … … 242 231 { 243 232 return 'image/vnd.microsoft.icon'; 244 233 } 245 else 246 { 247 return false; 248 } 234 235 return false; 249 236 } 250 237 251 238 /** … … 256 243 public function feed_or_html() 257 244 { 258 245 $len = strlen($this->file->body); 259 $pos = strspn($this->file->body, "\x09\x0A\x0D\x20 ");246 $pos = strspn($this->file->body, "\x09\x0A\x0D\x20\xEF\xBB\xBF"); 260 247 261 248 while ($pos < $len) 262 249 { … … 329 316 return 'text/html'; 330 317 } 331 318 } 332 -
SimplePie/Copyright.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 104 103 { 105 104 return $this->url; 106 105 } 107 else 108 { 109 return null; 110 } 106 107 return null; 111 108 } 112 109 113 110 /** … … 121 118 { 122 119 return $this->label; 123 120 } 124 else 125 { 126 return null; 127 } 121 122 return null; 128 123 } 129 124 } 130 -
SimplePie/Core.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-20 09, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue -
SimplePie/Credit.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 113 112 { 114 113 return $this->role; 115 114 } 116 else 117 { 118 return null; 119 } 115 116 return null; 120 117 } 121 118 122 119 /** … … 130 127 { 131 128 return $this->scheme; 132 129 } 133 else 134 { 135 return null; 136 } 130 131 return null; 137 132 } 138 133 139 134 /** … … 147 142 { 148 143 return $this->name; 149 144 } 150 else 151 { 152 return null; 153 } 145 146 return null; 154 147 } 155 148 } 156 -
SimplePie/Decode/HTML/Entities.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 118 117 $this->consumed .= $this->data[$this->position]; 119 118 return $this->data[$this->position++]; 120 119 } 121 else 122 { 123 return false; 124 } 120 121 return false; 125 122 } 126 123 127 124 /** … … 140 137 $this->position += $len; 141 138 return $data; 142 139 } 143 else 144 { 145 return false; 146 } 140 141 return false; 147 142 } 148 143 149 144 /** … … 169 164 case "\x09": 170 165 case "\x0A": 171 166 case "\x0B": 172 case "\x0B":173 167 case "\x0C": 174 168 case "\x20": 175 169 case "\x3C": … … 614 608 } 615 609 } 616 610 } 617 -
SimplePie/Enclosure.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 283 282 { 284 283 return $this->bitrate; 285 284 } 286 else 287 { 288 return null; 289 } 285 286 return null; 290 287 } 291 288 292 289 /** … … 302 299 { 303 300 return $captions[$key]; 304 301 } 305 else 306 { 307 return null; 308 } 302 303 return null; 309 304 } 310 305 311 306 /** … … 319 314 { 320 315 return $this->captions; 321 316 } 322 else 323 { 324 return null; 325 } 317 318 return null; 326 319 } 327 320 328 321 /** … … 338 331 { 339 332 return $categories[$key]; 340 333 } 341 else 342 { 343 return null; 344 } 334 335 return null; 345 336 } 346 337 347 338 /** … … 355 346 { 356 347 return $this->categories; 357 348 } 358 else 359 { 360 return null; 361 } 349 350 return null; 362 351 } 363 352 364 353 /** … … 372 361 { 373 362 return $this->channels; 374 363 } 375 else 376 { 377 return null; 378 } 364 365 return null; 379 366 } 380 367 381 368 /** … … 389 376 { 390 377 return $this->copyright; 391 378 } 392 else 393 { 394 return null; 395 } 379 380 return null; 396 381 } 397 382 398 383 /** … … 408 393 { 409 394 return $credits[$key]; 410 395 } 411 else 412 { 413 return null; 414 } 396 397 return null; 415 398 } 416 399 417 400 /** … … 425 408 { 426 409 return $this->credits; 427 410 } 428 else 429 { 430 return null; 431 } 411 412 return null; 432 413 } 433 414 434 415 /** … … 442 423 { 443 424 return $this->description; 444 425 } 445 else 446 { 447 return null; 448 } 426 427 return null; 449 428 } 450 429 451 430 /** 452 431 * Get the duration of the enclosure 453 432 * 454 * @param string$convert Convert seconds into hh:mm:ss433 * @param bool $convert Convert seconds into hh:mm:ss 455 434 * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found) 456 435 */ 457 436 public function get_duration($convert = false) … … 463 442 $time = SimplePie_Misc::time_hms($this->duration); 464 443 return $time; 465 444 } 466 else 467 { 468 return $this->duration; 469 } 445 446 return $this->duration; 470 447 } 471 else 472 { 473 return null; 474 } 448 449 return null; 475 450 } 476 451 477 452 /** … … 485 460 { 486 461 return $this->expression; 487 462 } 488 else 489 { 490 return 'full'; 491 } 463 464 return 'full'; 492 465 } 493 466 494 467 /** … … 520 493 { 521 494 return $this->framerate; 522 495 } 523 else 524 { 525 return null; 526 } 496 497 return null; 527 498 } 528 499 529 500 /** … … 550 521 { 551 522 return $hashes[$key]; 552 523 } 553 else 554 { 555 return null; 556 } 524 525 return null; 557 526 } 558 527 559 528 /** … … 567 536 { 568 537 return $this->hashes; 569 538 } 570 else 571 { 572 return null; 573 } 539 540 return null; 574 541 } 575 542 576 543 /** … … 584 551 { 585 552 return $this->height; 586 553 } 587 else 588 { 589 return null; 590 } 554 555 return null; 591 556 } 592 557 593 558 /** … … 602 567 { 603 568 return $this->lang; 604 569 } 605 else 606 { 607 return null; 608 } 570 571 return null; 609 572 } 610 573 611 574 /** … … 621 584 { 622 585 return $keywords[$key]; 623 586 } 624 else 625 { 626 return null; 627 } 587 588 return null; 628 589 } 629 590 630 591 /** … … 638 599 { 639 600 return $this->keywords; 640 601 } 641 else 642 { 643 return null; 644 } 602 603 return null; 645 604 } 646 605 647 606 /** … … 655 614 { 656 615 return $this->length; 657 616 } 658 else 659 { 660 return null; 661 } 617 618 return null; 662 619 } 663 620 664 621 /** … … 672 629 { 673 630 return urldecode($this->link); 674 631 } 675 else 676 { 677 return null; 678 } 632 633 return null; 679 634 } 680 635 681 636 /** … … 690 645 { 691 646 return $this->medium; 692 647 } 693 else 694 { 695 return null; 696 } 648 649 return null; 697 650 } 698 651 699 652 /** … … 708 661 { 709 662 return $this->player; 710 663 } 711 else 712 { 713 return null; 714 } 664 665 return null; 715 666 } 716 667 717 668 /** … … 727 678 { 728 679 return $ratings[$key]; 729 680 } 730 else 731 { 732 return null; 733 } 681 682 return null; 734 683 } 735 684 736 685 /** … … 744 693 { 745 694 return $this->ratings; 746 695 } 747 else 748 { 749 return null; 750 } 696 697 return null; 751 698 } 752 699 753 700 /** … … 763 710 { 764 711 return $restrictions[$key]; 765 712 } 766 else 767 { 768 return null; 769 } 713 714 return null; 770 715 } 771 716 772 717 /** … … 780 725 { 781 726 return $this->restrictions; 782 727 } 783 else 784 { 785 return null; 786 } 728 729 return null; 787 730 } 788 731 789 732 /** … … 797 740 { 798 741 return $this->samplingrate; 799 742 } 800 else 801 { 802 return null; 803 } 743 744 return null; 804 745 } 805 746 806 747 /** … … 815 756 { 816 757 return round($length/1048576, 2); 817 758 } 818 else 819 { 820 return null; 821 } 759 760 return null; 822 761 } 823 762 824 763 /** … … 834 773 { 835 774 return $thumbnails[$key]; 836 775 } 837 else 838 { 839 return null; 840 } 776 777 return null; 841 778 } 842 779 843 780 /** … … 851 788 { 852 789 return $this->thumbnails; 853 790 } 854 else 855 { 856 return null; 857 } 791 792 return null; 858 793 } 859 794 860 795 /** … … 868 803 { 869 804 return $this->title; 870 805 } 871 else 872 { 873 return null; 874 } 806 807 return null; 875 808 } 876 809 877 810 /** … … 886 819 { 887 820 return $this->type; 888 821 } 889 else 890 { 891 return null; 892 } 822 823 return null; 893 824 } 894 825 895 826 /** … … 903 834 { 904 835 return $this->width; 905 836 } 906 else 907 { 908 return null; 909 } 837 838 return null; 910 839 } 911 840 912 841 /** … … 942 871 * - `height` (integer): The height of the embedded media. Accepts any 943 872 * numeric pixel value (such as `360`) or `auto`. Defaults to `auto`, 944 873 * and it is recommended that you use this default. 945 * - `loop` (boolean): Do you want the media to loop when it s done?874 * - `loop` (boolean): Do you want the media to loop when it's done? 946 875 * Defaults to `false`. 947 876 * - `mediaplayer` (string): The location of the included 948 877 * `mediaplayer.swf` file. This allows for the playback of Flash Video … … 1366 1295 { 1367 1296 return 'mp3'; 1368 1297 } 1369 else 1370 { 1371 return null; 1372 } 1298 1299 return null; 1373 1300 } 1374 else 1375 { 1376 return $type; 1377 } 1301 1302 return $type; 1378 1303 } 1379 1304 } 1380 -
SimplePie/Exception.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.4-dev 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue -
SimplePie/File.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 64 63 var $redirects = 0; 65 64 var $error; 66 65 var $method = SIMPLEPIE_FILE_SOURCE_NONE; 66 var $permanent_url; 67 67 68 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false )68 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $curl_options = array()) 69 69 { 70 70 if (class_exists('idna_convert')) 71 71 { 72 72 $idn = new idna_convert(); 73 73 $parsed = SimplePie_Misc::parse_url($url); 74 $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);74 $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], NULL); 75 75 } 76 76 $this->url = $url; 77 $this->permanent_url = $url; 77 78 $this->useragent = $useragent; 78 79 if (preg_match('/^http(s)?:\/\//i', $url)) 79 80 { … … 102 103 curl_setopt($fp, CURLOPT_URL, $url); 103 104 curl_setopt($fp, CURLOPT_HEADER, 1); 104 105 curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); 106 curl_setopt($fp, CURLOPT_FAILONERROR, 1); 105 107 curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); 106 108 curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); 107 109 curl_setopt($fp, CURLOPT_REFERER, $url); … … 112 114 curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); 113 115 curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); 114 116 } 117 foreach ($curl_options as $curl_param => $curl_value) { 118 curl_setopt($fp, $curl_param, $curl_value); 119 } 115 120 116 121 $this->headers = curl_exec($fp); 117 122 if (curl_errno($fp) === 23 || curl_errno($fp) === 61) … … 126 131 } 127 132 else 128 133 { 129 $info = curl_getinfo($fp); 134 // Use the updated url provided by curl_getinfo after any redirects. 135 if ($info = curl_getinfo($fp)) { 136 $this->url = $info['url']; 137 } 130 138 curl_close($fp); 131 $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); 132 $this->headers = array_pop($this->headers); 139 $this->headers = SimplePie_HTTP_Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1); 133 140 $parser = new SimplePie_HTTP_Parser($this->headers); 134 141 if ($parser->parse()) 135 142 { 136 143 $this->headers = $parser->headers; 137 $this->body = $parser->body;144 $this->body = trim($parser->body); 138 145 $this->status_code = $parser->status_code; 139 146 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) 140 147 { 141 148 $this->redirects++; 142 149 $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); 143 return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 150 $previousStatusCode = $this->status_code; 151 $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 152 $this->permanent_url = ($previousStatusCode == 301) ? $location : $url; 153 return; 144 154 } 145 155 } 146 156 } … … 222 232 { 223 233 $this->redirects++; 224 234 $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); 225 return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 235 $previousStatusCode = $this->status_code; 236 $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 237 $this->permanent_url = ($previousStatusCode == 301) ? $location : $url; 238 return; 226 239 } 227 240 if (isset($this->headers['content-encoding'])) 228 241 { … … 239 252 } 240 253 else 241 254 { 242 $this->body = $decoder->data;255 $this->body = trim($decoder->data); 243 256 } 244 257 break; 245 258 … … 282 295 else 283 296 { 284 297 $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; 285 if ( !$this->body = file_get_contents($url))298 if (empty($url) || !($this->body = trim(file_get_contents($url)))) 286 299 { 287 300 $this->error = 'file_get_contents could not read the file'; 288 301 $this->success = false; -
SimplePie/HTTP/Parser.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 156 155 { 157 156 return true; 158 157 } 159 else 160 { 161 $this->http_version = ''; 162 $this->status_code = ''; 163 $this->reason = ''; 164 $this->headers = array(); 165 $this->body = ''; 166 return false; 167 } 158 159 $this->http_version = ''; 160 $this->status_code = ''; 161 $this->reason = ''; 162 $this->headers = array(); 163 $this->body = ''; 164 return false; 168 165 } 169 166 170 167 /** … … 497 494 } 498 495 } 499 496 } 497 498 /** 499 * Prepare headers (take care of proxies headers) 500 * 501 * @param string $headers Raw headers 502 * @param integer $count Redirection count. Default to 1. 503 * 504 * @return string 505 */ 506 static public function prepareHeaders($headers, $count = 1) 507 { 508 $data = explode("\r\n\r\n", $headers, $count); 509 $data = array_pop($data); 510 if (false !== stripos($data, "HTTP/1.0 200 Connection established\r\n\r\n")) { 511 $data = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $data); 512 } 513 if (false !== stripos($data, "HTTP/1.1 200 Connection established\r\n\r\n")) { 514 $data = str_ireplace("HTTP/1.1 200 Connection established\r\n\r\n", '', $data); 515 } 516 return $data; 517 } 500 518 } -
SimplePie/IRI.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 212 211 { 213 212 return $this->normalization[$this->scheme][$name]; 214 213 } 215 else 216 { 217 return $return; 218 } 214 215 return $return; 219 216 } 220 217 221 218 /** … … 226 223 */ 227 224 public function __isset($name) 228 225 { 229 if (method_exists($this, 'get_' . $name) || isset($this->$name)) 230 { 231 return true; 232 } 233 else 234 { 235 return false; 236 } 226 return method_exists($this, 'get_' . $name) || isset($this->$name); 237 227 } 238 228 239 229 /** … … 260 250 } 261 251 262 252 /** 253 * Clean up 254 */ 255 public function __destruct() { 256 $this->set_iri(null, true); 257 $this->set_path(null, true); 258 $this->set_authority(null, true); 259 } 260 261 /** 263 262 * Create a new IRI object by resolving a relative IRI 264 263 * 265 264 * Returns false if $base is not absolute, otherwise an IRI. … … 348 347 $target->scheme_normalization(); 349 348 return $target; 350 349 } 351 else 352 { 353 return false; 354 } 350 351 return false; 355 352 } 356 353 } 357 354 … … 388 385 } 389 386 return $match; 390 387 } 391 else 392 { 393 // This can occur when a paragraph is accidentally parsed as a URI 394 return false; 395 } 388 389 // This can occur when a paragraph is accidentally parsed as a URI 390 return false; 396 391 } 397 392 398 393 /** … … 768 763 */ 769 764 public function is_valid() 770 765 { 771 $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; 772 if ($this->ipath !== '' && 773 ( 774 $isauthority && ( 775 $this->ipath[0] !== '/' || 776 substr($this->ipath, 0, 2) === '//' 777 ) || 778 ( 779 $this->scheme === null && 780 !$isauthority && 781 strpos($this->ipath, ':') !== false && 782 (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) 783 ) 784 ) 785 ) 786 { 787 return false; 788 } 766 if ($this->ipath === '') return true; 789 767 768 $isauthority = $this->iuserinfo !== null || $this->ihost !== null || 769 $this->port !== null; 770 if ($isauthority && $this->ipath[0] === '/') return true; 771 772 if (!$isauthority && (substr($this->ipath, 0, 2) === '//')) return false; 773 774 // Relative urls cannot have a colon in the first path segment (and the 775 // slashes themselves are not included so skip the first character). 776 if (!$this->scheme && !$isauthority && 777 strpos($this->ipath, ':') !== false && 778 strpos($this->ipath, '/', 1) !== false && 779 strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false; 780 790 781 return true; 791 782 } 792 783 … … 797 788 * @param string $iri 798 789 * @return bool 799 790 */ 800 public function set_iri($iri )791 public function set_iri($iri, $clear_cache = false) 801 792 { 802 793 static $cache; 794 if ($clear_cache) 795 { 796 $cache = null; 797 return; 798 } 803 799 if (!$cache) 804 800 { 805 801 $cache = array(); … … 821 817 $return) = $cache[$iri]; 822 818 return $return; 823 819 } 824 else 820 821 $parsed = $this->parse_iri((string) $iri); 822 if (!$parsed) 825 823 { 826 $parsed = $this->parse_iri((string) $iri); 827 if (!$parsed) 828 { 829 return false; 830 } 824 return false; 825 } 831 826 832 833 834 835 836 827 $return = $this->set_scheme($parsed['scheme']) 828 && $this->set_authority($parsed['authority']) 829 && $this->set_path($parsed['path']) 830 && $this->set_query($parsed['query']) 831 && $this->set_fragment($parsed['fragment']); 837 832 838 $cache[$iri] = array($this->scheme, 839 $this->iuserinfo, 840 $this->ihost, 841 $this->port, 842 $this->ipath, 843 $this->iquery, 844 $this->ifragment, 845 $return); 846 return $return; 847 } 833 $cache[$iri] = array($this->scheme, 834 $this->iuserinfo, 835 $this->ihost, 836 $this->port, 837 $this->ipath, 838 $this->iquery, 839 $this->ifragment, 840 $return); 841 return $return; 848 842 } 849 843 850 844 /** … … 879 873 * @param string $authority 880 874 * @return bool 881 875 */ 882 public function set_authority($authority )876 public function set_authority($authority, $clear_cache = false) 883 877 { 884 878 static $cache; 879 if ($clear_cache) 880 { 881 $cache = null; 882 return; 883 } 885 884 if (!$cache) 886 885 $cache = array(); 887 886 … … 901 900 902 901 return $return; 903 902 } 903 904 $remaining = $authority; 905 if (($iuserinfo_end = strrpos($remaining, '@')) !== false) 906 { 907 $iuserinfo = substr($remaining, 0, $iuserinfo_end); 908 $remaining = substr($remaining, $iuserinfo_end + 1); 909 } 904 910 else 905 911 { 906 $remaining = $authority; 907 if (($iuserinfo_end = strrpos($remaining, '@')) !== false) 912 $iuserinfo = null; 913 } 914 if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) 915 { 916 if (($port = substr($remaining, $port_start + 1)) === false) 908 917 { 909 $iuserinfo = substr($remaining, 0, $iuserinfo_end);910 $remaining = substr($remaining, $iuserinfo_end + 1);911 }912 else913 {914 $iuserinfo = null;915 }916 if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false)917 {918 if (($port = substr($remaining, $port_start + 1)) === false)919 {920 $port = null;921 }922 $remaining = substr($remaining, 0, $port_start);923 }924 else925 {926 918 $port = null; 927 919 } 920 $remaining = substr($remaining, 0, $port_start); 921 } 922 else 923 { 924 $port = null; 925 } 928 926 929 930 931 927 $return = $this->set_userinfo($iuserinfo) && 928 $this->set_host($remaining) && 929 $this->set_port($port); 932 930 933 934 935 936 931 $cache[$authority] = array($this->iuserinfo, 932 $this->ihost, 933 $this->port, 934 $return); 937 935 938 return $return; 939 } 936 return $return; 940 937 } 941 938 942 939 /** … … 1036 1033 $this->scheme_normalization(); 1037 1034 return true; 1038 1035 } 1039 else 1040 { 1041 $this->port = null; 1042 return false; 1043 } 1036 1037 $this->port = null; 1038 return false; 1044 1039 } 1045 1040 1046 1041 /** … … 1049 1044 * @param string $ipath 1050 1045 * @return bool 1051 1046 */ 1052 public function set_path($ipath )1047 public function set_path($ipath, $clear_cache = false) 1053 1048 { 1054 1049 static $cache; 1050 if ($clear_cache) 1051 { 1052 $cache = null; 1053 return; 1054 } 1055 1055 if (!$cache) 1056 1056 { 1057 1057 $cache = array(); … … 1166 1166 { 1167 1167 $iri .= $this->ipath; 1168 1168 } 1169 1169 elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') 1170 1170 { 1171 1171 $iri .= $this->normalization[$this->scheme]['ipath']; 1172 1172 } … … 1210 1210 { 1211 1211 $iauthority .= $this->ihost; 1212 1212 } 1213 if ($this->port !== null)1213 if ($this->port !== null && $this->port !== 0) 1214 1214 { 1215 1215 $iauthority .= ':' . $this->port; 1216 1216 } 1217 1217 return $iauthority; 1218 1218 } 1219 else 1220 { 1221 return null; 1222 } 1219 1220 return null; 1223 1221 } 1224 1222 1225 1223 /** … … 1232 1230 $iauthority = $this->get_iauthority(); 1233 1231 if (is_string($iauthority)) 1234 1232 return $this->to_uri($iauthority); 1235 else 1236 1233 1234 return $iauthority; 1237 1235 } 1238 1236 } -
SimplePie/Item.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 148 147 { 149 148 return $this->data['child'][$namespace][$tag]; 150 149 } 151 else 152 { 153 return null; 154 } 150 151 return null; 155 152 } 156 153 157 154 /** … … 203 200 * 204 201 * Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute 205 202 * for RDF. If none of these are supplied (or `$hash` is true), creates an 206 * MD5 hash based on the permalink and title. If either of those are not 207 * supplied, creates a hash based on the full feed data. 203 * MD5 hash based on the permalink, title and content. 208 204 * 209 205 * @since Beta 2 210 206 * @param boolean $hash Should we force using a hash instead of the supplied ID? 211 * @return string 207 * @param string|false $fn User-supplied function to generate an hash 208 * @return string|null 212 209 */ 213 public function get_id($hash = false )210 public function get_id($hash = false, $fn = 'md5') 214 211 { 215 212 if (!$hash) 216 213 { … … 238 235 { 239 236 return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT); 240 237 } 241 elseif (($return = $this->get_permalink()) !== null)242 {243 return $return;244 }245 elseif (($return = $this->get_title()) !== null)246 {247 return $return;248 }249 238 } 250 if ($ this->get_permalink() !== null || $this->get_title() !== null)239 if ($fn === false) 251 240 { 252 return md5($this->get_permalink() . $this->get_title());241 return null; 253 242 } 254 else 243 elseif (!is_callable($fn)) 255 244 { 256 return md5(serialize($this->data)); 245 trigger_error('User-supplied function $fn must be callable', E_USER_WARNING); 246 $fn = 'md5'; 257 247 } 248 return call_user_func($fn, 249 $this->get_permalink().$this->get_title().$this->get_content()); 258 250 } 259 251 260 252 /** … … 322 314 */ 323 315 public function get_description($description_only = false) 324 316 { 325 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) 317 if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) && 318 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 326 319 { 327 return $ this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));320 return $return; 328 321 } 329 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) 322 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) && 323 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 330 324 { 331 return $ this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));325 return $return; 332 326 } 333 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) 327 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) && 328 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0])))) 334 329 { 335 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));330 return $return; 336 331 } 337 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) 332 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) && 333 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) 338 334 { 339 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));335 return $return; 340 336 } 341 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) 337 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) && 338 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) 342 339 { 343 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);340 return $return; 344 341 } 345 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) 342 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) && 343 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) 346 344 { 347 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);345 return $return; 348 346 } 349 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) 347 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) && 348 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) 350 349 { 351 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));350 return $return; 352 351 } 353 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) 352 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) && 353 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) 354 354 { 355 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);355 return $return; 356 356 } 357 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) 357 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) && 358 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML))) 358 359 { 359 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);360 return $return; 360 361 } 361 362 362 363 elseif (!$description_only) … … 363 364 { 364 365 return $this->get_content(true); 365 366 } 366 else 367 { 368 return null; 369 } 367 368 return null; 370 369 } 371 370 372 371 /** … … 385 384 */ 386 385 public function get_content($content_only = false) 387 386 { 388 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) 387 if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) && 388 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 389 389 { 390 return $ this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));390 return $return; 391 391 } 392 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) 392 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) && 393 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 393 394 { 394 return $ this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));395 return $return; 395 396 } 396 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) 397 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) && 398 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) 397 399 { 398 return $ this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));400 return $return; 399 401 } 400 402 elseif (!$content_only) 401 403 { 402 404 return $this->get_description(true); 403 405 } 404 else 406 407 return null; 408 } 409 410 /** 411 * Get the media:thumbnail of the item 412 * 413 * Uses `<media:thumbnail>` 414 * 415 * 416 * @return array|null 417 */ 418 public function get_thumbnail() 419 { 420 if (!isset($this->data['thumbnail'])) 405 421 { 406 return null; 422 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) 423 { 424 $this->data['thumbnail'] = $return[0]['attribs']['']; 425 } 426 else 427 { 428 $this->data['thumbnail'] = null; 429 } 407 430 } 431 return $this->data['thumbnail']; 408 432 } 409 433 410 434 /** … … 421 445 { 422 446 return $categories[$key]; 423 447 } 424 else 425 { 426 return null; 427 } 448 449 return null; 428 450 } 429 451 430 452 /** … … 433 455 * Uses `<atom:category>`, `<category>` or `<dc:subject>` 434 456 * 435 457 * @since Beta 3 436 * @return array|null List of {@see SimplePie_Category} objects458 * @return SimplePie_Category[]|null List of {@see SimplePie_Category} objects 437 459 */ 438 460 public function get_categories() 439 461 { 440 462 $categories = array(); 441 463 442 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) 464 $type = 'category'; 465 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, $type) as $category) 443 466 { 444 467 $term = null; 445 468 $scheme = null; … … 456 479 { 457 480 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 458 481 } 459 $categories[] = $this->registry->create('Category', array($term, $scheme, $label ));482 $categories[] = $this->registry->create('Category', array($term, $scheme, $label, $type)); 460 483 } 461 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)484 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, $type) as $category) 462 485 { 463 486 // This is really the label, but keep this as the term also for BC. 464 487 // Label will also work on retrieving because that falls back to term. … … 471 494 { 472 495 $scheme = null; 473 496 } 474 $categories[] = $this->registry->create('Category', array($term, $scheme, null ));497 $categories[] = $this->registry->create('Category', array($term, $scheme, null, $type)); 475 498 } 476 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) 499 500 $type = 'subject'; 501 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, $type) as $category) 477 502 { 478 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null ));503 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null, $type)); 479 504 } 480 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)505 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, $type) as $category) 481 506 { 482 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null ));507 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null, $type)); 483 508 } 484 509 485 510 if (!empty($categories)) … … 486 511 { 487 512 return array_unique($categories); 488 513 } 489 else 490 { 491 return null; 492 } 514 515 return null; 493 516 } 494 517 495 518 /** … … 506 529 { 507 530 return $authors[$key]; 508 531 } 509 else 510 { 511 return null; 512 } 532 533 return null; 513 534 } 514 535 515 536 /** … … 526 547 { 527 548 return $contributors[$key]; 528 549 } 529 else 530 { 531 return null; 532 } 550 551 return null; 533 552 } 534 553 535 554 /** … … 538 557 * Uses `<atom:contributor>` 539 558 * 540 559 * @since 1.1 541 * @return array|null List of {@see SimplePie_Author} objects560 * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects 542 561 */ 543 562 public function get_contributors() 544 563 { … … 592 611 { 593 612 return array_unique($contributors); 594 613 } 595 else 596 { 597 return null; 598 } 614 615 return null; 599 616 } 600 617 601 618 /** … … 604 621 * Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>` 605 622 * 606 623 * @since Beta 2 607 * @return array|null List of {@see SimplePie_Author} objects624 * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects 608 625 */ 609 626 public function get_authors() 610 627 { … … 682 699 { 683 700 return $authors; 684 701 } 685 else 686 { 687 return null; 688 } 702 703 return null; 689 704 } 690 705 691 706 /** … … 710 725 { 711 726 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 712 727 } 713 else 714 { 715 return null; 716 } 728 729 return null; 717 730 } 718 731 719 732 /** … … 738 751 { 739 752 $this->data['date']['raw'] = $return[0]['data']; 740 753 } 741 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ ATOM_10, 'updated'))754 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) 742 755 { 743 756 $this->data['date']['raw'] = $return[0]['data']; 744 757 } 745 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ ATOM_03, 'issued'))758 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) 746 759 { 747 760 $this->data['date']['raw'] = $return[0]['data']; 748 761 } 749 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ ATOM_03, 'created'))762 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) 750 763 { 751 764 $this->data['date']['raw'] = $return[0]['data']; 752 765 } 753 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_ 03, 'modified'))766 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) 754 767 { 755 768 $this->data['date']['raw'] = $return[0]['data']; 756 769 } 757 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ RSS_20, 'pubDate'))770 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) 758 771 { 759 772 $this->data['date']['raw'] = $return[0]['data']; 760 773 } 761 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ DC_11, 'date'))774 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) 762 775 { 763 776 $this->data['date']['raw'] = $return[0]['data']; 764 777 } 765 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ DC_10, 'date'))778 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) 766 779 { 767 780 $this->data['date']['raw'] = $return[0]['data']; 768 781 } … … 792 805 return date($date_format, $this->data['date']['parsed']); 793 806 } 794 807 } 795 else 796 { 797 return null; 798 } 808 809 return null; 799 810 } 800 811 801 812 /** … … 821 832 if (!empty($this->data['updated']['raw'])) 822 833 { 823 834 $parser = $this->registry->call('Parse_Date', 'get'); 824 $this->data['updated']['parsed'] = $parser->parse($this->data[' date']['raw']);835 $this->data['updated']['parsed'] = $parser->parse($this->data['updated']['raw']); 825 836 } 826 837 else 827 838 { … … 843 854 return date($date_format, $this->data['updated']['parsed']); 844 855 } 845 856 } 846 else 847 { 848 return null; 849 } 857 858 return null; 850 859 } 851 860 852 861 /** … … 872 881 { 873 882 return strftime($date_format, $date); 874 883 } 875 else 876 { 877 return null; 878 } 884 885 return null; 879 886 } 880 887 881 888 /** … … 936 943 { 937 944 return $enclosure->get_link(); 938 945 } 939 else 940 { 941 return null; 942 } 946 947 return null; 943 948 } 944 949 945 950 /** … … 957 962 { 958 963 return $links[$key]; 959 964 } 960 else 961 { 962 return null; 963 } 965 966 return null; 964 967 } 965 968 966 969 /** … … 1040 1043 { 1041 1044 return $this->data['links'][$rel]; 1042 1045 } 1043 else 1044 { 1045 return null; 1046 } 1046 1047 return null; 1047 1048 } 1048 1049 1049 1050 /** … … 1063 1064 { 1064 1065 return $enclosures[$key]; 1065 1066 } 1066 else 1067 { 1068 return null; 1069 } 1067 1068 return null; 1070 1069 } 1071 1070 1072 1071 /** … … 1080 1079 * 1081 1080 * @since Beta 2 1082 1081 * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). 1083 * @todo If an element exists at a level, but it 's value is empty, we should fall back to the value from the parent (if it exists).1084 * @return array|null List of SimplePie_Enclosure items1082 * @todo If an element exists at a level, but its value is empty, we should fall back to the value from the parent (if it exists). 1083 * @return SimplePie_Enclosure[]|null List of SimplePie_Enclosure items 1085 1084 */ 1086 1085 public function get_enclosures() 1087 1086 { … … 2658 2657 // PLAYER 2659 2658 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 2660 2659 { 2661 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2660 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'])) { 2661 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2662 } 2662 2663 } 2663 2664 else 2664 2665 { … … 2733 2734 { 2734 2735 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 2735 2736 { 2736 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2737 if (isset($thumbnail['attribs']['']['url'])) { 2738 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2739 } 2737 2740 } 2738 2741 if (is_array($thumbnails)) 2739 2742 { … … 2789 2792 { 2790 2793 $length = ceil($link['attribs']['']['length']); 2791 2794 } 2795 if (isset($link['attribs']['']['title'])) 2796 { 2797 $title = $this->sanitize($link['attribs']['']['title'], SIMPLEPIE_CONSTRUCT_TEXT); 2798 } 2799 else 2800 { 2801 $title = $title_parent; 2802 } 2792 2803 2793 2804 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 2794 $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));2805 $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, $width)); 2795 2806 } 2796 2807 } 2797 2808 … … 2877 2888 { 2878 2889 return $this->data['enclosures']; 2879 2890 } 2880 else 2881 { 2882 return null; 2883 } 2891 2892 return null; 2884 2893 } 2885 2894 2886 2895 /** … … 2905 2914 { 2906 2915 return (float) $match[1]; 2907 2916 } 2908 else 2909 { 2910 return null; 2911 } 2917 2918 return null; 2912 2919 } 2913 2920 2914 2921 /** … … 2937 2944 { 2938 2945 return (float) $match[2]; 2939 2946 } 2940 else 2941 { 2942 return null; 2943 } 2947 2948 return null; 2944 2949 } 2945 2950 2946 2951 /** … … 2955 2960 { 2956 2961 return $this->registry->create('Source', array($this, $return[0])); 2957 2962 } 2958 else 2959 { 2960 return null; 2961 } 2963 2964 return null; 2962 2965 } 2963 2966 } 2964 -
SimplePie/Locator.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 63 62 var $base_location = 0; 64 63 var $checked_feeds = 0; 65 64 var $max_checked_feeds = 10; 65 var $force_fsockopen = false; 66 var $curl_options = array(); 66 67 protected $registry; 67 68 68 public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10 )69 public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10, $force_fsockopen = false, $curl_options = array()) 69 70 { 70 71 $this->file = $file; 71 72 $this->useragent = $useragent; 72 73 $this->timeout = $timeout; 73 74 $this->max_checked_feeds = $max_checked_feeds; 75 $this->force_fsockopen = $force_fsockopen; 76 $this->curl_options = $curl_options; 74 77 75 78 if (class_exists('DOMDocument')) 76 79 { … … 121 124 { 122 125 if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) 123 126 { 124 return $working ;127 return $working[0]; 125 128 } 126 129 127 130 if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) 128 131 { 129 return $working ;132 return $working[0]; 130 133 } 131 134 132 135 if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) 133 136 { 134 return $working ;137 return $working[0]; 135 138 } 136 139 137 140 if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) 138 141 { 139 return $working ;142 return $working[0]; 140 143 } 141 144 } 142 145 return null; 143 146 } 144 147 145 public function is_feed($file )148 public function is_feed($file, $check_html = false) 146 149 { 147 150 if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) 148 151 { 149 152 $sniffer = $this->registry->create('Content_Type_Sniffer', array($file)); 150 153 $sniffed = $sniffer->get_type(); 151 if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) 154 $mime_types = array('application/rss+xml', 'application/rdf+xml', 155 'text/rdf', 'application/atom+xml', 'text/xml', 156 'application/xml', 'application/x-rss+xml'); 157 if ($check_html) 152 158 { 153 return true;159 $mime_types[] = 'text/html'; 154 160 } 155 else 156 { 157 return false; 158 } 161 162 return in_array($sniffed, $mime_types); 159 163 } 160 164 elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) 161 165 { … … 204 208 { 205 209 return array_values($feeds); 206 210 } 207 else 208 { 209 return null; 210 } 211 212 return null; 211 213 } 212 214 213 215 protected function search_elements_by_tag($name, &$done, $feeds) … … 226 228 } 227 229 if ($link->hasAttribute('href') && $link->hasAttribute('rel')) 228 230 { 229 $rel = array_unique($this->registry->call('Misc', 'space_sep erated_tokens', array(strtolower($link->getAttribute('rel')))));231 $rel = array_unique($this->registry->call('Misc', 'space_separated_tokens', array(strtolower($link->getAttribute('rel'))))); 230 232 $line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1; 231 233 232 234 if ($this->base_location < $line) … … 242 244 continue; 243 245 } 244 246 245 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]))247 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('text/html', 'application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) 246 248 { 247 249 $this->checked_feeds++; 248 250 $headers = array( 249 251 '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', 250 252 ); 251 $feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent ));252 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 ))253 $feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options)); 254 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, true)) 253 255 { 254 256 $feeds[$href] = $feed; 255 257 } … … 275 277 { 276 278 $href = trim($link->getAttribute('href')); 277 279 $parsed = $this->registry->call('Misc', 'parse_url', array($href)); 278 if ($parsed['scheme'] === '' || preg_match('/^(http (s)|feed)?$/i', $parsed['scheme']))280 if ($parsed['scheme'] === '' || preg_match('/^(https?|feed)?$/i', $parsed['scheme'])) 279 281 { 280 282 if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo()) 281 283 { … … 312 314 return null; 313 315 } 314 316 317 public function get_rel_link($rel) 318 { 319 if ($this->dom === null) 320 { 321 throw new SimplePie_Exception('DOMDocument not found, unable to use '. 322 'locator'); 323 } 324 if (!class_exists('DOMXpath')) 325 { 326 throw new SimplePie_Exception('DOMXpath not found, unable to use '. 327 'get_rel_link'); 328 } 329 330 $xpath = new DOMXpath($this->dom); 331 $query = '//a[@rel and @href] | //link[@rel and @href]'; 332 foreach ($xpath->query($query) as $link) 333 { 334 $href = trim($link->getAttribute('href')); 335 $parsed = $this->registry->call('Misc', 'parse_url', array($href)); 336 if ($parsed['scheme'] === '' || 337 preg_match('/^https?$/i', $parsed['scheme'])) 338 { 339 if (method_exists($link, 'getLineNo') && 340 $this->base_location < $link->getLineNo()) 341 { 342 $href = 343 $this->registry->call('Misc', 'absolutize_url', 344 array(trim($link->getAttribute('href')), 345 $this->base)); 346 } 347 else 348 { 349 $href = 350 $this->registry->call('Misc', 'absolutize_url', 351 array(trim($link->getAttribute('href')), 352 $this->http_base)); 353 } 354 if ($href === false) 355 { 356 return null; 357 } 358 $rel_values = explode(' ', strtolower($link->getAttribute('rel'))); 359 if (in_array($rel, $rel_values)) 360 { 361 return $href; 362 } 363 } 364 } 365 return null; 366 } 367 315 368 public function extension(&$array) 316 369 { 317 370 foreach ($array as $key => $value) … … 327 380 $headers = array( 328 381 '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', 329 382 ); 330 $feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent ));383 $feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options)); 331 384 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)) 332 385 { 333 return $feed;386 return array($feed); 334 387 } 335 388 else 336 389 { … … 355 408 $headers = array( 356 409 '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', 357 410 ); 358 $feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent ));411 $feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->curl_options)); 359 412 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)) 360 413 { 361 return $feed;414 return array($feed); 362 415 } 363 416 else 364 417 { … … 369 422 return null; 370 423 } 371 424 } 372 -
SimplePie/Misc.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 138 137 foreach ($element['attribs'] as $key => $value) 139 138 { 140 139 $key = strtolower($key); 141 $full .= " $key=\"" . htmlspecialchars($value['data'] ) . '"';140 $full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"'; 142 141 } 143 142 if ($element['self_closing']) 144 143 { … … 218 217 { 219 218 return substr_replace($url, 'itpc', 0, 4); 220 219 } 221 else 220 221 return $url; 222 } 223 224 public static function array_merge_recursive($array1, $array2) 225 { 226 foreach ($array2 as $key => $value) 222 227 { 223 return $url; 228 if (is_array($value)) 229 { 230 $array1[$key] = SimplePie_Misc::array_merge_recursive($array1[$key], $value); 231 } 232 else 233 { 234 $array1[$key] = $value; 235 } 224 236 } 237 238 return $array1; 225 239 } 226 240 227 241 public static function parse_url($url) … … 260 274 { 261 275 return chr($integer); 262 276 } 263 else 264 { 265 return strtoupper($match[0]); 266 } 277 278 return strtoupper($match[0]); 267 279 } 268 280 269 281 /** … … 317 329 { 318 330 return $return; 319 331 } 320 // This is last, as behaviour of this varies with OS userland and PHP version332 // This is third, as behaviour of this varies with OS userland and PHP version 321 333 elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output))) 322 334 { 323 335 return $return; 324 336 } 325 // If we can't do anything, just fail326 else 337 // This is last, as behaviour of this varies with OS userland and PHP version 338 elseif (class_exists('\UConverter') && ($return = SimplePie_Misc::change_encoding_uconverter($data, $input, $output))) 327 339 { 328 return false;340 return $return; 329 341 } 342 343 // If we can't do anything, just fail 344 return false; 330 345 } 331 346 332 347 protected static function change_encoding_mbstring($data, $input, $output) … … 373 388 } 374 389 375 390 /** 391 * @param string $data 392 * @param string $input 393 * @param string $output 394 * @return string|false 395 */ 396 protected static function change_encoding_uconverter($data, $input, $output) 397 { 398 return @\UConverter::transcode($data, $output, $input); 399 } 400 401 /** 376 402 * Normalize an encoding name 377 403 * 378 404 * This is automatically generated by create.php … … 1826 1852 { 1827 1853 return trim($mime); 1828 1854 } 1829 else 1830 { 1831 return trim(substr($mime, 0, $pos)); 1832 } 1855 1856 return trim(substr($mime, 0, $pos)); 1833 1857 } 1834 1858 1835 1859 public static function atom_03_construct_type($attribs) … … 1862 1886 return SIMPLEPIE_CONSTRUCT_NONE | $mode; 1863 1887 } 1864 1888 } 1865 else 1866 { 1867 return SIMPLEPIE_CONSTRUCT_TEXT | $mode; 1868 } 1889 1890 return SIMPLEPIE_CONSTRUCT_TEXT | $mode; 1869 1891 } 1870 1892 1871 1893 public static function atom_10_construct_type($attribs) … … 1915 1937 return SIMPLEPIE_CONSTRUCT_BASE64; 1916 1938 } 1917 1939 } 1918 else 1919 { 1920 return SIMPLEPIE_CONSTRUCT_TEXT; 1921 } 1940 1941 return SIMPLEPIE_CONSTRUCT_TEXT; 1922 1942 } 1923 1943 1924 1944 public static function is_isegment_nz_nc($string) … … 1926 1946 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); 1927 1947 } 1928 1948 1929 public static function space_sep erated_tokens($string)1949 public static function space_separated_tokens($string) 1930 1950 { 1931 1951 $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; 1932 1952 $string_length = strlen($string); … … 1975 1995 { 1976 1996 return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); 1977 1997 } 1978 else 1979 { 1980 // U+FFFD REPLACEMENT CHARACTER 1981 return "\xEF\xBF\xBD"; 1982 } 1998 1999 // U+FFFD REPLACEMENT CHARACTER 2000 return "\xEF\xBF\xBD"; 1983 2001 } 1984 2002 1985 2003 /** … … 2183 2201 { 2184 2202 return filemtime(dirname(__FILE__) . '/Core.php'); 2185 2203 } 2186 else 2187 { 2188 return filemtime(__FILE__); 2189 } 2204 2205 return filemtime(__FILE__); 2190 2206 } 2191 2207 2192 2208 /** … … 2244 2260 // No-op 2245 2261 } 2246 2262 } 2247 -
SimplePie/Net/IPv6.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 174 173 { 175 174 return implode(':', $ip_parts); 176 175 } 177 else 178 { 179 return $ip_parts[0]; 180 } 176 177 return $ip_parts[0]; 181 178 } 182 179 183 180 /** … … 201 198 $ipv4_part = substr($ip, $pos + 1); 202 199 return array($ipv6_part, $ipv4_part); 203 200 } 204 else 205 { 206 return array($ip, ''); 207 } 201 202 return array($ip, ''); 208 203 } 209 204 210 205 /** … … 254 249 } 255 250 return true; 256 251 } 257 else 258 { 259 return false; 260 } 252 253 return false; 261 254 } 262 255 263 256 /** -
SimplePie/Parse/Date.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 173 172 'aug' => 8, 174 173 'august' => 8, 175 174 'sep' => 9, 176 'september' => 8,175 'september' => 9, 177 176 'oct' => 10, 178 177 'october' => 10, 179 178 'nov' => 11, … … 614 613 * 615 614 * @final 616 615 * @access public 617 * @param call able$callback616 * @param callback $callback 618 617 */ 619 618 public function add_callback($callback) 620 619 { … … 631 630 /** 632 631 * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as 633 632 * well as allowing any of upper or lower case "T", horizontal tabs, or 634 * spaces to be used as the time sep erator (including more than one))633 * spaces to be used as the time separator (including more than one)) 635 634 * 636 635 * @access protected 637 636 * @return int Timestamp … … 691 690 } 692 691 693 692 // Convert the number of seconds to an integer, taking decimals into account 694 $second = round( $match[6] +$match[7] / pow(10, strlen($match[7])));693 $second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7]))); 695 694 696 695 return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; 697 696 } 698 else 699 { 700 return false; 701 } 697 698 return false; 702 699 } 703 700 704 701 /** … … 721 718 { 722 719 $output .= substr($string, $position, $pos - $position); 723 720 $position = $pos + 1; 724 if ($ string[$pos - 1] !== '\\')721 if ($pos === 0 || $string[$pos - 1] !== '\\') 725 722 { 726 723 $depth++; 727 724 while ($depth && $position < $length) … … 849 846 850 847 return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; 851 848 } 852 else 853 { 854 return false; 855 } 849 850 return false; 856 851 } 857 852 858 853 /** … … 914 909 915 910 return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; 916 911 } 917 else 918 { 919 return false; 920 } 912 913 return false; 921 914 } 922 915 923 916 /** … … 956 949 $month = $this->month[strtolower($match[2])]; 957 950 return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); 958 951 } 959 else 960 { 961 return false; 962 } 952 953 return false; 963 954 } 964 955 965 956 /** … … 975 966 { 976 967 return false; 977 968 } 978 else 979 { 980 return $strtotime; 981 } 969 970 return $strtotime; 982 971 } 983 972 } 984 -
SimplePie/Parser.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 75 74 $this->registry = $registry; 76 75 } 77 76 78 public function parse(&$data, $encoding )77 public function parse(&$data, $encoding, $url = '') 79 78 { 79 if (class_exists('DOMXpath') && function_exists('Mf2\parse')) { 80 $doc = new DOMDocument(); 81 @$doc->loadHTML($data); 82 $xpath = new DOMXpath($doc); 83 // Check for both h-feed and h-entry, as both a feed with no entries 84 // and a list of entries without an h-feed wrapper are both valid. 85 $query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '. 86 'contains(concat(" ", @class, " "), " h-entry ")]'; 87 $result = $xpath->query($query); 88 if ($result->length !== 0) { 89 return $this->parse_microformats($data, $url); 90 } 91 } 92 80 93 // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character 81 94 if (strtoupper($encoding) === 'US-ASCII') 82 95 { … … 120 133 if ($declaration->parse()) 121 134 { 122 135 $data = substr($data, $pos + 2); 123 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;136 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' ."\n". $this->declare_html_entities() . $data; 124 137 } 125 138 else 126 139 { … … 163 176 xml_parser_free($xml); 164 177 return $return; 165 178 } 166 else 179 180 libxml_clear_errors(); 181 $xml = new XMLReader(); 182 $xml->xml($data); 183 while (@$xml->read()) 167 184 { 168 libxml_clear_errors(); 169 $xml = new XMLReader(); 170 $xml->xml($data); 171 while (@$xml->read()) 185 switch ($xml->nodeType) 172 186 { 173 switch ($xml->nodeType)174 {175 187 176 case constant('XMLReader::END_ELEMENT'): 188 case constant('XMLReader::END_ELEMENT'): 189 if ($xml->namespaceURI !== '') 190 { 191 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 192 } 193 else 194 { 195 $tagName = $xml->localName; 196 } 197 $this->tag_close(null, $tagName); 198 break; 199 case constant('XMLReader::ELEMENT'): 200 $empty = $xml->isEmptyElement; 201 if ($xml->namespaceURI !== '') 202 { 203 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 204 } 205 else 206 { 207 $tagName = $xml->localName; 208 } 209 $attributes = array(); 210 while ($xml->moveToNextAttribute()) 211 { 177 212 if ($xml->namespaceURI !== '') 178 213 { 179 $ tagName = $xml->namespaceURI . $this->separator . $xml->localName;214 $attrName = $xml->namespaceURI . $this->separator . $xml->localName; 180 215 } 181 216 else 182 217 { 183 $ tagName = $xml->localName;218 $attrName = $xml->localName; 184 219 } 220 $attributes[$attrName] = $xml->value; 221 } 222 $this->tag_open(null, $tagName, $attributes); 223 if ($empty) 224 { 185 225 $this->tag_close(null, $tagName); 186 break; 187 case constant('XMLReader::ELEMENT'): 188 $empty = $xml->isEmptyElement; 189 if ($xml->namespaceURI !== '') 190 { 191 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 192 } 193 else 194 { 195 $tagName = $xml->localName; 196 } 197 $attributes = array(); 198 while ($xml->moveToNextAttribute()) 199 { 200 if ($xml->namespaceURI !== '') 201 { 202 $attrName = $xml->namespaceURI . $this->separator . $xml->localName; 203 } 204 else 205 { 206 $attrName = $xml->localName; 207 } 208 $attributes[$attrName] = $xml->value; 209 } 210 $this->tag_open(null, $tagName, $attributes); 211 if ($empty) 212 { 213 $this->tag_close(null, $tagName); 214 } 215 break; 216 case constant('XMLReader::TEXT'): 226 } 227 break; 228 case constant('XMLReader::TEXT'): 217 229 218 case constant('XMLReader::CDATA'): 219 $this->cdata(null, $xml->value); 220 break; 221 } 230 case constant('XMLReader::CDATA'): 231 $this->cdata(null, $xml->value); 232 break; 222 233 } 223 if ($error = libxml_get_last_error())224 {225 $this->error_code = $error->code;226 $this->error_string = $error->message;227 $this->current_line = $error->line;228 $this->current_column = $error->column;229 return false;230 }231 else232 {233 return true;234 }235 234 } 235 if ($error = libxml_get_last_error()) 236 { 237 $this->error_code = $error->code; 238 $this->error_string = $error->message; 239 $this->current_line = $error->line; 240 $this->current_column = $error->column; 241 return false; 242 } 243 244 return true; 236 245 } 237 246 238 247 public function get_error_code() … … 404 413 } 405 414 return $cache[$string]; 406 415 } 416 417 private function parse_hcard($data, $category = false) { 418 $name = ''; 419 $link = ''; 420 // Check if h-card is set and pass that information on in the link. 421 if (isset($data['type']) && in_array('h-card', $data['type'])) { 422 if (isset($data['properties']['name'][0])) { 423 $name = $data['properties']['name'][0]; 424 } 425 if (isset($data['properties']['url'][0])) { 426 $link = $data['properties']['url'][0]; 427 if ($name === '') { 428 $name = $link; 429 } 430 else { 431 // can't have commas in categories. 432 $name = str_replace(',', '', $name); 433 } 434 $person_tag = $category ? '<span class="person-tag"></span>' : ''; 435 return '<a class="h-card" href="'.$link.'">'.$person_tag.$name.'</a>'; 436 } 437 } 438 return isset($data['value']) ? $data['value'] : ''; 439 } 440 441 private function parse_microformats(&$data, $url) { 442 $feed_title = ''; 443 $feed_author = NULL; 444 $author_cache = array(); 445 $items = array(); 446 $entries = array(); 447 $mf = Mf2\parse($data, $url); 448 // First look for an h-feed. 449 $h_feed = array(); 450 foreach ($mf['items'] as $mf_item) { 451 if (in_array('h-feed', $mf_item['type'])) { 452 $h_feed = $mf_item; 453 break; 454 } 455 // Also look for h-feed or h-entry in the children of each top level item. 456 if (!isset($mf_item['children'][0]['type'])) continue; 457 if (in_array('h-feed', $mf_item['children'][0]['type'])) { 458 $h_feed = $mf_item['children'][0]; 459 // In this case the parent of the h-feed may be an h-card, so use it as 460 // the feed_author. 461 if (in_array('h-card', $mf_item['type'])) $feed_author = $mf_item; 462 break; 463 } 464 else if (in_array('h-entry', $mf_item['children'][0]['type'])) { 465 $entries = $mf_item['children']; 466 // In this case the parent of the h-entry list may be an h-card, so use 467 // it as the feed_author. 468 if (in_array('h-card', $mf_item['type'])) $feed_author = $mf_item; 469 break; 470 } 471 } 472 if (isset($h_feed['children'])) { 473 $entries = $h_feed['children']; 474 // Also set the feed title and store author from the h-feed if available. 475 if (isset($mf['items'][0]['properties']['name'][0])) { 476 $feed_title = $mf['items'][0]['properties']['name'][0]; 477 } 478 if (isset($mf['items'][0]['properties']['author'][0])) { 479 $feed_author = $mf['items'][0]['properties']['author'][0]; 480 } 481 } 482 else if (count($entries) === 0) { 483 $entries = $mf['items']; 484 } 485 for ($i = 0; $i < count($entries); $i++) { 486 $entry = $entries[$i]; 487 if (in_array('h-entry', $entry['type'])) { 488 $item = array(); 489 $title = ''; 490 $description = ''; 491 if (isset($entry['properties']['url'][0])) { 492 $link = $entry['properties']['url'][0]; 493 if (isset($link['value'])) $link = $link['value']; 494 $item['link'] = array(array('data' => $link)); 495 } 496 if (isset($entry['properties']['uid'][0])) { 497 $guid = $entry['properties']['uid'][0]; 498 if (isset($guid['value'])) $guid = $guid['value']; 499 $item['guid'] = array(array('data' => $guid)); 500 } 501 if (isset($entry['properties']['name'][0])) { 502 $title = $entry['properties']['name'][0]; 503 if (isset($title['value'])) $title = $title['value']; 504 $item['title'] = array(array('data' => $title)); 505 } 506 if (isset($entry['properties']['author'][0]) || isset($feed_author)) { 507 // author is a special case, it can be plain text or an h-card array. 508 // If it's plain text it can also be a url that should be followed to 509 // get the actual h-card. 510 $author = isset($entry['properties']['author'][0]) ? 511 $entry['properties']['author'][0] : $feed_author; 512 if (!is_string($author)) { 513 $author = $this->parse_hcard($author); 514 } 515 else if (strpos($author, 'http') === 0) { 516 if (isset($author_cache[$author])) { 517 $author = $author_cache[$author]; 518 } 519 else { 520 $mf = Mf2\fetch($author); 521 foreach ($mf['items'] as $hcard) { 522 // Only interested in an h-card by itself in this case. 523 if (!in_array('h-card', $hcard['type'])) { 524 continue; 525 } 526 // It must have a url property matching what we fetched. 527 if (!isset($hcard['properties']['url']) || 528 !(in_array($author, $hcard['properties']['url']))) { 529 continue; 530 } 531 // Save parse_hcard the trouble of finding the correct url. 532 $hcard['properties']['url'][0] = $author; 533 // Cache this h-card for the next h-entry to check. 534 $author_cache[$author] = $this->parse_hcard($hcard); 535 $author = $author_cache[$author]; 536 break; 537 } 538 } 539 } 540 $item['author'] = array(array('data' => $author)); 541 } 542 if (isset($entry['properties']['photo'][0])) { 543 // If a photo is also in content, don't need to add it again here. 544 $content = ''; 545 if (isset($entry['properties']['content'][0]['html'])) { 546 $content = $entry['properties']['content'][0]['html']; 547 } 548 $photo_list = array(); 549 for ($j = 0; $j < count($entry['properties']['photo']); $j++) { 550 $photo = $entry['properties']['photo'][$j]; 551 if (!empty($photo) && strpos($content, $photo) === false) { 552 $photo_list[] = $photo; 553 } 554 } 555 // When there's more than one photo show the first and use a lightbox. 556 // Need a permanent, unique name for the image set, but don't have 557 // anything unique except for the content itself, so use that. 558 $count = count($photo_list); 559 if ($count > 1) { 560 $image_set_id = preg_replace('/[[:^alnum:]]/', '', $photo_list[0]); 561 $description = '<p>'; 562 for ($j = 0; $j < $count; $j++) { 563 $hidden = $j === 0 ? '' : 'class="hidden" '; 564 $description .= '<a href="'.$photo_list[$j].'" '.$hidden. 565 'data-lightbox="image-set-'.$image_set_id.'">'. 566 '<img src="'.$photo_list[$j].'"></a>'; 567 } 568 $description .= '<br><b>'.$count.' photos</b></p>'; 569 } 570 else if ($count == 1) { 571 $description = '<p><img src="'.$photo_list[0].'"></p>'; 572 } 573 } 574 if (isset($entry['properties']['content'][0]['html'])) { 575 // e-content['value'] is the same as p-name when they are on the same 576 // element. Use this to replace title with a strip_tags version so 577 // that alt text from images is not included in the title. 578 if ($entry['properties']['content'][0]['value'] === $title) { 579 $title = strip_tags($entry['properties']['content'][0]['html']); 580 $item['title'] = array(array('data' => $title)); 581 } 582 $description .= $entry['properties']['content'][0]['html']; 583 if (isset($entry['properties']['in-reply-to'][0])) { 584 $in_reply_to = ''; 585 if (is_string($entry['properties']['in-reply-to'][0])) { 586 $in_reply_to = $entry['properties']['in-reply-to'][0]; 587 } 588 else if (isset($entry['properties']['in-reply-to'][0]['value'])) { 589 $in_reply_to = $entry['properties']['in-reply-to'][0]['value']; 590 } 591 if ($in_reply_to !== '') { 592 $description .= '<p><span class="in-reply-to"></span> '. 593 '<a href="'.$in_reply_to.'">'.$in_reply_to.'</a><p>'; 594 } 595 } 596 $item['description'] = array(array('data' => $description)); 597 } 598 if (isset($entry['properties']['category'])) { 599 $category_csv = ''; 600 // Categories can also contain h-cards. 601 foreach ($entry['properties']['category'] as $category) { 602 if ($category_csv !== '') $category_csv .= ', '; 603 if (is_string($category)) { 604 // Can't have commas in categories. 605 $category_csv .= str_replace(',', '', $category); 606 } 607 else { 608 $category_csv .= $this->parse_hcard($category, true); 609 } 610 } 611 $item['category'] = array(array('data' => $category_csv)); 612 } 613 if (isset($entry['properties']['published'][0])) { 614 $timestamp = strtotime($entry['properties']['published'][0]); 615 $pub_date = date('F j Y g:ia', $timestamp).' GMT'; 616 $item['pubDate'] = array(array('data' => $pub_date)); 617 } 618 // The title and description are set to the empty string to represent 619 // a deleted item (which also makes it an invalid rss item). 620 if (isset($entry['properties']['deleted'][0])) { 621 $item['title'] = array(array('data' => '')); 622 $item['description'] = array(array('data' => '')); 623 } 624 $items[] = array('child' => array('' => $item)); 625 } 626 } 627 // Mimic RSS data format when storing microformats. 628 $link = array(array('data' => $url)); 629 $image = ''; 630 if (!is_string($feed_author) && 631 isset($feed_author['properties']['photo'][0])) { 632 $image = array(array('child' => array('' => array('url' => 633 array(array('data' => $feed_author['properties']['photo'][0])))))); 634 } 635 // Use the name given for the h-feed, or get the title from the html. 636 if ($feed_title !== '') { 637 $feed_title = array(array('data' => htmlspecialchars($feed_title))); 638 } 639 else if ($position = strpos($data, '<title>')) { 640 $start = $position < 200 ? 0 : $position - 200; 641 $check = substr($data, $start, 400); 642 $matches = array(); 643 if (preg_match('/<title>(.+)<\/title>/', $check, $matches)) { 644 $feed_title = array(array('data' => htmlspecialchars($matches[1]))); 645 } 646 } 647 $channel = array('channel' => array(array('child' => array('' => 648 array('link' => $link, 'image' => $image, 'title' => $feed_title, 649 'item' => $items))))); 650 $rss = array(array('attribs' => array('' => array('version' => '2.0')), 651 'child' => array('' => $channel))); 652 $this->data = array('child' => array('' => array('rss' => $rss))); 653 return true; 654 } 655 656 private function declare_html_entities() { 657 // This is required because the RSS specification says that entity-encoded 658 // html is allowed, but the xml specification says they must be declared. 659 return '<!DOCTYPE html [ <!ENTITY nbsp " "> <!ENTITY iexcl "¡"> <!ENTITY cent "¢"> <!ENTITY pound "£"> <!ENTITY curren "¤"> <!ENTITY yen "¥"> <!ENTITY brvbar "¦"> <!ENTITY sect "§"> <!ENTITY uml "¨"> <!ENTITY copy "©"> <!ENTITY ordf "ª"> <!ENTITY laquo "«"> <!ENTITY not "¬"> <!ENTITY shy "­"> <!ENTITY reg "®"> <!ENTITY macr "¯"> <!ENTITY deg "°"> <!ENTITY plusmn "±"> <!ENTITY sup2 "²"> <!ENTITY sup3 "³"> <!ENTITY acute "´"> <!ENTITY micro "µ"> <!ENTITY para "¶"> <!ENTITY middot "·"> <!ENTITY cedil "¸"> <!ENTITY sup1 "¹"> <!ENTITY ordm "º"> <!ENTITY raquo "»"> <!ENTITY frac14 "¼"> <!ENTITY frac12 "½"> <!ENTITY frac34 "¾"> <!ENTITY iquest "¿"> <!ENTITY Agrave "À"> <!ENTITY Aacute "Á"> <!ENTITY Acirc "Â"> <!ENTITY Atilde "Ã"> <!ENTITY Auml "Ä"> <!ENTITY Aring "Å"> <!ENTITY AElig "Æ"> <!ENTITY Ccedil "Ç"> <!ENTITY Egrave "È"> <!ENTITY Eacute "É"> <!ENTITY Ecirc "Ê"> <!ENTITY Euml "Ë"> <!ENTITY Igrave "Ì"> <!ENTITY Iacute "Í"> <!ENTITY Icirc "Î"> <!ENTITY Iuml "Ï"> <!ENTITY ETH "Ð"> <!ENTITY Ntilde "Ñ"> <!ENTITY Ograve "Ò"> <!ENTITY Oacute "Ó"> <!ENTITY Ocirc "Ô"> <!ENTITY Otilde "Õ"> <!ENTITY Ouml "Ö"> <!ENTITY times "×"> <!ENTITY Oslash "Ø"> <!ENTITY Ugrave "Ù"> <!ENTITY Uacute "Ú"> <!ENTITY Ucirc "Û"> <!ENTITY Uuml "Ü"> <!ENTITY Yacute "Ý"> <!ENTITY THORN "Þ"> <!ENTITY szlig "ß"> <!ENTITY agrave "à"> <!ENTITY aacute "á"> <!ENTITY acirc "â"> <!ENTITY atilde "ã"> <!ENTITY auml "ä"> <!ENTITY aring "å"> <!ENTITY aelig "æ"> <!ENTITY ccedil "ç"> <!ENTITY egrave "è"> <!ENTITY eacute "é"> <!ENTITY ecirc "ê"> <!ENTITY euml "ë"> <!ENTITY igrave "ì"> <!ENTITY iacute "í"> <!ENTITY icirc "î"> <!ENTITY iuml "ï"> <!ENTITY eth "ð"> <!ENTITY ntilde "ñ"> <!ENTITY ograve "ò"> <!ENTITY oacute "ó"> <!ENTITY ocirc "ô"> <!ENTITY otilde "õ"> <!ENTITY ouml "ö"> <!ENTITY divide "÷"> <!ENTITY oslash "ø"> <!ENTITY ugrave "ù"> <!ENTITY uacute "ú"> <!ENTITY ucirc "û"> <!ENTITY uuml "ü"> <!ENTITY yacute "ý"> <!ENTITY thorn "þ"> <!ENTITY yuml "ÿ"> <!ENTITY OElig "Œ"> <!ENTITY oelig "œ"> <!ENTITY Scaron "Š"> <!ENTITY scaron "š"> <!ENTITY Yuml "Ÿ"> <!ENTITY fnof "ƒ"> <!ENTITY circ "ˆ"> <!ENTITY tilde "˜"> <!ENTITY Alpha "Α"> <!ENTITY Beta "Β"> <!ENTITY Gamma "Γ"> <!ENTITY Epsilon "Ε"> <!ENTITY Zeta "Ζ"> <!ENTITY Eta "Η"> <!ENTITY Theta "Θ"> <!ENTITY Iota "Ι"> <!ENTITY Kappa "Κ"> <!ENTITY Lambda "Λ"> <!ENTITY Mu "Μ"> <!ENTITY Nu "Ν"> <!ENTITY Xi "Ξ"> <!ENTITY Omicron "Ο"> <!ENTITY Pi "Π"> <!ENTITY Rho "Ρ"> <!ENTITY Sigma "Σ"> <!ENTITY Tau "Τ"> <!ENTITY Upsilon "Υ"> <!ENTITY Phi "Φ"> <!ENTITY Chi "Χ"> <!ENTITY Psi "Ψ"> <!ENTITY Omega "Ω"> <!ENTITY alpha "α"> <!ENTITY beta "β"> <!ENTITY gamma "γ"> <!ENTITY delta "δ"> <!ENTITY epsilon "ε"> <!ENTITY zeta "ζ"> <!ENTITY eta "η"> <!ENTITY theta "θ"> <!ENTITY iota "ι"> <!ENTITY kappa "κ"> <!ENTITY lambda "λ"> <!ENTITY mu "μ"> <!ENTITY nu "ν"> <!ENTITY xi "ξ"> <!ENTITY omicron "ο"> <!ENTITY pi "π"> <!ENTITY rho "ρ"> <!ENTITY sigmaf "ς"> <!ENTITY sigma "σ"> <!ENTITY tau "τ"> <!ENTITY upsilon "υ"> <!ENTITY phi "φ"> <!ENTITY chi "χ"> <!ENTITY psi "ψ"> <!ENTITY omega "ω"> <!ENTITY thetasym "ϑ"> <!ENTITY upsih "ϒ"> <!ENTITY piv "ϖ"> <!ENTITY ensp " "> <!ENTITY emsp " "> <!ENTITY thinsp " "> <!ENTITY zwnj "‌"> <!ENTITY zwj "‍"> <!ENTITY lrm "‎"> <!ENTITY rlm "‏"> <!ENTITY ndash "–"> <!ENTITY mdash "—"> <!ENTITY lsquo "‘"> <!ENTITY rsquo "’"> <!ENTITY sbquo "‚"> <!ENTITY ldquo "“"> <!ENTITY rdquo "”"> <!ENTITY bdquo "„"> <!ENTITY dagger "†"> <!ENTITY Dagger "‡"> <!ENTITY bull "•"> <!ENTITY hellip "…"> <!ENTITY permil "‰"> <!ENTITY prime "′"> <!ENTITY Prime "″"> <!ENTITY lsaquo "‹"> <!ENTITY rsaquo "›"> <!ENTITY oline "‾"> <!ENTITY frasl "⁄"> <!ENTITY euro "€"> <!ENTITY image "ℑ"> <!ENTITY weierp "℘"> <!ENTITY real "ℜ"> <!ENTITY trade "™"> <!ENTITY alefsym "ℵ"> <!ENTITY larr "←"> <!ENTITY uarr "↑"> <!ENTITY rarr "→"> <!ENTITY darr "↓"> <!ENTITY harr "↔"> <!ENTITY crarr "↵"> <!ENTITY lArr "⇐"> <!ENTITY uArr "⇑"> <!ENTITY rArr "⇒"> <!ENTITY dArr "⇓"> <!ENTITY hArr "⇔"> <!ENTITY forall "∀"> <!ENTITY part "∂"> <!ENTITY exist "∃"> <!ENTITY empty "∅"> <!ENTITY nabla "∇"> <!ENTITY isin "∈"> <!ENTITY notin "∉"> <!ENTITY ni "∋"> <!ENTITY prod "∏"> <!ENTITY sum "∑"> <!ENTITY minus "−"> <!ENTITY lowast "∗"> <!ENTITY radic "√"> <!ENTITY prop "∝"> <!ENTITY infin "∞"> <!ENTITY ang "∠"> <!ENTITY and "∧"> <!ENTITY or "∨"> <!ENTITY cap "∩"> <!ENTITY cup "∪"> <!ENTITY int "∫"> <!ENTITY there4 "∴"> <!ENTITY sim "∼"> <!ENTITY cong "≅"> <!ENTITY asymp "≈"> <!ENTITY ne "≠"> <!ENTITY equiv "≡"> <!ENTITY le "≤"> <!ENTITY ge "≥"> <!ENTITY sub "⊂"> <!ENTITY sup "⊃"> <!ENTITY nsub "⊄"> <!ENTITY sube "⊆"> <!ENTITY supe "⊇"> <!ENTITY oplus "⊕"> <!ENTITY otimes "⊗"> <!ENTITY perp "⊥"> <!ENTITY sdot "⋅"> <!ENTITY lceil "⌈"> <!ENTITY rceil "⌉"> <!ENTITY lfloor "⌊"> <!ENTITY rfloor "⌋"> <!ENTITY lang "〈"> <!ENTITY rang "〉"> <!ENTITY loz "◊"> <!ENTITY spades "♠"> <!ENTITY clubs "♣"> <!ENTITY hearts "♥"> <!ENTITY diams "♦"> ]>'; 660 } 407 661 } -
SimplePie/Rating.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 104 103 { 105 104 return $this->scheme; 106 105 } 107 else 108 { 109 return null; 110 } 106 107 return null; 111 108 } 112 109 113 110 /** … … 121 118 { 122 119 return $this->value; 123 120 } 124 else 125 { 126 return null; 127 } 121 122 return null; 128 123 } 129 124 } -
SimplePie/Registry.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 113 112 */ 114 113 public function register($type, $class, $legacy = false) 115 114 { 116 if (! is_subclass_of($class, $this->default[$type]))115 if (!@is_subclass_of($class, $this->default[$type])) 117 116 { 118 117 return false; 119 118 } … … 222 221 $result = call_user_func_array(array($class, $method), $parameters); 223 222 return $result; 224 223 } 225 } 226 No newline at end of file 224 } -
SimplePie/Restriction.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 113 112 { 114 113 return $this->relationship; 115 114 } 116 else 117 { 118 return null; 119 } 115 116 return null; 120 117 } 121 118 122 119 /** … … 130 127 { 131 128 return $this->type; 132 129 } 133 else 134 { 135 return null; 136 } 130 131 return null; 137 132 } 138 133 139 134 /** … … 147 142 { 148 143 return $this->value; 149 144 } 150 else 151 { 152 return null; 153 } 145 146 return null; 154 147 } 155 148 } -
SimplePie/Sanitize.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 61 60 var $image_handler = ''; 62 61 var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); 63 62 var $encode_instead_of_strip = false; 64 var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); 63 var $strip_attributes = array('bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); 64 var $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none')); 65 65 var $strip_comments = false; 66 66 var $output_encoding = 'UTF-8'; 67 67 var $enable_cache = true; … … 160 160 $this->encode_instead_of_strip = (bool) $encode; 161 161 } 162 162 163 public function strip_attributes($attribs = array('bgsound', ' class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))163 public function strip_attributes($attribs = array('bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) 164 164 { 165 165 if ($attribs) 166 166 { … … 179 179 } 180 180 } 181 181 182 public function add_attributes($attribs = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none'))) 183 { 184 if ($attribs) 185 { 186 if (is_array($attribs)) 187 { 188 $this->add_attributes = $attribs; 189 } 190 else 191 { 192 $this->add_attributes = explode(',', $attribs); 193 } 194 } 195 else 196 { 197 $this->add_attributes = false; 198 } 199 } 200 182 201 public function strip_comments($strip = false) 183 202 { 184 203 $this->strip_comments = (bool) $strip; … … 249 268 250 269 if (!class_exists('DOMDocument')) 251 270 { 252 $this->registry->call('Misc', 'error', array('DOMDocument not found, unable to use sanitizer', E_USER_WARNING, __FILE__, __LINE__)); 253 return ''; 271 throw new SimplePie_Exception('DOMDocument not found, unable to use sanitizer'); 254 272 } 255 273 $document = new DOMDocument(); 256 274 $document->encoding = 'UTF-8'; 275 257 276 $data = $this->preprocess($data, $type); 258 277 259 278 set_error_handler(array('SimplePie_Misc', 'silence_errors')); … … 260 279 $document->loadHTML($data); 261 280 restore_error_handler(); 262 281 282 $xpath = new DOMXPath($document); 283 263 284 // Strip comments 264 285 if ($this->strip_comments) 265 286 { 266 $xpath = new DOMXPath($document);267 287 $comments = $xpath->query('//comment()'); 268 288 269 289 foreach ($comments as $comment) … … 279 299 { 280 300 foreach ($this->strip_htmltags as $tag) 281 301 { 282 $this->strip_tag($tag, $document, $ type);302 $this->strip_tag($tag, $document, $xpath, $type); 283 303 } 284 304 } 285 305 … … 287 307 { 288 308 foreach ($this->strip_attributes as $attrib) 289 309 { 290 $this->strip_attr($attrib, $ document);310 $this->strip_attr($attrib, $xpath); 291 311 } 292 312 } 293 313 314 if ($this->add_attributes) 315 { 316 foreach ($this->add_attributes as $tag => $valuePairs) 317 { 318 $this->add_attr($tag, $valuePairs, $document); 319 } 320 } 321 294 322 // Replace relative URLs 295 323 $this->base = $base; 296 324 foreach ($this->replace_url_attributes as $element => $attributes) … … 326 354 } 327 355 else 328 356 { 329 trigger_error("$this->cache_location is not writ eable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);357 trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); 330 358 } 331 359 } 332 360 } … … 334 362 } 335 363 } 336 364 337 // Remove the DOCTYPE 338 // Seems to cause segfaulting if we don't do this 339 if ($document->firstChild instanceof DOMDocumentType) 365 // Get content node 366 $div = $document->getElementsByTagName('body')->item(0)->firstChild; 367 // Finally, convert to a HTML string 368 if (version_compare(PHP_VERSION, '5.3.6', '>=')) 340 369 { 341 $d ocument->removeChild($document->firstChild);370 $data = trim($document->saveHTML($div)); 342 371 } 372 else 373 { 374 $data = trim($document->saveXML($div)); 375 } 343 376 344 // Move everything from the body to the root345 $real_body = $document->getElementsByTagName('body')->item(0)->childNodes->item(0);346 $document->replaceChild($real_body, $document->firstChild);347 348 // Finally, convert to a HTML string349 $data = trim($document->saveHTML());350 351 377 if ($this->remove_div) 352 378 { 353 379 $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data); … … 384 410 protected function preprocess($html, $type) 385 411 { 386 412 $ret = ''; 413 $html = preg_replace('%</?(?:html|body)[^>]*?'.'>%is', '', $html); 387 414 if ($type & ~SIMPLEPIE_CONSTRUCT_XHTML) 388 415 { 389 416 // Atom XHTML constructs are wrapped with a div by default … … 456 483 } 457 484 } 458 485 459 protected function strip_tag($tag, $document, $ type)486 protected function strip_tag($tag, $document, $xpath, $type) 460 487 { 461 $xpath = new DOMXPath($document);462 488 $elements = $xpath->query('body//' . $tag); 463 489 if ($this->encode_instead_of_strip) 464 490 { … … 541 567 } 542 568 } 543 569 544 protected function strip_attr($attrib, $ document)570 protected function strip_attr($attrib, $xpath) 545 571 { 546 $xpath = new DOMXPath($document);547 572 $elements = $xpath->query('//*[@' . $attrib . ']'); 548 573 549 574 foreach ($elements as $element) … … 551 576 $element->removeAttribute($attrib); 552 577 } 553 578 } 579 580 protected function add_attr($tag, $valuePairs, $document) 581 { 582 $elements = $document->getElementsByTagName($tag); 583 foreach ($elements as $element) 584 { 585 foreach ($valuePairs as $attrib => $value) 586 { 587 $element->setAttribute($attrib, $value); 588 } 589 } 590 } 554 591 } -
SimplePie/Source.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 80 79 { 81 80 return $this->data['child'][$namespace][$tag]; 82 81 } 83 else 84 { 85 return null; 86 } 82 83 return null; 87 84 } 88 85 89 86 public function get_base($element = array()) … … 131 128 { 132 129 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 133 130 } 134 else 135 { 136 return null; 137 } 131 132 return null; 138 133 } 139 134 140 135 public function get_category($key = 0) … … 144 139 { 145 140 return $categories[$key]; 146 141 } 147 else 148 { 149 return null; 150 } 142 143 return null; 151 144 } 152 145 153 146 public function get_categories() … … 201 194 { 202 195 return array_unique($categories); 203 196 } 204 else 205 { 206 return null; 207 } 197 198 return null; 208 199 } 209 200 210 201 public function get_author($key = 0) … … 214 205 { 215 206 return $authors[$key]; 216 207 } 217 else 218 { 219 return null; 220 } 208 209 return null; 221 210 } 222 211 223 212 public function get_authors() … … 284 273 { 285 274 return array_unique($authors); 286 275 } 287 else 288 { 289 return null; 290 } 276 277 return null; 291 278 } 292 279 293 280 public function get_contributor($key = 0) … … 297 284 { 298 285 return $contributors[$key]; 299 286 } 300 else 301 { 302 return null; 303 } 287 288 return null; 304 289 } 305 290 306 291 public function get_contributors() … … 355 340 { 356 341 return array_unique($contributors); 357 342 } 358 else 359 { 360 return null; 361 } 343 344 return null; 362 345 } 363 346 364 347 public function get_link($key = 0, $rel = 'alternate') … … 368 351 { 369 352 return $links[$key]; 370 353 } 371 else 372 { 373 return null; 374 } 354 355 return null; 375 356 } 376 357 377 358 /** … … 450 431 { 451 432 return $this->data['links'][$rel]; 452 433 } 453 else 454 { 455 return null; 456 } 434 435 return null; 457 436 } 458 437 459 438 public function get_description() … … 494 473 { 495 474 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 496 475 } 497 else 498 { 499 return null; 500 } 476 477 return null; 501 478 } 502 479 503 480 public function get_copyright() … … 522 499 { 523 500 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 524 501 } 525 else 526 { 527 return null; 528 } 502 503 return null; 529 504 } 530 505 531 506 public function get_language() … … 546 521 { 547 522 return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); 548 523 } 549 else 550 { 551 return null; 552 } 524 525 return null; 553 526 } 554 527 555 528 public function get_latitude() … … 562 535 { 563 536 return (float) $match[1]; 564 537 } 565 else 566 { 567 return null; 568 } 538 539 return null; 569 540 } 570 541 571 542 public function get_longitude() … … 582 553 { 583 554 return (float) $match[2]; 584 555 } 585 else 586 { 587 return null; 588 } 556 557 return null; 589 558 } 590 559 591 560 public function get_image_url() … … 602 571 { 603 572 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 604 573 } 605 else 606 { 607 return null; 608 } 574 575 return null; 609 576 } 610 577 } 611 -
SimplePie/XML/Declaration/Parser.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 137 136 { 138 137 return true; 139 138 } 140 else 141 { 142 $this->version = ''; 143 $this->encoding = ''; 144 $this->standalone = ''; 145 return false; 146 } 139 140 $this->version = ''; 141 $this->encoding = ''; 142 $this->standalone = ''; 143 return false; 147 144 } 148 145 149 146 /** -
SimplePie/gzdecode.php
5 5 * A PHP-Based RSS and Atom Feed Framework. 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * 11 11 * Redistribution and use in source and binary forms, with or without modification, are … … 33 33 * POSSIBILITY OF SUCH DAMAGE. 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 38 * @author Geoffrey Sneddon 40 39 * @author Ryan McCue … … 339 338 { 340 339 return false; 341 340 } 342 else343 {344 $this->position = $this->compressed_size - 8;345 }346 341 342 $this->position = $this->compressed_size - 8; 343 347 344 // Check CRC of data 348 345 $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); 349 346 $this->position += 4; … … 363 360 // Wow, against all odds, we've actually got a valid gzip string 364 361 return true; 365 362 } 366 else 367 { 368 return false; 369 } 363 364 return false; 370 365 } 371 366 }