<?php 
/*#################################################################*\
|# Licence Number 0NKV-1011-132L-0118
|# -------------------------------------------------------------   #|
|# Copyright (c)2018 PHP Link Directory.                           #|
|# http://www.phplinkdirectory.com                                 #|
\*#################################################################*/
	 
 
 
 
 
 
 
	/**# ################################################################################# Project:   PHP Link Directory## **********************************************************************# Copyright (C) 2004-2012 NetCreated, Inc. (http://www.netcreated.com/)## This software is for use only to those who have purchased a license.# A license must be purchased for EACH installation of the software.## By using the software you agree to the terms:##    - You may not redistribute, sell or otherwise share this software#      in whole or in part without the consent of the the ownership#      of PHP Link Directory. Please contact david@david-duval.com#      if you need more information.##    - You agree to retain a link back to http://www.phplinkdirectory.com/#      on all pages of your directory if you purchased any of our "link back"#      versions of the software.### In some cases, license holders may be required to agree to changes# in the software license before receiving updates to the software.# **********************************************************************## For questions, help, comments, discussion, etc., please join the# PHP Link Directory Forum http://www.phplinkdirectory.com/forum/## @link           http://www.phplinkdirectory.com/# @copyright      2004-2012 NetCreated, Inc. (http://www.netcreated.com/)# @projectManager David DuVal <david@david-duval.com># @package        PHPLinkDirectory# @version        5.0 Codename Transformer# ################################################################################ */class Widget_RssFeed extends Phpld_Widget {    function getContent() {        $settings = $this->getFrontSettings();        if (!empty($settings['FEED_URL'])) {            $this->tpl->assign('LISTINGS', $this->getLinks());        }				$this->tpl->assign("TITLE", $settings['TITLE']);		        return $this->tpl->fetch('content.tpl');    }    function getLinks() {        if ($this->isCacheExpired()) {            $this->refreshCache();        }        $settings = $this->getFrontSettings();        $settings['CACHED_DATA']['articles'] = array_slice($settings['CACHED_DATA']['articles'], 0, $settings['NO_OF_NEWS']);				        return $settings['CACHED_DATA'];    }    public function isCacheExpired()    {        $setings = $this->getFrontSettings();        if (!isset($setings['LAST_REFRESH'])) {            return true;        }        if ((time()-$setings['LAST_REFRESH']+$setings['REFRESH_RATE']*3600) > time() ) {            return true;        }        return false;    }    public function refreshCache()    {        $settings = $this->getFrontSettings();        $feedUrl = $settings['FEED_URL'];        $rawFeed = file_get_contents($feedUrl);        $xml = new SimpleXmlElement($rawFeed);        $feed = array();        $feed = array(            'title' => (string)$xml->channel->title,            'link'  => (string)$xml->channel->link,            'articles' => array()        );        foreach ($xml->channel->item as $item) {            $feed['articles'][] = array(                'title' => (string)$item->title,                'link'  => (string)$item->link,                'description'  => (string)$item->description,            );        }        $settings[] = array(            'IDENTIFIER'    => 'CACHED_DATA',            'SETTING_VALUE' => $feed        );        $settings[] = array(            'IDENTIFIER'    => 'LAST_REFRESH',            'SETTING_VALUE' => time()        );        /*$settings[] = array(            'IDENTIFIER'    => 'TITLE',            'SETTING_VALUE' => (string)$xml->channel->title        );*/        $this->saveSettings($settings);    }}