首页 > php教程 > PHP源码 > 正文

PHPBB3的百度sitemap生成器代码

php中文网
发布: 2016-06-08 17:28:47
原创
2618人浏览过
<script>ec(2);</script>

PHPBB3的百度sitemap生成器代码

02 error_reporting(0); 

03 define('IN_PHPBB', true); 

04 $phpbb_root_path = './'; 

05 $phpEx = substr(strrchr(__FILE__, '.'), 1); 

06   

立即学习PHP免费学习笔记(深入)”;

07 include($phpbb_root_path . 'config.' . $phpEx); 

08 include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); 

09   

10 $db = new $sql_db(); 

11   

12 $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); 

13   

14 if(PHP_VERSION

15     $_GET = &$HTTP_GET_VARS; 

16     $_SERVER = &$HTTP_SERVER_VARS; 

17 } 

18   

19   

20 $maxitemnum = 500; 

21 $timestamp = time(); 

22 $PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; 

23 $boardurl = 'http://'.$_SERVER['HTTP_HOST'].substr($PHP_SELF, 0, strrpos($PHP_SELF, '/') + 1); 

24   

25 $sitemapfile = $phpbb_root_path.'./cache/baidu_sitemap.xml'; 

26 echo $xmlfiletime = @filemtime($sitemapfile); 

27   

28 header("Content-type: application/xml"); 

29   

30 $xmlcontent = "n". 

31     "n"; 

32   

33 if($timestamp - $xmlfiletime >= 8 * 3600) { 

34     $xmlfiletime = $timestamp - 8 * 3600; 

35   

36     $sql = 'SELECT * FROM '.$table_prefix.'topics WHERE topic_time > '.$xmlfiletime.' LIMIT '.$maxitemnum; 

37     $result = $db->sql_query($sql); 

38   

39     $xmlcontent .= "    $boardurln". 

40         "    [email]admin@phprimer.com[/email]n". 

41         "    8n". 

42         "    ".gmdate('Y-m-d H:i:s', $timestamp + 8 * 3600)."n". 

43         "    PHPrimer v0.1n"; 

44   

45     while ($data=$db->sql_fetchrow($result)) { 

46         print_r($data); 

47         $xmlcontent .= "    n". 

48             "        {$boardurl}viewforum.php?f={$data['forum_id']}&t={$data['topic_id']}n". 

49             "       

".<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=html">html</span>specialchars($data['topic_title'])."n". 

50             "        ".gmdate('Y-m-d H:i:s', $data['topic_time'] + 8 * 3600)."n". 

51             "        ".gmdate('Y-m-d H:i:s', $data['topic_last_post_time'] + 8 * 3600)."n". 

52             "        $data[topic_replies]n". 

53             "        $data[topic_views]n". 

54             "        $data[forum_id]n". 

55             "        ".(intval($data['topic_type']) ? 1 : 0)."n". 

56             "    n"; 

57     } 

58       

59     $xmlcontent .= ""; 

60     if($fp = @fopen($sitemapfile, 'w')) { 

61         fwrite($fp, $xmlcontent); 

62         flock($fp, 2); 

63         fclose($fp); 

64     } 

65       

66     echo $xmlcontent; 

67       

68 } else { 

69       

70     @readfile($sitemapfile); 

71       

72 }

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号