Kapisi/roles/Foundation/files/custom/bin/sitemap.php

33 lines
866 B
PHP
Raw Normal View History

<?php
2022-07-02 10:24:10 -05:00
/*
2022-07-02 10:24:10 -05:00
* 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) | grep -E \.php\$ | grep -vE ^./unlisted\|^./errors/\|head.php\|foot.php\|test\|Template\|darknet", $output);
foreach ($output as &$file) {
2022-07-02 10:24:10 -05:00
echo ' <url>
';
echo ' <loc>https://aninix.net/'.substr($file,strlen($path)).'</loc>
';
echo ' <lastmod>'.date('Y-m-d',filemtime($file)).'</lastmod>
';
echo ' </url>
';
2022-07-02 10:24:10 -05:00
}
/* Print footer */
2022-07-02 10:24:10 -05:00
echo '</urlset>
';
?>