<?php
// /sitemap.php — Starweb Designs dynamic sitemap
// This outputs XML directly and keeps sitemap dates current.

if (!ob_get_level()) {
    ob_start();
}

$SITE_BASE = 'https://starwebdesigns.com';
$today     = date('Y-m-d');

$STATIC_PAGES = [
    '/' => ['weekly', '1.0'],
    '/packages.php' => ['monthly', '0.9'],
    '/portfolio.php' => ['monthly', '0.8'],
    '/about.php' => ['yearly', '0.5'],
    '/contact.php' => ['monthly', '0.7'],

    // SEO landing pages
    '/web-designers-in-tampa/' => ['monthly', '0.9'],
	'/web-design-st-petersburg-fl/' => ['monthly', '0.9'],
    '/custom-web-development/' => ['monthly', '0.9'],
    '/web-design/' => ['monthly', '0.9'],
    '/dynamic-product-visualization/' => ['monthly', '0.9'],
    '/responsive-web-design/' => ['monthly', '0.9'],
    '/ai-search-for-ecommerce/' => ['monthly', '0.9'],
    '/b2b-web-commerce/' => ['monthly', '0.9'],
    '/ai-website-assistant-for-products-and-services/' => ['monthly', '0.9'],
    '/gemini-ai-seo-case-study/' => ['monthly', '0.9'],
    '/autonomous-web-applications-business-automation/' => ['monthly', '0.9'],
    '/why-dynamic-product-visualization-is-a-game-changer/' => ['monthly', '0.9'],
    '/why-ecommerce-sites-fail/' => ['monthly', '0.9'],
    '/business-process-automation/' => ['monthly', '0.9'],
    '/custom-website-vs-shopify/' => ['monthly', '0.9'],
    '/edi-automation-services/' => ['monthly', '0.9'],
    '/erp-ecommerce-integration/' => ['monthly', '0.9'],

    // Newer pages
    '/insights.php' => ['weekly', '0.8'],
    '/erp-ecommerce-integration-checklist/' => ['monthly', '0.8'],
    '/business-growth/' => ['monthly', '0.9'],
    '/product-configurator/' => ['monthly', '0.9'],
    '/automated-business-systems/' => ['monthly', '0.9'],
    '/ai-blade-selection-configurator/' => ['monthly', '0.9'],
    '/ai-hydraulic-hose-configurator/' => ['monthly', '0.9'],
    '/ai-pump-selection-configurator/' => ['monthly', '0.9'],
    '/starwebaiq/' => ['weekly', '0.9'],
	'/starwebaiq/seal-selector/' => ['weekly', '0.9'],
	'/starwebaiq/pump-selector/' => ['weekly', '0.9'],
	'/starwebaiq/hose-selector/' => ['weekly', '0.9'],
	'/starwebaiq/blade-selector/' => ['weekly', '0.9'],
];

ob_clean();
header('Content-Type: application/xml; charset=UTF-8');

function xml_escape($value)
{
    return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
}

function emit_url($loc, $lastmod, $changefreq, $priority)
{
    echo "  <url>\n";
    echo "    <loc>" . xml_escape($loc) . "</loc>\n";
    echo "    <lastmod>" . xml_escape($lastmod) . "</lastmod>\n";
    echo "    <changefreq>" . xml_escape($changefreq) . "</changefreq>\n";
    echo "    <priority>" . xml_escape($priority) . "</priority>\n";
    echo "  </url>\n";
}

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

foreach ($STATIC_PAGES as $path => $settings) {
    [$changefreq, $priority] = $settings;
    emit_url(rtrim($SITE_BASE, '/') . $path, $today, $changefreq, $priority);
}

echo "</urlset>\n";
