<?php 
define("__ROOT__", $_SERVER["DOCUMENT_ROOT"]."");

require_once(__ROOT__ . "/system/functions.php"); 

function moduller($id) {
    global $db;
    $data_query = $db->prepare("SELECT * FROM modul WHERE ad=?");
    $data_query->execute(array($id));
    $data_results = $data_query->fetch(PDO::FETCH_ASSOC);
    if ($data_query->rowCount() < 1) {return false;} else {return $data_results;}
}

 header('Content-type: Application/xml; charset="utf8"', true);
echo '
<urlset
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	  xmlns:xhtml="http://www.w3.org/1999/xhtml"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">	
<url>
   <loc>'.rtrim($site,"/").'</loc>
   <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>
   <changefreq>daily</changefreq>
   <priority>1.0000</priority>
</url>
<url>
   <loc>'.$site.'siparis-takibi</loc>
   <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>
   <changefreq>daily</changefreq>
   <priority>0.8000</priority>
</url>
<url>
   <loc>'.$site.'blog</loc>
   <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>
   <changefreq>daily</changefreq>
   <priority>0.8000</priority>
</url>
    ';


    $query = $db->query("SELECT * FROM blog ORDER BY id ASC"); 

                while ($data = $query->fetch(PDO::FETCH_OBJ)) {

echo '
<url>
       <loc>'.$site."blog/".$data->url.'</loc>

       <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>

       <changefreq>daily</changefreq>

       <priority>0.8000</priority>

  </url>
  ';
 }
    $query = $db->query("SELECT * FROM sayfa ORDER BY id ASC"); 

                while ($data = $query->fetch(PDO::FETCH_OBJ)) {

echo '
<url>
       <loc>'.$site.$data->sayfa.'</loc>

       <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>

       <changefreq>daily</changefreq>

       <priority>0.8000</priority>

  </url>
  ';
 }

$urunlerkategori=moduller("urunlerkategori");
$urunsayfa=moduller("urunsayfa");
if($urunsayfa["durum"]=="1"){
	    $query = $db->query("SELECT * FROM urun ORDER BY id ASC"); 

                while ($data = $query->fetch(PDO::FETCH_OBJ)) {

echo '
<url>
       <loc>'.$site.settings("urun_url");?>/<?=$data->url.'</loc>

       <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>

       <changefreq>daily</changefreq>

       <priority>0.8000</priority>

  </url>
  ';
 }
	
}
if($urunlerkategori["durum"]=="1"){
	
echo '<url>
   <loc>'.$site.'urunler</loc>
   <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>
   <changefreq>daily</changefreq>
   <priority>0.8000</priority>
</url>
    ';
	    $query = $db->query("SELECT * FROM kategori ORDER BY id ASC"); 

                while ($data = $query->fetch(PDO::FETCH_OBJ)) {

echo '
<url>
       <loc>'.$site.settings("kategori_url");?>/<?=$data->url.'</loc>

       <lastmod>'.date("Y")."-".date("m")."-".date("d")."T".date("H:i:s").'+00:00</lastmod>

       <changefreq>daily</changefreq>

       <priority>0.8000</priority>

  </url>
  ';
 }
}
echo '
</urlset>';
 ?>