Call from a page called sitemap.htm in any directory. Within that page, put the following and thgen MODIFY const directory to desired site:

Thanksgiving Website PHP Sitemap (From Common Location)

Page Created: 11/26/2026 Page Last Updated:

Loading sitemap…

This is the actual called script that reside in /common/sitemaps/sitemap.php getFilename(), $second->getFilename()) ?: strcmp($first->getFilename(), $second->getFilename()); } function ezmapRender(string $directory, string $url, array $settings, array &$counts): void { $folders = []; $files = []; try { $entries = new FilesystemIterator($directory, FilesystemIterator::SKIP_DOTS); foreach ($entries as $entry) { $name = $entry->getFilename(); if ($name[0] === '.' || $entry->isLink()) { continue; } if ($entry->isDir()) { if (!isset($settings['excludedDirectories'][strtolower($name)])) { $folders[] = $entry; } continue; } if (!$entry->isFile() || isset($settings['excludedFiles'][strtolower($name)])) { continue; } $extension = strtolower($entry->getExtension()); if (isset($settings['excludedExtensions'][$extension])) { continue; } $isImage = isset($settings['imageExtensions'][$extension]); if ($isImage) { $counts['images']++; } if ($isImage || isset($settings['extensions'][$extension])) { $files[] = $entry; } } } catch (RuntimeException $exception) { $counts['unreadable']++; echo '

This directory could not be read.

'; return; } if (!$folders && !$files) { echo '

No matching files or subdirectories to list.

'; return; } usort($files, 'ezmapSort'); usort($folders, 'ezmapSort'); echo ''; } $settings = [ 'extensions' => array_fill_keys(array_map('strtolower', $extensions), true), 'imageExtensions' => array_fill_keys($imageExtensions, true), 'excludedExtensions' => array_fill_keys(array_map('strtolower', $excludedExtensions), true), 'excludedDirectories' => array_fill_keys(array_map('strtolower', $excludedDirectories), true), 'excludedFiles' => array_fill_keys(array_map('strtolower', $excludedFiles), true), 'showDetails' => $showFileDetails, ]; $counts = [ 'folders' => 0, 'files' => 0, 'htm' => 0, 'images' => 0, 'mp3' => 0, 'mp4' => 0, 'unreadable' => 0, ]; $documentRoot = $_SERVER['DOCUMENT_ROOT'] ?? ''; $root = $documentRoot === '' ? false : realpath($documentRoot); $error = ''; $directory = false; $url = '/'; $path = str_replace('\\', '/', $siteDirectory); $decodedPath = rawurldecode($path); if ( !is_string($requestedPath) || strpos($decodedPath, "\0") !== false || preg_match('~(^|/)\.\.?(/|$)~', $decodedPath) || strpos($decodedPath, '\\') !== false ) { $error = 'The configured directory is unavailable.'; } else { $segments = explode('/', trim($decodedPath, '/')); $segments = array_values(array_filter($segments, static function ($segment) { return $segment !== ''; })); $url = $segments ? '/' . implode('/', array_map('rawurlencode', $segments)) . '/' : '/'; if ($root === false || !is_dir($root)) { $error = 'The website document root could not be resolved.'; } else { $directory = $root; foreach ($segments as $segment) { if ( $segment[0] === '.' || isset($settings['excludedDirectories'][strtolower($segment)]) ) { $error = 'The configured directory is unavailable.'; break; } $directory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $segment; if (is_link($directory) || !is_dir($directory)) { $error = 'The configured directory is unavailable.'; break; } } if ($error === '') { $realDirectory = realpath($directory); $rootPrefix = rtrim($root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if ( $realDirectory === false || ($realDirectory !== $root && !str_starts_with($realDirectory, $rootPrefix)) ) { $error = 'The configured directory is unavailable.'; } else { $directory = $realDirectory; } } } } if ($error !== '') { http_response_code(500); } header('Content-Type: text/html; charset=UTF-8'); ?> Sitemap for <?= ezmapEscape($siteDirectory) ?>

This Is The Current Sitemap For

Expand a folder to view its contents.

Files listed:
.htm files listed:
Image files found:
MP3 files listed:
MP4 files listed:
Subfolders listed: 0) { ?>
Unreadable folders:

0) { ?> FULLY Commented! getFilename(), $second->getFilename()) ?: strcmp($first->getFilename(), $second->getFilename()); } // Scan and display one directory. Each included subfolder calls this // function again. Every call updates the same running totals in $counts. function ezmapRender(string $directory, string $url, array $settings, array &$counts): void { $folders = []; $files = []; try { $entries = new FilesystemIterator($directory, FilesystemIterator::SKIP_DOTS); foreach ($entries as $entry) { $name = $entry->getFilename(); // Skip hidden entries and symbolic links. if ($name[0] === '.' || $entry->isLink()) { continue; } // Collect eligible folders for scanning after the files are shown. if ($entry->isDir()) { if (!isset($settings['excludedDirectories'][strtolower($name)])) { $folders[] = $entry; } continue; } // Skip anything other than a regular file and skip excluded names. if (!$entry->isFile() || isset($settings['excludedFiles'][strtolower($name)])) { continue; } // Treat uppercase and lowercase extensions alike, such as JPG and jpg. $extension = strtolower($entry->getExtension()); // Apply exclusions before counting or listing the file. if (isset($settings['excludedExtensions'][$extension])) { continue; } $isImage = isset($settings['imageExtensions'][$extension]); if ($isImage) { $counts['images']++; } // Include images and all other file types selected in the settings. if ($isImage || isset($settings['extensions'][$extension])) { $files[] = $entry; } } } catch (RuntimeException $exception) { // Report the unreadable folder and let the rest of the sitemap continue. $counts['unreadable']++; echo '

This directory could not be read.

'; return; } if (!$folders && !$files) { echo '

No matching files or subdirectories to list.

'; return; } // Sort each group so the files can appear before the folders. usort($files, 'ezmapSort'); usort($folders, 'ezmapSort'); echo ''; } // Turn the settings lists into lookup tables for the scan. $settings = [ 'extensions' => array_fill_keys(array_map('strtolower', $extensions), true), 'imageExtensions' => array_fill_keys($imageExtensions, true), 'excludedExtensions' => array_fill_keys(array_map('strtolower', $excludedExtensions), true), 'excludedDirectories' => array_fill_keys(array_map('strtolower', $excludedDirectories), true), 'excludedFiles' => array_fill_keys(array_map('strtolower', $excludedFiles), true), 'showDetails' => $showFileDetails, ]; // Start the running totals at zero for each page load. $counts = [ 'folders' => 0, 'files' => 0, 'htm' => 0, 'images' => 0, 'mp3' => 0, 'mp4' => 0, 'unreadable' => 0, ]; // ============================================================ // FIND AND VALIDATE THE DIRECTORY ON THE SERVER // ============================================================ // Resolve paths from the website root, even if sitemap.php is in /common/. $documentRoot = $_SERVER['DOCUMENT_ROOT'] ?? ''; $root = $documentRoot === '' ? false : realpath($documentRoot); $error = ''; $directory = false; $url = '/'; // Normalize slashes and decode the requested path before checking it. $path = str_replace('\\', '/', $siteDirectory); $decodedPath = rawurldecode($path); // Reject invalid input and path segments that could navigate up a directory. if ( !is_string($requestedPath) || strpos($decodedPath, "\0") !== false || preg_match('~(^|/)\.\.?(/|$)~', $decodedPath) || strpos($decodedPath, '\\') !== false ) { $error = 'The configured directory is unavailable.'; } else { // Break the path into folder names and discard empty segments. $segments = explode('/', trim($decodedPath, '/')); $segments = array_values(array_filter($segments, static function ($segment) { return $segment !== ''; })); // Build the website URL used as the starting point for clickable links. $url = $segments ? '/' . implode('/', array_map('rawurlencode', $segments)) . '/' : '/'; if ($root === false || !is_dir($root)) { $error = 'The website document root could not be resolved.'; } else { $directory = $root; // Check every folder in the requested path against the exclusions. foreach ($segments as $segment) { if ( $segment[0] === '.' || isset($settings['excludedDirectories'][strtolower($segment)]) ) { $error = 'The configured directory is unavailable.'; break; } $directory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $segment; // Each segment must be an existing directory. Skip symbolic links. if (is_link($directory) || !is_dir($directory)) { $error = 'The configured directory is unavailable.'; break; } } // Confirm the final directory is the website root or is inside it. if ($error === '') { $realDirectory = realpath($directory); $rootPrefix = rtrim($root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if ( $realDirectory === false || ($realDirectory !== $root && !str_starts_with($realDirectory, $rootPrefix)) ) { $error = 'The configured directory is unavailable.'; } else { $directory = $realDirectory; } } } } // Send the response status and character encoding before printing HTML. if ($error !== '') { http_response_code(500); } header('Content-Type: text/html; charset=UTF-8'); ?> Sitemap for <?= ezmapEscape($siteDirectory) ?>

This Is The Current Sitemap For

Expand a folder to view its contents.

Files listed:
.htm files listed:
Image files found:
MP3 files listed:
MP4 files listed:
Subfolders listed: 0) { ?>
Unreadable folders:

0) { ?>