Thread: [Winmerge-svn] SF.net SVN: winmerge:[6709] trunk/Web/engine/simplepie/simplepie.inc
Windows visual diff and merge for files and directories
Brought to you by:
christianlist,
grimmdp
From: <ge...@us...> - 2009-04-26 12:07:42
|
Revision: 6709 http://winmerge.svn.sourceforge.net/winmerge/?rev=6709&view=rev Author: gerundt Date: 2009-04-26 12:07:32 +0000 (Sun, 26 Apr 2009) Log Message: ----------- Web: Update to SimplePie 1.1.3 Modified Paths: -------------- trunk/Web/engine/simplepie/simplepie.inc Modified: trunk/Web/engine/simplepie/simplepie.inc =================================================================== --- trunk/Web/engine/simplepie/simplepie.inc 2009-04-26 11:37:40 UTC (rev 6708) +++ trunk/Web/engine/simplepie/simplepie.inc 2009-04-26 12:07:32 UTC (rev 6709) @@ -33,7 +33,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package SimplePie - * @version 1.1.2 + * @version 1.1.3 * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon * @author Ryan Parman * @author Geoffrey Sneddon @@ -51,12 +51,12 @@ /** * SimplePie Version */ -define('SIMPLEPIE_VERSION', '1.1.2'); +define('SIMPLEPIE_VERSION', '1.1.3'); /** * SimplePie Build */ -define('SIMPLEPIE_BUILD', '20081109150825'); +define('SIMPLEPIE_BUILD', 20081219); /** * SimplePie Website URL @@ -745,7 +745,7 @@ { return md5(serialize($this->data)); } - + /** * Remove items that link back to this before destroying this object */ @@ -768,7 +768,7 @@ unset($this->data['ordered_items']); } } - + /** * Force the given data/URL to be treated as a feed no matter what it * appears like @@ -1690,7 +1690,7 @@ { $data = $this->raw_data; } - + // Set up array of possible encodings $encodings = array(); @@ -1699,10 +1699,10 @@ { $encodings[] = $this->input_encoding; } - + $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity'); $text_types = array('text/xml', 'text/xml-external-parsed-entity'); - + // RFC 3023 (only applies to sniffed content) if (isset($sniffed)) { @@ -1729,15 +1729,15 @@ $encodings[] = 'US-ASCII'; } } - + // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1 $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data)); $encodings[] = 'UTF-8'; $encodings[] = 'ISO-8859-1'; - + // There's no point in trying an encoding twice $encodings = array_unique($encodings); - + // If we want the XML, just output that with the most likely encoding and quit if ($this->xml_dump) { @@ -1745,7 +1745,7 @@ echo $data; exit; } - + // Loop through each possible encoding, till we return something, or run out of possibilities foreach ($encodings as $encoding) { @@ -1754,7 +1754,7 @@ { // Create new parser $parser =& new $this->parser_class(); - + // If it's parsed fine if ($parser->parse($utf8_data, 'UTF-8')) { @@ -1766,7 +1766,7 @@ $this->data['headers'] = $headers; } $this->data['build'] = SIMPLEPIE_BUILD; - + // Cache the file if caching is enabled if ($cache && !$cache->save($this)) { @@ -3076,7 +3076,7 @@ { return md5(serialize($this->data)); } - + /** * Remove items that link back to this before destroying this object */ @@ -5552,7 +5552,7 @@ return null; } } - + function get_source() { if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) @@ -5681,7 +5681,7 @@ { return md5(serialize($this->data)); } - + /** * Remove items that link back to this before destroying this object */ @@ -7109,7 +7109,7 @@ // Mime-types by handler. $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash - $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player + $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 @@ -7742,7 +7742,7 @@ if (isset($this->headers['content-encoding'])) { // Hey, we act dumb elsewhere, so let's do that here too - switch(strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) + switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) { case 'gzip': case 'x-gzip': @@ -7757,7 +7757,7 @@ $this->body = $decoder->data; } break; - + case 'deflate': if (($body = gzuncompress($this->body)) === false) { @@ -7769,7 +7769,7 @@ } $this->body = $body; break; - + default: $this->error = 'Unknown content coding'; $this->success = false; @@ -8242,35 +8242,35 @@ * @see gzdecode::$data */ var $compressed_data; - + /** * Size of compressed data * * @access private */ var $compressed_size; - + /** * Minimum size of a valid gzip string * * @access private */ var $min_compressed_size = 18; - + /** * Current position of pointer * * @access private */ var $position = 0; - + /** * Flags (FLG) * * @access private */ var $flags; - + /** * Uncompressed data * @@ -8278,28 +8278,28 @@ * @see gzdecode::$compressed_data */ var $data; - + /** * Modified time * * @access public */ var $MTIME; - + /** * Extra Flags * * @access public */ var $XFL; - + /** * Operating System * * @access public */ var $OS; - + /** * Subfield ID 1 * @@ -8308,7 +8308,7 @@ * @see gzdecode::$SI2 */ var $SI1; - + /** * Subfield ID 2 * @@ -8317,7 +8317,7 @@ * @see gzdecode::$SI1 */ var $SI2; - + /** * Extra field content * @@ -8326,21 +8326,21 @@ * @see gzdecode::$SI2 */ var $extra_field; - + /** * Original filename * * @access public */ var $filename; - + /** * Human readable comment * * @access public */ var $comment; - + /** * Don't allow anything to be set * @@ -8350,7 +8350,7 @@ { trigger_error("Cannot write property $name", E_USER_ERROR); } - + /** * Set the compressed string and related properties * @@ -8361,7 +8361,7 @@ $this->compressed_data = $data; $this->compressed_size = strlen($data); } - + /** * Decode the GZIP stream * @@ -8376,19 +8376,19 @@ { return false; } - + // Get the FLG (FLaGs) $this->flags = ord($this->compressed_data[3]); - + // FLG bits above (1 << 4) are reserved - if ($flg > 0x1F) + if ($this->flags > 0x1F) { return false; } - + // Advance the pointer after the above $this->position += 4; - + // MTIME $mtime = substr($this->compressed_data, $this->position, 4); // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness @@ -8398,30 +8398,30 @@ } $this->MTIME = current(unpack('l', $mtime)); $this->position += 4; - + // Get the XFL (eXtra FLags) $this->XFL = ord($this->compressed_data[$this->position++]); - + // Get the OS (Operating System) $this->OS = ord($this->compressed_data[$this->position++]); - + // Parse the FEXTRA if ($this->flags & 4) { // Read subfield IDs $this->SI1 = $this->compressed_data[$this->position++]; $this->SI2 = $this->compressed_data[$this->position++]; - + // SI2 set to zero is reserved for future use if ($this->SI2 === "\x00") { return false; } - + // Get the length of the extra field $len = current(unpack('v', substr($this->compressed_data, $this->position, 2))); $position += 2; - + // Check the length of the string is still valid $this->min_compressed_size += $len + 4; if ($this->compressed_size >= $this->min_compressed_size) @@ -8435,13 +8435,13 @@ return false; } } - + // Parse the FNAME if ($this->flags & 8) { // Get the length of the filename $len = strspn($this->compressed_data, "\x00", $this->position); - + // Check the length of the string is still valid $this->min_compressed_size += $len + 1; if ($this->compressed_size >= $this->min_compressed_size) @@ -8455,13 +8455,13 @@ return false; } } - + // Parse the FCOMMENT if ($this->flags & 16) { // Get the length of the comment $len = strspn($this->compressed_data, "\x00", $this->position); - + // Check the length of the string is still valid $this->min_compressed_size += $len + 1; if ($this->compressed_size >= $this->min_compressed_size) @@ -8475,7 +8475,7 @@ return false; } } - + // Parse the FHCRC if ($this->flags & 2) { @@ -8485,7 +8485,7 @@ { // Read the CRC $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2))); - + // Check the CRC matches if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) { @@ -8501,7 +8501,7 @@ return false; } } - + // Decompress the actual data if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) { @@ -8511,23 +8511,23 @@ { $this->position = $this->compressed_size - 8; } - + // Check CRC of data - $crc = current(unpack('N', substr($this->compressed_data, $this->position, 4))); + $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); $this->position += 4; - if (extension_loaded('hash') && hexdec(hash('crc32b', $this->data)) !== $crc) + /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) { return false; - } - + }*/ + // Check ISIZE of data - $isize = current(unpack('N', substr($this->compressed_data, $this->position, 4))); + $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4))); $this->position += 4; - if (strlen($this->data) & 0xFFFFFFFF !== $isize) + if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) { return false; } - + // Wow, against all odds, we've actually got a valid gzip string return true; } @@ -9059,7 +9059,7 @@ return ''; } } - + /** * Converts a Windows-1252 encoded string to a UTF-8 encoded string * @@ -9071,7 +9071,7 @@ function windows_1252_to_utf8($string) { static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF"); - + return strtr($string, $convert_table); } @@ -9079,7 +9079,7 @@ { $input = SimplePie_Misc::encoding($input); $output = SimplePie_Misc::encoding($output); - + // We fail to fail on non US-ASCII bytes if ($input === 'US-ASCII') { @@ -9126,47 +9126,47 @@ case 'adobestandardencoding': case 'csadobestandardencoding': return 'Adobe-Standard-Encoding'; - + case 'adobesymbolencoding': case 'cshppsmath': return 'Adobe-Symbol-Encoding'; - + case 'ami1251': case 'ami1251': case 'amiga1251': case 'amiga1251': return 'Amiga-1251'; - + case 'ansix31101983': case 'csat5001983': case 'csiso99naplps': case 'isoir99': case 'naplps': return 'ANSI_X3.110-1983'; - + case 'arabic7': case 'asmo449': case 'csiso89asmo449': case 'isoir89': case 'iso9036': return 'ASMO_449'; - + case 'big5': case 'csbig5': case 'xxbig5': return 'Big5'; - + case 'big5hkscs': return 'Big5-HKSCS'; - + case 'bocu1': case 'csbocu1': return 'BOCU-1'; - + case 'brf': case 'csbrf': return 'BRF'; - + case 'bs4730': case 'csiso4unitedkingdom': case 'gb': @@ -9174,16 +9174,16 @@ case 'iso646gb': case 'uk': return 'BS_4730'; - + case 'bsviewdata': case 'csiso47bsviewdata': case 'isoir47': return 'BS_viewdata'; - + case 'cesu8': case 'cscesu8': return 'CESU-8'; - + case 'ca': case 'csa71': case 'csaz243419851': @@ -9191,137 +9191,137 @@ case 'isoir121': case 'iso646ca': return 'CSA_Z243.4-1985-1'; - + case 'csa72': case 'csaz243419852': case 'csiso122canadian2': case 'isoir122': case 'iso646ca2': return 'CSA_Z243.4-1985-2'; - + case 'csaz24341985gr': case 'csiso123csaz24341985gr': case 'isoir123': return 'CSA_Z243.4-1985-gr'; - + case 'csiso139csn369103': case 'csn369103': case 'isoir139': return 'CSN_369103'; - + case 'csdecmcs': case 'dec': case 'decmcs': return 'DEC-MCS'; - + case 'csiso21german': case 'de': case 'din66003': case 'isoir21': case 'iso646de': return 'DIN_66003'; - + case 'csdkus': case 'dkus': return 'dk-us'; - + case 'csiso646danish': case 'dk': case 'ds2089': case 'ds2089': case 'iso646dk': return 'DS_2089'; - + case 'csibmebcdicatde': case 'ebcdicatde': return 'EBCDIC-AT-DE'; - + case 'csebcdicatdea': case 'ebcdicatdea': return 'EBCDIC-AT-DE-A'; - + case 'csebcdiccafr': case 'ebcdiccafr': return 'EBCDIC-CA-FR'; - + case 'csebcdicdkno': case 'ebcdicdkno': return 'EBCDIC-DK-NO'; - + case 'csebcdicdknoa': case 'ebcdicdknoa': return 'EBCDIC-DK-NO-A'; - + case 'csebcdices': case 'ebcdices': return 'EBCDIC-ES'; - + case 'csebcdicesa': case 'ebcdicesa': return 'EBCDIC-ES-A'; - + case 'csebcdicess': case 'ebcdicess': return 'EBCDIC-ES-S'; - + case 'csebcdicfise': case 'ebcdicfise': return 'EBCDIC-FI-SE'; - + case 'csebcdicfisea': case 'ebcdicfisea': return 'EBCDIC-FI-SE-A'; - + case 'csebcdicfr': case 'ebcdicfr': return 'EBCDIC-FR'; - + case 'csebcdicit': case 'ebcdicit': return 'EBCDIC-IT'; - + case 'csebcdicpt': case 'ebcdicpt': return 'EBCDIC-PT'; - + case 'csebcdicuk': case 'ebcdicuk': return 'EBCDIC-UK'; - + case 'csebcdicus': case 'ebcdicus': return 'EBCDIC-US'; - + case 'csiso111ecmacyrillic': case 'ecmacyrillic': case 'isoir111': case 'koi8e': return 'ECMA-cyrillic'; - + case 'csiso17spanish': case 'es': case 'isoir17': case 'iso646es': return 'ES'; - + case 'csiso85spanish2': case 'es2': case 'isoir85': case 'iso646es2': return 'ES2'; - + case 'cseucfixwidjapanese': case 'extendedunixcodefixedwidthforjapanese': return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; - + case 'cseucpkdfmtjapanese': case 'eucjp': case 'extendedunixcodepackedformatforjapanese': return 'Extended_UNIX_Code_Packed_Format_for_Japanese'; - + case 'gb18030': return 'GB18030'; - + case 'cp936': case 'gbk': case 'ms936': @@ -9333,143 +9333,143 @@ case 'gb231280': case 'isoir58': return 'GBK'; - + case 'cn': case 'csiso57gb1988': case 'gb198880': case 'isoir57': case 'iso646cn': return 'GB_1988-80'; - + case 'csiso153gost1976874': case 'gost1976874': case 'isoir153': case 'stsev35888': return 'GOST_19768-74'; - + case 'csiso150': case 'csiso150greekccitt': case 'greekccitt': case 'isoir150': return 'greek-ccitt'; - + case 'csiso88greek7': case 'greek7': case 'isoir88': return 'greek7'; - + case 'csiso18greek7old': case 'greek7old': case 'isoir18': return 'greek7-old'; - + case 'cshpdesktop': case 'hpdesktop': return 'HP-DeskTop'; - + case 'cshplegal': case 'hplegal': return 'HP-Legal'; - + case 'cshpmath8': case 'hpmath8': return 'HP-Math8'; - + case 'cshppifont': case 'hppifont': return 'HP-Pi-font'; - + case 'cshproman8': case 'hproman8': case 'r8': case 'roman8': return 'hp-roman8'; - + case 'hzgb2312': return 'HZ-GB-2312'; - + case 'csibmsymbols': case 'ibmsymbols': return 'IBM-Symbols'; - + case 'csibmthai': case 'ibmthai': return 'IBM-Thai'; - + case 'ccsid00858': case 'cp00858': case 'ibm00858': case 'pcmultilingual850euro': return 'IBM00858'; - + case 'ccsid00924': case 'cp00924': case 'ebcdiclatin9euro': case 'ibm00924': return 'IBM00924'; - + case 'ccsid01140': case 'cp01140': case 'ebcdicus37euro': case 'ibm01140': return 'IBM01140'; - + case 'ccsid01141': case 'cp01141': case 'ebcdicde273euro': case 'ibm01141': return 'IBM01141'; - + case 'ccsid01142': case 'cp01142': case 'ebcdicdk277euro': case 'ebcdicno277euro': case 'ibm01142': return 'IBM01142'; - + case 'ccsid01143': case 'cp01143': case 'ebcdicfi278euro': case 'ebcdicse278euro': case 'ibm01143': return 'IBM01143'; - + case 'ccsid01144': case 'cp01144': case 'ebcdicit280euro': case 'ibm01144': return 'IBM01144'; - + case 'ccsid01145': case 'cp01145': case 'ebcdices284euro': case 'ibm01145': return 'IBM01145'; - + case 'ccsid01146': case 'cp01146': case 'ebcdicgb285euro': case 'ibm01146': return 'IBM01146'; - + case 'ccsid01147': case 'cp01147': case 'ebcdicfr297euro': case 'ibm01147': return 'IBM01147'; - + case 'ccsid01148': case 'cp01148': case 'ebcdicinternational500euro': case 'ibm01148': return 'IBM01148'; - + case 'ccsid01149': case 'cp01149': case 'ebcdicis871euro': case 'ibm01149': return 'IBM01149'; - + case 'cp037': case 'csibm037': case 'ebcdiccpca': @@ -9478,306 +9478,306 @@ case 'ebcdiccpwt': case 'ibm037': return 'IBM037'; - + case 'cp038': case 'csibm038': case 'ebcdicint': case 'ibm038': return 'IBM038'; - + case 'cp273': case 'csibm273': case 'ibm273': return 'IBM273'; - + case 'cp274': case 'csibm274': case 'ebcdicbe': case 'ibm274': return 'IBM274'; - + case 'cp275': case 'csibm275': case 'ebcdicbr': case 'ibm275': return 'IBM275'; - + case 'csibm277': case 'ebcdiccpdk': case 'ebcdiccpno': case 'ibm277': return 'IBM277'; - + case 'cp278': case 'csibm278': case 'ebcdiccpfi': case 'ebcdiccpse': case 'ibm278': return 'IBM278'; - + case 'cp280': case 'csibm280': case 'ebcdiccpit': case 'ibm280': return 'IBM280'; - + case 'cp281': case 'csibm281': case 'ebcdicjpe': case 'ibm281': return 'IBM281'; - + case 'cp284': case 'csibm284': case 'ebcdiccpes': case 'ibm284': return 'IBM284'; - + case 'cp285': case 'csibm285': case 'ebcdiccpgb': case 'ibm285': return 'IBM285'; - + case 'cp290': case 'csibm290': case 'ebcdicjpkana': case 'ibm290': return 'IBM290'; - + case 'cp297': case 'csibm297': case 'ebcdiccpfr': case 'ibm297': return 'IBM297'; - + case 'cp420': case 'csibm420': case 'ebcdiccpar1': case 'ibm420': return 'IBM420'; - + case 'cp423': case 'csibm423': case 'ebcdiccpgr': case 'ibm423': return 'IBM423'; - + case 'cp424': case 'csibm424': case 'ebcdiccphe': case 'ibm424': return 'IBM424'; - + case '437': case 'cp437': case 'cspc8codepage437': case 'ibm437': return 'IBM437'; - + case 'cp500': case 'csibm500': case 'ebcdiccpbe': case 'ebcdiccpch': case 'ibm500': return 'IBM500'; - + case 'cp775': case 'cspc775baltic': case 'ibm775': return 'IBM775'; - + case '850': case 'cp850': case 'cspc850multilingual': case 'ibm850': return 'IBM850'; - + case '851': case 'cp851': case 'csibm851': case 'ibm851': return 'IBM851'; - + case '852': case 'cp852': case 'cspcp852': case 'ibm852': return 'IBM852'; - + case '855': case 'cp855': case 'csibm855': case 'ibm855': return 'IBM855'; - + case '857': case 'cp857': case 'csibm857': case 'ibm857': return 'IBM857'; - + case '860': case 'cp860': case 'csibm860': case 'ibm860': return 'IBM860'; - + case '861': case 'cpis': case 'cp861': case 'csibm861': case 'ibm861': return 'IBM861'; - + case '862': case 'cp862': case 'cspc862latinhebrew': case 'ibm862': return 'IBM862'; - + case '863': case 'cp863': case 'csibm863': case 'ibm863': return 'IBM863'; - + case 'cp864': case 'csibm864': case 'ibm864': return 'IBM864'; - + case '865': case 'cp865': case 'csibm865': case 'ibm865': return 'IBM865'; - + case '866': case 'cp866': case 'csibm866': case 'ibm866': return 'IBM866'; - + case 'cpar': case 'cp868': case 'csibm868': case 'ibm868': return 'IBM868'; - + case '869': case 'cpgr': case 'cp869': case 'csibm869': case 'ibm869': return 'IBM869'; - + case 'cp870': case 'csibm870': case 'ebcdiccproece': case 'ebcdiccpyu': case 'ibm870': return 'IBM870'; - + case 'cp871': case 'csibm871': case 'ebcdiccpis': case 'ibm871': return 'IBM871'; - + case 'cp880': case 'csibm880': case 'ebcdiccyrillic': case 'ibm880': return 'IBM880'; - + case 'cp891': case 'csibm891': case 'ibm891': return 'IBM891'; - + case 'cp903': case 'csibm903': case 'ibm903': return 'IBM903'; - + case '904': case 'cp904': case 'csibbm904': case 'ibm904': return 'IBM904'; - + case 'cp905': case 'csibm905': case 'ebcdiccptr': case 'ibm905': return 'IBM905'; - + case 'cp918': case 'csibm918': case 'ebcdiccpar2': case 'ibm918': return 'IBM918'; - + case 'cp1026': case 'csibm1026': case 'ibm1026': return 'IBM1026'; - + case 'ibm1047': case 'ibm1047': return 'IBM1047'; - + case 'csiso143iecp271': case 'iecp271': case 'isoir143': return 'IEC_P27-1'; - + case 'csiso49inis': case 'inis': case 'isoir49': return 'INIS'; - + case 'csiso50inis8': case 'inis8': case 'isoir50': return 'INIS-8'; - + case 'csiso51iniscyrillic': case 'iniscyrillic': case 'isoir51': return 'INIS-cyrillic'; - + case 'csinvariant': case 'invariant': return 'INVARIANT'; - + case 'iso2022cn': return 'ISO-2022-CN'; - + case 'iso2022cnext': return 'ISO-2022-CN-EXT'; - + case 'csiso2022jp': case 'iso2022jp': return 'ISO-2022-JP'; - + case 'csiso2022jp2': case 'iso2022jp2': return 'ISO-2022-JP-2'; - + case 'csiso2022kr': case 'iso2022kr': return 'ISO-2022-KR'; - + case 'cswindows30latin1': case 'iso88591windows30latin1': return 'ISO-8859-1-Windows-3.0-Latin-1'; - + case 'cswindows31latin1': case 'iso88591windows31latin1': return 'ISO-8859-1-Windows-3.1-Latin-1'; - + case 'csisolatin2': case 'iso88592': case 'isoir101': @@ -9786,11 +9786,11 @@ case 'l2': case 'latin2': return 'ISO-8859-2'; - + case 'cswindows31latin2': case 'iso88592windowslatin2': return 'ISO-8859-2-Windows-Latin-2'; - + case 'csisolatin3': case 'iso88593': case 'isoir109': @@ -9799,7 +9799,7 @@ case 'l3': case 'latin3': return 'ISO-8859-3'; - + case 'csisolatin4': case 'iso88594': case 'isoir110': @@ -9808,7 +9808,7 @@ case 'l4': case 'latin4': return 'ISO-8859-4'; - + case 'csisolatincyrillic': case 'cyrillic': case 'iso88595': @@ -9816,7 +9816,7 @@ case 'iso88595': case 'iso885951988': return 'ISO-8859-5'; - + case 'arabic': case 'asmo708': case 'csisolatinarabic': @@ -9826,17 +9826,17 @@ case 'iso88596': case 'iso885961987': return 'ISO-8859-6'; - + case 'csiso88596e': case 'iso88596e': case 'iso88596e': return 'ISO-8859-6-E'; - + case 'csiso88596i': case 'iso88596i': case 'iso88596i': return 'ISO-8859-6-I'; - + case 'csisolatingreek': case 'ecma118': case 'elot928': @@ -9847,7 +9847,7 @@ case 'iso88597': case 'iso885971987': return 'ISO-8859-7'; - + case 'csisolatinhebrew': case 'hebrew': case 'iso88598': @@ -9855,21 +9855,21 @@ case 'iso88598': case 'iso885981988': return 'ISO-8859-8'; - + case 'csiso88598e': case 'iso88598e': case 'iso88598e': return 'ISO-8859-8-E'; - + case 'csiso88598i': case 'iso88598i': case 'iso88598i': return 'ISO-8859-8-I'; - + case 'cswindows31latin5': case 'iso88599windowslatin5': return 'ISO-8859-9-Windows-Latin-5'; - + case 'csisolatin6': case 'iso885910': case 'isoir157': @@ -9877,10 +9877,10 @@ case 'l6': case 'latin6': return 'ISO-8859-10'; - + case 'iso885913': return 'ISO-8859-13'; - + case 'iso885914': case 'isoceltic': case 'isoir199': @@ -9889,12 +9889,12 @@ case 'l8': case 'latin8': return 'ISO-8859-14'; - + case 'iso885915': case 'iso885915': case 'latin9': return 'ISO-8859-15'; - + case 'iso885916': case 'isoir226': case 'iso885916': @@ -9902,120 +9902,120 @@ case 'l10': case 'latin10': return 'ISO-8859-16'; - + case 'iso10646j1': return 'ISO-10646-J-1'; - + case 'csunicode': case 'iso10646ucs2': return 'ISO-10646-UCS-2'; - + case 'csucs4': case 'iso10646ucs4': return 'ISO-10646-UCS-4'; - + case 'csunicodeascii': case 'iso10646ucsbasic': return 'ISO-10646-UCS-Basic'; - + case 'csunicodelatin1': case 'iso10646': case 'iso10646unicodelatin1': return 'ISO-10646-Unicode-Latin1'; - + case 'csiso10646utf1': case 'iso10646utf1': return 'ISO-10646-UTF-1'; - + case 'csiso115481': case 'iso115481': case 'iso115481': case 'isotr115481': return 'ISO-11548-1'; - + case 'csiso90': case 'isoir90': return 'iso-ir-90'; - + case 'csunicodeibm1261': case 'isounicodeibm1261': return 'ISO-Unicode-IBM-1261'; - + case 'csunicodeibm1264': case 'isounicodeibm1264': return 'ISO-Unicode-IBM-1264'; - + case 'csunicodeibm1265': case 'isounicodeibm1265': return 'ISO-Unicode-IBM-1265'; - + case 'csunicodeibm1268': case 'isounicodeibm1268': return 'ISO-Unicode-IBM-1268'; - + case 'csunicodeibm1276': case 'isounicodeibm1276': return 'ISO-Unicode-IBM-1276'; - + case 'csiso646basic1983': case 'iso646basic1983': case 'ref': return 'ISO_646.basic:1983'; - + case 'csiso2intlrefversion': case 'irv': case 'isoir2': case 'iso646irv1983': return 'ISO_646.irv:1983'; - + case 'csiso2033': case 'e13b': case 'isoir98': case 'iso20331983': return 'ISO_2033-1983'; - + case 'csiso5427cyrillic': case 'isoir37': case 'iso5427': return 'ISO_5427'; - + case 'isoir54': case 'iso5427cyrillic1981': case 'iso54271981': return 'ISO_5427:1981'; - + case 'csiso5428greek': case 'isoir55': case 'iso54281980': return 'ISO_5428:1980'; - + case 'csiso6937add': case 'isoir152': case 'iso6937225': return 'ISO_6937-2-25'; - + case 'csisotextcomm': case 'isoir142': case 'iso69372add': return 'ISO_6937-2-add'; - + case 'csiso8859supp': case 'isoir154': case 'iso8859supp': case 'latin125': return 'ISO_8859-supp'; - + case 'csiso10367box': case 'isoir155': case 'iso10367box': return 'ISO_10367-box'; - + case 'csiso15italian': case 'isoir15': case 'iso646it': case 'it': return 'IT'; - + case 'csiso13jisc6220jp': case 'isoir13': case 'jisc62201969': @@ -10023,77 +10023,77 @@ case 'katakana': case 'x02017': return 'JIS_C6220-1969-jp'; - + case 'csiso14jisc6220ro': case 'isoir14': case 'iso646jp': case 'jisc62201969ro': case 'jp': return 'JIS_C6220-1969-ro'; - + case 'csiso42jisc62261978': case 'isoir42': case 'jisc62261978': return 'JIS_C6226-1978'; - + case 'csiso87jisx0208': case 'isoir87': case 'jisc62261983': case 'jisx02081983': case 'x0208': return 'JIS_C6226-1983'; - + case 'csiso91jisc62291984a': case 'isoir91': case 'jisc62291984a': case 'jpocra': return 'JIS_C6229-1984-a'; - + case 'csiso92jisc62991984b': case 'isoir92': case 'iso646jpocrb': case 'jisc62291984b': case 'jpocrb': return 'JIS_C6229-1984-b'; - + case 'csiso93jis62291984badd': case 'isoir93': case 'jisc62291984badd': case 'jpocrbadd': return 'JIS_C6229-1984-b-add'; - + case 'csiso94jis62291984hand': case 'isoir94': case 'jisc62291984hand': case 'jpocrhand': return 'JIS_C6229-1984-hand'; - + case 'csiso95jis62291984handadd': case 'isoir95': case 'jisc62291984handadd': case 'jpocrhandadd': return 'JIS_C6229-1984-hand-add'; - + case 'csiso96jisc62291984kana': case 'isoir96': case 'jisc62291984kana': return 'JIS_C6229-1984-kana'; - + case 'csjisencoding': case 'jisencoding': return 'JIS_Encoding'; - + case 'cshalfwidthkatakana': case 'jisx0201': case 'x0201': return 'JIS_X0201'; - + case 'csiso159jisx02121990': case 'isoir159': case 'jisx02121990': case 'x0212': return 'JIS_X0212-1990'; - + case 'csiso141jusib1002': case 'isoir141': case 'iso646yu': @@ -10101,120 +10101,120 @@ case 'jusib1002': case 'yu': return 'JUS_I.B1.002'; - + case 'csiso147macedonian': case 'isoir147': case 'jusib1003mac': case 'macedonian': return 'JUS_I.B1.003-mac'; - + case 'csiso146serbian': case 'isoir146': case 'jusib1003serb': case 'serbian': return 'JUS_I.B1.003-serb'; - + case 'koi7switched': return 'KOI7-switched'; - + case 'cskoi8r': case 'koi8r': return 'KOI8-R'; - + case 'koi8u': return 'KOI8-U'; - + case 'csksc5636': case 'iso646kr': case 'ksc5636': return 'KSC5636'; - + case 'cskz1048': case 'kz1048': case 'rk1048': case 'strk10482002': return 'KZ-1048'; - + case 'csiso19latingreek': case 'isoir19': case 'latingreek': return 'latin-greek'; - + case 'csiso27latingreek1': case 'isoir27': case 'latingreek1': return 'Latin-greek-1'; - + case 'csiso158lap': case 'isoir158': case 'lap': case 'latinlap': return 'latin-lap'; - + case 'csmacintosh': case 'mac': case 'macintosh': return 'macintosh'; - + case 'csmicrosoftpublishing': case 'microsoftpublishing': return 'Microsoft-Publishing'; - + case 'csmnem': case 'mnem': return 'MNEM'; - + case 'csmnemonic': case 'mnemonic': return 'MNEMONIC'; - + case 'csiso86hungarian': case 'hu': case 'isoir86': case 'iso646hu': case 'msz77953': return 'MSZ_7795.3'; - + case 'csnatsdano': case 'isoir91': case 'natsdano': return 'NATS-DANO'; - + case 'csnatsdanoadd': case 'isoir92': case 'natsdanoadd': return 'NATS-DANO-ADD'; - + case 'csnatssefi': case 'isoir81': case 'natssefi': return 'NATS-SEFI'; - + case 'csnatssefiadd': case 'isoir82': case 'natssefiadd': return 'NATS-SEFI-ADD'; - + case 'csiso151cuba': case 'cuba': case 'isoir151': case 'iso646cu': case 'ncnc001081': return 'NC_NC00-10:81'; - + case 'csiso69french': case 'fr': case 'isoir69': case 'iso646fr': case 'nfz62010': return 'NF_Z_62-010'; - + case 'csiso25french': case 'isoir25': case 'iso646fr1': case 'nfz620101973': return 'NF_Z_62-010_(1973)'; - + case 'csiso60danishnorwegian': case 'csiso60norwegian1': case 'isoir60': @@ -10222,53 +10222,53 @@ case 'no': case 'ns45511': return 'NS_4551-1'; - + case 'csiso61norwegian2': case 'isoir61': case 'iso646no2': case 'no2': case 'ns45512': return 'NS_4551-2'; - + case 'osdebcdicdf03irv': return 'OSD_EBCDIC_DF03_IRV'; - + case 'osdebcdicdf041': return 'OSD_EBCDIC_DF04_1'; - + case 'osdebcdicdf0415': return 'OSD_EBCDIC_DF04_15'; - + case 'cspc8danishnorwegian': case 'pc8danishnorwegian': return 'PC8-Danish-Norwegian'; - + case 'cspc8turkish': case 'pc8turkish': return 'PC8-Turkish'; - + case 'csiso16portuguese': case 'isoir16': case 'iso646pt': case 'pt': return 'PT'; - + case 'csiso84portuguese2': case 'isoir84': case 'iso646pt2': case 'pt2': return 'PT2'; - + case 'cp154': case 'csptcp154': case 'cyrillicasian': case 'pt154': case 'ptcp154': return 'PTCP154'; - + case 'scsu': return 'SCSU'; - + case 'csiso10swedish': case 'fi': case 'isoir10': @@ -10277,51 +10277,51 @@ case 'se': case 'sen850200b': return 'SEN_850200_B'; - + case 'csiso11swedishfornames': case 'isoir11': case 'iso646se2': case 'se2': case 'sen850200c': return 'SEN_850200_C'; - + case 'csshiftjis': case 'mskanji': case 'shiftjis': return 'Shift_JIS'; - + case 'csiso102t617bit': case 'isoir102': case 't617bit': return 'T.61-7bit'; - + case 'csiso103t618bit': case 'isoir103': case 't61': case 't618bit': return 'T.61-8bit'; - + case 'csiso128t101g2': case 'isoir128': case 't101g2': return 'T.101-G2'; - + case 'cstscii': case 'tscii': return 'TSCII'; - + case 'csunicode11': case 'unicode11': return 'UNICODE-1-1'; - + case 'csunicode11utf7': case 'unicode11utf7': return 'UNICODE-1-1-UTF-7'; - + case 'csunknown8bit': case 'unknown8bit': return 'UNKNOWN-8BIT'; - + case 'ansix341968': case 'ansix341986': case 'ascii': @@ -10334,68 +10334,68 @@ case 'us': case 'usascii': return 'US-ASCII'; - + case 'csusdk': case 'usdk': return 'us-dk'; - + case 'utf7': return 'UTF-7'; - + case 'utf8': return 'UTF-8'; - + case 'utf16': return 'UTF-16'; - + case 'utf16be': return 'UTF-16BE'; - + case 'utf16le': return 'UTF-16LE'; - + case 'utf32': return 'UTF-32'; - + case 'utf32be': return 'UTF-32BE'; - + case 'utf32le': return 'UTF-32LE'; - + case 'csventurainternational': case 'venturainternational': return 'Ventura-International'; - + case 'csventuramath': case 'venturamath': return 'Ventura-Math'; - + case 'csventuraus': case 'venturaus': return 'Ventura-US'; - + case 'csiso70videotexsupp1': case 'isoir70': case 'videotexsuppl': return 'videotex-suppl'; - + case 'csviqr': case 'viqr': return 'VIQR'; - + case 'csviscii': case 'viscii': return 'VISCII'; - + case 'cswindows31j': case 'windows31j': return 'Windows-31J'; - + case 'iso885911': case 'tis620': return 'Windows-874'; - + case 'cseuckr': case 'euckr': case 'windows949': @@ -10406,13 +10406,13 @@ case 'ksc56011987': case 'ksc56011989': return 'Windows-949'; - + case 'windows1250': return 'windows-1250'; - + case 'windows1251': return 'windows-1251'; - + case 'cp819': case 'csisolatin1': case 'ibm819': @@ -10423,13 +10423,13 @@ case 'latin1': case 'windows1252': return 'Windows-1252'; - + case 'windows1252': return 'windows-1252'; - + case 'windows1253': return 'windows-1253'; - + case 'csisolatin5': case 'iso88599': case 'isoir148': @@ -10438,22 +10438,22 @@ case 'latin5': case 'windows1254': return 'Windows-1254'; - + case 'windows1254': return 'windows-1254'; - + case 'windows1255': return 'windows-1255'; - + case 'windows1256': return 'windows-1256'; - + case 'windows1257': return 'windows-1257'; - + case 'windows1258': return 'windows-1258'; - + default: return $charset; } @@ -10572,9 +10572,9 @@ $position = 0; $length = strlen($string); $depth = 0; - + $output = ''; - + while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) { $output .= substr($string, $position, $pos - $position); @@ -10597,7 +10597,7 @@ case '(': $depth++; break; - + case ')': $depth--; break; @@ -10616,7 +10616,7 @@ } } $output .= substr($string, $position); - + return $output; } @@ -10880,7 +10880,7 @@ trigger_error('needle is not a string or an integer', E_USER_WARNING); return false; } - + return strpos(strtolower($haystack), $needle, $offset); } } @@ -10916,7 +10916,7 @@ return $return; } - + /** * Detect XML encoding, as per XML 1.0 Appendix F.1 * @@ -11730,7 +11730,7 @@ { $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; - + static $cache; if (!isset($cache[get_class($this)])) { @@ -11748,7 +11748,7 @@ { $all_methods = get_class_methods($this); } - + foreach ($all_methods as $method) { if (strtolower(substr($method, 0, 5)) === 'date_') @@ -11757,13 +11757,13 @@ } } } - + foreach ($cache[get_class($this)] as $method) { $this->built_in[] = $method; } } - + /** * Get the object * @@ -11796,7 +11796,7 @@ return $returned; } } - + foreach ($this->built_in as $method) { if (($returned = call_user_func(array(&$this, $method), $date)) !== false) @@ -12035,7 +12035,7 @@ { $match[4] += 1900; } - + // Second is optional, if it is empty set it to zero if ($match[7] !== '') { @@ -12195,7 +12195,7 @@ * @access private */ var $file; - + /** * Create an instance of the class with the input file * @@ -12206,7 +12206,7 @@ { $this->file = $file; } - + /** * Get the Content-Type of the specified file * @@ -12224,9 +12224,9 @@ { return $this->text_or_binary(); } - + if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) - { + { $official = substr($this->file->headers['content-type'], 0, $pos); } else @@ -12234,7 +12234,7 @@ $official = $this->file->headers['content-type']; } $official = strtolower($official); - + if ($official === 'unknown/unknown' || $official === 'application/unknown') { @@ -12271,7 +12271,7 @@ return $this->unknown(); } } - + /** * Sniff text or binary * @@ -12296,7 +12296,7 @@ return 'text/plain'; } } - + /** * Sniff unknown * @@ -12342,7 +12342,7 @@ return $this->text_or_binary(); } } - + /** * Sniff images * @@ -12373,7 +12373,7 @@ return false; } } - + /** * Sniff HTML * @@ -12384,7 +12384,7 @@ { $len = strlen($this->file->body); $pos = strspn($this->file->body, "\x09\x0A\x0D\x20"); - + while ($pos < $len) { switch ($this->file->body[$pos]) @@ -12395,15 +12395,15 @@ case "\x20": $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); continue 2; - + case '<': $pos++; break; - + default: return 'text/html'; } - + if (substr($this->file->body, $pos, 3) === '!--') { $pos += 3; @@ -12452,7 +12452,7 @@ return 'text/html'; } } - + return 'text/html'; } } @@ -12471,7 +12471,7 @@ * @var string */ var $version = '1.0'; - + /** * Encoding * @@ -12479,7 +12479,7 @@ * @var string */ var $encoding = 'UTF-8'; - + /** * Standalone * @@ -12495,7 +12495,7 @@ * @var string */ var $state = 'before_version_name'; - + /** * Input data * @@ -12519,7 +12519,7 @@ * @access private */ var $position = 0; - + /** * Create an instance of the class with the input data * @@ -12569,7 +12569,7 @@ { return (bool) ($this->position < $this->data_length); } - + /** * Advance past any whitespace * @@ -12581,7 +12581,7 @@ $this->position += $whitespace; return $whitespace; } - + /** * Read value */ @@ -12601,7 +12601,7 @@ } return false; } - + function before_version_name() { if ($this->skip_whitespace()) @@ -12613,7 +12613,7 @@ $this->state = false; } } - + function version_name() { if (substr($this->data, $this->position, 7) === 'version') @@ -12627,7 +12627,7 @@ $this->state = false; } } - + function version_equals() { if (substr($this->data, $this->position, 1) === '=') @@ -12641,7 +12641,7 @@ $this->state = false; } } - + function version_value() { if ($this->version = $this->get_value()) @@ -12661,7 +12661,7 @@ $this->state = 'standalone_name'; } } - + function encoding_name() { if (substr($this->data, $this->position, 8) === 'encoding') @@ -12675,7 +12675,7 @@ $this->state = false; } } - + function encoding_equals() { if (substr($this->data, $this->position, 1) === '=') @@ -12689,7 +12689,7 @@ $this->state = false; } } - + function encoding_value() { if ($this->encoding = $this->get_value()) @@ -12709,7 +12709,7 @@ $this->state = false; } } - + function standalone_name() { if (substr($this->data, $this->position, 10) === 'standalone') @@ -12723,7 +12723,7 @@ $this->state = false; } } - + function standalone_equals() { if (substr($this->data, $this->position, 1) === '=') @@ -12737,7 +12737,7 @@ $this->state = false; } } - + function standalone_value() { if ($standalone = $this->get_value()) @@ -12747,16 +12747,16 @@ case 'yes': $this->standalone = true; break; - + case 'no': $this->standalone = false; break; - + default: $this->state = false; return; } - + $this->skip_whitespace(); if ($this->has_data()) { @@ -12806,7 +12806,7 @@ { return $this->file; } - + if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) { $sniffer = new $this->content_type_sniffer_class($this->file); @@ -13080,7 +13080,7 @@ { $data = substr($data, 3); } - + if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false) { $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); @@ -13095,17 +13095,14 @@ return false; } } - - // Work around libxml 2.7.0/2.7.1 bug, at least when in PHP 5.1+ - if (version_compare(PHP_VERSION, '5.1', '>=') && (LIBXML_VERSION === 20700 || LIBXML_VERSION === 20701)) - { - $data = str_replace('<', '<', $data); - $data = str_replace('>', '>', $data); - $data = str_replace('&', '&', $data); - $data = str_replace(''', ''', $data); - $data = str_replace('"', '"', $data); - } + // Work around libxml bug + $data = str_replace('<', '<', $data); + $data = str_replace('>', '>', $data); + $data = str_replace('&', '&', $data); + $data = str_replace(''', ''', $data); + $data = str_replace('"', '"', $data); + $return = true; // Create the parser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ge...@us...> - 2009-10-31 18:53:18
|
Revision: 7031 http://winmerge.svn.sourceforge.net/winmerge/?rev=7031&view=rev Author: gerundt Date: 2009-10-31 18:53:08 +0000 (Sat, 31 Oct 2009) Log Message: ----------- Web: Update to SimplePie 1.2 Modified Paths: -------------- trunk/Web/engine/simplepie/simplepie.inc Modified: trunk/Web/engine/simplepie/simplepie.inc =================================================================== --- trunk/Web/engine/simplepie/simplepie.inc 2009-10-26 13:27:43 UTC (rev 7030) +++ trunk/Web/engine/simplepie/simplepie.inc 2009-10-31 18:53:08 UTC (rev 7031) @@ -5,7 +5,7 @@ * A PHP-Based RSS and Atom Feed Framework. * Takes the hard work out of managing a complete RSS/Atom solution. * - * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon + * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are @@ -33,8 +33,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package SimplePie - * @version 1.1.3 - * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon + * @version 1.2 + * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon * @author Ryan Parman * @author Geoffrey Sneddon * @link http://simplepie.org/ SimplePie @@ -51,12 +51,12 @@ /** * SimplePie Version */ -define('SIMPLEPIE_VERSION', '1.1.3'); +define('SIMPLEPIE_VERSION', '1.2'); /** * SimplePie Build */ -define('SIMPLEPIE_BUILD', 20081219); +define('SIMPLEPIE_BUILD', '20090627192103'); /** * SimplePie Website URL @@ -242,6 +242,21 @@ define('SIMPLEPIE_CONSTRUCT_ALL', 63); /** + * Don't change case + */ +define('SIMPLEPIE_SAME_CASE', 1); + +/** + * Change to lowercase + */ +define('SIMPLEPIE_LOWERCASE', 2); + +/** + * Change to uppercase + */ +define('SIMPLEPIE_UPPERCASE', 4); + +/** * PCRE for HTML attributes */ define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*'); @@ -376,11 +391,6 @@ * SimplePie * * @package SimplePie - * @version "Razzleberry" - * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon - * @author Ryan Parman - * @author Geoffrey Sneddon - * @todo Option for type of fetching (cache, not modified header, fetch, etc.) */ class SimplePie { @@ -639,6 +649,13 @@ var $max_checked_feeds = 10; /** + * @var array All the feeds found during the autodiscovery process + * @see SimplePie::get_all_discovered_feeds() + * @access private + */ + var $all_discovered_feeds = array(); + + /** * @var string Web-accessible path to the handler_favicon.php file. * @see SimplePie::set_favicon_handler() * @access private @@ -751,21 +768,24 @@ */ function __destruct() { - if (!empty($this->data['items'])) + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) { - foreach ($this->data['items'] as $item) + if (!empty($this->data['items'])) { - $item->__destruct(); + foreach ($this->data['items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['items']); } - unset($this->data['items']); - } - if (!empty($this->data['ordered_items'])) - { - foreach ($this->data['ordered_items'] as $item) + if (!empty($this->data['ordered_items'])) { - $item->__destruct(); + foreach ($this->data['ordered_items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['ordered_items']); } - unset($this->data['ordered_items']); } } @@ -1437,7 +1457,7 @@ */ function set_favicon_handler($page = false, $qs = 'i') { - if ($page != false) + if ($page !== false) { $this->favicon_handler = $page . '?' . $qs . '='; } @@ -1456,7 +1476,7 @@ */ function set_image_handler($page = false, $qs = 'i') { - if ($page != false) + if ($page !== false) { $this->sanitize->set_image_handler($page . '?' . $qs . '='); } @@ -1479,45 +1499,31 @@ function init() { + // Check absolute bare minimum requirements. if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre')) { return false; } - if (isset($_GET[$this->javascript])) + // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. + elseif (!extension_loaded('xmlreader')) { - if (function_exists('ob_gzhandler')) + static $xml_is_sane = null; + if ($xml_is_sane === null) { - ob_start('ob_gzhandler'); + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); } - header('Content-type: text/javascript; charset: UTF-8'); - header('Cache-Control: must-revalidate'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days - ?> -function embed_odeo(link) { - document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>'); -} + if (!$xml_is_sane) + { + return false; + } + } -function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { - if (placeholder != '') { - document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); - } - else { - document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); - } -} - -function embed_flash(bgcolor, width, height, link, loop, type) { - document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>'); -} - -function embed_flv(width, height, link, placeholder, loop, player) { - document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>'); -} - -function embed_wmedia(width, height, link) { - document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); -} - <?php + if (isset($_GET[$this->javascript])) + { + SimplePie_Misc::output_javascript(); exit; } @@ -1547,13 +1553,13 @@ if (!empty($this->data)) { // If the cache is for an outdated build of SimplePie - if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD) + if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) { $cache->unlink(); $this->data = array(); } // If we've hit a collision just rerun it with caching disabled - elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url) + elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) { $cache = false; $this->data = array(); @@ -1565,7 +1571,7 @@ if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) { // Do not need to do feed autodiscovery yet. - if ($this->data['feed_url'] == $this->data['url']) + if ($this->data['feed_url'] === $this->data['url']) { $cache->unlink(); $this->data = array(); @@ -1595,7 +1601,7 @@ $file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen); if ($file->success) { - if ($file->status_code == 304) + if ($file->status_code === 304) { $cache->touch(); return true; @@ -1627,7 +1633,7 @@ // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. if (!isset($file)) { - if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url) + if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url) { $file =& $this->file; } @@ -1637,7 +1643,7 @@ } } // If the file connection has an error, set SimplePie::error to that and quit - if (!$file->success) + if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) { $this->error = $file->error; if (!empty($this->data)) @@ -1658,14 +1664,14 @@ { // We need to unset this so that if SimplePie::set_file() has been called that object is untouched unset($file); - if ($file = $locate->find($this->autodiscovery)) + if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds)) { if ($cache) { $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); if (!$cache->save($this)) { - trigger_error("$cache->name is not writeable", E_USER_WARNING); + trigger_error("$this->cache_location is not writeable", E_USER_WARNING); } $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'); } @@ -1683,7 +1689,7 @@ $headers = $file->headers; $data = $file->body; - $sniffer = new $this->content_type_sniffer_class($file); + $sniffer =& new $this->content_type_sniffer_class($file); $sniffed = $sniffer->get_type(); } else @@ -1783,8 +1789,15 @@ } } } - // We have an error, just set SimplePie::error to it and quit - $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); + if(isset($parser)) + { + // We have an error, just set SimplePie_Misc::error to it and quit + $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); + } + else + { + $this->error = 'The data could not be converted to UTF-8'; + } SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); return false; } @@ -1879,18 +1892,18 @@ $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; } } - elseif (isset($this->data['child']['']['rss'])) + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) { $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; - if (isset($this->data['child']['']['rss'][0]['attribs']['']['version'])) + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) { - switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version'])) + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) { case '0.91': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; - if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data'])) + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) { - switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data'])) + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) { case '0': $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; @@ -1959,9 +1972,9 @@ { $file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) + if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) { - $sniffer = new $this->content_type_sniffer_class($file); + $sniffer =& new $this->content_type_sniffer_class($file); if (substr($sniffer->get_type(), 0, 6) === 'image/') { if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) @@ -1974,6 +1987,11 @@ return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); } } + // not an image + else + { + return false; + } } } } @@ -2018,7 +2036,7 @@ { if ($this->feed_url !== null) { - return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); + return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); } else { @@ -2063,12 +2081,12 @@ { if ($this->subscribe_url()) { - $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url); + $return = $feed_url . rawurlencode($this->feed_url); if ($site_url !== null && $this->get_link() !== null) { - $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link()); + $return .= $site_url . rawurlencode($this->get_link()); } - return $return; + return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); } else { @@ -2083,7 +2101,7 @@ function subscribe_bloglines() { - return urldecode($this->subscribe_service('http://www.bloglines.com/sub/')); + return $this->subscribe_service('http://www.bloglines.com/sub/'); } function subscribe_eskobo() @@ -2177,9 +2195,9 @@ } if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { - if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag])) + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) { - return $this->data['child']['']['rss'][0]['child'][$namespace][$tag]; + return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]; } } return null; @@ -2217,7 +2235,7 @@ } if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { - if ($channel = $this->get_feed_tags('', 'channel')) + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) { if (isset($channel[0]['child'][$namespace][$tag])) { @@ -2253,7 +2271,7 @@ } if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { - if ($image = $this->get_channel_tags('', 'image')) + if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) { if (isset($image[0]['child'][$namespace][$tag])) { @@ -2303,7 +2321,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_channel_tags('', 'title')) + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } @@ -2357,9 +2375,20 @@ } $categories[] =& new $this->category_class($term, $scheme, $label); } - foreach ((array) $this->get_channel_tags('', 'category') as $category) + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { - $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] =& new $this->category_class($term, $scheme, null); } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { @@ -2591,7 +2620,7 @@ { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - if ($links = $this->get_channel_tags('', 'link')) + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } @@ -2611,7 +2640,7 @@ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; } } - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; } @@ -2629,6 +2658,11 @@ } } + function get_all_discovered_feeds() + { + return $this->all_discovered_feeds; + } + function get_description() { if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) @@ -2647,9 +2681,9 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_channel_tags('', 'description')) + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) { @@ -2683,7 +2717,7 @@ { return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - elseif ($return = $this->get_channel_tags('', 'copyright')) + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -2703,7 +2737,7 @@ function get_language() { - if ($return = $this->get_channel_tags('', 'language')) + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -2783,7 +2817,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - elseif ($return = $this->get_image_tags('', 'title')) + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -2823,7 +2857,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } - elseif ($return = $this->get_image_tags('', 'url')) + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } @@ -2843,7 +2877,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } - elseif ($return = $this->get_image_tags('', 'link')) + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); } @@ -2855,11 +2889,11 @@ function get_image_width() { - if ($return = $this->get_image_tags('', 'width')) + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) { return round($return[0]['data']); } - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url')) + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 88.0; } @@ -2871,11 +2905,11 @@ function get_image_height() { - if ($return = $this->get_image_tags('', 'height')) + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) { return round($return[0]['data']); } - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url')) + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { return 31.0; } @@ -2887,8 +2921,9 @@ function get_item_quantity($max = 0) { + $max = (int) $max; $qty = count($this->get_items()); - if ($max == 0) + if ($max === 0) { return $qty; } @@ -2913,58 +2948,62 @@ function get_items($start = 0, $end = 0) { - if (!empty($this->multifeed_objects)) + if (!isset($this->data['items'])) { - return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); - } - elseif (!isset($this->data['items'])) - { - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) + if (!empty($this->multifeed_objects)) { - $keys = array_keys($items); - foreach ($keys as $key) - { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); - } + $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) + else { - $keys = array_keys($items); - foreach ($keys as $key) + $this->data['items'] = array(); + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] =& new $this->item_class($this, $items[$key]); + } } - } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] =& new $this->item_class($this, $items[$key]); + } } - } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] =& new $this->item_class($this, $items[$key]); + } } - } - if ($items = $this->get_channel_tags('', 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] =& new $this->item_class($this, $items[$key]); + } } + if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] =& new $this->item_class($this, $items[$key]); + } + } } } if (!empty($this->data['items'])) { // If we want to order it by date, check if all items have a date, and then sort it - if ($this->order_by_date) + if ($this->order_by_date && empty($this->multifeed_objects)) { if (!isset($this->data['ordered_items'])) { @@ -2992,7 +3031,7 @@ } // Slice the data as desired - if ($end == 0) + if ($end === 0) { return array_slice($items, $start); } @@ -3007,11 +3046,17 @@ } } + /** + * @static + */ function sort_items($a, $b) { return $a->get_date('U') <= $b->get_date('U'); } + /** + * @static + */ function merge_items($urls, $start = 0, $end = 0, $limit = 0) { if (is_array($urls) && sizeof($urls) > 0) @@ -3044,7 +3089,7 @@ usort($items, array('SimplePie', 'sort_items')); } - if ($end == 0) + if ($end === 0) { return array_slice($items, $start); } @@ -3082,7 +3127,10 @@ */ function __destruct() { - unset($this->feed); + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) + { + unset($this->feed); + } } function get_item_tags($namespace, $tag) @@ -3124,7 +3172,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - elseif ($return = $this->get_item_tags('', 'guid')) + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -3175,7 +3223,7 @@ { $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_item_tags('', 'title')) + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } @@ -3209,7 +3257,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_item_tags('', 'description')) + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); } @@ -3299,9 +3347,20 @@ } $categories[] =& new $this->feed->category_class($term, $scheme, $label); } - foreach ((array) $this->get_item_tags('', 'category') as $category) + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { - $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] =& new $this->feed->category_class($term, $scheme, null); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { @@ -3406,9 +3465,6 @@ } } - /** - * @todo Atom inheritance (item author, source author, feed author) - */ function get_authors() { $authors = array(); @@ -3456,7 +3512,7 @@ $authors[] =& new $this->feed->author_class($name, $url, $email); } } - if ($author = $this->get_item_tags('', 'author')) + if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) { $authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); } @@ -3535,7 +3591,7 @@ { $this->data['date']['raw'] = $return[0]['data']; } - elseif ($return = $this->get_item_tags('', 'pubDate')) + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) { $this->data['date']['raw'] = $return[0]['data']; } @@ -3656,13 +3712,13 @@ { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - if ($links = $this->get_item_tags('', 'link')) + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - if ($links = $this->get_item_tags('', 'guid')) + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) { - if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true') + if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } @@ -3683,7 +3739,7 @@ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; } } - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; } @@ -4249,7 +4305,7 @@ $restriction_relationship = 'allow'; $restriction_type = null; $restriction_value = 'itunes'; - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes') + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { $restriction_relationship = 'deny'; } @@ -4285,7 +4341,7 @@ $restriction_relationship = 'allow'; $restriction_type = null; $restriction_value = 'itunes'; - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes') + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { $restriction_relationship = 'deny'; } @@ -5396,7 +5452,7 @@ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) { - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure') + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') { // Attributes $bitrate = null; @@ -5431,7 +5487,7 @@ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) { - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure') + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') { // Attributes $bitrate = null; @@ -5464,7 +5520,7 @@ } } - if ($enclosure = $this->get_item_tags('', 'enclosure')) + if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) { if (isset($enclosure[0]['attribs']['']['url'])) { @@ -5499,7 +5555,7 @@ } } - if (sizeof($this->data['enclosures']) == 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) + if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) { // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $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); @@ -5578,16 +5634,16 @@ { if ($this->get_permalink() !== null) { - $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink()); + $return = $item_url . rawurlencode($this->get_permalink()); if ($title_url !== null && $this->get_title() !== null) { - $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title()); + $return .= $title_url . rawurlencode($this->get_title()); } if ($summary_url !== null && $this->get_description() !== null) { - $return .= $this->sanitize($summary_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_description()); + $return .= $summary_url . rawurlencode($this->get_description()); } - return $return; + return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); } else { @@ -5682,14 +5738,6 @@ return md5(serialize($this->data)); } - /** - * Remove items that link back to this before destroying this object - */ - function __destruct() - { - unset($this->item); - } - function get_source_tags($namespace, $tag) { if (isset($this->data['child'][$namespace][$tag])) @@ -5735,7 +5783,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_source_tags('', 'title')) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } @@ -5789,9 +5837,20 @@ } $categories[] =& new $this->item->feed->category_class($term, $scheme, $label); } - foreach ((array) $this->get_source_tags('', 'category') as $category) + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { - $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] =& new $this->item->feed->category_class($term, $scheme, null); } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { @@ -6023,7 +6082,7 @@ { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } - if ($links = $this->get_source_tags('', 'link')) + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); } @@ -6043,7 +6102,7 @@ $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; } } - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; } @@ -6079,7 +6138,7 @@ { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } - elseif ($return = $this->get_source_tags('', 'description')) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); } @@ -6115,7 +6174,7 @@ { return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); } - elseif ($return = $this->get_source_tags('', 'copyright')) + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -6135,7 +6194,7 @@ function get_language() { - if ($return = $this->get_source_tags('', 'language')) + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } @@ -6934,11 +6993,11 @@ $mime = $mime[0]; // Process values for 'auto' - if ($width == 'auto') + if ($width === 'auto') { - if ($mime == 'video') + if ($mime === 'video') { - if ($height == 'auto') + if ($height === 'auto') { $width = 480; } @@ -6957,15 +7016,15 @@ } } - if ($height == 'auto') + if ($height === 'auto') { - if ($mime == 'audio') + if ($mime === 'audio') { $height = 0; } - elseif ($mime == 'video') + elseif ($mime === 'video') { - if ($width == 'auto') + if ($width === 'auto') { if ($widescreen) { @@ -6990,17 +7049,17 @@ $height = 376; } } - elseif ($mime == 'audio') + elseif ($mime === 'audio') { $height = 0; } // Set proper placeholder value - if ($mime == 'audio') + if ($mime === 'audio') { $placeholder = $audio; } - elseif ($mime == 'video') + elseif ($mime === 'video') { $placeholder = $video; } @@ -7019,7 +7078,7 @@ } // Odeo Feed MP3's - if ($handler == 'odeo') + if ($handler === 'odeo') { if ($native) { @@ -7032,7 +7091,7 @@ } // Flash - elseif ($handler == 'flash') + elseif ($handler === 'flash') { if ($native) { @@ -7046,7 +7105,7 @@ // Flash Media Player file types. // Preferred handler for MP3 file types. - elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != '')) + elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) { $height += 20; if ($native) @@ -7061,15 +7120,17 @@ // QuickTime 7 file types. Need to test with QuickTime 6. // Only handle MP3's if the Flash Media Player is not present. - elseif ($handler == 'quicktime' || ($handler == 'mp3' && $mediaplayer == '')) + elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) { $height += 16; if ($native) { - if ($placeholder != ""){ + if ($placeholder !== '') + { $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; } - else { + else + { $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; } } @@ -7080,7 +7141,7 @@ } // Windows Media - elseif ($handler == 'wmedia') + elseif ($handler === 'wmedia') { $height += 45; if ($native) @@ -7102,7 +7163,7 @@ function get_real_type($find_handler = false) { // If it's Odeo, let's get it out of the way. - if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com') + if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com') { return 'odeo'; } @@ -7630,7 +7691,7 @@ } $this->headers = curl_exec($fp); - if (curl_errno($fp) == 23 || curl_errno($fp) == 61) + if (curl_errno($fp) === 23 || curl_errno($fp) === 61) { curl_setopt($fp, CURLOPT_ENCODING, 'none'); $this->headers = curl_exec($fp); @@ -7652,7 +7713,7 @@ $this->headers = $parser->headers; $this->body = $parser->body; $this->status_code = $parser->status_code; - if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + 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) { $this->redirects++; $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); @@ -7665,7 +7726,7 @@ { $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; $url_parts = parse_url($url); - if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https') + if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { $url_parts['host'] = "ssl://$url_parts[host]"; $url_parts['port'] = 443; @@ -7733,7 +7794,7 @@ $this->headers = $parser->headers; $this->body = $parser->body; $this->status_code = $parser->status_code; - if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + 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) { $this->redirects++; $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); @@ -7746,7 +7807,7 @@ { case 'gzip': case 'x-gzip': - $decoder = new SimplePie_gzdecode($this->body); + $decoder =& new SimplePie_gzdecode($this->body); if (!$decoder->parse()) { $this->error = 'Unable to decode HTTP "gzip" stream'; @@ -8440,7 +8501,7 @@ if ($this->flags & 8) { // Get the length of the filename - $len = strspn($this->compressed_data, "\x00", $this->position); + $len = strcspn($this->compressed_data, "\x00", $this->position); // Check the length of the string is still valid $this->min_compressed_size += $len + 1; @@ -8460,7 +8521,7 @@ if ($this->flags & 16) { // Get the length of the comment - $len = strspn($this->compressed_data, "\x00", $this->position); + $len = strcspn($this->compressed_data, "\x00", $this->position); // Check the length of the string is still valid $this->min_compressed_size += $len + 1; @@ -8558,7 +8619,19 @@ */ function create($location, $filename, $extension) { - return new SimplePie_Cache_File($location, $filename, $extension); + $location_iri =& new SimplePie_IRI($location); + switch ($location_iri->get_scheme()) + { + case 'mysql': + if (extension_loaded('mysql')) + { + return new SimplePie_Cache_MySQL($location_iri, $filename, $extension); + } + break; + + default: + return new SimplePie_Cache_File($location, $filename, $extension); + } } } @@ -8572,9 +8645,9 @@ function SimplePie_Cache_File($location, $filename, $extension) { $this->location = $location; - $this->filename = rawurlencode($filename); - $this->extension = rawurlencode($extension); - $this->name = "$location/$this->filename.$this->extension"; + $this->filename = $filename; + $this->extension = $extension; + $this->name = "$this->location/$this->filename.$this->extension"; } function save($data) @@ -8643,112 +8716,398 @@ } } -class SimplePie_Misc +class SimplePie_Cache_DB { - function time_hms($seconds) + function prepare_simplepie_object_for_cache($data) { - $time = ''; + $items = $data->get_items(); + $items_by_id = array(); - $hours = floor($seconds / 3600); - $remainder = $seconds % 3600; - if ($hours > 0) + if (!empty($items)) { - $time .= $hours.':'; + foreach ($items as $item) + { + $items_by_id[$item->get_id()] = $item; + } + + if (count($items_by_id) !== count($items)) + { + $items_by_id = array(); + foreach ($items as $item) + { + $items_by_id[$item->get_id(true)] = $item; + } + } + + if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]; + } + else + { + $channel = null; + } + + if ($channel !== null) + { + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']); + } + } + if (isset($data->data['items'])) + { + unset($data->data['items']); + } + if (isset($data->data['ordered_items'])) + { + unset($data->data['ordered_items']); + } } + return array(serialize($data->data), $items_by_id); + } +} - $minutes = floor($remainder / 60); - $seconds = $remainder % 60; - if ($minutes < 10 && $hours > 0) +class SimplePie_Cache_MySQL extends SimplePie_Cache_DB +{ + var $mysql; + var $options; + var $id; + + function SimplePie_Cache_MySQL($mysql_location, $name, $extension) + { + $host = $mysql_location->get_host(); + if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')') { - $minutes = '0' . $minutes; + $server = ':' . substr($host, 5, -1); } - if ($seconds < 10) + else { - $seconds = '0' . $seconds; + $server = $host; + if ($mysql_location->get_port() !== null) + { + $server .= ':' . $mysql_location->get_port(); + } } - $time .= $minutes.':'; - $time .= $seconds; + if (strpos($mysql_location->get_userinfo(), ':') !== false) + { + list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2); + } + else + { + $username = $mysql_location->get_userinfo(); + $password = null; + } - return $time; + if ($this->mysql = mysql_connect($server, $username, $password)) + { + $this->id = $name . $extension; + $this->options = SimplePie_Misc::parse_str($mysql_location->get_query()); + if (!isset($this->options['prefix'][0])) + { + $this->options['prefix'][0] = ''; + } + + if (mysql_select_db(ltrim($mysql_location->get_path(), '/')) + && mysql_query('SET NAMES utf8') + && ($query = mysql_unbuffered_query('SHOW TABLES'))) + { + $db = array(); + while ($row = mysql_fetch_row($query)) + { + $db[] = $row[0]; + } + + if (!in_array($this->options['prefix'][0] . 'cache_data', $db)) + { + if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . '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)))')) + { + $this->mysql = null; + } + } + + if (!in_array($this->options['prefix'][0] . 'items', $db)) + { + if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))')) + { + $this->mysql = null; + } + } + } + else + { + $this->mysql = null; + } + } } - function absolutize_url($relative, $base) + function save($data) { - if ($relative !== '') + if ($this->mysql) { - $relative = SimplePie_Misc::parse_url($relative); - if ($relative['scheme'] !== '') + $feed_id = "'" . mysql_real_escape_string($this->id) . "'"; + + if (is_a($data, 'SimplePie')) { - $target = $relative; - } - elseif ($base !== '') - { - $base = SimplePie_Misc::parse_url($base); - $target = SimplePie_Misc::parse_url(''); - if ($relative['authority'] !== '') + if (SIMPLEPIE_PHP5) { - $target = $relative; - $target['scheme'] = $base['scheme']; + // This keyword needs to defy coding standards for PHP4 compatibility + $data = clone($data); } - else + + $prepared = $this->prepare_simplepie_object_for_cache($data); + + if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) { - $target['scheme'] = $base['scheme']; - $target['authority'] = $base['authority']; - if ($relative['path'] !== '') + if (mysql_num_rows($query)) { - if (strpos($relative['path'], '/') === 0) + $items = count($prepared[1]); + if ($items) { - $target['path'] = $relative['path']; + $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; } - elseif ($base['authority'] !== '' && $base['path'] === '') + else { - $target['path'] = '/' . $relative['path']; + $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; } - elseif (($last_segment = strrpos($base['path'], '/')) !== false) + + if (!mysql_query($sql, $this->mysql)) { - $target['path'] = substr($base['path'], 0, $last_segment + 1) . $relative['path']; + return false; } - else - { - $target['path'] = $relative['path']; - } - $target['query'] = $relative['query']; } - else + elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql)) { - $target['path'] = $base['path']; - if ($relative['query'] !== '') + return false; + } + + $ids = array_keys($prepared[1]); + if (!empty($ids)) + { + foreach ($ids as $id) { - $target['query'] = $relative['query']; + $database_ids[] = mysql_real_escape_string($id); } - elseif ($base['query'] !== '') + + if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql)) { - $target['query'] = $base['query']; + $existing_ids = array(); + while ($row = mysql_fetch_row($query)) + { + $existing_ids[] = $row[0]; + } + + $new_ids = array_diff($ids, $existing_ids); + + foreach ($new_ids as $new_id) + { + if (!($date = $prepared[1][$new_id]->get_date('U'))) + { + $date = time(); + } + + if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql)) + { + return false; + } + } + return true; } } + else + { + return true; + } } - $target['fragment'] = $relative['fragment']; } + elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) + { + if (mysql_num_rows($query)) + { + if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql)) + { + return true; + } + } + elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql)) + { + return true; + } + } + } + return false; + } + + function load() + { + if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) + { + $data = unserialize($row[1]); + + if (isset($this->options['items'][0])) + { + $items = (int) $this->options['items'][0]; + } else { - // No base URL, just return the relative URL - $target = $relative; + $items = (int) $row[0]; } - $return = SimplePie_Misc::compress_parse_url($target['scheme'], $target['authority'], $target['path'], $target['query'], $target['fragment']); + + if ($items !== 0) + { + if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]; + } + else + { + $feed = null; + } + + if ($feed !== null) + { + $sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC'; + if ($items > 0) + { + $sql .= ' LIMIT ' . $items; + } + + if ($query = mysql_unbuffered_query($sql, $this->mysql)) + { + while ($row = mysql_fetch_row($query)) + { + $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]); + } + } + else + { + return false; + } + } + } + return $data; } + return false; + } + + function mtime() + { + if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) + { + return $row[0]; + } else { - $return = $base; + return false; } - $return = SimplePie_Misc::normalize_url($return); - return $return; } + function touch() + { + if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql)) + { + return true; + } + else + { + return false; + } + } + + function unlink() + { + if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql))) + { + return true; + } + else + { + return false; + } + } +} + +class SimplePie_Misc +{ + function time_hms($seconds) + { + $time = ''; + + $hours = floor($seconds / 3600); + $remainder = $seconds % 3600; + if ($hours > 0) + { + $time .= $hours.':'; + } + + $minutes = floor($remainder / 60); + $seconds = $remainder % 60; + if ($minutes < 10 && $hours > 0) + { + $minutes = '0' . $minutes; + } + if ($seconds < 10) + { + $seconds = '0' . $seconds; + } + + $time .= $minutes.':'; + $time .= $seconds; + + return $time; + } + + function absolutize_url($relative, $base) + { + $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative); + return $iri->get_iri(); + } + function remove_dot_segments($input) { $output = ''; - while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..') + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, if (strpos($input, '../') === 0) @@ -8764,7 +9123,7 @@ { $input = substr_replace($input, '/', 0, 3); } - elseif ($input == '/.') + elseif ($input === '/.') { $input = '/'; } @@ -8774,13 +9133,13 @@ $input = substr_replace($input, '/', 0, 4); $output = substr_replace($output, '', strrpos($output, '/')); } - elseif ($input == '/..') + elseif ($input === '/..') { $input = '/'; $output = substr_replace($output, '', strrpos($output, '/')); } // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, - elseif ($input == '.' || $input == '..') + elseif ($input === '.' || $input === '..') { $input = ''; } @@ -8824,7 +9183,7 @@ { for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) { - if (count($attribs[$j]) == 2) + if (count($attribs[$j]) === 2) { $attribs[$j][2] = $attribs[$j][1]; } @@ -8857,22 +9216,25 @@ function error($message, $level, $file, $line) { - switch ($level) + if ((ini_get('error_reporting') & $level) > 0) { - case E_USER_ERROR: - $note = 'PH... [truncated message content] |