<?php
header('Content-Type: application/xml; charset=utf-8');
header('X-Robots-Tag: noindex');

$base  = 'https://a4sattaresult.com';
$now   = date('c');
$today = date('Y-m-d');
$cur_y = (int)date('Y');
$cur_m = (int)date('n');

$result_slugs = [
    'delhi-bazar','gali','disawar','ghaziabad','faridabad',
    'shri-ganesh','metro-city','ramgarh','manipur','sadar-bazar',
    'gwalior','bikaner','pune-city','marine-night',
    'delhi-matka','agra','alwar','dwarka'
];

$pages = [
    'about','chart-guide','contact','disclaimer','faq',
    'how-to-play','next-result','privacy','sitemap-page',
    'subscribe','terms','tips-tricks'
];

$blogs = ['chart-guide','history','how-to-win','terminology','what-is-satta'];

$games = ['faq','how-to-play','rules','satta-king','satta-matka','tips'];

$predictions = ['jodi','today'];

$month_names = [
    1=>'january',2=>'february',3=>'march',4=>'april',
    5=>'may',6=>'june',7=>'july',8=>'august',
    9=>'september',10=>'october',11=>'november',12=>'december'
];

// Build month-year list from Jan 2024 to current month
$month_years = [];
for ($y = 2024; $y <= $cur_y; $y++) {
    $max_m = ($y == $cur_y) ? $cur_m : 12;
    for ($m = 1; $m <= $max_m; $m++) {
        $days = cal_days_in_month(CAL_GREGORIAN, $m, $y);
        $month_years[] = [
            'y'    => $y,
            'm'    => $m,
            'name' => $month_names[$m],
            'last' => "$y-" . str_pad($m, 2, '0', STR_PAD_LEFT) . "-$days",
            'cur'  => ($y == $cur_y && $m == $cur_m)
        ];
    }
}

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">

<!-- HOMEPAGE -->
<url>
    <loc><?= $base ?>/</loc>
    <lastmod><?= $today ?>T<?= date('H:i:s') ?>+05:30</lastmod>
    <changefreq>hourly</changefreq>
    <priority>1.0</priority>
    <news:news>
        <news:publication><news:name>A4 Satta King</news:name><news:language>hi</news:language></news:publication>
        <news:publication_date><?= $now ?></news:publication_date>
        <news:title>A4 Satta King Live Result Today <?= date('d M Y') ?> | Gali Disawar Delhi Bazar Fastest Result</news:title>
    </news:news>
</url>

<!-- RESULT PAGES -->
<?php foreach ($result_slugs as $slug):
    $d = ucwords(str_replace('-',' ',$slug)); ?>
<url>
    <loc><?= $base ?>/results/<?= $slug ?>.php</loc>
    <lastmod><?= $today ?>T<?= date('H:i:s') ?>+05:30</lastmod>
    <changefreq>hourly</changefreq>
    <priority>0.9</priority>
    <news:news>
        <news:publication><news:name>A4 Satta King</news:name><news:language>hi</news:language></news:publication>
        <news:publication_date><?= $now ?></news:publication_date>
        <news:title><?= $d ?> Satta King Result Today <?= date('d M Y') ?> | A4 Satta King</news:title>
    </news:news>
</url>
<?php endforeach; ?>

<!-- PAGES FOLDER -->
<?php foreach ($pages as $p): ?>
<url>
    <loc><?= $base ?>/pages/<?= $p ?>.php</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.7</priority>
</url>
<?php endforeach; ?>

<!-- BLOG FOLDER -->
<?php foreach ($blogs as $b): ?>
<url>
    <loc><?= $base ?>/blog/<?= $b ?>.php</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.6</priority>
</url>
<?php endforeach; ?>

<!-- GAME FOLDER -->
<?php foreach ($games as $g): ?>
<url>
    <loc><?= $base ?>/game/<?= $g ?>.php</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.6</priority>
</url>
<?php endforeach; ?>

<!-- PREDICTIONS FOLDER -->
<?php foreach ($predictions as $pr): ?>
<url>
    <loc><?= $base ?>/predictions/<?= $pr ?>.php</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>0.7</priority>
</url>
<?php endforeach; ?>

<!-- MONTHLY CHART PAGES (same as competitor strategy) -->
<?php foreach ($result_slugs as $slug):
    $d = ucwords(str_replace('-',' ',$slug));
    foreach ($month_years as $my):
        $freq = $my['cur'] ? 'daily' : 'monthly';
        $pri  = $my['cur'] ? '0.8'   : '0.6';
        $lmod = $my['cur'] ? $today  : $my['last'];
        $mn   = ucfirst($my['name']);
        $y    = $my['y'];
        $m    = str_pad($my['m'], 2, '0', STR_PAD_LEFT);
?>
<url>
    <loc><?= $base ?>/results/<?= $slug ?>.php?month=<?= $my['m'] ?>&amp;year=<?= $y ?></loc>
    <lastmod><?= $lmod ?></lastmod>
    <changefreq><?= $freq ?></changefreq>
    <priority><?= $pri ?></priority>
</url>
<?php endforeach; endforeach; ?>

</urlset>