#!/home/sys/php
<?php
include(dirname(__FILE__)."/GLOBALS.php");
include(dirname(__FILE__)."/classes/classes_database.php");
include(dirname(__FILE__)."/ubb.php");
include(dirname(__FILE__)."/functions.php");

$db = new DatabaseConnection;

header('Content-type: application/xml; charset="utf-8"',true);

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n".
     "<urlset xmlns=\"https://www.google.com/schemas/sitemap/0.84\" xmlns:xsi=\"https://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"https://www.google.com/schemas/sitemap/0.84 https://www.google.com/schemas/sitemap/0.84/sitemap.xsd\">\r\n";
     
// haal alle hoofdcategorieen op

$priority = "0.9";

$query = "SELECT c.directory AS c_dir
          FROM categories c
          WHERE c.bln_publish = 1 AND c.right_id = 0 AND c.language_id = ".LANGUAGE_ID."
          ORDER BY c.priority";
$rs    = $db->executeQuery($query);
while($row = $db->getFetchedArray($rs)){
 if(!in_array($row['c_dir'], array('404', 'zoeken', 'search', 'cerca', 'suche', 'mail-een-vriend', 'mail-a-friend', 'rss'))){
  echo "<url>\r\n".
       " <loc>https://www.kostenlospokeronline.de/".($row['c_dir'] == 'home' ? "" : $row['c_dir']."/")."</loc>\r\n".
       " <priority>".$priority."</priority>\r\n".
       "</url>\r\n";
 }
}

// haal alle subcategorieeen op

$priority = "0.9";

$query = "SELECT c.directory AS c_dir, s.directory AS s_dir
          FROM categories c
          INNER JOIN subcategories s ON s.category_id = c.id
          WHERE s.bln_publish = 1 AND s.right_id = 0 AND c.language_id = ".LANGUAGE_ID."
          ORDER BY c.priority, s.priority";
$rs    = $db->executeQuery($query);
while($row = $db->getFetchedArray($rs)){
 echo "<url>\r\n".
      " <loc>https://www.kostenlospokeronline.de/".$row['c_dir']."/".$row['s_dir']."/</loc>\r\n".
      " <priority>".$priority."</priority>\r\n".
      "</url>\r\n";
}

// haal alle sub-subcategorieeen op

$priority = "0.9";

$query = "SELECT c.directory AS c_dir, s.directory AS s_dir, ss.directory AS ss_dir
          FROM categories c
          INNER JOIN subcategories s ON s.category_id = c.id
          INNER JOIN subcategories ss ON ss.subcategory_id = s.id
          WHERE ss.bln_publish = 1 AND ss.right_id = 0 AND c.language_id = ".LANGUAGE_ID."
          ORDER BY c.priority, s.priority, ss.priority";
$rs    = $db->executeQuery($query);
while($row = $db->getFetchedArray($rs)){
 echo "<url>\r\n".
      " <loc>https://www.kostenlospokeronline.de/".$row['c_dir']."/".$row['s_dir']."/".$row['ss_dir']."/</loc>\r\n".
      " <priority>".$priority."</priority>\r\n".      
      "</url>\r\n";
}

// haal alle blog-artikelen op

$priority = "0.7";

$query = "SELECT b.id, b.title
          FROM blog b
          WHERE b.language_id = ".LANGUAGE_ID."
          ORDER BY publish_date DESC";
$rs    = $db->executeQuery($query);
while($row = $db->getFetchedArray($rs)){
 echo "<url>\r\n".
      " <loc>https://www.kostenlospokeronline.de/".($row['lang'] == "en" ? "poker-articles" : "poker-artikelen")."/".$row['id']."/".cleanForUrl($row['title'])."/</loc>\r\n".
      " <priority>".$priority."</priority>\r\n".
      "</url>\r\n";
}

// haal alle reviews, testimonials en bonussen op

$lastmod  = "2007-07-01";
$priority = "0.8";

$query = "SELECT c.title
          FROM client_reviews r
          INNER JOIN clients c ON c.id = r.client_id
          WHERE r.bln_publish AND r.language_id = ".LANGUAGE_ID."
          AND c.bln_publish
          ORDER BY c.priority";
$rs    = $db->executeQuery($query);
while($row = $db->getFetchedArray($rs)){
 echo "<url>\r\n".
      " <loc>https://www.kostenlospokeronline.de/".translate($db, 93, "", 4)."/".str_replace(" ", "-", strtolower($row['title']))."/</loc>\r\n".
 //     " <lastmod>".$lastmod."</lastmod>\r\n".
      " <priority>".$priority."</priority>\r\n".
      "</url>\r\n";
      
 //echo "<url>\r\n".
 //     " <loc>https://www.kostenlospokeronline.de/".translate($db, 93, "", 4)."/".str_replace(" ", "-", strtolower($row['title']))."/".translate($db, 158, "", 4)."/</loc>\r\n".
 //     " <lastmod>".$lastmod."</lastmod>\r\n".
 //     " <priority>".$priority."</priority>\r\n".
 //     "</url>\r\n"; 
      
 //echo "<url>\r\n".
 //     " <loc>https://www.kostenlospokeronline.de/".translate($db, 101, "", 4)."/".str_replace(" ", "-", strtolower($row['title']))."/</loc>\r\n".
 //     " <lastmod>".$lastmod."</lastmod>\r\n".
 //     " <priority>".$priority."</priority>\r\n".
 //     "</url>\r\n";      
}

echo "</urlset>";
?>