60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
require_once __DIR__.'/../init.php';
|
|
require_once 'lib/files.php';
|
|
|
|
global $config;
|
|
|
|
use samdark\sitemap\Sitemap;
|
|
|
|
$db = DB();
|
|
|
|
$sitemap = new Sitemap($config['sitemap_dir'].'/sitemap.xml');
|
|
$addr = 'https://'.$config['domain'];
|
|
|
|
$sitemap->addItem("{$addr}/",
|
|
changeFrequency: Sitemap::WEEKLY);
|
|
|
|
// pages
|
|
$q = $db->query("SELECT short_name FROM pages");
|
|
while ($row = $db->fetch($q)) {
|
|
$sitemap->addItem("{$addr}/{$row['short_name']}/",
|
|
changeFrequency: Sitemap::WEEKLY);
|
|
}
|
|
|
|
// files
|
|
$sitemap->addItem("{$addr}/files/",
|
|
changeFrequency: Sitemap::WEEKLY);
|
|
foreach (FilesCollection::cases() as $fc) {
|
|
$sitemap->addItem("{$addr}/files/".$fc->value.'/',
|
|
changeFrequency: Sitemap::MONTHLY);
|
|
}
|
|
|
|
foreach ([FilesCollection::WilliamFriedman, FilesCollection::Baconiana] as $fc) {
|
|
$q = $db->query("SELECT id FROM {$fc->value}_collection WHERE type=?", FilesItemType::FOLDER);
|
|
while ($row = $db->fetch($q)) {
|
|
$sitemap->addItem("{$addr}/files/".$fc->value.'/'.$row['id'].'/',
|
|
changeFrequency: Sitemap::MONTHLY);
|
|
}
|
|
}
|
|
|
|
$q = $db->query("SELECT id FROM books WHERE type=? AND external=0", FilesItemType::FOLDER);
|
|
while ($row = $db->fetch($q)) {
|
|
$sitemap->addItem("{$addr}/files/".$row['id'].'/',
|
|
changeFrequency: Sitemap::MONTHLY);
|
|
}
|
|
|
|
// posts
|
|
//foreach (PostLanguage::cases() as $pl) {
|
|
// $sitemap->addItem("{$addr}/articles/".($pl != PostLanguage::English ? '?lang='.$pl->value : ''),
|
|
// changeFrequency: Sitemap::WEEKLY);
|
|
//
|
|
// $q = $db->query("SELECT * FROM posts WHERE visible=1");
|
|
// while ($row = $db->fetch($q)) {
|
|
// $post = new Post($row);
|
|
// $sitemap->addItem("{$addr}".$post->getUrl($pl),
|
|
// changeFrequency: Sitemap::WEEKLY);
|
|
// }
|
|
//}
|
|
|
|
$sitemap->write(); |