首页 > 编程技术 > php

PHPBB3的百度sitemap生成器代码

发布时间:2016-11-25 15:59

PHPBB3的百度sitemap生成器代码
<?php 

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 . '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 < '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.<SPAN class=t_tag onclick=tagshow(event) href="tag.php?name=xml">xml</SPAN>'; 

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

27   

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

29   

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

31     "<document xmlns:bbs="http://www.baidu.com/search/bbs_sitemap.xsd">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 .= "    <webSite>$boardurl</webSite>n". 

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

41         "    <updatePeri>8</updatePeri>n". 

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

43         "    <version>PHPrimer v0.1</version>n"; 

44   

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

46         print_r($data); 

47         $xmlcontent .= "    <item>n". 

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

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

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

51             "        <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". 

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

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

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

55             "        <bbs:pick>".(intval($data['topic_type']) ? 1 : 0)."</bbs:pick>n". 

56             "    </item>n"; 

57     } 

58       

59     $xmlcontent .= "</document>"; 

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 301二级域名定义方法
<?php 

02 //本<SPAN class=t_tag onclick=tagshow(event) href="tag.php?name=%B3%CC%D0%F2">程序</SPAN>由 uit88 修改! 

03 $mydomin = $_SERVER['HTTP_HOST'];//获取输入的域名 

04 switch ($mydomin) { 

05     case ("www.023wo.com") : 

06         header('HTTP/1.1 301 Moved Permanently');//发出301头部信息    

07         header('Location: [url]http://www.023wo.com/wo'[/url]);  //跳转到相应域名目录  

08         break; 

09     case ("023wo.com") : 

10         header('HTTP/1.1 301 Moved Permanently');  

11         header('Location: [url]http://www.023wo.com/wo'[/url]); 

12         break; 

13     case ("www.sionwes.com") : 

14         header('HTTP/1.1 301 Moved Permanently'); 

15         header('Location: [url]http://www.sionwes.com/studio'[/url]); 

16         break; 

17     case ("sionwes.com") : 

18         header('HTTP/1.1 301 Moved Permanently');  

19         header('Location: [url]http://www.sionwes.com/studio'[/url]); 

20         break; 

21     case ("www.111cn.net") : 

22         header('HTTP/1.1 301 Moved Permanently');   

23         header('Location: [url]http://www.lansiru.com/siru'[/url]); 

24         break; 

25     case ("lansiru.com") : 

26         header('HTTP/1.1 301 Moved Permanently');  

27         header('Location: [url]http://www.lansiru.com/siru'[/url]); 

28         break; 

29 } 

30 ?>

域名whois查询函数[万网和新网]
function whois_hichina($domain) {
preg_match("|<pre>(.+?)</pre>|is", @file_get_contents('http://whois.hichina.com/cgi-bin/whois?domain='.$domain.''), $whois);

$whois[0] = str_replace('友情提示:按注册局要求,过期域名可能会处于注册商自动续费期阶段,您在此查询所看到的域名到期日仅供参考<br />请您<a href="http://www.net.cn/has_client/userlogon/user_logon1.asp" target="_blank" class="link_gl">进入会员区</a>查看该域名的实际到期时间,并请及时进行续费,谢谢!', '', ($whois[0]));//过滤掉此段文字


return $whois[0]);

}

//新网 whois (非新网提供,只是根据新网自身网站的url修改实现)
function whois_xinnet($domain) {
preg_match("|<div class="lyTableInfoWrap">(.+?)</div>|is", @file_get_contents('http://www.xinnet.cn/Modules/agent/serv/pages/domain_whois.jsp?domainNameWhois='.$domain.'&noCode=noCode'), $whois);

return $whois[0];
}
}

$_SERVER['PHP_SELF'] #当前正在执行脚本的文件名,与 document root相关。
$_SERVER['argv'] #传递给该脚本的参数。
$_SERVER['argc'] #包含传递给程序的命令行参数的个数(如果运行在命令行模式)。
$_SERVER['GATEWAY_INTERFACE'] #服务器使用的 CGI 规范的版本。例如,“CGI/1.1”。
$_SERVER['SERVER_NAME'] #当前运行脚本所在服务器主机的名称。
$_SERVER['SERVER_SOFTWARE'] #服务器标识的字串,在响应请求时的头部中给出。
$_SERVER['SERVER_PROTOCOL'] #请求页面时通信协议的名称和版本。例如,“HTTP/1.0”。
$_SERVER['REQUEST_METHOD'] #访问页面时的请求方法。例如:“GET”、“HEAD”,“POST”,“PUT”。
$_SERVER['QUERY_STRING'] #查询(query)的字符串。
$_SERVER['DOCUMENT_ROOT'] #当前运行脚本所在的文档根目录。在服务器配置文件中定义。
$_SERVER['HTTP_ACCEPT'] #当前请求的 Accept: 头部的内容。
$_SERVER['HTTP_ACCEPT_CHARSET'] #当前请求的 Accept-Charset: 头部的内容。例如:“iso-8859-1,*,utf-8”。
$_SERVER['HTTP_ACCEPT_ENCODING'] #当前请求的 Accept-Encoding: 头部的内容。例如:“gzip”。
$_SERVER['HTTP_ACCEPT_LANGUAGE']#当前请求的 Accept-Language: 头部的内容。例如:“en”。
$_SERVER['HTTP_CONNECTION'] #当前请求的 Connection: 头部的内容。例如:“Keep-Alive”。
$_SERVER['HTTP_HOST'] #当前请求的 Host: 头部的内容。
$_SERVER['HTTP_REFERER'] #链接到当前页面的前一页面的 URL 地址。
$_SERVER['HTTP_USER_AGENT'] #当前请求的 User_Agent: 头部的内容。
$_SERVER['HTTPS'] — 如果通过https访问,则被设为一个非空的值(on),否则返回off
$_SERVER['REMOTE_ADDR'] #正在浏览当前页面用户的 IP 地址。
$_SERVER['REMOTE_HOST'] #正在浏览当前页面用户的主机名。
$_SERVER['REMOTE_PORT'] #用户连接到服务器时所使用的端口。
$_SERVER['SCRIPT_FILENAME'] #当前执行脚本的绝对路径名。
$_SERVER['SERVER_ADMIN'] #管理员信息
$_SERVER['SERVER_PORT'] #服务器所使用的端口
$_SERVER['SERVER_SIGNATURE'] #包含服务器版本和虚拟主机名的字符串。
$_SERVER['PATH_TRANSLATED'] #当前脚本所在文件系统(不是文档根目录)的基本路径。
$_SERVER['SCRIPT_NAME'] #包含当前脚本的路径。这在页面需要指向自己时非常有用。
$_SERVER['REQUEST_URI'] #访问此页面所需的 URI。例如,“/index.html”。
$_SERVER['PHP_AUTH_USER'] #当 PHP 运行在 Apache 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的用户名。
$_SERVER['PHP_AUTH_PW'] #当 PHP 运行在 Apache 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的密码。
$_SERVER['AUTH_TYPE'] #当 PHP 运行在 Apache 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是认证的类型。

php简单留言板代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php简单留言板代码</title>
</head>

<body>
<table width="98%" border="0">
<form id="form1" name="form1" method="post" action="comment/comment.php?nid=21">
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">
      <label></label>
      <label>
      <textarea name="content" cols="40" rows="8" id="content"></textarea>
      </label>     
 </td>
  </tr>
  <tr>
    <td width="5%"><label>
      <input name="code" type="text" id="code" size="8" />
    </label></td>
    <td width="95%"><label><img" width=100% src="../inc/code/encode.php" onclick="javascript:this.src='../inc/code/encode.php';"  />    </label>
输入验证码</td>
  </tr>
  <tr>
    <td colspan="2"><input type="submit" name="Submit" value="提交评论" /></td>
  </tr>
  </form>
</table>
$content = PostGet('content',1);
$tel = PostGet('tel',1);
$cname = PostGet('mail',1);
//$ip = getRealIp();

if( mb_strlen( $content ) > 100 || mb_strlen( $content )<5 )
{
 MessAge('留言内容长度5-100字符');
}
else if( strlen($tel) <5 && strlen( $tel )>15 )
{
 MessAge('联系电话错误!');
}
else if(!preg_match("/^([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})$/",$cname))
{
 MessAge('输入正确的邮箱地址!');
}
else
{
 
 $date = date("Y-m-d H:i:s");
 $Db = new Db();
 $sql = "Insert into cn_loupan_news_comment(nid,content,datetime,cname,ip) values('0','$content','$date','$cname','$tel')";
  try{
   $Db->query( $sql );
   MessAge('谢谢你的建议,我们将尽快处理...!','/Complaints.php');
  }catch (Execption $e ){
   MessAge('发送信息失败!');
  }
}

function PostGet($str,$post=0)
 {
  empty($str)?die('para is null'.$str.'!'):'';
  if( $post )
  {
   return addslashes(htmlspecialchars(isset($_POST[$str])?$_POST[$str]:''));
  }
  else
  {
   return addslashes(htmlspecialchars(isset($_GET[$str])?$_GET[$str]:''));   
  }
 }
?>
</body>
</html>

标签:[!--infotagslink--]

您可能感兴趣的文章: