Example #1
0
define('PUN_ROOT', dirname(__FILE__) . '/');
require PUN_ROOT . 'include/common.php';
//
// CONFIGURATION BEGINS HERE
//
// false = write to file, true = dynamic
define('GENERATE_DYNAMIC_SITEMAP', true);
// This only matters if you're writing to the file
define('STATIC_SITEMAP_FILENAME', PUN_ROOT . 'sitemap.xml');
//
// CONFIGURATION ENDS HERE
//
if (GENERATE_DYNAMIC_SITEMAP) {
    $generator = new DynamicSitemapGenerator();
} else {
    $generator = new StaticSitemapGenerator(STATIC_SITEMAP_FILENAME);
}
$generator->addUrl(get_base_url() . '/', time(), null, '1.0');
// Output the data for the forums
$result = $db->query('SELECT f.id as forum_id, f.forum_name, last_post, num_topics FROM ' . $db->prefix . 'forums AS f LEFT JOIN ' . $db->prefix . 'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY f.id DESC') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
while ($cur_forum = $db->fetch_assoc($result)) {
    $generator->addUrl(get_base_url() . '/' . fluxrewrite("forum-", $cur_forum['forum_id'], $cur_forum['forum_name'], 1, false, false), $cur_forum['last_post'], null, '0.5');
    $num_pages = ceil($cur_forum['num_topics'] / $pun_config['o_disp_topics_default']);
    // Add page number for subsequent pages
    for ($i = 2; $i <= $num_pages; ++$i) {
        $generator->addUrl(get_base_url() . '/forum-' . $cur_forum['forum_id'] . '-' . clean_url($cur_forum['forum_name']) . '-page-' . $i . '.html', $cur_forum['last_post'], null, '0.5');
    }
}
// Output the data for the topics
$result = $db->query('SELECT t.id as topic_id, t.subject, last_post, sticky, num_replies FROM ' . $db->prefix . 'topics AS t LEFT JOIN ' . $db->prefix . 'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL ORDER BY last_post DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
while ($cur_topic = $db->fetch_assoc($result)) {
define('PUN_ROOT', './');
require PUN_ROOT . 'include/common.php';
//
// CONFIGURATION BEGINS HERE
//
// false = write to file, true = dynamic
define('GENERATE_DYNAMIC_SITEMAP', true);
// This only matters if you're writing to the file
define('STATIC_SITEMAP_FILENAME', PUN_ROOT . 'sitemap.xml');
//
// CONFIGURATION ENDS HERE
//
if (GENERATE_DYNAMIC_SITEMAP) {
    $generator = new DynamicSitemapGenerator();
} else {
    $generator = new StaticSitemapGenerator(STATIC_SITEMAP_FILENAME);
}
$generator->addUrl($pun_config['o_base_url'] . '/', time(), null, '1.0');
// Output the data for the forums
$result = $db->query('SELECT f.id as forum_id, last_post, num_topics FROM ' . $db->prefix . 'forums AS f LEFT JOIN ' . $db->prefix . 'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY f.id DESC') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
while ($cur_forum = $db->fetch_assoc($result)) {
    $generator->addUrl($pun_config['o_base_url'] . '/viewforum.php?id=' . $cur_forum['forum_id'], $cur_forum['last_post'], null, '0.5');
    $num_pages = ceil($cur_forum['num_topics'] / $pun_config['o_disp_topics_default']);
    // Add page number for subsequent pages
    for ($i = 2; $i <= $num_pages; ++$i) {
        $generator->addUrl($pun_config['o_base_url'] . '/viewforum.php?id=' . $cur_forum['forum_id'] . '&p=' . $i, $cur_forum['last_post'], null, '0.5');
    }
}
// Output the data for the topics
$result = $db->query('SELECT t.id as topic_id, last_post, sticky, num_replies FROM ' . $db->prefix . 'topics AS t LEFT JOIN ' . $db->prefix . 'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL ORDER BY last_post DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
while ($cur_topic = $db->fetch_assoc($result)) {