sorbetcms/sitemap.php

60 lines
1.7 KiB
PHP
Executable File

<?php
if (!defined('entry')) {
define('entry', true);
}
/* ===========================
Sorbet CMS - A PHP based tumblelog CMS forked from Gelato CMS
Sorbet CMS is a free software licensed under the GPL 3.0
=========================== */
?>
<?php
require('entry.php');
global $conf, $tumble, $db;
// Code modified from the one at http://paste.ubuntu-nl.org/44548/
header("Content-type: text/xml; charset=utf-8");
$isFeed = true;
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<?xml-stylesheet type=\"text/xsl\" href=\"".$conf->urlSorbet."/sitemap.xsl\"?>\n";
$rs = $tumble->getPosts(1);
?>
<!-- generator="Sorbet CMS" -->
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc><?php echo $conf->urlSorbet;?></loc>
<?php
if ($db->contarRegistros()>0) {
$register = $rs->fetch();
$formatedDate = gmdate("Y-m-d", strtotime($register["date"]));
echo "\n\t<lastmod>".$formatedDate."</lastmod>";
}
?>
<changefreq>hourly</changefreq>
<priority>0.9</priority>
</url>
<?php
$rs = $tumble->getPosts($tumble->getPostsNumber());
if ($db->contarRegistros()>0) {
while ($register = $rs->fetch()) {
$url = $tumble->getPermalink($register["id_post"]);
$formatedDate = gmdate("Y-m-d", strtotime($register["date"])); ?>
<url>
<loc><?php echo $url; ?></loc>
<lastmod><?php echo $formatedDate; ?></lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<?php
}
}
?>
</urlset>