<?php
  $lastChange = filemtime("index.php");

  // etag
  $etag = substr(md5($lastChange), 5, 11);
  if (trim(@$_SERVER["HTTP_IF_NONE_MATCH"], " '\"") == $etag)
  {
    header("HTTP/1.1 304 Not Modified");
    exit;
  }

  header("Content-Type: application/xml");
  header("Last-Modified: ".gmdate("D, d M Y H:i:s T", $lastChange));

  // let's go !
  echo '<?xml version="1.0" encoding="UTF-8"?>';
?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

 <!-- web sites -->

 <url>
  <loc>https://skating.stephan-brumme.com/</loc>
  <lastmod><?= date("c", $lastChange); ?></lastmod>
 </url>

 <!-- race certificates -->

<?php
  $files = glob("urkunde-*");
  rsort($files);
  foreach ($files as $filename)
  {
    echo " <url>\n".
         "  <loc>https://skating.stephan-brumme.com/$filename</loc>\n".
         "  <lastmod>".date("c", filemtime($filename))."</lastmod>\n".
         "  <changefreq>yearly</changefreq>\n".
         " </url>\n";
  }
?>
</urlset>
