<?php
header('Content-Type: application/xml; charset=UTF-8');
header('Cache-Control: public, max-age=3600');

$base = 'https://gpsfinance.com.au';
$lastmod = date('Y-m-d', max(filemtime(__FILE__), filemtime(__DIR__ . '/index.php')));
$pages = [
    ['/', 'weekly', '1.0'],
    ['/solutions', 'monthly', '0.9'],
    ['/business-loans', 'monthly', '0.9'],
    ['/business-line-of-credit', 'monthly', '0.9'],
    ['/working-capital-loans', 'monthly', '0.9'],
    ['/unsecured-business-loans', 'monthly', '0.9'],
    ['/invoice-finance', 'monthly', '0.9'],
    ['/asset-equipment-finance', 'monthly', '0.9'],
    ['/commercial-property-finance', 'monthly', '0.9'],
    ['/fast-business-loans', 'monthly', '0.8'],
    ['/non-bank-business-lenders', 'monthly', '0.9'],
    ['/bank-declined-business-loan', 'monthly', '0.9'],
    ['/business-finance-broker-sydney', 'monthly', '0.9'],
    ['/finance-scenarios', 'monthly', '0.85'],
    ['/scenarios/bank-declined-business-loan-options', 'monthly', '0.75'],
    ['/scenarios/working-capital-cash-flow-gap', 'monthly', '0.75'],
    ['/scenarios/invoice-finance-for-unpaid-invoices', 'monthly', '0.75'],
    ['/scenarios/construction-equipment-finance', 'monthly', '0.7'],
    ['/scenarios/transport-equipment-finance', 'monthly', '0.7'],
    ['/scenarios/business-line-of-credit-seasonal-cash-flow', 'monthly', '0.75'],
    ['/scenarios/low-doc-unsecured-business-loan', 'monthly', '0.7'],
    ['/scenarios/urgent-business-loan-payroll-suppliers', 'monthly', '0.75'],
    ['/case-studies/bank-said-no-150k-line-of-credit', 'monthly', '0.8'],
    ['/industries/trades-construction-finance', 'monthly', '0.7'],
    ['/industries/transport-logistics-finance', 'monthly', '0.7'],
    ['/industries/hospitality-finance', 'monthly', '0.7'],
    ['/industries/professional-services-finance', 'monthly', '0.7'],
    ['/industries/healthcare-medical-finance', 'monthly', '0.7'],
    ['/industries/education-finance', 'monthly', '0.7'],
    ['/industries/b2b-wholesale-manufacturing-finance', 'monthly', '0.7'],
    ['/guides/business-loan-serviceability', 'monthly', '0.8'],
    ['/guides/business-bank-conduct-credit-history', 'monthly', '0.8'],
    ['/guides/business-loan-security-collateral', 'monthly', '0.7'],
    ['/guides/how-lenders-read-business-financials', 'monthly', '0.8'],
    ['/guides/why-business-loan-applications-get-delayed', 'monthly', '0.7'],
    ['/guides/business-loan-document-pack', 'monthly', '0.8'],
    ['/resources', 'weekly', '0.8'],
    ['/payday-super-calculator', 'monthly', '0.8'],
    ['/car-loan-calculator', 'monthly', '0.6'],
    ['/personal-loan-calculator', 'monthly', '0.6'],
    ['/car-loans', 'monthly', '0.6'],
    ['/personal-loans', 'monthly', '0.6'],
    ['/about', 'monthly', '0.7'],
    ['/partners', 'monthly', '0.7'],
    ['/contact', 'monthly', '0.7'],
    ['/quote', 'monthly', '0.8'],
    ['/credit-guide', 'yearly', '0.3'],
    ['/privacy', 'yearly', '0.2'],
    ['/terms', 'yearly', '0.2'],
    ['/complaints', 'yearly', '0.2'],
];

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($pages as [$path, $frequency, $priority]) {
    echo "  <url>\n";
    echo '    <loc>' . htmlspecialchars($base . $path, ENT_XML1, 'UTF-8') . "</loc>\n";
    echo "    <lastmod>{$lastmod}</lastmod>\n";
    echo "    <changefreq>{$frequency}</changefreq>\n";
    echo "    <priority>{$priority}</priority>\n";
    echo "  </url>\n";
}
echo '</urlset>';
