<?php
declare(strict_types=1);

header('Content-Type: application/xml; charset=UTF-8');

require_once __DIR__ . '/admin/inc/baglan.php';

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>

<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<url>
<loc>https://turkkanymm.com/</loc>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>

<?php

$tables=[

'sayfalar',
'hizmetler',
'haberler'

];

foreach($tables as $table){

$stmt=$db->query("

SELECT seo,guncelleme_tarihi

FROM {$table}

WHERE seo<>''

ORDER BY id DESC

");

while($row=$stmt->fetch(PDO::FETCH_ASSOC)){

$seo=trim($row['seo']);

if($seo==''){

continue;

}

$last=$row['guncelleme_tarihi'] ?? date('Y-m-d');

?>

<url>

<loc>

https://turkkanymm.com/<?=htmlspecialchars($seo)?>

</loc>

<lastmod><?=$last?></lastmod>

<changefreq>monthly</changefreq>

<priority>0.80</priority>

</url>

<?php

}

}

?>

</urlset>