Permalink
Browse files

Fix issue with RSS feed on dashboard causing white screen.

  • Loading branch information...
havok89 committed Mar 8, 2017
1 parent ab91c1f commit 7eb6dd402020e3d225704b73820fc46fd3ccfe00
@@ -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);
@@ -44,6 +44,7 @@
//Dashboard
$lang['dash_welcome'] = "Welcome <small>to Hoosk</small>";
$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";
@@ -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);
@@ -5,7 +5,7 @@
<div class="footer-inner">
<div class="container-fluid">
<div class="row">
<div class="col-md-12"> &copy; 2016 <a href="http://hoosk.org/">Hoosk CMS</a>. </div>
<div class="col-md-12"> &copy; <?php echo date("Y"); ?> <a href="http://hoosk.org/">Hoosk CMS</a>. </div>
<!-- /span12 -->
</div>
<!-- /row -->
@@ -22,27 +22,32 @@
<p><?php echo $this->lang->line('dash_message'); ?></p>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-newspaper-o fa-fw"></i>
<?php echo $this->lang->line('feed_heading'); ?>
</h3>
</div>
<div class="panel-body">
<ul class="list-group">
<?php
foreach ($hooskFeed as $item)
{
$date = date_create($item['pubDate']);
echo '<li class="list-group-item"><span class="badge">'.date_format($date,"jS M y").'</span>';
echo '<p><a href="'.$item['link'].'" class="news-item-title" target="_blank">'.$item['title'].'</a></p>';
echo '<p>'.wordlimit($item['description']).'</p>';
echo '</li>';
} ?>
</ul>
<?php if(RSS_FEED) { ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-newspaper-o fa-fw"></i>
<?php echo $this->lang->line('feed_heading'); ?>
</h3>
</div>
<div class="panel-body">
<ul class="list-group">
<?php
if($hooskFeed) {
foreach ($hooskFeed as $item) {
$date = date_create($item['pubDate']);
echo '<li class="list-group-item"><span class="badge">' . date_format($date, "jS M y") . '</span>';
echo '<p><a href="' . $item['link'] . '" class="news-item-title" target="_blank">' . $item['title'] . '</a></p>';
echo '<p>' . wordlimit($item['description']) . '</p>';
echo '</li>';
}
} else {
echo '<p>'.$this->lang->line('dash_unreachable').'</p>';
}?>
</ul>
</div>
</div>
</div>
<?php } ?>
</div>
<!-- /colmd6 -->
<div class="col-md-6">
View
@@ -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);
/*
*---------------------------------------------------------------

0 comments on commit 7eb6dd4

Please sign in to comment.