PheRum
Легенда
PHP Fatal error: Call to a member function get() on a non-object in sitemap.php on line 33
<?php
define('IN_PHPBB', true);
define('BB_ROOT', './');
include(BB_ROOT .'common.php');
include(INC_DIR .'functions_sitemap_fx.php');
$sitemap_config['sitemap_enable'] = true;
$sitemap_config['sitemap_cache_time'] = 60; // minutes
$sitemap_config['sitemap_priority_0'] = '1.0';
$sitemap_config['sitemap_priority_1'] = '0.9';
$sitemap_config['sitemap_priority_2'] = '0.8';
$sitemap_config['sitemap_priority_3'] = '0.7';
$sitemap_config['sitemap_freq_0'] = 'daily';
$sitemap_config['sitemap_freq_1'] = 'daily';
$sitemap_config['sitemap_freq_2'] = 'daily';
$sitemap_config['sitemap_freq_3'] = 'daily';
$sitemap_config['posts_per_page'] = 30;
if (!$sitemap_config['sitemap_enable'])
{
exit;
}
$url = make_url('/');
$last_forum_id = 0;
$user->session_start();
header("Content-Type: text/xml");
if (!$sitemap_index_file = CACHE('bb_cache')->get('sitemap_fx_index'))
{
$sitemap_index_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$sitemap_index_file .= "<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$sql = DB()->fetch_rowset("SELECT forum_id, forum_topics FROM ". BB_FORUMS);
foreach ($sql as $row)
{
if ($row['forum_id'] && ($row['forum_topics'] > 0))
{
sitemap_fx_forum((int) $row['forum_id']);
$sitemap_index_file .= "<sitemap>\n";
$sitemap_index_file .= "<loc>" . $url . "sitemap/" . $row['forum_id'] . ".xml</loc>\n";
$sitemap_index_file .= "<lastmod>" . bb_date(TIMENOW, '', '', 'false') . "</lastmod>\n";
$sitemap_index_file .= "</sitemap>\n";
$last_forum_id = $row['forum_id'];
}
}
if(!$bb_cfg['gzip_compress']) flush();
sitemap_fx_global((int) $last_forum_id);
$sitemap_index_file .= "<sitemap>\n";
$sitemap_index_file .= "<loc>" . $url . "sitemap/0.xml</loc>\n";
$sitemap_index_file .= "<lastmod>" . bb_date(TIMENOW, '', '', 'false') . "</lastmod>\n";
$sitemap_index_file .= "</sitemap>\n";
$sitemap_index_file .= "</sitemapindex>\n";
CACHE('bb_cache')->set("sitemap_fx_index", $sitemap_index_file, (60 * $sitemap_config['sitemap_cache_time']));
}
print $sitemap_index_file;
1: <br />
2: <b>Fatal error</b>: DB Error [includes/functions_sitemap_fx.php(27)] in <b>/includes/db/mysql.php</b> on line <b>803</b><br />
<?php
/**
* Generate sitemap
*/
function sitemap_fx_forum($forum_id)
{
global $sitemap_config;
$url = make_url('/');
$sitemap_file = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$sitemap_file .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$sql = DB()->fetch_rowset("SELECT topic_id, forum_id, topic_last_post_time, topic_type, topic_replies
FROM ". BB_TOPICS ."
WHERE forum_id = ". $forum_id);
foreach ($sql as $row)
{
$last_mod = bb_date($row['topic_last_post_time'], '', '' ,'false');
$pages = $row['topic_replies'] / $sitemap_config['posts_per_page'];
$pages = (int) $pages;
for ($i=0; $i<=$pages; $i++)
{
$sitemap_file .= "<url>\n";
if ($i == 0)
{
$sitemap_file .= "<loc>" . $url . "viewtopic.php?f=" . $row['forum_id'] . "&t=" . $row['topic_id'] . "</loc>\n";
}
else
{
$sitemap_file .= "<loc>" . $url . "viewtopic.php?f=" . $row['forum_id'] . "&t=" . $row['topic_id'] . "&start=" . $i * $sitemap_config['posts_per_page'] . "</loc>\n";
}
$sitemap_file .= "<lastmod>" . $last_mod . "</lastmod>\n";
switch ($row['topic_type'])
{
case POST_NORMAL:
$sitemap_file .= "<changefreq>" . $sitemap_config['sitemap_freq_0'] . "</changefreq>\n";
$sitemap_file .= "<priority>" . $sitemap_config['sitemap_priority_0'] . "</priority>\n";
break;
case POST_STICKY:
$sitemap_file .= "<changefreq>" . $sitemap_config['sitemap_freq_1'] . "</changefreq>\n";
$sitemap_file .= "<priority>" . $sitemap_config['sitemap_priority_1'] . "</priority>\n";
break;
case POST_ANNOUNCE:
$sitemap_file .= "<changefreq>" . $sitemap_config['sitemap_freq_2'] . "</changefreq>\n";
$sitemap_file .= "<priority>" . $sitemap_config['sitemap_priority_2'] . "</priority>\n";
break;
default:
$sitemap_file .= "<changefreq>" . $sitemap_config['sitemap_freq_0'] . "</changefreq>\n";
$sitemap_file .= "<priority>" . $sitemap_config['sitemap_priority_0'] . "</priority>\n";
}
$sitemap_file .= "</url>\n";
}
}
$sitemap_file .= "</urlset>\n";
$w=fopen("sitemap/$forum_id.xml",'w');
fwrite($w,$sitemap_file);
fclose($w);
}
function sitemap_fx_global($forum_id)
{
global $sitemap_config;
$url = make_url('/');
$sitemap_file = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$sitemap_file .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
$sql = DB()->fetch_rowset("SELECT topic_id, forum_id, topic_title, topic_last_post_time, topic_type, topic_replies
FROM ". BB_TOPICS ."
WHERE topic_type = ". POST_NORMAL);
foreach ($sql as $row)
{
$last_mod = bb_date($row['topic_last_post_time'], '', '', 'false');
$pages = $row['topic_replies'] / $sitemap_config['posts_per_page'];
$pages = (int) $pages;
for ($i=0; $i<=$pages; $i++)
{
$sitemap_file .= "<url>\n";
if ($i == 0)
{
$sitemap_file .= "<loc>" . $url . "viewtopic.php?f=" . $forum_id . "&t=" . $row['topic_id'] . "</loc>\n";
}
else
{
$sitemap_file .= "<loc>" . $url . "viewtopic.php?f=" . $forum_id . "&t=" . $row['topic_id'] . "&start=" . $i * $sitemap_config['posts_per_page'] . "</loc>\n";
}
$sitemap_file .= "<lastmod>" . $last_mod . "</lastmod>\n";
$sitemap_file .= "<changefreq>" . $sitemap_config['sitemap_freq_3'] . "</changefreq>\n";
$sitemap_file .= "<priority>" . $sitemap_config['sitemap_priority_3'] . "</priority>\n";
$sitemap_file .= "</url>\n";
}
}
$sql = DB()->fetch_rowset("SELECT forum_id FROM ". BB_FORUMS);
foreach ($sql as $row)
{
//if ($row['forum_type'] == 1)
//{
$sitemap_file .= "<url>\n";
$sitemap_file .= "<loc>" . $url . "/viewforum.php?f=" . $row['forum_id'] . "</loc>\n";
$sitemap_file .= "<lastmod>" . bb_date(TIMENOW, '', '', 'false') . "</lastmod>\n";
$sitemap_file .= "<changefreq>daily</changefreq>\n";
$sitemap_file .= "<priority>1</priority>\n";
$sitemap_file .= "</url>\n";
//}
}
$sitemap_file .= "</urlset>\n";
$w=fopen("sitemap/0.xml", 'w');
fwrite($w, $sitemap_file);
fclose($w);
}
Parse error: syntax error, unexpected $end in /sitemap.php on line 95