Gere en cas de flux rss invalide sur la page d'accueil

This commit is contained in:
Alan Garcia 2014-01-21 08:35:15 +00:00
parent 8f67797f3b
commit efc0e5881b
1 changed files with 29 additions and 28 deletions

View File

@ -58,6 +58,7 @@ if (file_exists($cache_file) && $timedif < $cache_time) {
} }
$xml = @simplexml_load_string($string); $xml = @simplexml_load_string($string);
if ( ! $xml === FALSE ) {
echo '<div align="center"><table class="tedit" cellspacing="0" cellpadding="6">'; echo '<div align="center"><table class="tedit" cellspacing="0" cellpadding="6">';
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 "<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 '<tr><th>'._("Title").'</th><th>'._("Date").'</th></tr>'; //echo '<tr><th>'._("Title").'</th><th>'._("Date").'</th></tr>';
@ -65,17 +66,17 @@ $count = 0;
$max = 5; $max = 5;
foreach ($xml->channel->item as $val) { foreach ($xml->channel->item as $val) {
if ($count < $max) { if ($count < $max) {
echo ' echo "<tr>\n<td ".(empty($val->pubDate)?'colpan=2':'').'><a target="_blank" href="'.$val->link.'">'.$val->title.'</a></td>';
<tr> if (!empty($val->pubDate)) {
<td '.(empty($val->pubDate)?'colpan=2':'').'><a target="_blank" href="'.$val->link.'">'.$val->title.'</a></td>'; echo '<td>'.strftime("%d/%m/%Y" , strtotime($val->pubDate)).'</td>';
if (!empty($val->pubDate)) { 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) {