<?php
header("Content-type: text/xml");

// Sertakan koneksi database
include "config/koneksi.php";

$query3 = "SELECT * FROM identitas";
$hasil3 = mysqli_query($konek, $query3);
$data3  = mysqli_fetch_array($hasil3);

// Mulai XML
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

echo"
<url>
    <loc>{$data3['alamat_website']}</loc>

    <priority>1.00</priority>
</url>
";


$querymenu = "SELECT * FROM menu WHERE aktif='Y' AND id_menu != 30 ORDER BY id_menu ASC";
$hasilmenu = mysqli_query($konek, $querymenu);

while ($m = mysqli_fetch_array($hasilmenu)) {
    echo "
<url>
    <loc>{$data3['alamat_website']}/{$m['link']}</loc>
   
    <priority>0.80</priority>
</url>
";
}







// Artikel dari agenda
$query = mysqli_query($konek, "SELECT tema_seo, tgl_posting FROM agenda ORDER BY id_agenda DESC");
while ($r = mysqli_fetch_assoc($query)) {
    $tgl = date('Y-m-d', strtotime($r['tgl_posting']));
    echo "<url>
<loc>{$data3['alamat_website']}/artikel-" . htmlspecialchars($r['tema_seo']) . "</loc>
<lastmod>{$tgl}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.80</priority>
</url>";
}

// Berita
$query = mysqli_query($konek, "SELECT judul_seo, tanggal FROM berita");
while ($r = mysqli_fetch_assoc($query)) {
    $tgl = date('Y-m-d', strtotime($r['tanggal']));
    echo "<url>
<loc>{$data3['alamat_website']}/layanan-" . htmlspecialchars($r['judul_seo']) . "</loc>

<changefreq>weekly</changefreq>
<priority>0.80</priority>
</url>";
}

// Berita
$query = mysqli_query($konek, "SELECT video_seo FROM video");
while ($r = mysqli_fetch_assoc($query)) {
  
    echo "<url>
<loc>{$data3['alamat_website']}/produk-" . htmlspecialchars($r['video_seo']) . "</loc>

<changefreq>weekly</changefreq>
<priority>0.80</priority>
</url>";
}




echo '</urlset>';
?>
