<?php
include __DIR__.'/inc/init.php';
header('Content-Type: application/xml; charset=utf-8');
$productsAll=include __DIR__.'/data/products.php'; $products=$productsAll[$theme] ?? reset($productsAll); $casesAll=include __DIR__.'/data/cases.php'; $cases=$casesAll[$theme] ?? reset($casesAll); $contentAll=include __DIR__.'/data/content.php'; $content=$contentAll[$theme] ?? reset($contentAll); $faqsAll=include __DIR__.'/data/faq.php'; $faqs=$faqsAll[$theme] ?? reset($faqsAll);
$contentProducts = txt_articles_load('product'); if($contentProducts){ $products = array_merge($contentProducts, $products); article_sort_desc($products); }
$contentCases = txt_articles_load('case'); if($contentCases){ $cases = array_merge($contentCases, $cases); article_sort_desc($cases); }
$contentFaqs = txt_articles_load('faq'); if($contentFaqs){ $faqs = array_merge($contentFaqs, $faqs); article_sort_desc($faqs); }
$urls=array('', 'about/', 'product/', 'case/', 'news/', 'faq/', 'contact/');
foreach($products as $p){$urls[]='product/'.$p['id'].'.html';}
foreach($cases as $c){$urls[]='case/'.$c['id'].'.html';}
$txtNews=txt_articles_load('news'); $newsItems=array_merge($txtNews, $content['company_news'] ?? array(), $content['industry_news'] ?? array()); article_sort_desc($newsItems); foreach($newsItems as $n){$urls[]='news/'.$n['id'].'.html';}
foreach($faqs as $f){$urls[]='faq/'.$f['id'].'.html';}
$urls = array_values(array_unique($urls));
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
foreach($urls as $u){echo "  <url><loc>".e(site_url($u))."</loc><lastmod>".date('Y-m-d')."</lastmod><changefreq>weekly</changefreq><priority>0.8</priority></url>\n";}
echo "</urlset>";
