PHPBB3 Baidu Sitemap Generator Code

Source: Internet
Author: User
Tags generator

PHPBB3 Baidu Sitemap Generator Code
<?php

error_reporting (0);

Define (' In_phpbb ', true);

$phpbb _root_path = './';

$phpEx = substr (STRRCHR (__file__, '. '), 1);

06

Include $phpbb _root_path. ' Config. '. $PHPEX);

Include ($phpbb _root_path. ' includes/db/'. $dbms. '.' . $PHPEX);

09

$db = new $sql _db ();

11

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

13

if (Php_version < ' 4.1.0 ') {

$_get = & $HTTP _get_vars;

$_server = & $HTTP _server_vars;

17}

18

19

$maxitemnum = 500;

$timestamp = time ();

$PHP _self = $_server[' php_self ']? $_server[' php_self ']: $_server[' script_name '];

$boardurl = ' http://' $_server[' http_host '].substr ($PHP _self, 0, Strrpos ($PHP _self, '/') + 1);

24

$sitemapfile = $phpbb _root_path. /cache/baidu_sitemap.<span Class=t_tag onclick=tagshow (event) href= "Tag.php?name=xml" >xml</SPAN>;

echo $xmlfiletime = @filemtime ($sitemapfile);

27

Header ("Content-type:application/xml");

29

$xmlcontent = "<?xml version=" 1.0 "encoding=" Utf-8 ">n".

"<document xmlns:bbs=" "N" >http://www.baidu.com/search/bbs_sitemap.xsd ">n";

32

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

$xmlfiletime = $timestamp-8 * 3600;

35

$sql = ' SELECT * from '. $table _prefix ' topics WHERE topic_time > '. $xmlfiletime. ' LIMIT '. $maxitemnum;

Panax Notoginseng $result = $db->sql_query ($sql);

38

$xmlcontent. = "<webSite> $boardurl </website>n".

"<webmaster>[email]admin@phprimer.com[/email]</webmaster>n".

"<updateperi>8</updateperi>n".

"<updatetime>" gmdate (' y-m-d h:i:s ', $timestamp + 8 * 3600). " </updatetime>n ".

"<version>phprimer v0.1</version>n";

44

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

Print_r ($data);

$xmlcontent. = "<item>n".

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

"<title>" <span Class=t_tag onclick=tagshow (event) href= "tag.php?name=html" >html</sp An>specialchars ($data [' Topic_title ']). " </title>n ".

"<pubDate>" gmdate (' y-m-d h:i:s ', $data [' topic_time '] + 8 * 3600). " </pubdate>n ".

Wuyi "<bbs:lastDate>" gmdate (' y-m-d h:i:s ', $data [' Topic_last_<span class=t_tag onclick=tagshow (event) href= "Tag.php?name=post" >post</span>_time '] + 8 * 3600). " </bbs:lastdate>n ".

"<bbs:reply> $data [topic_replies]</bbs:reply>n".

"<bbs:hit> $data [topic_views]</bbs:hit>n".

"<bbs:boardid> $data [forum_id]</bbs:boardid>n".

"<bbs:pick>". (Intval ($data [' Topic_type '])? 1:0). " </bbs:pick>n ".

"</item>n";

57}

58

$xmlcontent. = "</document>";

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

Fwrite ($fp, $xmlcontent);

Flock ($FP, 2);

Fclose ($FP);

64}

65

The Echo $xmlcontent;

67

in} else {

69

@readfile ($sitemapfile);

71

72}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.