33 lines
864 B
PHP
33 lines
864 B
PHP
<?php
|
|
|
|
/*
|
|
* Build a sitemap dynamically.
|
|
* Update Gitea's sitemap with: `php ./sitemap.php > /var/lib/gitea/custom/sitemap.xml`
|
|
*
|
|
* Builds according to https://www.sitemaps.org/protocol.html
|
|
*/
|
|
|
|
/* Globals */
|
|
$path="/srv/http/aninix.net/";
|
|
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
';
|
|
|
|
exec("(echo /srv/http/aninix.net/index.php; find /srv/http/aninix.net/pages -type f; find /srv/http/aninix.net/martialarts/ -type f) | egrep \.php\$ | egrep -v ^./unlisted\|^./errors/\|head.php\|foot.php\|test\|Template\|darknet", $output);
|
|
foreach ($output as &$file) {
|
|
echo ' <url>
|
|
';
|
|
echo ' <loc>https://aninix.net/'.substr($file,strlen($path)).'</loc>
|
|
';
|
|
echo ' <lastmod>'.date('Y-m-d',filemtime($file)).'</lastmod>
|
|
';
|
|
echo ' </url>
|
|
';
|
|
}
|
|
|
|
/* Print footer */
|
|
echo '</urlset>
|
|
';
|
|
?>
|