<?php
require_once 'admin/includes/Database.php';
require_once 'admin/config/config.php';

header('Content-Type: application/xml');

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://shaikhca.com/</loc>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/about.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/banking-finance.php</loc>
        <changefreq>weekly</changefreq>
        <priority>0.9</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/services.php</loc>
        <changefreq>weekly</changefreq>
        <priority>0.9</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/team.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/blog.php</loc>
        <changefreq>weekly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/calculator.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.9</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/contact.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://shaikhca.com/free-trial.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.9</priority>
    </url>
    
    <?php
    $services = $db->fetchAll("SELECT service_slug, updated_at FROM services WHERE is_active = 1");
    foreach ($services as $service):
    ?>
    <url>
        <loc><?php echo SITE_URL; ?>/service-detail.php?slug=<?php echo $service['service_slug']; ?></loc>
        <lastmod><?php echo date('Y-m-d', strtotime($service['updated_at'])); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <?php endforeach; ?>
    
    <?php
    $posts = $db->fetchAll("SELECT slug, updated_at FROM blog_posts WHERE status = 'published'");
    foreach ($posts as $post):
    ?>
    <url>
        <loc><?php echo SITE_URL; ?>/blog-detail.php?slug=<?php echo $post['slug']; ?></loc>
        <lastmod><?php echo date('Y-m-d', strtotime($post['updated_at'])); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.6</priority>
    </url>
    <?php endforeach; ?>
</urlset>
