2012-08-28 13:24:33 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* SimplePie
|
|
|
|
*
|
|
|
|
* A PHP-Based RSS and Atom Feed Framework.
|
|
|
|
* Takes the hard work out of managing a complete RSS/Atom solution.
|
|
|
|
*
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
* Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
|
2012-08-28 13:24:33 -04:00
|
|
|
* 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
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
|
2012-08-28 13:24:33 -04:00
|
|
|
* @author Ryan Parman
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
* @author Sam Sneddon
|
2012-08-28 13:24:33 -04:00
|
|
|
* @author Ryan McCue
|
|
|
|
* @link http://simplepie.org/ SimplePie
|
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used for fetching remote files and reading local files
|
|
|
|
*
|
|
|
|
* Supports HTTP 1.0 via cURL or fsockopen, with spotty HTTP 1.1 support
|
|
|
|
*
|
|
|
|
* This class can be overloaded with {@see SimplePie::set_file_class()}
|
|
|
|
*
|
|
|
|
* @package SimplePie
|
|
|
|
* @subpackage HTTP
|
|
|
|
* @todo Move to properly supporting RFC2616 (HTTP/1.1)
|
|
|
|
*/
|
|
|
|
class SimplePie_File
|
|
|
|
{
|
|
|
|
var $url;
|
|
|
|
var $useragent;
|
|
|
|
var $success = true;
|
|
|
|
var $headers = array();
|
|
|
|
var $body;
|
|
|
|
var $status_code;
|
|
|
|
var $redirects = 0;
|
|
|
|
var $error;
|
|
|
|
var $method = SIMPLEPIE_FILE_SOURCE_NONE;
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
var $permanent_url;
|
2012-08-28 13:24:33 -04:00
|
|
|
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $curl_options = array())
|
2012-08-28 13:24:33 -04:00
|
|
|
{
|
|
|
|
if (class_exists('idna_convert'))
|
|
|
|
{
|
|
|
|
$idn = new idna_convert();
|
|
|
|
$parsed = SimplePie_Misc::parse_url($url);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], NULL);
|
2012-08-28 13:24:33 -04:00
|
|
|
}
|
|
|
|
$this->url = $url;
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$this->permanent_url = $url;
|
2012-08-28 13:24:33 -04:00
|
|
|
$this->useragent = $useragent;
|
|
|
|
if (preg_match('/^http(s)?:\/\//i', $url))
|
|
|
|
{
|
|
|
|
if ($useragent === null)
|
|
|
|
{
|
|
|
|
$useragent = ini_get('user_agent');
|
|
|
|
$this->useragent = $useragent;
|
|
|
|
}
|
|
|
|
if (!is_array($headers))
|
|
|
|
{
|
|
|
|
$headers = array();
|
|
|
|
}
|
|
|
|
if (!$force_fsockopen && function_exists('curl_exec'))
|
|
|
|
{
|
|
|
|
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
|
|
|
|
$fp = curl_init();
|
|
|
|
$headers2 = array();
|
|
|
|
foreach ($headers as $key => $value)
|
|
|
|
{
|
|
|
|
$headers2[] = "$key: $value";
|
|
|
|
}
|
|
|
|
if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>='))
|
|
|
|
{
|
|
|
|
curl_setopt($fp, CURLOPT_ENCODING, '');
|
|
|
|
}
|
|
|
|
curl_setopt($fp, CURLOPT_URL, $url);
|
|
|
|
curl_setopt($fp, CURLOPT_HEADER, 1);
|
|
|
|
curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
curl_setopt($fp, CURLOPT_FAILONERROR, 1);
|
2012-08-28 13:24:33 -04:00
|
|
|
curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
|
|
|
|
curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
|
2021-12-20 14:33:00 -05:00
|
|
|
curl_setopt($fp, CURLOPT_REFERER, SimplePie_Misc::url_remove_credentials($url));
|
2012-08-28 13:24:33 -04:00
|
|
|
curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
|
|
|
|
curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
foreach ($curl_options as $curl_param => $curl_value) {
|
|
|
|
curl_setopt($fp, $curl_param, $curl_value);
|
|
|
|
}
|
2012-08-28 13:24:33 -04:00
|
|
|
|
|
|
|
$this->headers = curl_exec($fp);
|
|
|
|
if (curl_errno($fp) === 23 || curl_errno($fp) === 61)
|
|
|
|
{
|
|
|
|
curl_setopt($fp, CURLOPT_ENCODING, 'none');
|
|
|
|
$this->headers = curl_exec($fp);
|
|
|
|
}
|
2021-12-20 14:33:00 -05:00
|
|
|
$this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE);
|
2012-08-28 13:24:33 -04:00
|
|
|
if (curl_errno($fp))
|
|
|
|
{
|
|
|
|
$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
|
|
|
|
$this->success = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
// Use the updated url provided by curl_getinfo after any redirects.
|
|
|
|
if ($info = curl_getinfo($fp)) {
|
|
|
|
$this->url = $info['url'];
|
|
|
|
}
|
2012-08-28 13:24:33 -04:00
|
|
|
curl_close($fp);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$this->headers = SimplePie_HTTP_Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1);
|
2012-08-28 13:24:33 -04:00
|
|
|
$parser = new SimplePie_HTTP_Parser($this->headers);
|
|
|
|
if ($parser->parse())
|
|
|
|
{
|
|
|
|
$this->headers = $parser->headers;
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$this->body = trim($parser->body);
|
2012-08-28 13:24:33 -04:00
|
|
|
$this->status_code = $parser->status_code;
|
|
|
|
if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
|
|
|
|
{
|
|
|
|
$this->redirects++;
|
|
|
|
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$previousStatusCode = $this->status_code;
|
2020-10-16 13:20:07 -04:00
|
|
|
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
|
|
|
|
return;
|
2012-08-28 13:24:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
|
|
|
|
$url_parts = parse_url($url);
|
|
|
|
$socket_host = $url_parts['host'];
|
|
|
|
if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
|
|
|
|
{
|
|
|
|
$socket_host = "ssl://$url_parts[host]";
|
|
|
|
$url_parts['port'] = 443;
|
|
|
|
}
|
|
|
|
if (!isset($url_parts['port']))
|
|
|
|
{
|
|
|
|
$url_parts['port'] = 80;
|
|
|
|
}
|
|
|
|
$fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
|
|
|
|
if (!$fp)
|
|
|
|
{
|
|
|
|
$this->error = 'fsockopen error: ' . $errstr;
|
|
|
|
$this->success = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stream_set_timeout($fp, $timeout);
|
|
|
|
if (isset($url_parts['path']))
|
|
|
|
{
|
|
|
|
if (isset($url_parts['query']))
|
|
|
|
{
|
|
|
|
$get = "$url_parts[path]?$url_parts[query]";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$get = $url_parts['path'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$get = '/';
|
|
|
|
}
|
|
|
|
$out = "GET $get HTTP/1.1\r\n";
|
|
|
|
$out .= "Host: $url_parts[host]\r\n";
|
|
|
|
$out .= "User-Agent: $useragent\r\n";
|
|
|
|
if (extension_loaded('zlib'))
|
|
|
|
{
|
|
|
|
$out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($url_parts['user']) && isset($url_parts['pass']))
|
|
|
|
{
|
|
|
|
$out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
|
|
|
|
}
|
|
|
|
foreach ($headers as $key => $value)
|
|
|
|
{
|
|
|
|
$out .= "$key: $value\r\n";
|
|
|
|
}
|
|
|
|
$out .= "Connection: Close\r\n\r\n";
|
|
|
|
fwrite($fp, $out);
|
|
|
|
|
|
|
|
$info = stream_get_meta_data($fp);
|
|
|
|
|
|
|
|
$this->headers = '';
|
|
|
|
while (!$info['eof'] && !$info['timed_out'])
|
|
|
|
{
|
|
|
|
$this->headers .= fread($fp, 1160);
|
|
|
|
$info = stream_get_meta_data($fp);
|
|
|
|
}
|
|
|
|
if (!$info['timed_out'])
|
|
|
|
{
|
|
|
|
$parser = new SimplePie_HTTP_Parser($this->headers);
|
|
|
|
if ($parser->parse())
|
|
|
|
{
|
|
|
|
$this->headers = $parser->headers;
|
|
|
|
$this->body = $parser->body;
|
|
|
|
$this->status_code = $parser->status_code;
|
|
|
|
if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
|
|
|
|
{
|
|
|
|
$this->redirects++;
|
|
|
|
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$previousStatusCode = $this->status_code;
|
2020-10-16 13:20:07 -04:00
|
|
|
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
|
|
|
|
return;
|
2012-08-28 13:24:33 -04:00
|
|
|
}
|
|
|
|
if (isset($this->headers['content-encoding']))
|
|
|
|
{
|
|
|
|
// Hey, we act dumb elsewhere, so let's do that here too
|
|
|
|
switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20")))
|
|
|
|
{
|
|
|
|
case 'gzip':
|
|
|
|
case 'x-gzip':
|
|
|
|
$decoder = new SimplePie_gzdecode($this->body);
|
|
|
|
if (!$decoder->parse())
|
|
|
|
{
|
|
|
|
$this->error = 'Unable to decode HTTP "gzip" stream';
|
|
|
|
$this->success = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
$this->body = trim($decoder->data);
|
2012-08-28 13:24:33 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'deflate':
|
|
|
|
if (($decompressed = gzinflate($this->body)) !== false)
|
|
|
|
{
|
|
|
|
$this->body = $decompressed;
|
|
|
|
}
|
|
|
|
else if (($decompressed = gzuncompress($this->body)) !== false)
|
|
|
|
{
|
|
|
|
$this->body = $decompressed;
|
|
|
|
}
|
|
|
|
else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false)
|
|
|
|
{
|
|
|
|
$this->body = $decompressed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->error = 'Unable to decode HTTP "deflate" stream';
|
|
|
|
$this->success = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$this->error = 'Unknown content coding';
|
|
|
|
$this->success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->error = 'fsocket timed out';
|
|
|
|
$this->success = false;
|
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
|
External Libraries: Update the SimplePie library to the latest version (1.5.5).
This brings SimplePie in sync with the most up to date version, 1.5.5.
This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.
For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.
Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.
Built from https://develop.svn.wordpress.org/trunk@47733
git-svn-id: http://core.svn.wordpress.org/trunk@47509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-01 10:26:07 -04:00
|
|
|
if (empty($url) || !($this->body = trim(file_get_contents($url))))
|
2012-08-28 13:24:33 -04:00
|
|
|
{
|
|
|
|
$this->error = 'file_get_contents could not read the file';
|
|
|
|
$this->success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|