Skip to content

Commit

Permalink
Fix issue with RSS feed on dashboard causing white screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
havok89 committed Mar 8, 2017
1 parent ab91c1f commit 7eb6dd4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 40 deletions.
10 changes: 6 additions & 4 deletions hoosk/hoosk0/controllers/admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions hoosk/hoosk0/language/english/admin_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
12 changes: 10 additions & 2 deletions hoosk/hoosk0/libraries/Rssparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion hoosk/hoosk0/views/admin/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
45 changes: 25 additions & 20 deletions hoosk/hoosk0/views/admin/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
16 changes: 3 additions & 13 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
*---------------------------------------------------------------
Expand Down

0 comments on commit 7eb6dd4

Please sign in to comment.