This blob has been accessed 352 times via Git panel.
- <?php
- error_reporting(E_ERROR);
- $dir = "data/items";
- if ($dh_sitemap_items = opendir($dir)) {
- while (($entry_sitemap_items = readdir($dh_sitemap_items)) !== false) {
- $cat_dir = file_get_contents("data/items/$entry_sitemap_items/category.txt");
- if (file_exists("data/categories/$cat_dir/private.txt") and !file_exists("data/items/$entry_sitemap_items/cat.txt")) {
- continue;
- }
- if ($entry_sitemap_items != "." && $entry_sitemap_items != ".." && fnmatch("*", $entry_sitemap_items) && !file_exists("data/items/$entry_sitemap_items/private.txt")) {
- $show_sitemap_items[] = $entry_sitemap_items;
- }
- }
- closedir($dh_sitemap_items);
- }
- rsort($show_sitemap_items);
- reset($show_sitemap_items);
- $count_sitemap_items = count($show_sitemap_items);
- if ($count_sitemap_items > 0) {
- $sitemap_count = $sitemap_count + 1;
- header('Content-type: application/xml');
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- echo "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">\n";
- $increment_sitemap_entries = 0;
- while ($increment_sitemap_entries <= ($count_sitemap_items - 1)) {
- echo "<url>\n";
- $link = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php?entry=$show_sitemap_items[$increment_sitemap_entries]";
- $fix_link = array('//index.php', '///index.php');
- $link = str_replace($fix_link, '/index.php', $link);
- $link = trim($link);
- echo "<loc>$link</loc>\n";
- echo "<lastmod>";
- // This is supposed to work, but Google keeps saying the time format is invalid. Oh well...
- // $lastmod = date("Y-m-d\TH:i:s", filemtime("$dir/$show_sitemap_items[$increment_sitemap_entries]/body.txt"));
- // $timezone = str_replace("00", ":00", date("O", filemtime("$dir/$show_sitemap_items[$increment_sitemap_entries]/body.txt")));
- // $timezone = str_replace(":00:00", "00:00", $timezone);
- // echo $lastmod . $timezone;
- $lastmod = date("Y-m-d", filemtime("$dir/$show_sitemap_items[$increment_sitemap_entries]/body.txt"));
- echo $lastmod;
- echo "</lastmod>\n";
- echo "<priority>0.5</priority>\n";
- echo "</url>\n";
- $increment_sitemap_entries = $increment_sitemap_entries + 1;
- }
- echo "</urlset>";
- }
- ?>