Refonte RSS

This commit is contained in:
Alan Garcia 2012-08-23 18:54:26 +00:00
parent d0f8fd35b3
commit 667b4bcb67
1 changed files with 31 additions and 21 deletions

View File

@ -45,30 +45,40 @@ if ($mem->user["lastfail"]) {
printf(_("%1\$d login failed since last login")."<br />",$mem->user["lastfail"]); printf(_("%1\$d login failed since last login")."<br />",$mem->user["lastfail"]);
} }
?>
<center>
<?php
$feed_url = variable_get('rss_feed');
if (!empty($feed_url)) {
$cache_time = 60*5; // 5 minutes
$cache_file = "/tmp/alterncpanel_cache_main.rss";
$timedif = @(time() - filemtime($cache_file));
/* if (file_exists($cache_file) && $timedif < $cache_time) {
use MagpieRSS to syndicate content from another site if available $string = file_get_contents($cache_file);
this should work, since the debian package installs it in } else {
/usr/share/php, which is in the include path $string = file_get_contents("$feed_url");
*/ file_put_contents($cache_file,$string);
$rss_url = variable_get('rss_feed'); }
$inc = @include_once('magpierss/rss_fetch.inc'); $xml = @simplexml_load_string($string);
if ($inc && $rss_url) {
$rss = fetch_rss($rss_url);
if ($rss) { // place the code below somewhere in your html
echo "<h2>" . _("Latest news") . "</h2>"; echo '<table cellspacing="0" cellpadding="6" border="1" style="border-collapse: collapse">';
foreach ($rss->items as $item) { echo '<tr><th>'._("Title").'</th><th>'._("Date").'</th></tr>';
$href = $item['link']; $count = 0;
$title = $item['title']; $max = 5;
echo "<h3><a href=$href>$title</a></h3>"; foreach ($xml->channel->item as $val) {
echo '<span class="date">'.$item['pubdate'] .'</span> - '; if ($count < $max) {
echo '<span class="author">'.$item['dc']['creator'].'</span>'; echo '
echo $item['summary']; <tr>
} <td><a href="'.$val->link.'">'.$val->title.'</a></td><td>'.strftime("%d/%m/%Y" , strtotime($val->pubDate)).'</td></td>
} </tr>';
} }
$count++;
}
echo "</table>\n</center>";
} // empty feed_url
if($admin->enabled) { if($admin->enabled) {
$expiring = $admin->renew_get_expiring_accounts(); $expiring = $admin->renew_get_expiring_accounts();