replace simplepie-dev with simplepie-stable

This commit is contained in:
Alessandro Cosentino 2012-07-17 15:24:26 -04:00
Родитель 913beaef29
Коммит 05fd3ebe12
39 изменённых файлов: 3356 добавлений и 2074 удалений

26
3rdparty/SimplePie/LICENSE.txt поставляемый
Просмотреть файл

@ -1,26 +0,0 @@
Copyright (c) 2004-2007, Ryan Parman and Geoffrey Sneddon.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
* Neither the name of the SimplePie Team nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

996
3rdparty/SimplePie/SimplePie/IRI.php поставляемый
Просмотреть файл

@ -1,996 +0,0 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3-dev
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* IRI parser/serialiser
*
* @package SimplePie
*/
class SimplePie_IRI
{
/**
* Scheme
*
* @access private
* @var string
*/
var $scheme;
/**
* User Information
*
* @access private
* @var string
*/
var $userinfo;
/**
* Host
*
* @access private
* @var string
*/
var $host;
/**
* Port
*
* @access private
* @var string
*/
var $port;
/**
* Path
*
* @access private
* @var string
*/
var $path;
/**
* Query
*
* @access private
* @var string
*/
var $query;
/**
* Fragment
*
* @access private
* @var string
*/
var $fragment;
/**
* Whether the object represents a valid IRI
*
* @access private
* @var array
*/
var $valid = array();
/**
* Return the entire IRI when you try and read the object as a string
*
* @access public
* @return string
*/
public function __toString()
{
return $this->get_iri();
}
/**
* Create a new IRI object, from a specified string
*
* @access public
* @param string $iri
* @return SimplePie_IRI
*/
public function __construct($iri)
{
$iri = (string) $iri;
if ($iri !== '')
{
$parsed = $this->parse_iri($iri);
$this->set_scheme($parsed['scheme']);
$this->set_authority($parsed['authority']);
$this->set_path($parsed['path']);
$this->set_query($parsed['query']);
$this->set_fragment($parsed['fragment']);
}
}
/**
* Create a new IRI object by resolving a relative IRI
*
* @static
* @access public
* @param SimplePie_IRI $base Base IRI
* @param string $relative Relative IRI
* @return SimplePie_IRI
*/
public static function absolutize($base, $relative)
{
$relative = (string) $relative;
if ($relative !== '')
{
$relative = new SimplePie_IRI($relative);
if ($relative->get_scheme() !== null)
{
$target = $relative;
}
elseif ($base->get_iri() !== null)
{
if ($relative->get_authority() !== null)
{
$target = $relative;
$target->set_scheme($base->get_scheme());
}
else
{
$target = new SimplePie_IRI('');
$target->set_scheme($base->get_scheme());
$target->set_userinfo($base->get_userinfo());
$target->set_host($base->get_host());
$target->set_port($base->get_port());
if ($relative->get_path() !== null)
{
if (strpos($relative->get_path(), '/') === 0)
{
$target->set_path($relative->get_path());
}
elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null)
{
$target->set_path('/' . $relative->get_path());
}
elseif (($last_segment = strrpos($base->get_path(), '/')) !== false)
{
$target->set_path(substr($base->get_path(), 0, $last_segment + 1) . $relative->get_path());
}
else
{
$target->set_path($relative->get_path());
}
$target->set_query($relative->get_query());
}
else
{
$target->set_path($base->get_path());
if ($relative->get_query() !== null)
{
$target->set_query($relative->get_query());
}
elseif ($base->get_query() !== null)
{
$target->set_query($base->get_query());
}
}
}
$target->set_fragment($relative->get_fragment());
}
else
{
// No base URL, just return the relative URL
$target = $relative;
}
}
else
{
$target = $base;
}
return $target;
}
/**
* Parse an IRI into scheme/authority/path/query/fragment segments
*
* @access private
* @param string $iri
* @return array
*/
public function parse_iri($iri)
{
preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $iri, $match);
for ($i = count($match); $i <= 9; $i++)
{
$match[$i] = '';
}
return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
}
/**
* Remove dot segments from a path
*
* @access private
* @param string $input
* @return string
*/
public function remove_dot_segments($input)
{
$output = '';
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)
{
$input = substr($input, 3);
}
elseif (strpos($input, './') === 0)
{
$input = substr($input, 2);
}
// B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
elseif (strpos($input, '/./') === 0)
{
$input = substr_replace($input, '/', 0, 3);
}
elseif ($input === '/.')
{
$input = '/';
}
// C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
elseif (strpos($input, '/../') === 0)
{
$input = substr_replace($input, '/', 0, 4);
$output = substr_replace($output, '', strrpos($output, '/'));
}
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 === '..')
{
$input = '';
}
// E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
elseif (($pos = strpos($input, '/', 1)) !== false)
{
$output .= substr($input, 0, $pos);
$input = substr_replace($input, '', 0, $pos);
}
else
{
$output .= $input;
$input = '';
}
}
return $output . $input;
}
/**
* Replace invalid character with percent encoding
*
* @param string $string Input string
* @param string $valid_chars Valid characters not in iunreserved or iprivate (this is ASCII-only)
* @param int $case Normalise case
* @param bool $iprivate Allow iprivate
* @return string
*/
protected function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE, $iprivate = false)
{
// Normalize as many pct-encoded sections as possible
$string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string);
// Replace invalid percent characters
$string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
// Add unreserved and % to $valid_chars (the latter is safe because all
// pct-encoded sections are now valid).
$valid_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%';
// Now replace any bytes that aren't allowed with their pct-encoded versions
$position = 0;
$strlen = strlen($string);
while (($position += strspn($string, $valid_chars, $position)) < $strlen)
{
$value = ord($string[$position]);
// Start position
$start = $position;
// By default we are valid
$valid = true;
// No one byte sequences are valid due to the while.
// Two byte sequence:
if (($value & 0xE0) === 0xC0)
{
$character = ($value & 0x1F) << 6;
$length = 2;
$remaining = 1;
}
// Three byte sequence:
elseif (($value & 0xF0) === 0xE0)
{
$character = ($value & 0x0F) << 12;
$length = 3;
$remaining = 2;
}
// Four byte sequence:
elseif (($value & 0xF8) === 0xF0)
{
$character = ($value & 0x07) << 18;
$length = 4;
$remaining = 3;
}
// Invalid byte:
else
{
$valid = false;
$length = 1;
$remaining = 0;
}
if ($remaining)
{
if ($position + $length <= $strlen)
{
for ($position++; $remaining; $position++)
{
$value = ord($string[$position]);
// Check that the byte is valid, then add it to the character:
if (($value & 0xC0) === 0x80)
{
$character |= ($value & 0x3F) << (--$remaining * 6);
}
// If it is invalid, count the sequence as invalid and reprocess the current byte:
else
{
$valid = false;
$position--;
break;
}
}
}
else
{
$position = $strlen - 1;
$valid = false;
}
}
// Percent encode anything invalid or not in ucschar
if (
// Invalid sequences
!$valid
// Non-shortest form sequences are invalid
|| $length > 1 && $character <= 0x7F
|| $length > 2 && $character <= 0x7FF
|| $length > 3 && $character <= 0xFFFF
// Outside of range of ucschar codepoints
// Noncharacters
|| ($character & 0xFFFE) === 0xFFFE
|| $character >= 0xFDD0 && $character <= 0xFDEF
|| (
// Everything else not in ucschar
$character > 0xD7FF && $character < 0xF900
|| $character < 0xA0
|| $character > 0xEFFFD
)
&& (
// Everything not in iprivate, if it applies
!$iprivate
|| $character < 0xE000
|| $character > 0x10FFFD
)
)
{
// If we were a character, pretend we weren't, but rather an error.
if ($valid)
$position--;
for ($j = $start; $j <= $position; $j++)
{
$string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1);
$j += 2;
$position += 2;
$strlen += 2;
}
}
}
// Normalise case
if ($case & SIMPLEPIE_LOWERCASE)
{
$string = strtolower($string);
}
elseif ($case & SIMPLEPIE_UPPERCASE)
{
$string = strtoupper($string);
}
return $string;
}
/**
* Callback function for preg_replace_callback.
*
* Removes sequences of percent encoded bytes that represent UTF-8
* encoded characters in iunreserved
*
* @param array $match PCRE match
* @return string Replacement
*/
protected function remove_iunreserved_percent_encoded($match)
{
// As we just have valid percent encoded sequences we can just explode
// and ignore the first member of the returned array (an empty string).
$bytes = explode('%', $match[0]);
// Initialize the new string (this is what will be returned) and that
// there are no bytes remaining in the current sequence (unsurprising
// at the first byte!).
$string = '';
$remaining = 0;
// Loop over each and every byte, and set $value to its value
for ($i = 1, $len = count($bytes); $i < $len; $i++)
{
$value = hexdec($bytes[$i]);
// If we're the first byte of sequence:
if (!$remaining)
{
// Start position
$start = $i;
// By default we are valid
$valid = true;
// One byte sequence:
if ($value <= 0x7F)
{
$character = $value;
$length = 1;
}
// Two byte sequence:
elseif (($value & 0xE0) === 0xC0)
{
$character = ($value & 0x1F) << 6;
$length = 2;
$remaining = 1;
}
// Three byte sequence:
elseif (($value & 0xF0) === 0xE0)
{
$character = ($value & 0x0F) << 12;
$length = 3;
$remaining = 2;
}
// Four byte sequence:
elseif (($value & 0xF8) === 0xF0)
{
$character = ($value & 0x07) << 18;
$length = 4;
$remaining = 3;
}
// Invalid byte:
else
{
$valid = false;
$remaining = 0;
}
}
// Continuation byte:
else
{
// Check that the byte is valid, then add it to the character:
if (($value & 0xC0) === 0x80)
{
$remaining--;
$character |= ($value & 0x3F) << ($remaining * 6);
}
// If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence:
else
{
$valid = false;
$remaining = 0;
$i--;
}
}
// If we've reached the end of the current byte sequence, append it to Unicode::$data
if (!$remaining)
{
// Percent encode anything invalid or not in iunreserved
if (
// Invalid sequences
!$valid
// Non-shortest form sequences are invalid
|| $length > 1 && $character <= 0x7F
|| $length > 2 && $character <= 0x7FF
|| $length > 3 && $character <= 0xFFFF
// Outside of range of iunreserved codepoints
|| $character < 0x2D
|| $character > 0xEFFFD
// Noncharacters
|| ($character & 0xFFFE) === 0xFFFE
|| $character >= 0xFDD0 && $character <= 0xFDEF
// Everything else not in iunreserved (this is all BMP)
|| $character === 0x2F
|| $character > 0x39 && $character < 0x41
|| $character > 0x5A && $character < 0x61
|| $character > 0x7A && $character < 0x7E
|| $character > 0x7E && $character < 0xA0
|| $character > 0xD7FF && $character < 0xF900
)
{
for ($j = $start; $j <= $i; $j++)
{
$string .= '%' . strtoupper($bytes[$j]);
}
}
else
{
for ($j = $start; $j <= $i; $j++)
{
$string .= chr(hexdec($bytes[$j]));
}
}
}
}
// If we have any bytes left over they are invalid (i.e., we are
// mid-way through a multi-byte sequence)
if ($remaining)
{
for ($j = $start; $j < $len; $j++)
{
$string .= '%' . strtoupper($bytes[$j]);
}
}
return $string;
}
/**
* Check if the object represents a valid IRI
*
* @access public
* @return bool
*/
public function is_valid()
{
return array_sum($this->valid) === count($this->valid);
}
/**
* Set the scheme. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @access public
* @param string $scheme
* @return bool
*/
public function set_scheme($scheme)
{
if ($scheme === null || $scheme === '')
{
$this->scheme = null;
}
else
{
$len = strlen($scheme);
switch (true)
{
case $len > 1:
if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1))
{
$this->scheme = null;
$this->valid[__FUNCTION__] = false;
return false;
}
case $len > 0:
if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1))
{
$this->scheme = null;
$this->valid[__FUNCTION__] = false;
return false;
}
}
$this->scheme = strtolower($scheme);
}
$this->valid[__FUNCTION__] = true;
return true;
}
/**
* Set the authority. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @access public
* @param string $authority
* @return bool
*/
public function set_authority($authority)
{
if (($userinfo_end = strrpos($authority, '@')) !== false)
{
$userinfo = substr($authority, 0, $userinfo_end);
$authority = substr($authority, $userinfo_end + 1);
}
else
{
$userinfo = null;
}
if (($port_start = strpos($authority, ':')) !== false)
{
$port = substr($authority, $port_start + 1);
if ($port === false)
{
$port = null;
}
$authority = substr($authority, 0, $port_start);
}
else
{
$port = null;
}
return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port);
}
/**
* Set the userinfo.
*
* @access public
* @param string $userinfo
* @return bool
*/
public function set_userinfo($userinfo)
{
if ($userinfo === null || $userinfo === '')
{
$this->userinfo = null;
}
else
{
$this->userinfo = $this->replace_invalid_with_pct_encoding($userinfo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:');
}
$this->valid[__FUNCTION__] = true;
return true;
}
/**
* Set the host. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @access public
* @param string $host
* @return bool
*/
public function set_host($host)
{
if ($host === null || $host === '')
{
$this->host = null;
$this->valid[__FUNCTION__] = true;
return true;
}
elseif ($host[0] === '[' && substr($host, -1) === ']')
{
if (SimplePie_Net_IPv6::checkIPv6(substr($host, 1, -1)))
{
$this->host = $host;
$this->valid[__FUNCTION__] = true;
return true;
}
else
{
$this->host = null;
$this->valid[__FUNCTION__] = false;
return false;
}
}
else
{
$this->host = $this->replace_invalid_with_pct_encoding($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=', SIMPLEPIE_LOWERCASE);
$this->valid[__FUNCTION__] = true;
return true;
}
}
/**
* Set the port. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @access public
* @param string $port
* @return bool
*/
public function set_port($port)
{
if ($port === null || $port === '')
{
$this->port = null;
$this->valid[__FUNCTION__] = true;
return true;
}
elseif (strspn($port, '0123456789') === strlen($port))
{
$this->port = (int) $port;
$this->valid[__FUNCTION__] = true;
return true;
}
else
{
$this->port = null;
$this->valid[__FUNCTION__] = false;
return false;
}
}
/**
* Set the path.
*
* @access public
* @param string $path
* @return bool
*/
public function set_path($path)
{
if ($path === null || $path === '')
{
$this->path = null;
$this->valid[__FUNCTION__] = true;
return true;
}
elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null)
{
$this->path = null;
$this->valid[__FUNCTION__] = false;
return false;
}
else
{
$this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/');
if ($this->scheme !== null)
{
$this->path = $this->remove_dot_segments($this->path);
}
$this->valid[__FUNCTION__] = true;
return true;
}
}
/**
* Set the query.
*
* @access public
* @param string $query
* @return bool
*/
public function set_query($query)
{
if ($query === null || $query === '')
{
$this->query = null;
}
else
{
$this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&=');
}
$this->valid[__FUNCTION__] = true;
return true;
}
/**
* Set the fragment.
*
* @access public
* @param string $fragment
* @return bool
*/
public function set_fragment($fragment)
{
if ($fragment === null || $fragment === '')
{
$this->fragment = null;
}
else
{
$this->fragment = $this->replace_invalid_with_pct_encoding($fragment, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
}
$this->valid[__FUNCTION__] = true;
return true;
}
/**
* Get the complete IRI
*
* @access public
* @return string
*/
public function get_iri()
{
$iri = '';
if ($this->scheme !== null)
{
$iri .= $this->scheme . ':';
}
if (($authority = $this->get_authority()) !== null)
{
$iri .= '//' . $authority;
}
if ($this->path !== null)
{
$iri .= $this->path;
}
if ($this->query !== null)
{
$iri .= '?' . $this->query;
}
if ($this->fragment !== null)
{
$iri .= '#' . $this->fragment;
}
if ($iri !== '')
{
return $iri;
}
else
{
return null;
}
}
/**
* Get the scheme
*
* @access public
* @return string
*/
public function get_scheme()
{
return $this->scheme;
}
/**
* Get the complete authority
*
* @access public
* @return string
*/
public function get_authority()
{
$authority = '';
if ($this->userinfo !== null)
{
$authority .= $this->userinfo . '@';
}
if ($this->host !== null)
{
$authority .= $this->host;
}
if ($this->port !== null)
{
$authority .= ':' . $this->port;
}
if ($authority !== '')
{
return $authority;
}
else
{
return null;
}
}
/**
* Get the user information
*
* @access public
* @return string
*/
public function get_userinfo()
{
return $this->userinfo;
}
/**
* Get the host
*
* @access public
* @return string
*/
public function get_host()
{
return $this->host;
}
/**
* Get the port
*
* @access public
* @return string
*/
public function get_port()
{
return $this->port;
}
/**
* Get the path
*
* @access public
* @return string
*/
public function get_path()
{
return $this->path;
}
/**
* Get the query
*
* @access public
* @return string
*/
public function get_query()
{
return $this->query;
}
/**
* Get the fragment
*
* @access public
* @return string
*/
public function get_fragment()
{
return $this->fragment;
}
}

257
3rdparty/SimplePie/SimplePie/Net/IPv6.php поставляемый
Просмотреть файл

@ -1,257 +0,0 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3-dev
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Class to validate and to work with IPv6 addresses.
*
* @package SimplePie
* @copyright 2003-2005 The PHP Group
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/package/Net_IPv6
* @author Alexander Merz <alexander.merz@web.de>
* @author elfrink at introweb dot nl
* @author Josh Peck <jmp at joshpeck dot org>
* @author Geoffrey Sneddon <geoffers@gmail.com>
*/
class SimplePie_Net_IPv6
{
/**
* Removes a possible existing netmask specification of an IP address.
*
* @param string $ip the (compressed) IP as Hex representation
* @return string the IP the without netmask
* @since 1.1.0
* @access public
* @static
*/
public static function removeNetmaskSpec($ip)
{
if (strpos($ip, '/') !== false)
{
list($addr, $nm) = explode('/', $ip);
}
else
{
$addr = $ip;
}
return $addr;
}
/**
* Uncompresses an IPv6 address
*
* RFC 2373 allows you to compress zeros in an address to '::'. This
* function expects an valid IPv6 address and expands the '::' to
* the required zeros.
*
* Example: FF01::101 -> FF01:0:0:0:0:0:0:101
* ::1 -> 0:0:0:0:0:0:0:1
*
* @access public
* @static
* @param string $ip a valid IPv6-address (hex format)
* @return string the uncompressed IPv6-address (hex format)
*/
public static function Uncompress($ip)
{
$uip = SimplePie_Net_IPv6::removeNetmaskSpec($ip);
$c1 = -1;
$c2 = -1;
if (strpos($ip, '::') !== false)
{
list($ip1, $ip2) = explode('::', $ip);
if ($ip1 === '')
{
$c1 = -1;
}
else
{
$pos = 0;
if (($pos = substr_count($ip1, ':')) > 0)
{
$c1 = $pos;
}
else
{
$c1 = 0;
}
}
if ($ip2 === '')
{
$c2 = -1;
}
else
{
$pos = 0;
if (($pos = substr_count($ip2, ':')) > 0)
{
$c2 = $pos;
}
else
{
$c2 = 0;
}
}
if (strstr($ip2, '.'))
{
$c2++;
}
// ::
if ($c1 === -1 && $c2 === -1)
{
$uip = '0:0:0:0:0:0:0:0';
}
// ::xxx
else if ($c1 === -1)
{
$fill = str_repeat('0:', 7 - $c2);
$uip = str_replace('::', $fill, $uip);
}
// xxx::
else if ($c2 === -1)
{
$fill = str_repeat(':0', 7 - $c1);
$uip = str_replace('::', $fill, $uip);
}
// xxx::xxx
else
{
$fill = str_repeat(':0:', 6 - $c2 - $c1);
$uip = str_replace('::', $fill, $uip);
$uip = str_replace('::', ':', $uip);
}
}
return $uip;
}
/**
* Splits an IPv6 address into the IPv6 and a possible IPv4 part
*
* RFC 2373 allows you to note the last two parts of an IPv6 address as
* an IPv4 compatible address
*
* Example: 0:0:0:0:0:0:13.1.68.3
* 0:0:0:0:0:FFFF:129.144.52.38
*
* @access public
* @static
* @param string $ip a valid IPv6-address (hex format)
* @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
*/
public static function SplitV64($ip)
{
$ip = SimplePie_Net_IPv6::Uncompress($ip);
if (strstr($ip, '.'))
{
$pos = strrpos($ip, ':');
$ip[$pos] = '_';
$ipPart = explode('_', $ip);
return $ipPart;
}
else
{
return array($ip, '');
}
}
/**
* Checks an IPv6 address
*
* Checks if the given IP is IPv6-compatible
*
* @access public
* @static
* @param string $ip a valid IPv6-address
* @return bool true if $ip is an IPv6 address
*/
public static function checkIPv6($ip)
{
$ipPart = SimplePie_Net_IPv6::SplitV64($ip);
$count = 0;
if (!empty($ipPart[0]))
{
$ipv6 = explode(':', $ipPart[0]);
for ($i = 0; $i < count($ipv6); $i++)
{
$dec = hexdec($ipv6[$i]);
$hex = strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/', '\\1', $ipv6[$i]));
if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex === strtoupper(dechex($dec)))
{
$count++;
}
}
if ($count === 8)
{
return true;
}
elseif ($count === 6 && !empty($ipPart[1]))
{
$ipv4 = explode('.', $ipPart[1]);
$count = 0;
foreach ($ipv4 as $ipv4_part)
{
if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part))
{
$count++;
}
}
if ($count === 4)
{
return true;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
}

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -46,7 +46,7 @@
// autoloader // autoloader
spl_autoload_register(array(new SimplePie_Autoloader(), 'autoload')); spl_autoload_register(array(new SimplePie_Autoloader(), 'autoload'));
if (!class_exists('SimplePie_Core')) if (!class_exists('SimplePie'))
{ {
trigger_error('Autoloader not registered properly', E_USER_ERROR); trigger_error('Autoloader not registered properly', E_USER_ERROR);
} }
@ -55,6 +55,7 @@ if (!class_exists('SimplePie_Core'))
* Autoloader class * Autoloader class
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Autoloader class SimplePie_Autoloader
{ {
@ -63,7 +64,7 @@ class SimplePie_Autoloader
*/ */
public function __construct() public function __construct()
{ {
$this->path = dirname(__FILE__); $this->path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library';
} }
/** /**

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_author_class()} * This class can be overloaded with {@see SimplePie::set_author_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Author class SimplePie_Author
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* via {@see register()} * via {@see register()}
* *
* @package SimplePie * @package SimplePie
* @subpackage Caching
*/ */
class SimplePie_Cache class SimplePie_Cache
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -49,6 +49,7 @@
* to implement this interface. * to implement this interface.
* *
* @package SimplePie * @package SimplePie
* @subpackage Caching
*/ */
interface SimplePie_Cache_Base interface SimplePie_Cache_Base
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -46,6 +46,7 @@
* Base class for database-based caches * Base class for database-based caches
* *
* @package SimplePie * @package SimplePie
* @subpackage Caching
*/ */
abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base
{ {
@ -57,7 +58,7 @@ abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base
* @param SimplePie $data * @param SimplePie $data
* @return array First item is the serialized data for storage, second item is the unique ID for this item * @return array First item is the serialized data for storage, second item is the unique ID for this item
*/ */
protected static function prepare_simplepie_object_for_cache(&$data) protected static function prepare_simplepie_object_for_cache($data)
{ {
$items = $data->get_items(); $items = $data->get_items();
$items_by_id = array(); $items_by_id = array();

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -46,6 +46,7 @@
* Caches data to the filesystem * Caches data to the filesystem
* *
* @package SimplePie * @package SimplePie
* @subpackage Caching
*/ */
class SimplePie_Cache_File implements SimplePie_Cache_Base class SimplePie_Cache_File implements SimplePie_Cache_Base
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -47,11 +47,12 @@
* *
* Registered for URLs with the "memcache" protocol * Registered for URLs with the "memcache" protocol
* *
* For example, `memcache://localhost:11211/?timeout=3600^prefix=sp_` will * For example, `memcache://localhost:11211/?timeout=3600&prefix=sp_` will
* connect to memcache on `localhost` on port 11211. All tables will be * connect to memcache on `localhost` on port 11211. All tables will be
* prefixed with `sp_` and data will expire after 3600 seconds * prefixed with `sp_` and data will expire after 3600 seconds
* *
* @package SimplePie * @package SimplePie
* @subpackage Caching
* @uses Memcache * @uses Memcache
*/ */
class SimplePie_Cache_Memcache implements SimplePie_Cache_Base class SimplePie_Cache_Memcache implements SimplePie_Cache_Base
@ -94,7 +95,10 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base
'prefix' => 'simplepie_', 'prefix' => 'simplepie_',
), ),
); );
$this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); $parsed = SimplePie_Cache::parse_URL($location);
$this->options['host'] = empty($parsed['host']) ? $this->options['host'] : $parsed['host'];
$this->options['port'] = empty($parsed['port']) ? $this->options['port'] : $parsed['port'];
$this->options['extras'] = array_merge($this->options['extras'], $parsed['extras']);
$this->name = $this->options['extras']['prefix'] . md5("$name:$type"); $this->name = $this->options['extras']['prefix'] . md5("$name:$type");
$this->cache = new Memcache(); $this->cache = new Memcache();

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -52,6 +52,7 @@
* `root` and the password `password`. All tables will be prefixed with `sp_` * `root` and the password `password`. All tables will be prefixed with `sp_`
* *
* @package SimplePie * @package SimplePie
* @subpackage Caching
*/ */
class SimplePie_Cache_MySQL extends SimplePie_Cache_DB class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -51,6 +51,7 @@
* This class can be overloaded with {@see SimplePie::set_caption_class()} * This class can be overloaded with {@see SimplePie::set_caption_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Caption class SimplePie_Caption
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_category_class()} * This class can be overloaded with {@see SimplePie::set_category_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Category class SimplePie_Category
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -55,6 +55,7 @@
* This class can be overloaded with {@see SimplePie::set_content_type_sniffer_class()} * This class can be overloaded with {@see SimplePie::set_content_type_sniffer_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage HTTP
*/ */
class SimplePie_Content_Type_Sniffer class SimplePie_Content_Type_Sniffer
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_copyright_class()} * This class can be overloaded with {@see SimplePie::set_copyright_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Copyright class SimplePie_Copyright
{ {

57
3rdparty/SimplePie/library/SimplePie/Core.php поставляемый Normal file
Просмотреть файл

@ -0,0 +1,57 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2009, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* SimplePie class.
*
* Class for backward compatibility.
*
* @deprecated Use {@see SimplePie} directly
* @package SimplePie
* @subpackage API
*/
class SimplePie_Core extends SimplePie
{
}

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_credit_class()} * This class can be overloaded with {@see SimplePie::set_credit_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Credit class SimplePie_Credit
{ {

617
3rdparty/SimplePie/library/SimplePie/Decode/HTML/Entities.php поставляемый Normal file
Просмотреть файл

@ -0,0 +1,617 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Decode HTML Entities
*
* This implements HTML5 as of revision 967 (2007-06-28)
*
* @deprecated Use DOMDocument instead!
* @package SimplePie
*/
class SimplePie_Decode_HTML_Entities
{
/**
* Data to be parsed
*
* @access private
* @var string
*/
var $data = '';
/**
* Currently consumed bytes
*
* @access private
* @var string
*/
var $consumed = '';
/**
* Position of the current byte being parsed
*
* @access private
* @var int
*/
var $position = 0;
/**
* Create an instance of the class with the input data
*
* @access public
* @param string $data Input data
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Parse the input data
*
* @access public
* @return string Output data
*/
public function parse()
{
while (($this->position = strpos($this->data, '&', $this->position)) !== false)
{
$this->consume();
$this->entity();
$this->consumed = '';
}
return $this->data;
}
/**
* Consume the next byte
*
* @access private
* @return mixed The next byte, or false, if there is no more data
*/
public function consume()
{
if (isset($this->data[$this->position]))
{
$this->consumed .= $this->data[$this->position];
return $this->data[$this->position++];
}
else
{
return false;
}
}
/**
* Consume a range of characters
*
* @access private
* @param string $chars Characters to consume
* @return mixed A series of characters that match the range, or false
*/
public function consume_range($chars)
{
if ($len = strspn($this->data, $chars, $this->position))
{
$data = substr($this->data, $this->position, $len);
$this->consumed .= $data;
$this->position += $len;
return $data;
}
else
{
return false;
}
}
/**
* Unconsume one byte
*
* @access private
*/
public function unconsume()
{
$this->consumed = substr($this->consumed, 0, -1);
$this->position--;
}
/**
* Decode an entity
*
* @access private
*/
public function entity()
{
switch ($this->consume())
{
case "\x09":
case "\x0A":
case "\x0B":
case "\x0B":
case "\x0C":
case "\x20":
case "\x3C":
case "\x26":
case false:
break;
case "\x23":
switch ($this->consume())
{
case "\x78":
case "\x58":
$range = '0123456789ABCDEFabcdef';
$hex = true;
break;
default:
$range = '0123456789';
$hex = false;
$this->unconsume();
break;
}
if ($codepoint = $this->consume_range($range))
{
static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8");
if ($hex)
{
$codepoint = hexdec($codepoint);
}
else
{
$codepoint = intval($codepoint);
}
if (isset($windows_1252_specials[$codepoint]))
{
$replacement = $windows_1252_specials[$codepoint];
}
else
{
$replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
}
if (!in_array($this->consume(), array(';', false), true))
{
$this->unconsume();
}
$consumed_length = strlen($this->consumed);
$this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
$this->position += strlen($replacement) - $consumed_length;
}
break;
default:
static $entities = array(
'Aacute' => "\xC3\x81",
'aacute' => "\xC3\xA1",
'Aacute;' => "\xC3\x81",
'aacute;' => "\xC3\xA1",
'Acirc' => "\xC3\x82",
'acirc' => "\xC3\xA2",
'Acirc;' => "\xC3\x82",
'acirc;' => "\xC3\xA2",
'acute' => "\xC2\xB4",
'acute;' => "\xC2\xB4",
'AElig' => "\xC3\x86",
'aelig' => "\xC3\xA6",
'AElig;' => "\xC3\x86",
'aelig;' => "\xC3\xA6",
'Agrave' => "\xC3\x80",
'agrave' => "\xC3\xA0",
'Agrave;' => "\xC3\x80",
'agrave;' => "\xC3\xA0",
'alefsym;' => "\xE2\x84\xB5",
'Alpha;' => "\xCE\x91",
'alpha;' => "\xCE\xB1",
'AMP' => "\x26",
'amp' => "\x26",
'AMP;' => "\x26",
'amp;' => "\x26",
'and;' => "\xE2\x88\xA7",
'ang;' => "\xE2\x88\xA0",
'apos;' => "\x27",
'Aring' => "\xC3\x85",
'aring' => "\xC3\xA5",
'Aring;' => "\xC3\x85",
'aring;' => "\xC3\xA5",
'asymp;' => "\xE2\x89\x88",
'Atilde' => "\xC3\x83",
'atilde' => "\xC3\xA3",
'Atilde;' => "\xC3\x83",
'atilde;' => "\xC3\xA3",
'Auml' => "\xC3\x84",
'auml' => "\xC3\xA4",
'Auml;' => "\xC3\x84",
'auml;' => "\xC3\xA4",
'bdquo;' => "\xE2\x80\x9E",
'Beta;' => "\xCE\x92",
'beta;' => "\xCE\xB2",
'brvbar' => "\xC2\xA6",
'brvbar;' => "\xC2\xA6",
'bull;' => "\xE2\x80\xA2",
'cap;' => "\xE2\x88\xA9",
'Ccedil' => "\xC3\x87",
'ccedil' => "\xC3\xA7",
'Ccedil;' => "\xC3\x87",
'ccedil;' => "\xC3\xA7",
'cedil' => "\xC2\xB8",
'cedil;' => "\xC2\xB8",
'cent' => "\xC2\xA2",
'cent;' => "\xC2\xA2",
'Chi;' => "\xCE\xA7",
'chi;' => "\xCF\x87",
'circ;' => "\xCB\x86",
'clubs;' => "\xE2\x99\xA3",
'cong;' => "\xE2\x89\x85",
'COPY' => "\xC2\xA9",
'copy' => "\xC2\xA9",
'COPY;' => "\xC2\xA9",
'copy;' => "\xC2\xA9",
'crarr;' => "\xE2\x86\xB5",
'cup;' => "\xE2\x88\xAA",
'curren' => "\xC2\xA4",
'curren;' => "\xC2\xA4",
'Dagger;' => "\xE2\x80\xA1",
'dagger;' => "\xE2\x80\xA0",
'dArr;' => "\xE2\x87\x93",
'darr;' => "\xE2\x86\x93",
'deg' => "\xC2\xB0",
'deg;' => "\xC2\xB0",
'Delta;' => "\xCE\x94",
'delta;' => "\xCE\xB4",
'diams;' => "\xE2\x99\xA6",
'divide' => "\xC3\xB7",
'divide;' => "\xC3\xB7",
'Eacute' => "\xC3\x89",
'eacute' => "\xC3\xA9",
'Eacute;' => "\xC3\x89",
'eacute;' => "\xC3\xA9",
'Ecirc' => "\xC3\x8A",
'ecirc' => "\xC3\xAA",
'Ecirc;' => "\xC3\x8A",
'ecirc;' => "\xC3\xAA",
'Egrave' => "\xC3\x88",
'egrave' => "\xC3\xA8",
'Egrave;' => "\xC3\x88",
'egrave;' => "\xC3\xA8",
'empty;' => "\xE2\x88\x85",
'emsp;' => "\xE2\x80\x83",
'ensp;' => "\xE2\x80\x82",
'Epsilon;' => "\xCE\x95",
'epsilon;' => "\xCE\xB5",
'equiv;' => "\xE2\x89\xA1",
'Eta;' => "\xCE\x97",
'eta;' => "\xCE\xB7",
'ETH' => "\xC3\x90",
'eth' => "\xC3\xB0",
'ETH;' => "\xC3\x90",
'eth;' => "\xC3\xB0",
'Euml' => "\xC3\x8B",
'euml' => "\xC3\xAB",
'Euml;' => "\xC3\x8B",
'euml;' => "\xC3\xAB",
'euro;' => "\xE2\x82\xAC",
'exist;' => "\xE2\x88\x83",
'fnof;' => "\xC6\x92",
'forall;' => "\xE2\x88\x80",
'frac12' => "\xC2\xBD",
'frac12;' => "\xC2\xBD",
'frac14' => "\xC2\xBC",
'frac14;' => "\xC2\xBC",
'frac34' => "\xC2\xBE",
'frac34;' => "\xC2\xBE",
'frasl;' => "\xE2\x81\x84",
'Gamma;' => "\xCE\x93",
'gamma;' => "\xCE\xB3",
'ge;' => "\xE2\x89\xA5",
'GT' => "\x3E",
'gt' => "\x3E",
'GT;' => "\x3E",
'gt;' => "\x3E",
'hArr;' => "\xE2\x87\x94",
'harr;' => "\xE2\x86\x94",
'hearts;' => "\xE2\x99\xA5",
'hellip;' => "\xE2\x80\xA6",
'Iacute' => "\xC3\x8D",
'iacute' => "\xC3\xAD",
'Iacute;' => "\xC3\x8D",
'iacute;' => "\xC3\xAD",
'Icirc' => "\xC3\x8E",
'icirc' => "\xC3\xAE",
'Icirc;' => "\xC3\x8E",
'icirc;' => "\xC3\xAE",
'iexcl' => "\xC2\xA1",
'iexcl;' => "\xC2\xA1",
'Igrave' => "\xC3\x8C",
'igrave' => "\xC3\xAC",
'Igrave;' => "\xC3\x8C",
'igrave;' => "\xC3\xAC",
'image;' => "\xE2\x84\x91",
'infin;' => "\xE2\x88\x9E",
'int;' => "\xE2\x88\xAB",
'Iota;' => "\xCE\x99",
'iota;' => "\xCE\xB9",
'iquest' => "\xC2\xBF",
'iquest;' => "\xC2\xBF",
'isin;' => "\xE2\x88\x88",
'Iuml' => "\xC3\x8F",
'iuml' => "\xC3\xAF",
'Iuml;' => "\xC3\x8F",
'iuml;' => "\xC3\xAF",
'Kappa;' => "\xCE\x9A",
'kappa;' => "\xCE\xBA",
'Lambda;' => "\xCE\x9B",
'lambda;' => "\xCE\xBB",
'lang;' => "\xE3\x80\x88",
'laquo' => "\xC2\xAB",
'laquo;' => "\xC2\xAB",
'lArr;' => "\xE2\x87\x90",
'larr;' => "\xE2\x86\x90",
'lceil;' => "\xE2\x8C\x88",
'ldquo;' => "\xE2\x80\x9C",
'le;' => "\xE2\x89\xA4",
'lfloor;' => "\xE2\x8C\x8A",
'lowast;' => "\xE2\x88\x97",
'loz;' => "\xE2\x97\x8A",
'lrm;' => "\xE2\x80\x8E",
'lsaquo;' => "\xE2\x80\xB9",
'lsquo;' => "\xE2\x80\x98",
'LT' => "\x3C",
'lt' => "\x3C",
'LT;' => "\x3C",
'lt;' => "\x3C",
'macr' => "\xC2\xAF",
'macr;' => "\xC2\xAF",
'mdash;' => "\xE2\x80\x94",
'micro' => "\xC2\xB5",
'micro;' => "\xC2\xB5",
'middot' => "\xC2\xB7",
'middot;' => "\xC2\xB7",
'minus;' => "\xE2\x88\x92",
'Mu;' => "\xCE\x9C",
'mu;' => "\xCE\xBC",
'nabla;' => "\xE2\x88\x87",
'nbsp' => "\xC2\xA0",
'nbsp;' => "\xC2\xA0",
'ndash;' => "\xE2\x80\x93",
'ne;' => "\xE2\x89\xA0",
'ni;' => "\xE2\x88\x8B",
'not' => "\xC2\xAC",
'not;' => "\xC2\xAC",
'notin;' => "\xE2\x88\x89",
'nsub;' => "\xE2\x8A\x84",
'Ntilde' => "\xC3\x91",
'ntilde' => "\xC3\xB1",
'Ntilde;' => "\xC3\x91",
'ntilde;' => "\xC3\xB1",
'Nu;' => "\xCE\x9D",
'nu;' => "\xCE\xBD",
'Oacute' => "\xC3\x93",
'oacute' => "\xC3\xB3",
'Oacute;' => "\xC3\x93",
'oacute;' => "\xC3\xB3",
'Ocirc' => "\xC3\x94",
'ocirc' => "\xC3\xB4",
'Ocirc;' => "\xC3\x94",
'ocirc;' => "\xC3\xB4",
'OElig;' => "\xC5\x92",
'oelig;' => "\xC5\x93",
'Ograve' => "\xC3\x92",
'ograve' => "\xC3\xB2",
'Ograve;' => "\xC3\x92",
'ograve;' => "\xC3\xB2",
'oline;' => "\xE2\x80\xBE",
'Omega;' => "\xCE\xA9",
'omega;' => "\xCF\x89",
'Omicron;' => "\xCE\x9F",
'omicron;' => "\xCE\xBF",
'oplus;' => "\xE2\x8A\x95",
'or;' => "\xE2\x88\xA8",
'ordf' => "\xC2\xAA",
'ordf;' => "\xC2\xAA",
'ordm' => "\xC2\xBA",
'ordm;' => "\xC2\xBA",
'Oslash' => "\xC3\x98",
'oslash' => "\xC3\xB8",
'Oslash;' => "\xC3\x98",
'oslash;' => "\xC3\xB8",
'Otilde' => "\xC3\x95",
'otilde' => "\xC3\xB5",
'Otilde;' => "\xC3\x95",
'otilde;' => "\xC3\xB5",
'otimes;' => "\xE2\x8A\x97",
'Ouml' => "\xC3\x96",
'ouml' => "\xC3\xB6",
'Ouml;' => "\xC3\x96",
'ouml;' => "\xC3\xB6",
'para' => "\xC2\xB6",
'para;' => "\xC2\xB6",
'part;' => "\xE2\x88\x82",
'permil;' => "\xE2\x80\xB0",
'perp;' => "\xE2\x8A\xA5",
'Phi;' => "\xCE\xA6",
'phi;' => "\xCF\x86",
'Pi;' => "\xCE\xA0",
'pi;' => "\xCF\x80",
'piv;' => "\xCF\x96",
'plusmn' => "\xC2\xB1",
'plusmn;' => "\xC2\xB1",
'pound' => "\xC2\xA3",
'pound;' => "\xC2\xA3",
'Prime;' => "\xE2\x80\xB3",
'prime;' => "\xE2\x80\xB2",
'prod;' => "\xE2\x88\x8F",
'prop;' => "\xE2\x88\x9D",
'Psi;' => "\xCE\xA8",
'psi;' => "\xCF\x88",
'QUOT' => "\x22",
'quot' => "\x22",
'QUOT;' => "\x22",
'quot;' => "\x22",
'radic;' => "\xE2\x88\x9A",
'rang;' => "\xE3\x80\x89",
'raquo' => "\xC2\xBB",
'raquo;' => "\xC2\xBB",
'rArr;' => "\xE2\x87\x92",
'rarr;' => "\xE2\x86\x92",
'rceil;' => "\xE2\x8C\x89",
'rdquo;' => "\xE2\x80\x9D",
'real;' => "\xE2\x84\x9C",
'REG' => "\xC2\xAE",
'reg' => "\xC2\xAE",
'REG;' => "\xC2\xAE",
'reg;' => "\xC2\xAE",
'rfloor;' => "\xE2\x8C\x8B",
'Rho;' => "\xCE\xA1",
'rho;' => "\xCF\x81",
'rlm;' => "\xE2\x80\x8F",
'rsaquo;' => "\xE2\x80\xBA",
'rsquo;' => "\xE2\x80\x99",
'sbquo;' => "\xE2\x80\x9A",
'Scaron;' => "\xC5\xA0",
'scaron;' => "\xC5\xA1",
'sdot;' => "\xE2\x8B\x85",
'sect' => "\xC2\xA7",
'sect;' => "\xC2\xA7",
'shy' => "\xC2\xAD",
'shy;' => "\xC2\xAD",
'Sigma;' => "\xCE\xA3",
'sigma;' => "\xCF\x83",
'sigmaf;' => "\xCF\x82",
'sim;' => "\xE2\x88\xBC",
'spades;' => "\xE2\x99\xA0",
'sub;' => "\xE2\x8A\x82",
'sube;' => "\xE2\x8A\x86",
'sum;' => "\xE2\x88\x91",
'sup;' => "\xE2\x8A\x83",
'sup1' => "\xC2\xB9",
'sup1;' => "\xC2\xB9",
'sup2' => "\xC2\xB2",
'sup2;' => "\xC2\xB2",
'sup3' => "\xC2\xB3",
'sup3;' => "\xC2\xB3",
'supe;' => "\xE2\x8A\x87",
'szlig' => "\xC3\x9F",
'szlig;' => "\xC3\x9F",
'Tau;' => "\xCE\xA4",
'tau;' => "\xCF\x84",
'there4;' => "\xE2\x88\xB4",
'Theta;' => "\xCE\x98",
'theta;' => "\xCE\xB8",
'thetasym;' => "\xCF\x91",
'thinsp;' => "\xE2\x80\x89",
'THORN' => "\xC3\x9E",
'thorn' => "\xC3\xBE",
'THORN;' => "\xC3\x9E",
'thorn;' => "\xC3\xBE",
'tilde;' => "\xCB\x9C",
'times' => "\xC3\x97",
'times;' => "\xC3\x97",
'TRADE;' => "\xE2\x84\xA2",
'trade;' => "\xE2\x84\xA2",
'Uacute' => "\xC3\x9A",
'uacute' => "\xC3\xBA",
'Uacute;' => "\xC3\x9A",
'uacute;' => "\xC3\xBA",
'uArr;' => "\xE2\x87\x91",
'uarr;' => "\xE2\x86\x91",
'Ucirc' => "\xC3\x9B",
'ucirc' => "\xC3\xBB",
'Ucirc;' => "\xC3\x9B",
'ucirc;' => "\xC3\xBB",
'Ugrave' => "\xC3\x99",
'ugrave' => "\xC3\xB9",
'Ugrave;' => "\xC3\x99",
'ugrave;' => "\xC3\xB9",
'uml' => "\xC2\xA8",
'uml;' => "\xC2\xA8",
'upsih;' => "\xCF\x92",
'Upsilon;' => "\xCE\xA5",
'upsilon;' => "\xCF\x85",
'Uuml' => "\xC3\x9C",
'uuml' => "\xC3\xBC",
'Uuml;' => "\xC3\x9C",
'uuml;' => "\xC3\xBC",
'weierp;' => "\xE2\x84\x98",
'Xi;' => "\xCE\x9E",
'xi;' => "\xCE\xBE",
'Yacute' => "\xC3\x9D",
'yacute' => "\xC3\xBD",
'Yacute;' => "\xC3\x9D",
'yacute;' => "\xC3\xBD",
'yen' => "\xC2\xA5",
'yen;' => "\xC2\xA5",
'yuml' => "\xC3\xBF",
'Yuml;' => "\xC5\xB8",
'yuml;' => "\xC3\xBF",
'Zeta;' => "\xCE\x96",
'zeta;' => "\xCE\xB6",
'zwj;' => "\xE2\x80\x8D",
'zwnj;' => "\xE2\x80\x8C"
);
for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++)
{
$consumed = substr($this->consumed, 1);
if (isset($entities[$consumed]))
{
$match = $consumed;
}
}
if ($match !== null)
{
$this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
$this->position += strlen($entities[$match]) - strlen($consumed) - 1;
}
break;
}
}
}

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_enclosure_class()} * This class can be overloaded with {@see SimplePie::set_enclosure_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Enclosure class SimplePie_Enclosure
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_file_class()} * This class can be overloaded with {@see SimplePie::set_file_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage HTTP
* @todo Move to properly supporting RFC2616 (HTTP/1.1) * @todo Move to properly supporting RFC2616 (HTTP/1.1)
*/ */
class SimplePie_File class SimplePie_File

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -47,6 +47,7 @@
* HTTP Response Parser * HTTP Response Parser
* *
* @package SimplePie * @package SimplePie
* @subpackage HTTP
*/ */
class SimplePie_HTTP_Parser class SimplePie_HTTP_Parser
{ {

1234
3rdparty/SimplePie/library/SimplePie/IRI.php поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -51,24 +51,67 @@
* This class can be overloaded with {@see SimplePie::set_item_class()} * This class can be overloaded with {@see SimplePie::set_item_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Item class SimplePie_Item
{ {
/**
* Parent feed
*
* @access private
* @var SimplePie
*/
var $feed; var $feed;
/**
* Raw data
*
* @access private
* @var array
*/
var $data = array(); var $data = array();
/**
* Registry object
*
* @see set_registry
* @var SimplePie_Registry
*/
protected $registry; protected $registry;
/**
* Create a new item object
*
* This is usually used by {@see SimplePie::get_items} and
* {@see SimplePie::get_item}. Avoid creating this manually.
*
* @param SimplePie $feed Parent feed
* @param array $data Raw data
*/
public function __construct($feed, $data) public function __construct($feed, $data)
{ {
$this->feed = $feed; $this->feed = $feed;
$this->data = $data; $this->data = $data;
} }
public function set_registry(SimplePie_Registry &$registry) /**
* Set the registry handler
*
* This is usually used by {@see SimplePie_Registry::create}
*
* @since 1.3
* @param SimplePie_Registry $registry
*/
public function set_registry(SimplePie_Registry $registry)
{ {
$this->registry = &$registry; $this->registry = $registry;
} }
/**
* Get a string representation of the item
*
* @return string
*/
public function __toString() public function __toString()
{ {
return md5(serialize($this->data)); return md5(serialize($this->data));
@ -85,6 +128,20 @@ class SimplePie_Item
} }
} }
/**
* Get data for an item-level element
*
* This method allows you to get access to ANY element/attribute that is a
* sub-element of the item/entry tag.
*
* See {@see SimplePie::get_feed_tags()} for a description of the return value
*
* @since 1.0
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
* @param string $tag Tag name
* @return array
*/
public function get_item_tags($namespace, $tag) public function get_item_tags($namespace, $tag)
{ {
if (isset($this->data['child'][$namespace][$tag])) if (isset($this->data['child'][$namespace][$tag]))
@ -97,21 +154,62 @@ class SimplePie_Item
} }
} }
/**
* Get the base URL value from the parent feed
*
* Uses `<xml:base>`
*
* @param array $element
* @return string
*/
public function get_base($element = array()) public function get_base($element = array())
{ {
return $this->feed->get_base($element); return $this->feed->get_base($element);
} }
/**
* Sanitize feed data
*
* @access private
* @see SimplePie::sanitize()
* @param string $data Data to sanitize
* @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants
* @param string $base Base URL to resolve URLs against
* @return string Sanitized data
*/
public function sanitize($data, $type, $base = '') public function sanitize($data, $type, $base = '')
{ {
return $this->feed->sanitize($data, $type, $base); return $this->feed->sanitize($data, $type, $base);
} }
/**
* Get the parent feed
*
* Note: this may not work as you think for multifeeds!
*
* @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
* @since 1.0
* @return SimplePie
*/
public function get_feed() public function get_feed()
{ {
return $this->feed; return $this->feed;
} }
/**
* Get the unique identifier for the item
*
* This is usually used when writing code to check for new items in a feed.
*
* Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute
* for RDF. If none of these are supplied (or `$hash` is true), creates an
* MD5 hash based on the permalink and title. If either of those are not
* supplied, creates a hash based on the full feed data.
*
* @since Beta 2
* @param boolean $hash Should we force using a hash instead of the supplied ID?
* @return string
*/
public function get_id($hash = false) public function get_id($hash = false)
{ {
if (!$hash) if (!$hash)
@ -159,6 +257,14 @@ class SimplePie_Item
} }
} }
/**
* Get the title of the item
*
* Uses `<atom:title>`, `<title>` or `<dc:title>`
*
* @since Beta 2 (previously called `get_item_title` since 0.8)
* @return string|null
*/
public function get_title() public function get_title()
{ {
if (!isset($this->data['title'])) if (!isset($this->data['title']))
@ -199,6 +305,21 @@ class SimplePie_Item
return $this->data['title']; return $this->data['title'];
} }
/**
* Get the content for the item
*
* Prefers summaries over full content , but will return full content if a
* summary does not exist.
*
* To prefer full content instead, use {@see get_content}
*
* Uses `<atom:summary>`, `<description>`, `<dc:description>` or
* `<itunes:subtitle>`
*
* @since 0.8
* @param boolean $description_only Should we avoid falling back to the content?
* @return string|null
*/
public function get_description($description_only = false) public function get_description($description_only = false)
{ {
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
@ -248,6 +369,20 @@ class SimplePie_Item
} }
} }
/**
* Get the content for the item
*
* Prefers full content over summaries, but will return a summary if full
* content does not exist.
*
* To prefer summaries instead, use {@see get_description}
*
* Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module)
*
* @since 1.0
* @param boolean $content_only Should we avoid falling back to the description?
* @return string|null
*/
public function get_content($content_only = false) public function get_content($content_only = false)
{ {
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
@ -272,6 +407,13 @@ class SimplePie_Item
} }
} }
/**
* Get a category for the item
*
* @since Beta 3 (previously called `get_categories()` since Beta 2)
* @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Category|null
*/
public function get_category($key = 0) public function get_category($key = 0)
{ {
$categories = $this->get_categories(); $categories = $this->get_categories();
@ -285,6 +427,14 @@ class SimplePie_Item
} }
} }
/**
* Get all categories for the item
*
* Uses `<atom:category>`, `<category>` or `<dc:subject>`
*
* @since Beta 3
* @return array|null List of {@see SimplePie_Category} objects
*/
public function get_categories() public function get_categories()
{ {
$categories = array(); $categories = array();
@ -334,7 +484,7 @@ class SimplePie_Item
if (!empty($categories)) if (!empty($categories))
{ {
return $this->registry->call('Misc', 'array_unique', array($categories)); return array_unique($categories);
} }
else else
{ {
@ -342,6 +492,13 @@ class SimplePie_Item
} }
} }
/**
* Get an author for the item
*
* @since Beta 2
* @param int $key The author that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Author|null
*/
public function get_author($key = 0) public function get_author($key = 0)
{ {
$authors = $this->get_authors(); $authors = $this->get_authors();
@ -355,6 +512,13 @@ class SimplePie_Item
} }
} }
/**
* Get a contributor for the item
*
* @since 1.1
* @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Author|null
*/
public function get_contributor($key = 0) public function get_contributor($key = 0)
{ {
$contributors = $this->get_contributors(); $contributors = $this->get_contributors();
@ -368,6 +532,14 @@ class SimplePie_Item
} }
} }
/**
* Get all contributors for the item
*
* Uses `<atom:contributor>`
*
* @since 1.1
* @return array|null List of {@see SimplePie_Author} objects
*/
public function get_contributors() public function get_contributors()
{ {
$contributors = array(); $contributors = array();
@ -418,7 +590,7 @@ class SimplePie_Item
if (!empty($contributors)) if (!empty($contributors))
{ {
return $this->registry->call('Misc', 'array_unique', array($contributors)); return array_unique($contributors);
} }
else else
{ {
@ -426,6 +598,14 @@ class SimplePie_Item
} }
} }
/**
* Get all authors for the item
*
* Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>`
*
* @since Beta 2
* @return array|null List of {@see SimplePie_Author} objects
*/
public function get_authors() public function get_authors()
{ {
$authors = array(); $authors = array();
@ -492,7 +672,7 @@ class SimplePie_Item
if (!empty($authors)) if (!empty($authors))
{ {
return $this->registry->call('Misc', 'array_unique', array($authors)); return array_unique($authors);
} }
elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
{ {
@ -508,6 +688,14 @@ class SimplePie_Item
} }
} }
/**
* Get the copyright info for the item
*
* Uses `<atom:rights>` or `<dc:rights>`
*
* @since 1.1
* @return string
*/
public function get_copyright() public function get_copyright()
{ {
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
@ -528,6 +716,20 @@ class SimplePie_Item
} }
} }
/**
* Get the posting date/time for the item
*
* Uses `<atom:published>`, `<atom:updated>`, `<atom:issued>`,
* `<atom:modified>`, `<pubDate>` or `<dc:date>`
*
* Note: obeys PHP's timezone setting. To get a UTC date/time, use
* {@see get_gmdate}
*
* @since Beta 2 (previously called `get_item_date` since 0.8)
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
* @return int|string|null
*/
public function get_date($date_format = 'j F Y, g:i a') public function get_date($date_format = 'j F Y, g:i a')
{ {
if (!isset($this->data['date'])) if (!isset($this->data['date']))
@ -596,6 +798,17 @@ class SimplePie_Item
} }
} }
/**
* Get the update date/time for the item
*
* Uses `<atom:updated>`
*
* Note: obeys PHP's timezone setting. To get a UTC date/time, use
* {@see get_gmdate}
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
* @return int|string|null
*/
public function get_updated_date($date_format = 'j F Y, g:i a') public function get_updated_date($date_format = 'j F Y, g:i a')
{ {
if (!isset($this->data['updated'])) if (!isset($this->data['updated']))
@ -635,7 +848,20 @@ class SimplePie_Item
return null; return null;
} }
} }
/**
* Get the localized posting date/time for the item
*
* Returns the date formatted in the localized language. To display in
* languages other than the server's default, you need to change the locale
* with {@link http://php.net/setlocale setlocale()}. The available
* localizations depend on which ones are installed on your web server.
*
* @since 1.0
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
* @return int|string|null
*/
public function get_local_date($date_format = '%c') public function get_local_date($date_format = '%c')
{ {
if (!$date_format) if (!$date_format)
@ -652,6 +878,13 @@ class SimplePie_Item
} }
} }
/**
* Get the posting date/time for the item (UTC time)
*
* @see get_date
* @param string $date_format Supports any PHP date format from {@see http://php.net/date}
* @return int|string|null
*/
public function get_gmdate($date_format = 'j F Y, g:i a') public function get_gmdate($date_format = 'j F Y, g:i a')
{ {
$date = $this->get_date('U'); $date = $this->get_date('U');
@ -663,6 +896,13 @@ class SimplePie_Item
return gmdate($date_format, $date); return gmdate($date_format, $date);
} }
/**
* Get the update date/time for the item (UTC time)
*
* @see get_updated_date
* @param string $date_format Supports any PHP date format from {@see http://php.net/date}
* @return int|string|null
*/
public function get_updated_gmdate($date_format = 'j F Y, g:i a') public function get_updated_gmdate($date_format = 'j F Y, g:i a')
{ {
$date = $this->get_updated_date('U'); $date = $this->get_updated_date('U');
@ -674,6 +914,16 @@ class SimplePie_Item
return gmdate($date_format, $date); return gmdate($date_format, $date);
} }
/**
* Get the permalink for the item
*
* Returns the first link available with a relationship of "alternate".
* Identical to {@see get_link()} with key 0
*
* @see get_link
* @since 0.8
* @return string|null Permalink URL
*/
public function get_permalink() public function get_permalink()
{ {
$link = $this->get_link(); $link = $this->get_link();
@ -692,6 +942,14 @@ class SimplePie_Item
} }
} }
/**
* Get a single link for the item
*
* @since Beta 3
* @param int $key The link that you want to return. Remember that arrays begin with 0, not 1
* @param string $rel The relationship of the link to return
* @return string|null Link URL
*/
public function get_link($key = 0, $rel = 'alternate') public function get_link($key = 0, $rel = 'alternate')
{ {
$links = $this->get_links($rel); $links = $this->get_links($rel);
@ -705,6 +963,15 @@ class SimplePie_Item
} }
} }
/**
* Get all links for the item
*
* Uses `<atom:link>`, `<link>` or `<guid>`
*
* @since Beta 2
* @param string $rel The relationship of links to return
* @return array|null Links found for the item (strings)
*/
public function get_links($rel = 'alternate') public function get_links($rel = 'alternate')
{ {
if (!isset($this->data['links'])) if (!isset($this->data['links']))
@ -780,7 +1047,14 @@ class SimplePie_Item
} }
/** /**
* Get an enclosure from the item
*
* Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
*
* @since Beta 2
* @todo Add ability to prefer one type of content over another (in a media group). * @todo Add ability to prefer one type of content over another (in a media group).
* @param int $key The enclosure that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Enclosure|null
*/ */
public function get_enclosure($key = 0, $prefer = null) public function get_enclosure($key = 0, $prefer = null)
{ {
@ -796,14 +1070,18 @@ class SimplePie_Item
} }
/** /**
* Grabs all available enclosures (podcasts, etc.) * Get all available enclosures (podcasts, etc.)
* *
* Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS. * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
* *
* At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support. * At this point, we're pretty much assuming that all enclosures for an item
* are the same content. Anything else is too complicated to
* properly support.
* *
* @since Beta 2
* @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
* @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists). * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
* @return array|null List of SimplePie_Enclosure items
*/ */
public function get_enclosures() public function get_enclosures()
{ {
@ -896,7 +1174,7 @@ class SimplePie_Item
} }
if (is_array($captions_parent)) if (is_array($captions_parent))
{ {
$captions_parent = array_values($this->registry->call('Misc', 'array_unique', array($captions_parent))); $captions_parent = array_values(array_unique($captions_parent));
} }
// CATEGORIES // CATEGORIES
@ -971,7 +1249,7 @@ class SimplePie_Item
} }
if (is_array($categories_parent)) if (is_array($categories_parent))
{ {
$categories_parent = array_values($this->registry->call('Misc', 'array_unique', array($categories_parent))); $categories_parent = array_values(array_unique($categories_parent));
} }
// COPYRIGHT // COPYRIGHT
@ -1059,7 +1337,7 @@ class SimplePie_Item
} }
if (is_array($credits_parent)) if (is_array($credits_parent))
{ {
$credits_parent = array_values($this->registry->call('Misc', 'array_unique', array($credits_parent))); $credits_parent = array_values(array_unique($credits_parent));
} }
// DESCRIPTION // DESCRIPTION
@ -1151,7 +1429,7 @@ class SimplePie_Item
} }
if (is_array($hashes_parent)) if (is_array($hashes_parent))
{ {
$hashes_parent = array_values($this->registry->call('Misc', 'array_unique', array($hashes_parent))); $hashes_parent = array_values(array_unique($hashes_parent));
} }
// KEYWORDS // KEYWORDS
@ -1205,7 +1483,7 @@ class SimplePie_Item
} }
if (is_array($keywords_parent)) if (is_array($keywords_parent))
{ {
$keywords_parent = array_values($this->registry->call('Misc', 'array_unique', array($keywords_parent))); $keywords_parent = array_values(array_unique($keywords_parent));
} }
// PLAYER // PLAYER
@ -1295,7 +1573,7 @@ class SimplePie_Item
} }
if (is_array($ratings_parent)) if (is_array($ratings_parent))
{ {
$ratings_parent = array_values($this->registry->call('Misc', 'array_unique', array($ratings_parent))); $ratings_parent = array_values(array_unique($ratings_parent));
} }
// RESTRICTIONS // RESTRICTIONS
@ -1373,7 +1651,11 @@ class SimplePie_Item
} }
if (is_array($restrictions_parent)) if (is_array($restrictions_parent))
{ {
$restrictions_parent = array_values($this->registry->call('Misc', 'array_unique', array($restrictions_parent))); $restrictions_parent = array_values(array_unique($restrictions_parent));
}
else
{
$restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default'));
} }
// THUMBNAILS // THUMBNAILS
@ -1578,7 +1860,7 @@ class SimplePie_Item
} }
if (is_array($captions)) if (is_array($captions))
{ {
$captions = array_values($this->registry->call('Misc', 'array_unique', array($captions))); $captions = array_values(array_unique($captions));
} }
} }
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
@ -1614,7 +1896,7 @@ class SimplePie_Item
} }
if (is_array($captions)) if (is_array($captions))
{ {
$captions = array_values($this->registry->call('Misc', 'array_unique', array($captions))); $captions = array_values(array_unique($captions));
} }
} }
else else
@ -1677,15 +1959,15 @@ class SimplePie_Item
} }
if (is_array($categories) && is_array($categories_parent)) if (is_array($categories) && is_array($categories_parent))
{ {
$categories = array_values($this->registry->call('Misc', 'array_unique', array(array_merge($categories, $categories_parent)))); $categories = array_values(array_unique(array_merge($categories, $categories_parent)));
} }
elseif (is_array($categories)) elseif (is_array($categories))
{ {
$categories = array_values($this->registry->call('Misc', 'array_unique', array($categories))); $categories = array_values(array_unique($categories));
} }
elseif (is_array($categories_parent)) elseif (is_array($categories_parent))
{ {
$categories = array_values($this->registry->call('Misc', 'array_unique', array($categories_parent))); $categories = array_values(array_unique($categories_parent));
} }
// COPYRIGHTS // COPYRIGHTS
@ -1750,7 +2032,7 @@ class SimplePie_Item
} }
if (is_array($credits)) if (is_array($credits))
{ {
$credits = array_values($this->registry->call('Misc', 'array_unique', array($credits))); $credits = array_values(array_unique($credits));
} }
} }
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
@ -1780,7 +2062,7 @@ class SimplePie_Item
} }
if (is_array($credits)) if (is_array($credits))
{ {
$credits = array_values($this->registry->call('Misc', 'array_unique', array($credits))); $credits = array_values(array_unique($credits));
} }
} }
else else
@ -1825,7 +2107,7 @@ class SimplePie_Item
} }
if (is_array($hashes)) if (is_array($hashes))
{ {
$hashes = array_values($this->registry->call('Misc', 'array_unique', array($hashes))); $hashes = array_values(array_unique($hashes));
} }
} }
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
@ -1850,7 +2132,7 @@ class SimplePie_Item
} }
if (is_array($hashes)) if (is_array($hashes))
{ {
$hashes = array_values($this->registry->call('Misc', 'array_unique', array($hashes))); $hashes = array_values(array_unique($hashes));
} }
} }
else else
@ -1872,7 +2154,7 @@ class SimplePie_Item
} }
if (is_array($keywords)) if (is_array($keywords))
{ {
$keywords = array_values($this->registry->call('Misc', 'array_unique', array($keywords))); $keywords = array_values(array_unique($keywords));
} }
} }
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
@ -1888,7 +2170,7 @@ class SimplePie_Item
} }
if (is_array($keywords)) if (is_array($keywords))
{ {
$keywords = array_values($this->registry->call('Misc', 'array_unique', array($keywords))); $keywords = array_values(array_unique($keywords));
} }
} }
else else
@ -1933,7 +2215,7 @@ class SimplePie_Item
} }
if (is_array($ratings)) if (is_array($ratings))
{ {
$ratings = array_values($this->registry->call('Misc', 'array_unique', array($ratings))); $ratings = array_values(array_unique($ratings));
} }
} }
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
@ -1958,7 +2240,7 @@ class SimplePie_Item
} }
if (is_array($ratings)) if (is_array($ratings))
{ {
$ratings = array_values($this->registry->call('Misc', 'array_unique', array($ratings))); $ratings = array_values(array_unique($ratings));
} }
} }
else else
@ -1990,7 +2272,7 @@ class SimplePie_Item
} }
if (is_array($restrictions)) if (is_array($restrictions))
{ {
$restrictions = array_values($this->registry->call('Misc', 'array_unique', array($restrictions))); $restrictions = array_values(array_unique($restrictions));
} }
} }
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
@ -2016,7 +2298,7 @@ class SimplePie_Item
} }
if (is_array($restrictions)) if (is_array($restrictions))
{ {
$restrictions = array_values($this->registry->call('Misc', 'array_unique', array($restrictions))); $restrictions = array_values(array_unique($restrictions));
} }
} }
else else
@ -2033,7 +2315,7 @@ class SimplePie_Item
} }
if (is_array($thumbnails)) if (is_array($thumbnails))
{ {
$thumbnails = array_values($this->registry->call('Misc', 'array_unique', array($thumbnails))); $thumbnails = array_values(array_unique($thumbnails));
} }
} }
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
@ -2044,7 +2326,7 @@ class SimplePie_Item
} }
if (is_array($thumbnails)) if (is_array($thumbnails))
{ {
$thumbnails = array_values($this->registry->call('Misc', 'array_unique', array($thumbnails))); $thumbnails = array_values(array_unique($thumbnails));
} }
} }
else else
@ -2202,7 +2484,7 @@ class SimplePie_Item
} }
if (is_array($captions)) if (is_array($captions))
{ {
$captions = array_values($this->registry->call('Misc', 'array_unique', array($captions))); $captions = array_values(array_unique($captions));
} }
} }
else else
@ -2239,15 +2521,15 @@ class SimplePie_Item
} }
if (is_array($categories) && is_array($categories_parent)) if (is_array($categories) && is_array($categories_parent))
{ {
$categories = array_values($this->registry->call('Misc', 'array_unique', array(array_merge($categories, $categories_parent)))); $categories = array_values(array_unique(array_merge($categories, $categories_parent)));
} }
elseif (is_array($categories)) elseif (is_array($categories))
{ {
$categories = array_values($this->registry->call('Misc', 'array_unique', array($categories))); $categories = array_values(array_unique($categories));
} }
elseif (is_array($categories_parent)) elseif (is_array($categories_parent))
{ {
$categories = array_values($this->registry->call('Misc', 'array_unique', array($categories_parent))); $categories = array_values(array_unique($categories_parent));
} }
else else
{ {
@ -2302,7 +2584,7 @@ class SimplePie_Item
} }
if (is_array($credits)) if (is_array($credits))
{ {
$credits = array_values($this->registry->call('Misc', 'array_unique', array($credits))); $credits = array_values(array_unique($credits));
} }
} }
else else
@ -2343,7 +2625,7 @@ class SimplePie_Item
} }
if (is_array($hashes)) if (is_array($hashes))
{ {
$hashes = array_values($this->registry->call('Misc', 'array_unique', array($hashes))); $hashes = array_values(array_unique($hashes));
} }
} }
else else
@ -2365,7 +2647,7 @@ class SimplePie_Item
} }
if (is_array($keywords)) if (is_array($keywords))
{ {
$keywords = array_values($this->registry->call('Misc', 'array_unique', array($keywords))); $keywords = array_values(array_unique($keywords));
} }
} }
else else
@ -2406,7 +2688,7 @@ class SimplePie_Item
} }
if (is_array($ratings)) if (is_array($ratings))
{ {
$ratings = array_values($this->registry->call('Misc', 'array_unique', array($ratings))); $ratings = array_values(array_unique($ratings));
} }
} }
else else
@ -2438,7 +2720,7 @@ class SimplePie_Item
} }
if (is_array($restrictions)) if (is_array($restrictions))
{ {
$restrictions = array_values($this->registry->call('Misc', 'array_unique', array($restrictions))); $restrictions = array_values(array_unique($restrictions));
} }
} }
else else
@ -2455,7 +2737,7 @@ class SimplePie_Item
} }
if (is_array($thumbnails)) if (is_array($thumbnails))
{ {
$thumbnails = array_values($this->registry->call('Misc', 'array_unique', array($thumbnails))); $thumbnails = array_values(array_unique($thumbnails));
} }
} }
else else
@ -2589,7 +2871,7 @@ class SimplePie_Item
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
} }
$this->data['enclosures'] = array_values($this->registry->call('Misc', 'array_unique', array($this->data['enclosures']))); $this->data['enclosures'] = array_values(array_unique($this->data['enclosures']));
} }
if (!empty($this->data['enclosures'])) if (!empty($this->data['enclosures']))
{ {
@ -2601,6 +2883,18 @@ class SimplePie_Item
} }
} }
/**
* Get the latitude coordinates for the item
*
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
*
* Uses `<geo:lat>` or `<georss:point>`
*
* @since 1.0
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
* @link http://www.georss.org/ GeoRSS
* @return string|null
*/
public function get_latitude() public function get_latitude()
{ {
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
@ -2617,6 +2911,18 @@ class SimplePie_Item
} }
} }
/**
* Get the longitude coordinates for the item
*
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
*
* Uses `<geo:long>`, `<geo:lon>` or `<georss:point>`
*
* @since 1.0
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
* @link http://www.georss.org/ GeoRSS
* @return string|null
*/
public function get_longitude() public function get_longitude()
{ {
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
@ -2637,6 +2943,12 @@ class SimplePie_Item
} }
} }
/**
* Get the `<atom:source>` for the item
*
* @since 1.1
* @return SimplePie_Source|null
*/
public function get_source() public function get_source()
{ {
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -65,9 +65,9 @@ class SimplePie_Locator
var $max_checked_feeds = 10; var $max_checked_feeds = 10;
protected $registry; protected $registry;
public function __construct(&$file, $timeout = 10, $useragent = null, $max_checked_feeds = 10) public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10)
{ {
$this->file =& $file; $this->file = $file;
$this->useragent = $useragent; $this->useragent = $useragent;
$this->timeout = $timeout; $this->timeout = $timeout;
$this->max_checked_feeds = $max_checked_feeds; $this->max_checked_feeds = $max_checked_feeds;
@ -79,9 +79,9 @@ class SimplePie_Locator
restore_error_handler(); restore_error_handler();
} }
public function set_registry(SimplePie_Registry &$registry) public function set_registry(SimplePie_Registry $registry)
{ {
$this->registry = &$registry; $this->registry = $registry;
} }
public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working) public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
@ -135,7 +135,7 @@ class SimplePie_Locator
return null; return null;
} }
public function is_feed(&$file) public function is_feed($file)
{ {
if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
{ {
@ -170,7 +170,7 @@ class SimplePie_Locator
if ($element->hasAttribute('href')) if ($element->hasAttribute('href'))
{ {
$this->base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base)); $this->base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base));
$this->base_location = $element->getLineNo(); $this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0;
break; break;
} }
} }
@ -206,8 +206,9 @@ class SimplePie_Locator
if ($link->hasAttribute('href') && $link->hasAttribute('rel')) if ($link->hasAttribute('href') && $link->hasAttribute('rel'))
{ {
$rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel'))))); $rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel')))));
$line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1;
if ($this->base_location < $link->getLineNo()) if ($this->base_location < $line)
{ {
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base));
} }

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -80,61 +80,7 @@ class SimplePie_Misc
public static function absolutize_url($relative, $base) public static function absolutize_url($relative, $base)
{ {
$iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative); $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
return $iri->get_iri(); return $iri->get_uri();
}
public static function remove_dot_segments($input)
{
$output = '';
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)
{
$input = substr($input, 3);
}
elseif (strpos($input, './') === 0)
{
$input = substr($input, 2);
}
// B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
elseif (strpos($input, '/./') === 0)
{
$input = substr_replace($input, '/', 0, 3);
}
elseif ($input === '/.')
{
$input = '/';
}
// C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
elseif (strpos($input, '/../') === 0)
{
$input = substr_replace($input, '/', 0, 4);
$output = substr_replace($output, '', strrpos($output, '/'));
}
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 === '..')
{
$input = '';
}
// E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
elseif (($pos = strpos($input, '/', 1)) !== false)
{
$output .= substr($input, 0, $pos);
$input = substr_replace($input, '', 0, $pos);
}
else
{
$output .= $input;
$input = '';
}
}
return $output . $input;
} }
/** /**
@ -278,29 +224,29 @@ class SimplePie_Misc
{ {
$iri = new SimplePie_IRI($url); $iri = new SimplePie_IRI($url);
return array( return array(
'scheme' => (string) $iri->get_scheme(), 'scheme' => (string) $iri->scheme,
'authority' => (string) $iri->get_authority(), 'authority' => (string) $iri->authority,
'path' => (string) $iri->get_path(), 'path' => (string) $iri->path,
'query' => (string) $iri->get_query(), 'query' => (string) $iri->query,
'fragment' => (string) $iri->get_fragment() 'fragment' => (string) $iri->fragment
); );
} }
public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
{ {
$iri = new SimplePie_IRI(''); $iri = new SimplePie_IRI('');
$iri->set_scheme($scheme); $iri->scheme = $scheme;
$iri->set_authority($authority); $iri->authority = $authority;
$iri->set_path($path); $iri->path = $path;
$iri->set_query($query); $iri->query = $query;
$iri->set_fragment($fragment); $iri->fragment = $fragment;
return $iri->get_iri(); return $iri->get_uri();
} }
public static function normalize_url($url) public static function normalize_url($url)
{ {
$iri = new SimplePie_IRI($url); $iri = new SimplePie_IRI($url);
return $iri->get_iri(); return $iri->get_uri();
} }
public static function percent_encoding_normalization($match) public static function percent_encoding_normalization($match)
@ -389,6 +335,14 @@ class SimplePie_Misc
{ {
$output = 'EUC-KR'; $output = 'EUC-KR';
} }
if ($input === 'Windows-31J')
{
$input = 'SJIS';
}
if ($output === 'Windows-31J')
{
$output = 'SJIS';
}
// Check that the encoding is supported // Check that the encoding is supported
if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80") if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80")
@ -1759,40 +1713,6 @@ class SimplePie_Misc
return $curl; return $curl;
} }
public static function is_subclass_of($class1, $class2)
{
if (func_num_args() !== 2)
{
trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING);
}
elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1))
{
return is_subclass_of($class1, $class2);
}
elseif (is_string($class1) && is_string($class2))
{
if (class_exists($class1))
{
if (class_exists($class2))
{
$class2 = strtolower($class2);
while ($class1 = strtolower(get_parent_class($class1)))
{
if ($class1 === $class2)
{
return true;
}
}
}
}
else
{
trigger_error('Unknown class passed as parameter', E_USER_WARNNG);
}
}
return false;
}
/** /**
* Strip HTML comments * Strip HTML comments
* *
@ -1908,18 +1828,6 @@ class SimplePie_Misc
} }
} }
public static function htmlspecialchars_decode($string, $quote_style)
{
if (function_exists('htmlspecialchars_decode'))
{
return htmlspecialchars_decode($string, $quote_style);
}
else
{
return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
}
}
public static function atom_03_construct_type($attribs) public static function atom_03_construct_type($attribs)
{ {
if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
@ -2033,48 +1941,6 @@ class SimplePie_Misc
return $tokens; return $tokens;
} }
public static function array_unique($array)
{
if (version_compare(PHP_VERSION, '5.2', '>='))
{
return array_unique($array);
}
else
{
$array = (array) $array;
$new_array = array();
$new_array_strings = array();
foreach ($array as $key => $value)
{
if (is_object($value))
{
if (method_exists($value, '__toString'))
{
$cmp = $value->__toString();
}
else
{
trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR);
}
}
elseif (is_array($value))
{
$cmp = (string) reset($value);
}
else
{
$cmp = (string) $value;
}
if (!in_array($cmp, $new_array_strings))
{
$new_array[$key] = $value;
$new_array_strings[] = $cmp;
}
}
return $new_array;
}
}
/** /**
* Converts a unicode codepoint to a UTF-8 character * Converts a unicode codepoint to a UTF-8 character
* *
@ -2151,7 +2017,7 @@ class SimplePie_Misc
* @param SimplePie_Registry $registry Class registry * @param SimplePie_Registry $registry Class registry
* @return array Possible encodings * @return array Possible encodings
*/ */
public static function xml_encoding($data, &$registry) public static function xml_encoding($data, $registry)
{ {
// UTF-32 Big Endian BOM // UTF-32 Big Endian BOM
if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")

276
3rdparty/SimplePie/library/SimplePie/Net/IPv6.php поставляемый Normal file
Просмотреть файл

@ -0,0 +1,276 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Class to validate and to work with IPv6 addresses.
*
* @package SimplePie
* @subpackage HTTP
* @copyright 2003-2005 The PHP Group
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/package/Net_IPv6
* @author Alexander Merz <alexander.merz@web.de>
* @author elfrink at introweb dot nl
* @author Josh Peck <jmp at joshpeck dot org>
* @author Geoffrey Sneddon <geoffers@gmail.com>
*/
class SimplePie_Net_IPv6
{
/**
* Uncompresses an IPv6 address
*
* RFC 4291 allows you to compress concecutive zero pieces in an address to
* '::'. This method expects a valid IPv6 address and expands the '::' to
* the required number of zero pieces.
*
* Example: FF01::101 -> FF01:0:0:0:0:0:0:101
* ::1 -> 0:0:0:0:0:0:0:1
*
* @author Alexander Merz <alexander.merz@web.de>
* @author elfrink at introweb dot nl
* @author Josh Peck <jmp at joshpeck dot org>
* @copyright 2003-2005 The PHP Group
* @license http://www.opensource.org/licenses/bsd-license.php
* @param string $ip An IPv6 address
* @return string The uncompressed IPv6 address
*/
public static function uncompress($ip)
{
$c1 = -1;
$c2 = -1;
if (substr_count($ip, '::') === 1)
{
list($ip1, $ip2) = explode('::', $ip);
if ($ip1 === '')
{
$c1 = -1;
}
else
{
$c1 = substr_count($ip1, ':');
}
if ($ip2 === '')
{
$c2 = -1;
}
else
{
$c2 = substr_count($ip2, ':');
}
if (strpos($ip2, '.') !== false)
{
$c2++;
}
// ::
if ($c1 === -1 && $c2 === -1)
{
$ip = '0:0:0:0:0:0:0:0';
}
// ::xxx
else if ($c1 === -1)
{
$fill = str_repeat('0:', 7 - $c2);
$ip = str_replace('::', $fill, $ip);
}
// xxx::
else if ($c2 === -1)
{
$fill = str_repeat(':0', 7 - $c1);
$ip = str_replace('::', $fill, $ip);
}
// xxx::xxx
else
{
$fill = ':' . str_repeat('0:', 6 - $c2 - $c1);
$ip = str_replace('::', $fill, $ip);
}
}
return $ip;
}
/**
* Compresses an IPv6 address
*
* RFC 4291 allows you to compress concecutive zero pieces in an address to
* '::'. This method expects a valid IPv6 address and compresses consecutive
* zero pieces to '::'.
*
* Example: FF01:0:0:0:0:0:0:101 -> FF01::101
* 0:0:0:0:0:0:0:1 -> ::1
*
* @see uncompress()
* @param string $ip An IPv6 address
* @return string The compressed IPv6 address
*/
public static function compress($ip)
{
// Prepare the IP to be compressed
$ip = self::uncompress($ip);
$ip_parts = self::split_v6_v4($ip);
// Replace all leading zeros
$ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);
// Find bunches of zeros
if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE))
{
$max = 0;
$pos = null;
foreach ($matches[0] as $match)
{
if (strlen($match[0]) > $max)
{
$max = strlen($match[0]);
$pos = $match[1];
}
}
$ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max);
}
if ($ip_parts[1] !== '')
{
return implode(':', $ip_parts);
}
else
{
return $ip_parts[0];
}
}
/**
* Splits an IPv6 address into the IPv6 and IPv4 representation parts
*
* RFC 4291 allows you to represent the last two parts of an IPv6 address
* using the standard IPv4 representation
*
* Example: 0:0:0:0:0:0:13.1.68.3
* 0:0:0:0:0:FFFF:129.144.52.38
*
* @param string $ip An IPv6 address
* @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part
*/
private static function split_v6_v4($ip)
{
if (strpos($ip, '.') !== false)
{
$pos = strrpos($ip, ':');
$ipv6_part = substr($ip, 0, $pos);
$ipv4_part = substr($ip, $pos + 1);
return array($ipv6_part, $ipv4_part);
}
else
{
return array($ip, '');
}
}
/**
* Checks an IPv6 address
*
* Checks if the given IP is a valid IPv6 address
*
* @param string $ip An IPv6 address
* @return bool true if $ip is a valid IPv6 address
*/
public static function check_ipv6($ip)
{
$ip = self::uncompress($ip);
list($ipv6, $ipv4) = self::split_v6_v4($ip);
$ipv6 = explode(':', $ipv6);
$ipv4 = explode('.', $ipv4);
if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4)
{
foreach ($ipv6 as $ipv6_part)
{
// The section can't be empty
if ($ipv6_part === '')
return false;
// Nor can it be over four characters
if (strlen($ipv6_part) > 4)
return false;
// Remove leading zeros (this is safe because of the above)
$ipv6_part = ltrim($ipv6_part, '0');
if ($ipv6_part === '')
$ipv6_part = '0';
// Check the value is valid
$value = hexdec($ipv6_part);
if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF)
return false;
}
if (count($ipv4) === 4)
{
foreach ($ipv4 as $ipv4_part)
{
$value = (int) $ipv4_part;
if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF)
return false;
}
}
return true;
}
else
{
return false;
}
}
/**
* Checks if the given IP is a valid IPv6 address
*
* @codeCoverageIgnore
* @deprecated Use {@see SimplePie_Net_IPv6::check_ipv6()} instead
* @see check_ipv6
* @param string $ip An IPv6 address
* @return bool true if $ip is a valid IPv6 address
*/
public static function checkIPv6($ip)
{
return self::check_ipv6($ip);
}
}

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -47,6 +47,7 @@
* Date Parser * Date Parser
* *
* @package SimplePie * @package SimplePie
* @subpackage Parsing
*/ */
class SimplePie_Parse_Date class SimplePie_Parse_Date
{ {
@ -598,7 +599,7 @@ class SimplePie_Parse_Date
foreach ($this->built_in as $method) foreach ($this->built_in as $method)
{ {
if (($returned = call_user_func(array(&$this, $method), $date)) !== false) if (($returned = call_user_func(array($this, $method), $date)) !== false)
{ {
return $returned; return $returned;
} }

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -49,6 +49,7 @@
* This class can be overloaded with {@see SimplePie::set_parser_class()} * This class can be overloaded with {@see SimplePie::set_parser_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage Parsing
*/ */
class SimplePie_Parser class SimplePie_Parser
{ {
@ -69,9 +70,9 @@ class SimplePie_Parser
var $encoding; var $encoding;
protected $registry; protected $registry;
public function set_registry(SimplePie_Registry &$registry) public function set_registry(SimplePie_Registry $registry)
{ {
$this->registry = &$registry; $this->registry = $registry;
} }
public function parse(&$data, $encoding) public function parse(&$data, $encoding)
@ -317,7 +318,10 @@ class SimplePie_Parser
$this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
$this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')) || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')
|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_20 && in_array(end($this->element), array('title')))
|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_090 && in_array(end($this->element), array('title')))
|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_10 && in_array(end($this->element), array('title'))))
{ {
$this->current_xhtml_construct = 0; $this->current_xhtml_construct = 0;
} }

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_rating_class()} * This class can be overloaded with {@see SimplePie::set_rating_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Rating class SimplePie_Rating
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -113,7 +113,7 @@ class SimplePie_Registry
*/ */
public function register($type, $class, $legacy = false) public function register($type, $class, $legacy = false)
{ {
if (!$this->call('Misc', 'is_subclass_of', array($class, $this->default[$type]))) if (!is_subclass_of($class, $this->default[$type]))
{ {
return false; return false;
} }

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_restriction_class()} * This class can be overloaded with {@see SimplePie::set_restriction_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Restriction class SimplePie_Restriction
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -70,18 +70,13 @@ class SimplePie_Sanitize
var $timeout = 10; var $timeout = 10;
var $useragent = ''; var $useragent = '';
var $force_fsockopen = false; var $force_fsockopen = false;
var $replace_url_attributes = null;
var $replace_url_attributes = array( public function __construct()
'a' => 'href', {
'area' => 'href', // Set defaults
'blockquote' => 'cite', $this->set_url_replacements(null);
'del' => 'cite', }
'form' => 'action',
'img' => array('longdesc', 'src'),
'input' => 'src',
'ins' => 'cite',
'q' => 'cite'
);
public function remove_div($enable = true) public function remove_div($enable = true)
{ {
@ -100,7 +95,7 @@ class SimplePie_Sanitize
} }
} }
public function set_registry(SimplePie_Registry &$registry) public function set_registry(SimplePie_Registry $registry)
{ {
$this->registry = $registry; $this->registry = $registry;
} }
@ -198,12 +193,32 @@ class SimplePie_Sanitize
* Set element/attribute key/value pairs of HTML attributes * Set element/attribute key/value pairs of HTML attributes
* containing URLs that need to be resolved relative to the feed * containing URLs that need to be resolved relative to the feed
* *
* @access public * Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite,
* |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite,
* |q|@cite
*
* @since 1.0 * @since 1.0
* @param array $element_attribute Element/attribute key/value pairs * @param array|null $element_attribute Element/attribute key/value pairs, null for default
*/ */
public function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite')) public function set_url_replacements($element_attribute = null)
{ {
if ($element_attribute === null)
{
$element_attribute = array(
'a' => 'href',
'area' => 'href',
'blockquote' => 'cite',
'del' => 'cite',
'form' => 'action',
'img' => array(
'longdesc',
'src'
),
'input' => 'src',
'ins' => 'cite',
'q' => 'cite'
);
}
$this->replace_url_attributes = (array) $element_attribute; $this->replace_url_attributes = (array) $element_attribute;
} }
@ -328,17 +343,14 @@ class SimplePie_Sanitize
// Finally, convert to a HTML string // Finally, convert to a HTML string
$data = trim($document->saveHTML()); $data = trim($document->saveHTML());
if ($type & SIMPLEPIE_CONSTRUCT_XHTML) if ($this->remove_div)
{ {
if ($this->remove_div) $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
{ $data = preg_replace('/<\/div>$/', '', $data);
$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data); }
$data = preg_replace('/<\/div>$/', '', $data); else
} {
else $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
{
$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
}
} }
} }
@ -368,13 +380,13 @@ class SimplePie_Sanitize
// Atom XHTML constructs are wrapped with a div by default // Atom XHTML constructs are wrapped with a div by default
// Note: No protection if $html contains a stray </div>! // Note: No protection if $html contains a stray </div>!
$html = '<div>' . $html . '</div>'; $html = '<div>' . $html . '</div>';
$ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; $ret .= '<!DOCTYPE html>';
$content_type = 'application/xhtml+xml'; $content_type = 'text/html';
} }
else else
{ {
$ret .= '<!DOCTYPE html>'; $ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
$content_type = 'text/html'; $content_type = 'application/xhtml+xml';
} }
$ret .= '<html><head>'; $ret .= '<html><head>';
@ -383,7 +395,7 @@ class SimplePie_Sanitize
return $ret; return $ret;
} }
public function replace_urls(&$document, $tag, $attributes) public function replace_urls($document, $tag, $attributes)
{ {
if (!is_array($attributes)) if (!is_array($attributes))
{ {
@ -432,7 +444,7 @@ class SimplePie_Sanitize
} }
} }
protected function strip_tag($tag, &$document, $type) protected function strip_tag($tag, $document, $type)
{ {
$xpath = new DOMXPath($document); $xpath = new DOMXPath($document);
$elements = $xpath->query('body//' . $tag); $elements = $xpath->query('body//' . $tag);
@ -473,10 +485,14 @@ class SimplePie_Sanitize
$text .= '>'; $text .= '>';
$fragment->appendChild(new DOMText($text)); $fragment->appendChild(new DOMText($text));
} }
foreach ($element->childNodes as $child)
$number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--)
{ {
$child = $element->childNodes->item(0);
$fragment->appendChild($child); $fragment->appendChild($child);
} }
if (!in_array($tag, array('script', 'style'))) if (!in_array($tag, array('script', 'style')))
{ {
$fragment->appendChild(new DOMText('</' . $tag . '>')); $fragment->appendChild(new DOMText('</' . $tag . '>'));
@ -501,8 +517,10 @@ class SimplePie_Sanitize
foreach ($elements as $element) foreach ($elements as $element)
{ {
$fragment = $document->createDocumentFragment(); $fragment = $document->createDocumentFragment();
foreach ($element->childNodes as $child) $number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--)
{ {
$child = $element->childNodes->item(0);
$fragment->appendChild($child); $fragment->appendChild($child);
} }
@ -511,7 +529,7 @@ class SimplePie_Sanitize
} }
} }
protected function strip_attr($attrib, &$document) protected function strip_attr($attrib, $document)
{ {
$xpath = new DOMXPath($document); $xpath = new DOMXPath($document);
$elements = $xpath->query('//*[@' . $attrib . ']'); $elements = $xpath->query('//*[@' . $attrib . ']');

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -50,6 +50,7 @@
* This class can be overloaded with {@see SimplePie::set_source_class()} * This class can be overloaded with {@see SimplePie::set_source_class()}
* *
* @package SimplePie * @package SimplePie
* @subpackage API
*/ */
class SimplePie_Source class SimplePie_Source
{ {
@ -63,9 +64,9 @@ class SimplePie_Source
$this->data = $data; $this->data = $data;
} }
public function set_registry(SimplePie_Registry &$registry) public function set_registry(SimplePie_Registry $registry)
{ {
$this->registry = &$registry; $this->registry = $registry;
} }
public function __toString() public function __toString()
@ -198,7 +199,7 @@ class SimplePie_Source
if (!empty($categories)) if (!empty($categories))
{ {
return $this->registry->call('Misc', 'array_unique', array($categories)); return array_unique($categories);
} }
else else
{ {
@ -281,7 +282,7 @@ class SimplePie_Source
if (!empty($authors)) if (!empty($authors))
{ {
return $this->registry->call('Misc', 'array_unique', array($authors)); return array_unique($authors);
} }
else else
{ {
@ -352,7 +353,7 @@ class SimplePie_Source
if (!empty($contributors)) if (!empty($contributors))
{ {
return $this->registry->call('Misc', 'array_unique', array($contributors)); return array_unique($contributors);
} }
else else
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -47,6 +47,7 @@
* Parses the XML Declaration * Parses the XML Declaration
* *
* @package SimplePie * @package SimplePie
* @subpackage Parsing
*/ */
class SimplePie_XML_Declaration_Parser class SimplePie_XML_Declaration_Parser
{ {

Просмотреть файл

@ -33,7 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @package SimplePie * @package SimplePie
* @version 1.3-dev * @version 1.3
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman * @author Ryan Parman
* @author Geoffrey Sneddon * @author Geoffrey Sneddon
@ -47,6 +47,7 @@
* Decode 'gzip' encoded HTTP data * Decode 'gzip' encoded HTTP data
* *
* @package SimplePie * @package SimplePie
* @subpackage HTTP
* @link http://www.gzip.org/format.txt * @link http://www.gzip.org/format.txt
*/ */
class SimplePie_gzdecode class SimplePie_gzdecode

Просмотреть файл

@ -211,7 +211,7 @@ $(document).ready(function(){
event.stopPropagation(); event.stopPropagation();
}); });
var updateInterval = 20000; //how often the feeds should update (in msec) var updateInterval = 200000; //how often the feeds should update (in msec)
setInterval('News.Feed.updateAll()', updateInterval); setInterval('News.Feed.updateAll()', updateInterval);
}); });

Просмотреть файл

@ -12,7 +12,7 @@
// load SimplePie library // load SimplePie library
//TODO: is this file a suitable place for the following require? //TODO: is this file a suitable place for the following require?
require_once('news/3rdparty/SimplePie/SimplePieAutoloader.php'); require_once('news/3rdparty/SimplePie/autoloader.php');
class OC_News_Utils { class OC_News_Utils {