Commit 667b4bcb authored by Alan Garcia's avatar Alan Garcia
Browse files

Refonte RSS

parent d0f8fd35
......@@ -45,30 +45,40 @@ if ($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) {
$string = file_get_contents($cache_file);
} else {
$string = file_get_contents("$feed_url");
file_put_contents($cache_file,$string);
}
$xml = @simplexml_load_string($string);
// place the code below somewhere in your html
echo '<table cellspacing="0" cellpadding="6" border="1" style="border-collapse: collapse">';
echo '<tr><th>'._("Title").'</th><th>'._("Date").'</th></tr>';
$count = 0;
$max = 5;
foreach ($xml->channel->item as $val) {
if ($count < $max) {
echo '
<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>";
/*
use MagpieRSS to syndicate content from another site if available
this should work, since the debian package installs it in
/usr/share/php, which is in the include path
*/
$rss_url = variable_get('rss_feed');
$inc = @include_once('magpierss/rss_fetch.inc');
if ($inc && $rss_url) {
$rss = fetch_rss($rss_url);
if ($rss) {
echo "<h2>" . _("Latest news") . "</h2>";
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];
echo "<h3><a href=$href>$title</a></h3>";
echo '<span class="date">'.$item['pubdate'] .'</span> - ';
echo '<span class="author">'.$item['dc']['creator'].'</span>';
echo $item['summary'];
}
}
}
} // empty feed_url
if($admin->enabled) {
$expiring = $admin->renew_get_expiring_accounts();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment