Give the feed of an empty site the current date.

The feed passed NULL to strtotime() when there were no stories.
This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent 8d6282348c
commit b68c2eb568
2 changed files with 15 additions and 2 deletions
+4 -2
View File
@@ -18,6 +18,8 @@ $query = "SELECT MAX(`date`) FROM $table;";
$result = $db->query($query) or db_fail();
$most_recent = $result->fetch_row();
$now = date("D, d M Y H:i:s O");
// The date of the newest story, or now if there is none
$last_date = $most_recent[0] ? date("D, d M Y H:i:s O", strtotime($most_recent[0])) : $now;
echo '<?xml version="1.0"?>'."\n";
echo '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
@@ -27,14 +29,14 @@ echo '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom=
echo '<description>Most recent articles from '.xml_text(site_host()).'</description>'."\n";
echo '<language>en-za</language>'."\n";
echo '<pubDate>'.$now.'</pubDate>'."\n";
echo '<lastBuildDate>'.date("D, d M Y H:i:s O", strtotime($most_recent[0])).'</lastBuildDate>'."\n";
echo '<lastBuildDate>'.$last_date.'</lastBuildDate>'."\n";
echo '<managingEditor>'.hidden_email(site_email('editor')).' (Editors)</managingEditor>'."\n";
echo '<webMaster>'.hidden_email(site_email('webmaster')).' (Webmasters)</webMaster>'."\n";
echo '<atom:link href="'.$site.'/feed" rel="self" type="application/rss+xml" />'."\n";
echo '<item>'."\n";
echo '<title>Front Page</title>'."\n";
echo '<link>'.$site.'/</link>'."\n";
echo '<pubDate>'.date("D, d M Y H:i:s O", strtotime($most_recent[0])).'</pubDate>'."\n";
echo '<pubDate>'.$last_date.'</pubDate>'."\n";
echo '<guid>'.$site.'/</guid>'."\n";
echo '</item>'."\n";