From 013a7c944ad0eaf4621c8058aa03a03bafc82c34 Mon Sep 17 00:00:00 2001 From: Prasad <prasad@vtiger.com> Date: Wed, 26 Oct 2022 17:27:08 +0530 Subject: [PATCH] Fixed magpierss for php 8.x --- libraries/magpierss/rss_fetch.inc | 22 +++++++++++----------- libraries/magpierss/rss_parse.inc | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libraries/magpierss/rss_fetch.inc b/libraries/magpierss/rss_fetch.inc index 3888529fb..1cb759e7e 100755 --- a/libraries/magpierss/rss_fetch.inc +++ b/libraries/magpierss/rss_fetch.inc @@ -82,6 +82,7 @@ require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc'); \*=======================================================================*/ define('MAGPIE_VERSION', '0.72'); +define('MAGPIE_CACHE_ON', false); /* Fix: XML_Parser cannot be serialized */ $MAGPIE_ERROR = ""; @@ -265,17 +266,16 @@ function magpie_error ($errormsg="") { Output: an HTTP response object (see Snoopy.class.inc) \*=======================================================================*/ function _fetch_remote_file ($url, $headers = "" ) { - // Snoopy is an HTTP client in PHP - $client = new Snoopy(); - $client->agent = MAGPIE_USER_AGENT; - $client->read_timeout = MAGPIE_FETCH_TIME_OUT; - $client->use_gzip = MAGPIE_USE_GZIP; - if (is_array($headers) ) { - $client->rawheaders = $headers; - } - - $client->fetch($url); - return $client; + + require_once 'vtlib/Vtiger/Net/Client.php'; + + $client = new Vtiger_Net_Client($url); + if (is_array($headers)) $client->setHeaders($headers); + $content = $client->doGet(null, MAGPIE_FETCH_TIME_OUT); + $res = new stdClass; + $res->status = $client->client->getResponseCode(); + $res->results = $content; + return $res; } diff --git a/libraries/magpierss/rss_parse.inc b/libraries/magpierss/rss_parse.inc index 5d4c344b2..6ea0c35a9 100755 --- a/libraries/magpierss/rss_parse.inc +++ b/libraries/magpierss/rss_parse.inc @@ -91,7 +91,7 @@ class MagpieRSS { * source encoding. (caveat emptor) * */ - function MagpieRSS ($source, $output_encoding='UTF-8', + function __construct ($source, $output_encoding='UTF-8', $input_encoding=null, $detect_encoding=true) { # if PHP xml isn't compiled in, die @@ -106,7 +106,7 @@ class MagpieRSS { $output_encoding, $input_encoding, $detect_encoding); - if (!is_resource($parser)) { + if (!is_object($parser)) { $this->error( "Failed to create an instance of PHP's XML parser. " . "http://www.php.net/manual/en/ref.xml.php", E_USER_ERROR ); @@ -449,7 +449,7 @@ class MagpieRSS { * */ function create_parser($source, $out_enc, $in_enc, $detect) { - if ( substr(phpversion(),0,1) == 5) { + if ( substr(phpversion(),0,1) >= 5) { $parser = $this->php5_create_parser($in_enc, $detect); } else { -- GitLab