<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <!-- Homepage -->
    <url>
        <loc>https://codezonebd.com/</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>
    <!-- Product Listing -->
    <url>
        <loc>https://codezonebd.com/index.php</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.9</priority>
    </url>
    <!-- Cart -->
    <url>
        <loc>https://codezonebd.com/cart.php</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.8</priority>
    </url>
    <!-- User Login -->
    <url>
        <loc>https://codezonebd.com/user/login</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <!-- User Registration -->
    <url>
        <loc>https://codezonebd.com/user/register</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <!-- Contact Us -->
    <url>
        <loc>https://codezonebd.com/contact-us.php</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    <!-- Support Policy -->
    <url>
        <loc>https://codezonebd.com/templates/support-policy.php</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.6</priority>
    </url>
    <!-- Live Chat -->
    <url>
        <loc>https://codezonebd.com/chat/live_chat.php</loc>
        <lastmod>2025-10-16</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.6</priority>
    </url>
    <!-- Dynamic Product Pages -->
    <?php
    // Fetch all products from the database
    require_once 'db.php';
    try {
        $stmt = $pdo->query("SELECT id, name, updated_at FROM products");
        $products = $stmt->fetchAll(PDO::FETCH_ASSOC);
        foreach ($products as $product) {
            echo "
            <url>
                <loc>https://codezonebd.com/product.php?id={$product['id']}</loc>
                <lastmod>" . date('Y-m-d', strtotime($product['updated_at'])) . "</lastmod>
                <changefreq>weekly</changefreq>
                <priority>0.9</priority>
            </url>
            ";
        }
    } catch (PDOException $e) {
        error_log("Error generating sitemap: " . $e->getMessage());
    }
    ?>
</urlset>
