Ec (2); PHP B3's Baidu sitemap builder code & lt ;? Php & nbsp; 02error_reporting (0); & nbsp; 03 define (IN_PHPBB, true); & nbsp; 04 $ phpbb_root_path .; & nbsp; 05 $ phpExsubstr (strrchr (_ FILE __,.), 1); & nbsp; 0 "script" ec (2); "script"
Code of Baidu sitemap generator of PHPBB3
02 error_reporting (0 );
03 define ('in _ phpbb', true );
04 $ phpbb_root_path = './';
05 $ phpEx = substr (strrchr (_ FILE __, '.'), 1 );
06
07 include ($ phpbb_root_path. 'config. '. $ phpEx );
08 include ($ phpbb_root_path. 'mongodes/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 <'4. 1.0 '){
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. =" $ Boardurl N ".
40" [Email] admin@phprimer.com [/email] N ".
41" 8 N ".
42" ". Gmdate ('Y-m-d H: I: s', $ timestamp + 8*3600 )." N ".
43" PHPrimer v0.1 N ";
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}