First git commit
This commit is contained in:
34
public_html/sitemap.php
Normal file
34
public_html/sitemap.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// Dynamic XML sitemap: public pages, plus one entry per forum and per topic.
|
||||
require_once __DIR__ . '/lib/config.php';
|
||||
|
||||
$base = 'https://wap.txt3.net';
|
||||
$db = new PDO('sqlite:' . DB_FILE, null, null, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
]);
|
||||
|
||||
$urls = [];
|
||||
$urls[] = ['loc' => $base . '/index.php', 'changefreq' => 'daily', 'priority' => '1.0'];
|
||||
$urls[] = ['loc' => $base . '/about.php', 'changefreq' => 'monthly', 'priority' => '0.6'];
|
||||
$urls[] = ['loc' => $base . '/forum.php', 'changefreq' => 'daily', 'priority' => '0.8'];
|
||||
|
||||
foreach ($db->query("SELECT id, name FROM forums ORDER BY id") as $f) {
|
||||
$urls[] = ['loc' => $base . '/forum.php?f=' . $f['id'],
|
||||
'changefreq' => 'weekly', 'priority' => '0.5'];
|
||||
}
|
||||
foreach ($db->query("SELECT id FROM topics ORDER BY bumped_at DESC LIMIT 500") as $t) {
|
||||
$urls[] = ['loc' => $base . '/topic.php?t=' . $t['id'],
|
||||
'changefreq' => 'monthly', 'priority' => '0.4'];
|
||||
}
|
||||
|
||||
header('Content-Type: application/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
||||
foreach ($urls as $u) {
|
||||
echo ' <url>' . "\n";
|
||||
echo ' <loc>' . htmlspecialchars($u['loc'], ENT_XML1, 'UTF-8') . '</loc>' . "\n";
|
||||
echo ' <changefreq>' . $u['changefreq'] . '</changefreq>' . "\n";
|
||||
echo ' <priority>' . $u['priority'] . '</priority>' . "\n";
|
||||
echo ' </url>' . "\n";
|
||||
}
|
||||
echo '</urlset>' . "\n";
|
||||
Reference in New Issue
Block a user