From 5765a2450839593e51104e256341c326b9615d90 Mon Sep 17 00:00:00 2001 From: azett Date: Thu, 16 Apr 2020 14:09:30 +0200 Subject: [PATCH] Added a sitemap for search engines. See https://forum.flatpress.org/viewtopic.php?f=4&t=126 for more details. --- sitemap.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sitemap.php diff --git a/sitemap.php b/sitemap.php new file mode 100644 index 0000000..9ef17e8 --- /dev/null +++ b/sitemap.php @@ -0,0 +1,80 @@ + + + +' . BLOG_BASEURL . ' +' . date("c") . ' +daily +1.0 +'; +// XML head done + +// we start with the blog entries +$q = new FPDB_Query(array( + 'start' => 0, + 'count' => -1, + 'fullparse' => true +), null); +while ($q->hasMore()) { + list ($id, $e) = $q->getEntry(); + if (isset($e ['lastupdate'])) { + $lastmod = $e ['lastupdate'] - (60 * 60 * $offset); + } else { + $lastmod = $e ['date'] - (60 * 60 * $offset); + } + $loc = get_permalink($id); + + echo ' +' . $loc . ' +' . date("c", $lastmod) . ' + +'; +} +// done with the entries + +// now the static pages +$statics = static_getlist(); +foreach ($statics as $currentstatic) { + $currentStaticData = static_parse($currentstatic); + $loc = BLOG_BASEURL . '?page=' . $currentstatic; + + // If current static has no date, use timestamp of now + if (array_key_exists('date', $currentStaticData)) { + $d = $currentStaticData ['date'] - (60 * 60 * $offset); + } else { + $d = time(); + } + + $d = date('c', $d); + echo ' +' . $loc . ' +' . $d . ' +'; +} +// done with the static pages + +echo ''; \ No newline at end of file