İçeriğe geç
Tüm kodlar

ER3NSHOP

Kurulum sihirbazlı online mağaza sistemi

20 satır · 1,1 KBHamİndir
<?php
header('Content-Type: application/xml; charset=utf-8');

$urls = [[url(), date('Y-m-d'), '1.0'], [url('urunler'), date('Y-m-d'), '0.8'], [url('iletisim'), null, '0.4']];
foreach (db_all('SELECT slug, created_at FROM categories WHERE status = 1') as $row) {
    $urls[] = [category_url($row), substr($row['created_at'], 0, 10), '0.8'];
}
foreach (db_all('SELECT slug, COALESCE(updated_at, created_at) AS changed FROM products WHERE status = 1') as $row) {
    $urls[] = [product_url($row), substr($row['changed'], 0, 10), '0.7'];
}
foreach (db_all('SELECT slug, updated_at FROM pages WHERE status = 1') as $row) {
    $urls[] = [page_url($row), $row['updated_at'] ? substr($row['updated_at'], 0, 10) : null, '0.4'];
}

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

Lisans bilgisi projenin LICENSE dosyasında.