Gere en cas de flux rss invalide sur la page d'accueil
This commit is contained in:
parent
8f67797f3b
commit
efc0e5881b
|
@ -46,36 +46,37 @@ if (!empty($error) ) { echo "<p class='alert alert-danger'>$error</p>";$error=''
|
||||||
|
|
||||||
$feed_url = variable_get('rss_feed');
|
$feed_url = variable_get('rss_feed');
|
||||||
if (!empty($feed_url)) {
|
if (!empty($feed_url)) {
|
||||||
$cache_time = 60*5; // 5 minutes
|
$cache_time = 60*5; // 5 minutes
|
||||||
$cache_file = "/tmp/alterncpanel_cache_main.rss";
|
$cache_file = "/tmp/alterncpanel_cache_main.rss";
|
||||||
$timedif = @(time() - filemtime($cache_file));
|
$timedif = @(time() - filemtime($cache_file));
|
||||||
|
|
||||||
if (file_exists($cache_file) && $timedif < $cache_time) {
|
if (file_exists($cache_file) && $timedif < $cache_time) {
|
||||||
$string = file_get_contents($cache_file);
|
$string = file_get_contents($cache_file);
|
||||||
} else {
|
} else {
|
||||||
$string = file_get_contents("$feed_url");
|
$string = file_get_contents("$feed_url");
|
||||||
file_put_contents($cache_file,$string);
|
file_put_contents($cache_file,$string);
|
||||||
}
|
}
|
||||||
$xml = @simplexml_load_string($string);
|
$xml = @simplexml_load_string($string);
|
||||||
|
|
||||||
echo '<div align="center"><table class="tedit" cellspacing="0" cellpadding="6">';
|
if ( ! $xml === FALSE ) {
|
||||||
echo "<tr><th colspan='2'><a target='_blank' style='font-size: 18px;font-weight: bold;color: #10507C;' href='".$xml->channel->link."'>".$xml->channel->title."</a><br/><i>".$xml->channel->description."</i></th></tr>";
|
echo '<div align="center"><table class="tedit" cellspacing="0" cellpadding="6">';
|
||||||
//echo '<tr><th>'._("Title").'</th><th>'._("Date").'</th></tr>';
|
echo "<tr><th colspan='2'><a target='_blank' style='font-size: 18px;font-weight: bold;color: #10507C;' href='".$xml->channel->link."'>".$xml->channel->title."</a><br/><i>".$xml->channel->description."</i></th></tr>";
|
||||||
$count = 0;
|
//echo '<tr><th>'._("Title").'</th><th>'._("Date").'</th></tr>';
|
||||||
$max = 5;
|
$count = 0;
|
||||||
foreach ($xml->channel->item as $val) {
|
$max = 5;
|
||||||
if ($count < $max) {
|
foreach ($xml->channel->item as $val) {
|
||||||
echo '
|
if ($count < $max) {
|
||||||
<tr>
|
echo "<tr>\n<td ".(empty($val->pubDate)?'colpan=2':'').'><a target="_blank" href="'.$val->link.'">'.$val->title.'</a></td>';
|
||||||
<td '.(empty($val->pubDate)?'colpan=2':'').'><a target="_blank" href="'.$val->link.'">'.$val->title.'</a></td>';
|
if (!empty($val->pubDate)) {
|
||||||
if (!empty($val->pubDate)) { echo '<td>'.strftime("%d/%m/%Y" , strtotime($val->pubDate)).'</td>'; }
|
echo '<td>'.strftime("%d/%m/%Y" , strtotime($val->pubDate)).'</td>';
|
||||||
|
}
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
$count++;
|
$count++;
|
||||||
}
|
} //foreach
|
||||||
echo "</table></div>\n";
|
echo "</table></div>\n";
|
||||||
echo "<br/>";
|
echo "<br/>";
|
||||||
|
} // $xml === FALSE
|
||||||
} // empty feed_url
|
} // empty feed_url
|
||||||
|
|
||||||
if($admin->enabled) {
|
if($admin->enabled) {
|
||||||
|
|
Loading…
Reference in New Issue