PHP中BB生成sitemap地圖文件的方法
本文介紹下,在PHPBB論壇中生成sitemap地圖文件的實現代碼,感興趣的朋友參考學習下。
將以下PHP文件放到網站的根目錄。
加入此sitemap的前提:
必須將PHPBB論壇的默認URL規格改成以下文件裏生成的'格式。
具體方法,請參考:
注意:
紅色部分的代碼,修改成自己網站對應的內容:
複製代碼 代碼示例:
<?php
// By: Arlinger On 2012-6-4
//
// CUSTOM INSTALLATION VARIABLES:
$subdomain='www.';
$domain=' '; //這裏要改成你的網站名
$folder='/forum/'; //這裏要改成你把博客所在的文件夾的名字
$urls=50000;
// Change Nothing Below Here:
$domainpath='http://'.$subdomain.$domain.$folder;
// Connect
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'config.' . $phpEx);
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
$db = new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
// Gzip compression
if (@extension_loaded('zlib') && !headers_sent())
{
ob_start('ob_gzhandler');
}
// Send Header
header("Content-Type: text/xml;charset=iso-8859-1");
// Send initial Data
echo '<?xml version="1.0" encoding="UTF-8"?>'."n";
echo '<urlset xmlns="">'."n";
// Send Index
$current_time=time();
echo '<url>
<loc>'.$domainpath.'</loc>
<lastmod>'("Y-m-dTH:i:sP",$current_time).'</lastmod>
</url>';
$urls=$urls-1;
// Send Forums
$sql = 'SELECT forum_id, forum_last_post_time FROM '.$table_prefix.'forums WHERE enable_indexing=1 LIMIT '.$urls;
$result = $db->sql_query($sql);
while ($data=$db->sql_fetchrow($result)) {
// Fix for parents forums showing 1969
if ($data['forum_last_post_time'] == 0) {
$data['forum_last_post_time']=$current_time;}
echo '<url>
<loc>'.$domainpath.'viewforum-'.$data['forum_id'].''.'</loc>
<lastmod>'("Y-m-dTH:i:sP",$data['forum_last_post_time']).'</lastmod>
</url>';
$urls=$urls-1;
}
$db->sql_freeresult($result);
// Send Topics
$sql = 'SELECT * FROM '.$table_prefix.'topics as t, '.$table_prefix.'forums as f WHERE c_approved=1 AND m_id=m_id AND le_indexing=1 ORDER BY c_id DESC LIMIT '.$urls;
$result = $db->sql_query($sql);
while ($data=$db->sql_fetchrow($result)) {
echo '<url>
<loc>'.$domainpath.'viewtopic-'.$data['topic_id'].''.'</loc>
<lastmod>'("Y-m-dTH:i:sP",$data['topic_last_post_time']).'</lastmod>
</url>';
}
$db->sql_freeresult($result);
// Send Closing Tags
echo ' </urlset>';
?>
相關文章
-
PHPBB生成sitemap地圖文件的方法
本文介紹下,在PHPBB論壇中生成sitemap地圖文件的實現代碼,感興趣的朋友參考學習下。就跟隨本站小編一起去了解下吧,想了解更多相關信息請持續關注我們應屆畢業生考試網! 將以下PHP文件放到網站的根目錄。加入此sitema -
PHP生成SiteMap文件代碼的方法
分享一例php生成sitemap地圖文件的代碼,用於生成google sitemap地圖,有需要的'朋友參考學習下。例子:複製代碼 代碼示例:<?php/*** 生成sitemap文件* 平常在用的一段代碼,分享給大家* edit: */require_once(''); -
php自動生成sitemap地圖的代碼
計劃是管理的一項重要職能,任何組織中的各項管理活動都離不開計劃。下面是本站小編爲您精心整理的地理教師優秀的學期工作計劃。地理教師優秀的學期工作計劃1一、教育教學目標:(1)德育目標:通過本期的地理學習,讓學生形成 -
php自動生成sitemap地圖代碼
如何生成sitemap地圖呢?本文分享一例php代碼,用於自動動態生成最新的sitemap地圖文件,並通知google網站地圖的'更新,感興趣的朋友參考下吧。本節內容:php自動生成sitemap地圖例子,:主要生成sitemap的類。代碼:複製代碼 代碼 -
php自動生成sitemap地圖的代碼大綱
如何生成sitemap地圖呢?本文分享一例php代碼,用於自動動態生成最新的`sitemap地圖文件,並通知google網站地圖的更新,感興趣的朋友參考下吧。內容:php自動生成sitemap地圖例子,:主要生成sitemap的類。代碼:複製代碼 代碼示例:< -
PHP生成SiteMap文件的代碼
一、全冊教學分析 1、 教材名稱、版本: 義務教育課程標準實驗教科書 數學 五年級(上 ) 2、全冊教材簡析: 本冊教材共編排了十個單元的教學內容。在“數與代數”領域教學負數的初步知識、小數的意義與性質、小數的四則計算,結 -
php sitemap文件生成器代碼
本文分享一例php生成sitemap文件的代碼,一個簡單的google sitemap文件生成器代碼,有需要的朋友參考下。就跟隨小編去了解下吧,想了解更多相關信息請 持續關注我們應屆畢業生考試網!php sitemap文件生成器例子:複製代碼 代 -
php安裝xdebug/pear/phpunit圖文詳解
首先,本文是基於wamp環境的基礎上的,所以,如果您看到這裏還沒有搭建好wamp環境的話,介意您先把環境搭建好,因爲這裏都是一些實踐性的內容。1.準備wamp環境中,我使用的各個軟件的版本如下windows 2003 Standard Edition SP2 -
Chimp Cops Arbitrate Disputes美文欣賞
It sounds like the premise for a bad police drama, maybe NYPD Chimp. But scientists have found that high-ranking chimpanzees can act like cops: intervening to settle public disputes. The study appears -
Why Public Speaking Is So Important 公共演說的重要性大學英語
Many students ask why they shouldlea to give speeches. They often argue that they don’t plan to bepoliticians, members of board, or company presidents. Students think that those are the only careers