PHPBB生成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>';
?>
-
用PHP實現文件上傳二法
PHP(HypertextPreprocessor)是一種HTML內嵌式的語言(類似IIS上的ASP)。而PHP獨特的語法混合了C、Java、Perl以及PHP式的新語法。它可以比CGI或者Perl更快速的執行動態網頁。除此之外,用PHP寫出來的Web後端CGI程序,可以很輕易的移植到不同的系統平台上。我們在做...
-
PHP常用開發技巧
PHP開發常用技巧能使你在開發過程中快而有效.以下就是小編精心推薦PHP常用開發技巧,希望對大家有幫助!1使用dowhile避免多層if語句嵌套我們直接舉例説明:實現方式①if($name=='hedong'){if($sex=='male'){if($major=='PHP'){$ret='...
-
PHP程序員基本要求和必備技能
PHP程序員有什麼必備知識呢?以下是本站小編精心為大家整理的PHP程序員基本要求和必備技能,希望對大家成為程序員有所幫助!更多內容請關注應屆畢業生網!一名PHP程序員的基本要求:1、精通html、CSS、JS等網站前端技術。2、掌握PHP編程技術。3、瞭解Linux及Apache、...
-
tp搜索時首頁分頁和搜索頁保持條件分頁的方法
在做搜索查詢時突然發現在首頁用的`分頁代碼在搜索頁使用時出現錯誤,首頁分頁代碼(代碼中標註start與end部分為分頁代碼),下面是由本站小編為大家整理的Thinkphp搜索時首頁分頁和搜索頁保持條件分頁的方法,喜歡的可以收藏一下!瞭解更多詳情資訊,請關注應屆畢業生...