This blob has been accessed 392 times via Git panel.
- <?php
- error_reporting(E_ERROR);
- if (file_exists("data/offset.txt")) {
- $offset = file_get_contents("data/offset.txt");
- }
- else {
- $offset = 0;
- }
- $dir = "data/items";
- if ($dh_sitemap_items = opendir($dir)) {
- while (($entry_sitemap_items = readdir($dh_sitemap_items)) !== false) {
- if (($entry_sitemap_items > $today) and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
- continue;
- }
- if (file_exists("data/items/$entry_sitemap_items/private.txt")) {
- continue;
- }
- if (file_exists("data/items/$entry_sitemap_items/member.txt")) {
- continue;
- }
- $private = "0";
- if (file_exists("data/items/$entry_sitemap_items/categories")) {
- if ($dh_cat_rss = opendir("data/items/$entry_sitemap_items/categories")) {
- while (($entry_cat_rss = readdir($dh_cat_rss)) !== false) {
- if ($entry_cat_rss != "." && $entry_cat_rss != "..") {
- if (file_exists("data/categories/$entry_cat_rss/private.txt")) {
- $private = $private + 1;
- }
- }
- }
- closedir($dh_cat_rss);
- }
- }
- if (($private > 0) and !file_exists("data/items/$entry_sitemap_items/cat.txt")) {
- continue;
- }
- if ($entry_sitemap_items != "." && $entry_sitemap_items != "..") {
- $show_sitemap_items[] = $entry_sitemap_items;
- }
- }
- closedir($dh_sitemap_items);
- }
- rsort($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>";
- }
- ?>