<?php
require_once dirname(__FILE__).'/lib.php';
$all=json_read(STORAGE_DIR.'/history.json',array());$live=fetch_matches(false);foreach($live as $id=>$m)$all[$id]=$m;
header('Content-Type: application/xml; charset=UTF-8');echo '<?xml version="1.0" encoding="UTF-8"?>';echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
echo '<url><loc>'.xml(SITE_URL.'/').'</loc><changefreq>hourly</changefreq><priority>1.0</priority></url>';
foreach($all as $m){if(!is_array($m)||empty($m['_id']))continue;echo '<url><loc>'.xml(match_url($m)).'</loc><lastmod>'.xml(date('c',isset($m['_saved_at'])?(int)$m['_saved_at']:time())).'</lastmod><changefreq>hourly</changefreq><priority>0.8</priority></url>';}
echo '</urlset>';function xml($s){return htmlspecialchars($s,ENT_XML1|ENT_QUOTES,'UTF-8');}
