From 7eb6dd402020e3d225704b73820fc46fd3ccfe00 Mon Sep 17 00:00:00 2001 From: havok89 Date: Wed, 8 Mar 2017 23:02:16 +0000 Subject: [PATCH] Fix issue with RSS feed on dashboard causing white screen. --- hoosk/hoosk0/controllers/admin/Admin.php | 10 +++-- hoosk/hoosk0/language/english/admin_lang.php | 1 + hoosk/hoosk0/libraries/Rssparser.php | 12 +++++- hoosk/hoosk0/views/admin/footer.php | 2 +- hoosk/hoosk0/views/admin/home.php | 45 +++++++++++--------- index.php | 16 ++----- 6 files changed, 46 insertions(+), 40 deletions(-) diff --git a/hoosk/hoosk0/controllers/admin/Admin.php b/hoosk/hoosk0/controllers/admin/Admin.php index c66c6ae..eb766c8 100644 --- a/hoosk/hoosk0/controllers/admin/Admin.php +++ b/hoosk/hoosk0/controllers/admin/Admin.php @@ -21,10 +21,12 @@ public function index() Admincontrol_helper::is_logged_in($this->session->userdata('userName')); $this->data['current'] = $this->uri->segment(2); $this->data['recenltyUpdated'] = $this->Hoosk_model->getUpdatedPages(); - $this->load->library('rssparser'); - $this->rssparser->set_feed_url('http://hoosk.org/feed/rss'); - $this->rssparser->set_cache_life(30); - $this->data['hooskFeed'] = $this->rssparser->getFeed(3); + if(RSS_FEED) { + $this->load->library('rssparser'); + $this->rssparser->set_feed_url('http://hoosk.org/feed/rss'); + $this->rssparser->set_cache_life(30); + $this->data['hooskFeed'] = $this->rssparser->getFeed(3); + } $this->data['header'] = $this->load->view('admin/header', $this->data, true); $this->data['footer'] = $this->load->view('admin/footer', '', true); $this->load->view('admin/home', $this->data); diff --git a/hoosk/hoosk0/language/english/admin_lang.php b/hoosk/hoosk0/language/english/admin_lang.php index a8cd1e3..dc6acfb 100644 --- a/hoosk/hoosk0/language/english/admin_lang.php +++ b/hoosk/hoosk0/language/english/admin_lang.php @@ -44,6 +44,7 @@ //Dashboard $lang['dash_welcome'] = "Welcome to Hoosk"; +$lang['dash_unreachable'] = "The news feed cannot be reached."; $lang['dash_recent'] = "Recently Updated Pages"; $lang['dash_message'] = "This is your Hoosk dashboard, Using the navigation bar you can add or edit the users, pages or navigation menus on your website. Hoosk is built around the bootstrap framework, this should make your website fully responsive with ease."; $lang['feed_heading'] = "Hoosk News"; diff --git a/hoosk/hoosk0/libraries/Rssparser.php b/hoosk/hoosk0/libraries/Rssparser.php index 92482a0..c62fde0 100644 --- a/hoosk/hoosk0/libraries/Rssparser.php +++ b/hoosk/hoosk0/libraries/Rssparser.php @@ -45,6 +45,10 @@ function __construct($callback = FALSE) } // -------------------------------------------------------------------- + function get_http_response_code($url) { + $headers = get_headers($url); + return substr($headers[0], 9, 3); + } function parse() { @@ -83,8 +87,12 @@ function parse() // Parse the document if (!isset($rawFeed)) { - $rawFeed = file_get_contents($this->feed_uri); - } + if($this->get_http_response_code($this->feed_uri) != "200"){ + return false; + }else{ + $rawFeed = file_get_contents($this->feed_uri); + } + } $xml = new SimpleXmlElement($rawFeed, 0, false); diff --git a/hoosk/hoosk0/views/admin/footer.php b/hoosk/hoosk0/views/admin/footer.php index d8d387a..6f8302d 100644 --- a/hoosk/hoosk0/views/admin/footer.php +++ b/hoosk/hoosk0/views/admin/footer.php @@ -5,7 +5,7 @@ -
-
-

- - lang->line('feed_heading'); ?> -

-
-
-
    - '.date_format($date,"jS M y").''; - echo '

    '.$item['title'].'

    '; - echo '

    '.wordlimit($item['description']).'

    '; - echo ''; - } ?> -
+ +
+
+

+ + lang->line('feed_heading'); ?> +

+
+
+
    + ' . date_format($date, "jS M y") . ''; + echo '

    ' . $item['title'] . '

    '; + echo '

    ' . wordlimit($item['description']) . '

    '; + echo ''; + } + } else { + echo '

    '.$this->lang->line('dash_unreachable').'

    '; + }?> +
+
-
+
diff --git a/index.php b/index.php index 5b07387..bb4dd26 100644 --- a/index.php +++ b/index.php @@ -61,23 +61,13 @@ * * NOTE: If you change these, also change the error_reporting() code below */ - define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production'); - - - - - - - - - +define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production'); //Used for encryption - be creative, if this is changed once set up then passwords will need reset define ('SALT', 'Once Up0n @ h00sK!'); - - - +//RSS off flag +define ('RSS_FEED', true); /* *---------------------------------------------------------------