Sitemap time fix

Отображение времени в карте сайта согласно стандарта.
This commit is contained in:
Exile 2014-08-20 02:11:20 +04:00
commit b1933c1d79
2 changed files with 31 additions and 44 deletions

View file

@ -69,7 +69,7 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $do
// Version info
$bb_cfg['tp_version'] = '2.0.9 (RC)';
$bb_cfg['tp_release_date'] = '19-08-2014';
$bb_cfg['tp_release_date'] = '20-08-2014';
$bb_cfg['tp_release_state'] = 'R596';
// Database

View file

@ -2,12 +2,12 @@
class sitemap
{
var $home = "";
var $home = '';
var $limit = 0;
var $topic_priority = "0.5";
var $stat_priority = "0.5";
var $priority = "0.6";
var $cat_priority = "0.7";
var $topic_priority = '0.5';
var $stat_priority = '0.5';
var $priority = '0.6';
var $cat_priority = '0.7';
function sitemap () {
global $bb_cfg;
@ -16,7 +16,6 @@ class sitemap
function build_map () {
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$map .= $this->get_static();
$map .= $this->get_forum();
$map .= $this->get_topic();
@ -26,16 +25,13 @@ class sitemap
}
function build_index ($count) {
$lm = date('c');
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$lastmod = date("Y-m-d");
$map .= "<sitemap>\n<loc>{$this->home}sitemap/sitemap1.xml</loc>\n<lastmod>{$lastmod}</lastmod>\n</sitemap>\n";
$map .= "<sitemap>\n<loc>{$this->home}sitemap/sitemap1.xml</loc>\n<lastmod>{$lm}</lastmod>\n</sitemap>\n";
for ($i = 0; $i < $count; $i++) {
$t = $i + 2;
$map .= "<sitemap>\n<loc>{$this->home}sitemap/sitemap{$t}.xml</loc>\n<lastmod>{$lastmod}</lastmod>\n</sitemap>\n";
$map .= "<sitemap>\n<loc>{$this->home}sitemap/sitemap{$t}.xml</loc>\n<lastmod>{$lm}</lastmod>\n</sitemap>\n";
}
$map .= "</sitemapindex>";
return $map;
@ -43,7 +39,6 @@ class sitemap
function build_stat () {
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$map .= $this->get_static();
$map .= $this->get_forum();
$map .= "</urlset>";
@ -53,7 +48,6 @@ class sitemap
function build_map_topic ($n) {
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$map .= $this->get_topic($n);
$map .= "</urlset>";
@ -64,16 +58,15 @@ class sitemap
global $datastore;
$this->priority = $this->cat_priority;
$xml = "";
$lastmod = date( "Y-m-d" );
$xml = '';
$lm = date('c');
if (!$forums = $datastore->get('cat_forums'))
{
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$not_forums_id = $forums['not_auth_forums']['guest_view'];
$not_forums_id = $forums['not_auth_forums']['guest_view'];
$ignore_forum_sql = ($not_forums_id) ? "WHERE forum_id NOT IN($not_forums_id)" : '';
$sql = DB()->sql_query("SELECT forum_id, forum_topics, forum_parent, forum_name FROM " . BB_FORUMS . " " . $ignore_forum_sql . " ORDER BY forum_id ASC");
@ -81,7 +74,7 @@ class sitemap
while ($row = DB()->sql_fetchrow($sql)) {
if (function_exists('seo_url')) $loc = $this->home . seo_url(FORUM_URL . $row['forum_id'], $row['forum_name']);
else $loc = $this->home . FORUM_URL . $row['forum_id'];
$xml .= $this->get_xml( $loc, $lastmod );
$xml .= $this->get_xml($loc, $lm);
}
return $xml;
@ -90,7 +83,7 @@ class sitemap
function get_topic ($page = false) {
global $datastore;
$xml = "";
$xml = '';
$this->priority = $this->topic_priority;
if ($page) {
@ -102,7 +95,7 @@ class sitemap
if ($this->limit) {
$this->limit = " LIMIT 0," . $this->limit;
} else {
$this->limit = "";
$this->limit = '';
}
}
@ -114,12 +107,12 @@ class sitemap
$not_forums_id = $forums['not_auth_forums']['guest_view'];
$ignore_forum_sql = ($not_forums_id) ? "WHERE forum_id NOT IN($not_forums_id)" : '';
$sql = DB()->sql_query("SELECT topic_id, topic_title, topic_time FROM " . BB_TOPICS . " ".$ignore_forum_sql." ORDER BY topic_time DESC" . $this->limit);
$sql = DB()->sql_query("SELECT topic_id, topic_title, topic_time FROM " . BB_TOPICS . " " . $ignore_forum_sql . " ORDER BY topic_time ASC" . $this->limit);
while ($row = DB()->sql_fetchrow($sql)) {
if (function_exists('seo_url')) $loc = $this->home . seo_url(TOPIC_URL . $row['topic_id'], $row['topic_title']);
else $loc = $this->home . TOPIC_URL . $row['topic_id'];
$xml .= $this->get_xml($loc, date("Y-m-d", $row['topic_time']));
$xml .= $this->get_xml($loc, date('c', $row['topic_time']));
}
return $xml;
@ -128,8 +121,8 @@ class sitemap
function get_static () {
global $bb_cfg;
$xml = "";
$lastmod = date("Y-m-d");
$xml = '';
$lm = date('c');
$this->priority = $this->stat_priority;
if (isset($bb_cfg['static_sitemap'])) {
@ -137,12 +130,10 @@ class sitemap
preg_match_all('#(https?://[\w-]+[\.\w-]+/((?!https?://)[\w- ./?%&=])+)#', $static_url, $out);
$static_url = count($out['0']);
if ($static_url > 0)
{
foreach($out['0'] as $url)
{
if ($static_url > 0) {
foreach ($out['0'] as $url) {
$loc = $url;
$xml .= $this->get_xml($loc, $lastmod);
$xml .= $this->get_xml($loc, $lm);
}
}
}
@ -150,11 +141,10 @@ class sitemap
return $xml;
}
function get_xml ($loc, $lastmod) {
function get_xml ($loc, $lm) {
$xml = "\t<url>\n";
$xml .= "\t\t<loc>$loc</loc>\n";
$xml .= "\t\t<lastmod>$lastmod</lastmod>\n";
$xml .= "\t\t<lastmod>$lm</lastmod>\n";
$xml .= "\t\t<priority>" . $this->priority . "</priority>\n";
$xml .= "\t</url>\n";
@ -191,14 +181,12 @@ class sitemap
$pages_count = @ceil($row['count'] / 40000);
$sitemap = $this->build_index($pages_count);
$handler = fopen(BB_ROOT. "/sitemap/sitemap.xml", "wb+");
fwrite($handler, $sitemap);
fclose($handler);
@chmod(BB_ROOT. "/sitemap/sitemap.xml", 0666);
$sitemap = $this->build_stat();
$handler = fopen(BB_ROOT. "/sitemap/sitemap1.xml", "wb+");
fwrite($handler, $sitemap);
fclose($handler);
@ -216,7 +204,6 @@ class sitemap
}
} else {
$sitemap = $this->build_map();
$handler = fopen(BB_ROOT. "/sitemap/sitemap.xml", "wb+");
fwrite($handler, $sitemap);
fclose($handler);