<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">
    
    <!-- صفحة التطبيق الرئيسية -->
    <url>
        <loc>https://vestore.net/app.php</loc>
        <lastmod>2026-01-07</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.9</priority>
        <mobile:mobile/>
    </url>
    
    <!-- صفحات الوحدات المربوطة بالتطبيق -->
    <?php
    require_once 'panel/config.php';
    
    try {
        $units = $pdo->query("SELECT id, updated_at FROM units WHERE status = 'available' LIMIT 100")->fetchAll(PDO::FETCH_ASSOC);
        foreach ($units as $unit) {
            $lastmod = date('Y-m-d', strtotime($unit['updated_at'] ?? 'now'));
            echo "    <url>\n";
            echo "        <loc>https://vestore.net/app-unit.php?id={$unit['id']}</loc>\n";
            echo "        <lastmod>{$lastmod}</lastmod>\n";
            echo "        <changefreq>weekly</changefreq>\n";
            echo "        <priority>0.8</priority>\n";
            echo "        <mobile:mobile/>\n";
            echo "    </url>\n";
        }
    } catch (Exception $e) {
        // خطأ في قاعدة البيانات
    }
    ?>
    
    <!-- صفحات الإعلانات المربوطة بالتطبيق -->
    <?php
    try {
        $ads = $pdo->query("SELECT id, updated_at FROM advertisements WHERE status = 'active' LIMIT 100")->fetchAll(PDO::FETCH_ASSOC);
        foreach ($ads as $ad) {
            $lastmod = date('Y-m-d', strtotime($ad['updated_at'] ?? 'now'));
            echo "    <url>\n";
            echo "        <loc>https://vestore.net/app-ad.php?id={$ad['id']}</loc>\n";
            echo "        <lastmod>{$lastmod}</lastmod>\n";
            echo "        <changefreq>weekly</changefreq>\n";
            echo "        <priority>0.7</priority>\n";
            echo "        <mobile:mobile/>\n";
            echo "    </url>\n";
        }
    } catch (Exception $e) {
        // خطأ في قاعدة البيانات
    }
    ?>
    
</urlset>
