<?php
/*
*
* @name googlesitemap.php v.1.0.0
* @package phpBB3
* @version $Id: googlesitemap.php,v 1.0 2006/11/27 22:29:16 ALEXIS Exp $
* @copyright (c) Canver Software
* @license
Open Source Initiative OSI - The GPL:Licensing | Open Source Initiative GNU Public License
*
*/
/**
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Begin Configuration Section
$CFG['exclude_forums'] = '';
$CFG['max_topics'] = '';
// End Configuration Section
// [+] define path
// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
$server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
if (!$script_name)
{
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
}
// Replace any number of consecutive backslashes and/or slashes with a single slash
// (could happen on some proxy setups and/or Windows servers)
$script_path = trim(dirname($script_name));
$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name;
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
{
$url .= ':' . $server_port;
}
$url .= $script_path;
// [-] define path
$output = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\n";
$output .= '<urlset xmlns="
http://www.google.com/schemas/sitemap/0.84">' . "\n";
// Exclude forums
$sql_where = '';
if ($CFG['exclude_forums'])
{
$exclude_forums = explode(',', $CFG['exclude_forums']);
foreach ($exclude_forums as $i => $id)
{
if ($id > 0)
{
$sql_where .= ' AND forum_id != ' . trim($id);
}
}
}
// SQL
$sql = 'SELECT forum_id, topic_id, topic_type, topic_time
FROM ' . TOPICS_TABLE . '
WHERE topic_status <> 2
AND topic_approved = 1
' . $sql_where . '
ORDER BY topic_time DESC';
$result = $db->sql_query_limit($sql, $CFG['max_topics']);
while( ($row = $db->sql_fetchrow($result)) && ($row['topic_id'] != '') )
{
$topic_id = $row['topic_id'];
$forum_id = $row['forum_id'];
/*$lastmodified = date('Y-m-d\TG:i:s+00:00', $row['topic_time']);*/
$lastmodified = date('Y-m-d', $row['topic_time']);
$viewtopic = append_sid("/viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']);
$priority = ( $row['topic_type'] == POST_STICKY || $row['topic_type'] == POST_ANNOUNCE ) ? '1.0' : '0.5';
$output .= "<url>\n";
$output .= "\t<loc>$url$viewtopic</loc>\n";
$output .= "\t<lastmod>$lastmodified</lastmod>\n";
$output .= "\t<changefreq>daily</changefreq>\n";
$output .= "\t<priority>$priority</priority>\n";
$output .= "</url>\n\n";
}
$output .= "</urlset>\n";
header('Content-type: application/xml');
echo $output;
?>