<?php
header('Content-Type: application/xml; charset=utf-8');
require_once 'includes/config.php';
$domain = rtrim(get_seo('canonical_domain'), '/');

echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'."\n";

$pages = [
  ['url' => '', 'priority' => '1.0', 'changefreq' => 'weekly'],
  ['url' => 'download.php', 'priority' => '0.95', 'changefreq' => 'monthly'],
  ['url' => 'features.php', 'priority' => '0.85', 'changefreq' => 'monthly'],
  ['url' => 'comparison.php', 'priority' => '0.85', 'changefreq' => 'monthly'],
  ['url' => 'news.php', 'priority' => '0.8', 'changefreq' => 'weekly'],
  ['url' => 'index-en.php', 'priority' => '0.7', 'changefreq' => 'weekly'],
  ['url' => 'download-en.php', 'priority' => '0.65', 'changefreq' => 'monthly'],
  ['url' => 'features-en.php', 'priority' => '0.6', 'changefreq' => 'monthly'],
  ['url' => 'comparison-en.php', 'priority' => '0.6', 'changefreq' => 'monthly'],
  ['url' => 'news-en.php', 'priority' => '0.55', 'changefreq' => 'weekly'],
];

foreach ($pages as $page) {
  $url = $domain ? ($domain . ($page['url'] === '' ? '/' : ('/' . $page['url']))) : ($page['url'] === '' ? '/' : $page['url']);
  echo '  <url>'."\n";
  echo '    <loc>'.htmlspecialchars($url).'</loc>'."\n";
  echo '    <lastmod>'.date('Y-m-d').'</lastmod>'."\n";
  echo '    <changefreq>'.$page['changefreq'].'</changefreq>'."\n";
  echo '    <priority>'.$page['priority'].'</priority>'."\n";
  echo '  </url>'."\n";
}

echo '</urlset>'."\n";
?>
