sitemap oluşturma dosyası aşağıdaki gibidir. sql den bilglileri çekerek xml dosyası oluşturmaktadır.
<?php
include ("ayar.php");
header("content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
function SeoLink($s){
$tr = array('ş','Ş','ı','İ','ğ','Ğ','ü','Ü','ö','Ö','Ç','ç');
$eng = array('s','s','i','i','g','g','u','u','o','o','c','c');
$s = str_replace($tr,$eng,$s);
$s = strtolower($s);
$s = preg_replace('/&.+?;/', '', $s);
$s = preg_replace('/[^%a-z0-9 _-]/', '', $s);
$s = preg_replace('/\s+/', '-', $s);
$s = preg_replace('|-+|', '-', $s);
$s = trim($s, '-');
return $s;
}
$file= mysql_query("select * from settings where id='1'");
while($al=mysql_fetch_array($file)){
$priority=$al['mappriority'];
$changefreq=$al['mapchangefreq'];
$adres=$al['mapadres'];
$muzikdurum=$al['muzikdurum'];
}
?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd">
<?php
if ($muzikdurum=="youtube")
{
$sonuc = mysql_query("Select * From videomp3 order by Id DESC");
while($benzer = mysql_fetch_array($sonuc)){
$videoad = $benzer['videoad'];
$videoid = $benzer['videoid'];
$seovideoad=SeoLink($videoad);
echo "<url>
<loc>$adres/$videoid/$seovideoad-dinle.htm</loc>
<priority>$priority</priority>
<changefreq>$changefreq</changefreq>
</url>";
}
}
else
{
$sonuc = mysql_query("Select * From music order by Id DESC");
while($satir = mysql_fetch_array($sonuc)){
$sanatci=$satir['sanatci'];
$sarkiad=$satir['sarkiad'];
$sanatciseo=SeoLink($sanatci);
$sarkiadseo=SeoLink($sarkiad);
echo "<url>
<loc>$adres/$sanatciseo/$sarkiadseo-sarkidinle</loc>
<priority>$priority</priority>
<changefreq>$changefreq</changefreq>
</url>";
}
}
?>
</urlset>