|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
urlset structure
|
|
|
|
|
url:
|
|
|
|
|
loc: fully qualified url of page
|
|
|
|
|
lastmod: date of last change to page
|
|
|
|
|
- W3C DATETIME format (http://www.w3.org/TR/NOTE-datetime).
|
|
|
|
|
- Example: 2005-05-10, or 2005-05-10T17:33:30+08:00
|
|
|
|
|
changefreq: optional, one of
|
|
|
|
|
- always, hourly, daily, weekly, monthly, yearly, never
|
|
|
|
|
- value "always" should be used to describe documents that change each
|
|
|
|
|
time they are accessed. The value "never" should be used to describe
|
|
|
|
|
archived URLs.
|
|
|
|
|
priority: optional, relative to other pages, from 0.0 to 1.0
|
|
|
|
|
*/
|
|
|
|
|
header('Content-Type: text/xml; charset=utf-8');
|
|
|
|
|
$stylesheet_url = $config['SITEMAP_STYLESHEET'] ?? '/sitemap/sitemap.xsl';
|
|
|
|
|
|
|
|
|
|
# Server Settings. Will select defaults for CLI usage
|
|
|
|
|
$document_root = $_SERVER['DOCUMENT_ROOT'] ?: realpath(__DIR__.'/..');
|
|
|
|
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
|
|
|
$host = $_SERVER['SERVER_NAME'] ?? 'localhost';
|
|
|
|
|
$base_url = $scheme . '://' . $host;
|
|
|
|
|
|
|
|
|
|
# Check for stylesheet before emitting xsl record
|
|
|
|
|
if (file_exists($document_root.$stylesheet_url)) {
|
|
|
|
|
$stylesheet = "<?xml-stylesheet type=\"text/xsl\" href=\"$stylesheet_url\"?" . ">\n";
|
|
|
|
|
} else {
|
|
|
|
|
error_log(__FILE__ . "$name cannot be found in $document_root");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Find relative folder and scan for docs
|
|
|
|
|
$article_path = str_replace($document_root, '', dirname(__FILE__));
|
|
|
|
|
$fileglob = glob('*.{php,md}',GLOB_BRACE);
|
|
|
|
|
?>
|
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<?= $stylesheet ?>
|
|
|
|
|
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
|
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
|
|
|
|
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd"
|
|
|
|
|
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
foreach($fileglob as $file) {
|
|
|
|
|
if ($file === 'index.php') continue;
|
|
|
|
|
if ($file === 'sitemap.php') continue;
|
|
|
|
|
if ($file === 'README.md') continue;
|
|
|
|
|
|
|
|
|
|
# $page = file_get_contents($file);
|
|
|
|
|
# $update = stat($file)->modified_date;
|
|
|
|
|
$file = basename($file, '.php');
|
|
|
|
|
$update = '2025-05-07';
|
|
|
|
|
?>
|
|
|
|
|
<url>
|
|
|
|
|
<loc><?= $base_url . $article_path . '/' . $file ?></loc>
|
|
|
|
|
<lastmod><?= $update ?></lastmod>
|
|
|
|
|
</url>
|
|
|
|
|
<?php
|
|
|
|
|
} // end foreach
|
|
|
|
|
?>
|
|
|
|
|
</urlset>
|