<?php

ob_start("ob_gzhandler");
header('Content-type: application/xml');

?>
<?php
require 'staging.php';

$allRecipe = mysqli_query($conn, "SET NAMES 'utf8'");


 $allRecipe = mysqli_query($conn, "SELECT r.bo_recipe_title, r.bo_recipe_id, DATE(r.bo_recipe_timestamp) as bo_recipe_timestamp
FROM  bo_recipe r
WHERE r.bo_recipe_deleted = 0
AND r.bo_recipe_draft = 0
GROUP BY r.bo_recipe_id
ORDER BY r.bo_recipe_timestamp ASC");

$sqlQuery = $allRecipe;
$data = array();
if($sqlQuery){
  while ($row = mysqli_fetch_assoc($sqlQuery)) {
      $myLittleId = $row['bo_recipe_id'];
      if (!isset($data[$row['bo_recipe_id']])) {
        $data[$row['bo_recipe_id']] = $row;
      }
  }
}

//print_r($data);
$lastmod = $data[$myLittleId]['bo_recipe_timestamp'];


?>
<?php echo "<?xml version='1.0' encoding='UTF-8'?>"; ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>http://bedste-opskrifter.dk/sitemap_recipes.xml</loc>
    <lastmod><? echo $lastmod ?></lastmod>
  </sitemap>
</sitemapindex>