/var/www-protected/php-debug.com/www/news.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
 * This the index page of PHP_Debug
 *
 * @version V2.0
 * @since 27 aug 2006
 * @author Vernet Loic
 * @copyright Phoenix
 * @package PHP_Debug_Website
 */
 
// Applications variables & gen includes  ======================================
require_once '../config/ApplicationCfg.php';
require_once PD_WEB_INCLUDES_ROOT. 'common.inc.php';
 
// Page constants ==============================================================
define('PAGE_ID' ,    'news'. PD_WEB_FILE_EXT);
define('PAGE_TR_ID' , 'news');
define('_FILE_', basename(__FILE__));
define('DEFAULT_ACTION', 'GETNEWS');
 
 
// Process =====================================================================
$Dbg->setAction(DEFAULT_ACTION);
 
 
// Pear XML for reading RSS ressources
require_once('XML/RSS.php');
 
// Include the package to cache highlight results
require_once('Cache/Lite.php');
 
// Set a few options
$options = array(
    'cacheDir' => PD_WEB_TEMP,
    'lifeTime' => 36000
);
 
// Create a Cache_Lite object
$Cache_Lite = new Cache_Lite($options);
 
// get the date 
$today = getdate(); 
$cachedFileName     = $today['year'] .$today['mon'] .$today['mday'] .".txt";
$cachedFileNameFull = PD_WEB_TEMP. $cachedFileName;
 
// Source forge RSS Urls
$rssNewsUrl = 'http://sourceforge.net/export/rss2_projnews.php?group_id=95715&rss_fulltext=1';
 
 
// Cache the news
if ($data = $Cache_Lite->get('news')) {
    $Dbg->add('Getting $news from cache');
    $news = unserialize($data);
} else {
 
    $rssNews =& new XML_RSS($rssNewsUrl);
    $rssNews->parse();    
    foreach ($rssNews->getItems() as $lkey => $lvalue) {
        $news[] =  $lvalue;
    }
 
    $Dbg->add('Saving $news to the cache');
    $Cache_Lite->save(serialize($news));
}
 
 
// Display =====================================================================
 
$smarty->assign('news', $news);
 
// Assign debug infos
$smarty->assign('file', PD_WEB_PHP_DEBUG_ROOT. DIRECTORY_SEPARATOR. PAGE_ID);
$smarty->assign('bodyTpl', PAGE_TR_ID);
$smarty->assign('debugBuffer', $Dbg->getOutput());       
 
// Display template
$smarty->display('index.tpl');
 
?>