From 827f5b42a667a9ac2ab68701c23885ae6e617907 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Thu, 24 Apr 2014 11:48:00 +0300 Subject: fix of rss headers problem --- inc/3rdparty/libraries/feedwriter/FeedWriter.php | 23 ++++++++++++++++++----- inc/3rdparty/makefulltextfeed.php | 6 +++--- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'inc/3rdparty') diff --git a/inc/3rdparty/libraries/feedwriter/FeedWriter.php b/inc/3rdparty/libraries/feedwriter/FeedWriter.php index 79639c0c..d708e99b 100755 --- a/inc/3rdparty/libraries/feedwriter/FeedWriter.php +++ b/inc/3rdparty/libraries/feedwriter/FeedWriter.php @@ -87,12 +87,25 @@ define('JSONP', 3, true); * @access public * @return void */ - public function genarateFeed() + public function genarateFeed($withHeaders = true) { - header('Content-type: text/xml; charset=UTF-8'); - // this line prevents Chrome 20 from prompting download - // used by Google: https://news.google.com/news/feeds?ned=us&topic=b&output=rss - header('X-content-type-options: nosniff'); + if ($withHeaders) { + if ($this->version == RSS2) { + header('Content-type: text/xml; charset=UTF-8'); + // this line prevents Chrome 20 from prompting download + // used by Google: https://news.google.com/news/feeds?ned=us&topic=b&output=rss + header('X-content-type-options: nosniff'); + } elseif ($this->version == JSON) { + header('Content-type: application/json; charset=UTF-8'); + } elseif ($this->version == JSONP) { + header('Content-type: application/javascript; charset=UTF-8'); + } + } + + if ($this->version == JSON || $this->version == JSONP) { + $this->json = new stdClass(); + } + $this->printHead(); $this->printChannels(); diff --git a/inc/3rdparty/makefulltextfeed.php b/inc/3rdparty/makefulltextfeed.php index 135964f1..4faad6d9 100755 --- a/inc/3rdparty/makefulltextfeed.php +++ b/inc/3rdparty/makefulltextfeed.php @@ -749,7 +749,7 @@ foreach ($items as $key => $item) { // add effective URL (URL after redirects) if (isset($effective_url)) { //TODO: ensure $effective_url is valid witout - sometimes it causes problems, e.g. - //http://www.siasat.pk/forum/showthread.php?108883-Pakistan-Chowk-by-Rana-Mubashir-–-25th-March-2012-Special-Program-from-Liari-(Karachi) + //http://www.siasat.pk/forum/showthread.php?108883-Pakistan-Chowk-by-Rana-Mubashir-�-25th-March-2012-Special-Program-from-Liari-(Karachi) //temporary measure: use utf8_encode() $newitem->addElement('dc:identifier', remove_url_cruft(utf8_encode($effective_url))); } else { @@ -831,7 +831,7 @@ if (!$debug_mode) { } if ($add_to_cache) { ob_start(); - $output->genarateFeed(); + $output->genarateFeed(false); $output = ob_get_contents(); ob_end_clean(); if ($html_only && $item_count == 0) { @@ -842,7 +842,7 @@ if (!$debug_mode) { } echo $output; } else { - $output->genarateFeed(); + $output->genarateFeed(false); } if ($callback) echo ');'; } -- cgit v1.2.3