<?php
error_reporting(0);
date_default_timezone_set('GMT');
header('Content-type: text/xml');
include_once "ayar/Config.php";
$sitepath = file_get_contents("ayar/Domain.php");
if (@$_SERVER["HTTPS"] == "on") {
    $http = "https://";
} else {
    $http = "http://";
}

echo "<?xml version='1.0' encoding='UTF-8'?>
  <urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>";
$query = $db->query("SELECT * FROM `sayfalar`  WHERE `sayfalar`.`aktifkontrol`='aktif' ORDER BY `sayfalar`.`sayfa_id` DESC", PDO::FETCH_ASSOC);
$query2 = $db->query("SELECT * FROM `blog`  WHERE `blog`.`aktifkontrol`='aktif' ORDER BY `blog`.`blog_id` DESC", PDO::FETCH_ASSOC);
$query3 = $db->query("SELECT * FROM `urunler`  WHERE `urunler`.`aktifkontrol`='aktif'", PDO::FETCH_ASSOC);
$query4 = $db->query("SELECT * FROM `personel` WHERE `personel`.`aktifkontrol`='aktif'", PDO::FETCH_ASSOC);
$query5 = $db->query("SELECT * FROM `video` WHERE `video`.`aktifkontrol`='aktif'", PDO::FETCH_ASSOC);


$sql = $db->prepare("SELECT * FROM `modul_ayarlari` WHERE id=?");
$sql->execute(array(
'1'));
$modul=$sql->fetch(PDO::FETCH_ASSOC);

echo "
   <url>
      <loc>" . $sitepath ."</loc>
      <lastmod>" . date('Y-m-d') . " " . date('H:i:s') . "</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>";
if ($modul["anasayfaurunler"]!="pasif"){
foreach ($query3 as $row) {
   echo "
      <url>
         <loc>" . $sitepath .$row["urun_seflink"]."</loc>
         <lastmod>" . date('Y-m-d', strtotime($row["duzenleme_tarihi"])) . " " . date('H:i:s') . "</lastmod>
         <changefreq>monthly</changefreq>
         <priority>0.9</priority>
      </url>";
   }}

foreach ($query as $row) {
echo "
   <url>
      <loc>" . $sitepath .$row["sayfa_seflink"]."</loc>
      <lastmod>" . date('Y-m-d', strtotime($row["duzenleme_tarihi"])) . " " . date('H:i:s') . "</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.7</priority>
   </url>";
}
if ($modul["ekibimiz"]=="aktif"){
foreach ($query4 as $row) {
echo "
   <url>
      <loc>" . $sitepath .$row["personelSeflink"]."</loc>
      <lastmod>" . date('Y-m-d', strtotime($row["duzenleme_tarihi"])) . " " . date('H:i:s') . "</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.4</priority>
   </url>";
}
}
if ($modul["blog"]!="kapali"){
foreach ($query2 as $row) {
echo "
   <url>
      <loc>" . $sitepath .'blog/'.$row["blog_seflink"]."</loc>
      <lastmod>" . date('Y-m-d', strtotime($row["duzenleme_tarihi"])) . " " . date('H:i:s') . "</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.6</priority>
   </url>";
}}
foreach ($query5 as $row) {
   echo "
      <url>
         <loc>" . $sitepath .$row["videoSeflink"]."</loc>
         <lastmod>" . date('Y-m-d', strtotime($row["duzenleme_tarihi"])) . " " . date('H:i:s') . "</lastmod>
         <changefreq>monthly</changefreq>
         <priority>0.6</priority>
      </url>";
   }

echo "</urlset> ";

?>
