Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Try cURL before fopen() when retrieving the RSS feed

  • Loading branch information...
commit c56526ffdb9c9ace67629da20eac2b5294b0f63f 1 parent 881cedf
@haraldpdl haraldpdl authored
Showing with 16 additions and 2 deletions.
  1. +16 −2 catalog/admin/includes/classes/rss.php
View
18 catalog/admin/includes/classes/rss.php
@@ -130,14 +130,28 @@ function unhtmlentities ($string) {
// Don't use Parse() in your scripts - use Get($rss_file) instead.
// -------------------------------------------------------------------
function Parse ($rss_url) {
+ $rss_content = '';
+
// Open and load RSS file
- if ($f = @fopen($rss_url, 'r')) {
- $rss_content = '';
+ if (function_exists('curl_init')) {
+ $curl = curl_init($rss_url);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
+
+ $rss_content = curl_exec($curl);
+
+ curl_close($curl);
+ } else {
+ if ($f = @fopen($rss_url, 'r')) {
while (!feof($f)) {
$rss_content .= fgets($f, 4096);
}
fclose($f);
+ }
+ }
+ if (!empty($rss_content)) {
// Parse document encoding
$result['encoding'] = $this->my_preg_match("'encoding=[\'\"](.*?)[\'\"]'si", $rss_content);
// if document codepage is specified, use it
Please sign in to comment.
Something went wrong with that request. Please try again.