2 if (!defined('AT_INCLUDE_PATH')) { exit; }
\r
4 if (!isset($this) || (isset($this) && (strtolower(get_class($this)) != 'module'))) { exit(__FILE__ . ' is not a Module'); }
\r
6 define('AT_ADMIN_PRIV_RSS', $this->getAdminPrivilege());
\r
8 define('AT_FEED_TIMEOUT', 21600); //feed is cached for this long. 21600 = 6 hours
\r
9 define('AT_FEED_NUM_RESULTS', 5);
\r
10 define('AT_FEED_SHOW_DESCRIPTION', FALSE);
\r
13 if (admin_authenticate(AT_ADMIN_PRIV_RSS, TRUE) || admin_authenticate(AT_ADMIN_PRIV_ADMIN, TRUE)) {
\r
15 if (admin_authenticate(AT_ADMIN_PRIV_ADMIN, TRUE)) {
\r
16 $this->_pages['admin/config_edit.php']['children'] = array('mods/_standard/rss_feeds/index.php');
\r
17 $this->_pages['mods/_standard/rss_feeds/index.php']['parent'] = 'admin/config_edit.php';
\r
19 $this->_pages[AT_NAV_ADMIN] = array('mods/_standard/rss_feeds/index.php');
\r
20 $this->_pages['mods/_standard/rss_feeds/index.php']['parent'] = AT_NAV_ADMIN;
\r
23 $this->_pages['mods/_standard/rss_feeds/index.php']['title_var'] = 'rss_feeds';
\r
24 $this->_pages['mods/_standard/rss_feeds/index.php']['children'] = array('mods/_standard/rss_feeds/add_feed.php');
\r
25 $this->_pages['mods/_standard/rss_feeds/index.php']['guide'] = 'admin/?p=feeds.php';
\r
27 $this->_pages['mods/_standard/rss_feeds/add_feed.php']['title_var'] = 'add';
\r
28 $this->_pages['mods/_standard/rss_feeds/add_feed.php']['parent'] = 'mods/_standard/rss_feeds/index.php';
\r
30 $this->_pages['mods/_standard/rss_feeds/edit_feed.php']['title_var'] = 'edit';
\r
31 $this->_pages['mods/_standard/rss_feeds/edit_feed.php']['parent'] = 'mods/_standard/rss_feeds/index.php';
\r
33 $this->_pages['mods/_standard/rss_feeds/delete_feed.php']['title_var'] = 'delete';
\r
34 $this->_pages['mods/_standard/rss_feeds/delete_feed.php']['parent'] = 'mods/_standard/rss_feeds/index.php';
\r
36 $this->_pages['mods/_standard/rss_feeds/preview.php']['title_var'] = 'preview';
\r
37 $this->_pages['mods/_standard/rss_feeds/preview.php']['parent'] = 'mods/_standard/rss_feeds/index.php';
\r
40 //make the rss files side menu stacks
\r
41 $rss_files = array();
\r
42 $dh = opendir(AT_CONTENT_DIR.'/feeds');
\r
44 while (false !== ($file = readdir($dh))) {
\r
45 if (strpos($file, '_rss.inc.php')) {
\r
46 $feed_id = intval($file);
\r
47 if (file_exists(AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss_title.cache')) {
\r
48 $title = @file_get_contents(AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss_title.cache');
\r
49 $this->_stacks[$feed_id.'_rss_title'] = array('title'=>$title, 'file'=>AT_CONTENT_DIR.'feeds/'.$file);
\r
54 //creates or updates the cache file
\r
55 function make_cache_file($feed_id) {
\r
59 if (!isset($rss)) {
\r
60 require_once(AT_INCLUDE_PATH.'../mods/_standard/rss_feeds/classes/lastRSS.php');
\r
61 $rss = new lastRSS;
\r
62 $rss->cache_dir = AT_CONTENT_DIR.'feeds/';
\r
63 $rss->num_results = AT_FEED_NUM_RESULTS;
\r
64 $rss->description = AT_FEED_SHOW_DESCRIPTION;
\r
67 $sql = "SELECT url, feed_id FROM ".TABLE_PREFIX."feeds WHERE feed_id=".intval($feed_id);
\r
68 $result = mysql_query($sql, $db);
\r
70 if ($row = mysql_fetch_assoc($result)) {
\r
71 $output = $rss->get($row['url'], $row['feed_id']);
\r
73 $cache_file = AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss.cache';
\r
74 if ($f = @fopen($cache_file, 'w')) {
\r
75 fwrite ($f, $output, strlen($output));
\r
80 $output = $rss->get($_POST['url'], 0);
\r
85 function print_rss_feed($file) {
\r
88 $feed_id = intval(basename($file));
\r
89 $cache_file = AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss.cache';
\r
90 $title_file = AT_CONTENT_DIR.'feeds/'.$feed_id.'_rss_title.cache';
\r
94 //if file doesn't exist or is more than AT_FEED_TIMEOUT old
\r
95 if (!file_exists($cache_file) || ((time() - filemtime($cache_file)) > AT_FEED_TIMEOUT) ) {
\r
96 make_cache_file($feed_id);
\r
98 if (file_exists($cache_file)) {
\r
99 readfile($cache_file);
\r
100 echo '<br /><small>'._AT('new_window').'</small>';
\r
102 echo _AT('no_content_avail');
\r
105 $savant->assign('dropdown_contents', ob_get_contents());
\r
108 $savant->assign('title', @file_get_contents($title_file));
\r
109 $savant->display('include/box.tmpl.php');
\r