[外掛] 自動記錄發言人UserAgent

MODs Released by Other phpbb Sites
非官方認證通過之 MOD ,或許有安全性之疑慮,所有問題由原發表者回覆!

版主: 版主管理群

主題已鎖定
puhongyi
星球普通子民
星球普通子民
文章: 5
註冊時間: 2004-11-17 14:14

[外掛] 自動記錄發言人UserAgent

文章 puhongyi »

我的論壇因為有特殊需要需要記錄發言人的瀏覽器和系統標識,例如「Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.7.5) Gecko/20041124 Firefox/1.0」,但是在phpbb.com卻沒有找到這樣的MOD,於是便自己做了一個,現在整理了一下發表上來,希望能夠幫助需要的人。
示例網址:http://www.firefox.net.cn/newforum/viewtopic.php?t=1953

如果你遇到問題。歡迎與我聯繫。

代碼: 選擇全部

############################################################## 
## MOD Title: UserAgent MOD 
## MOD Author: puhongyi < puhongyi@gmail.com > www.firefox.net.cn
## MOD Description: Record UserAgent (記錄用戶瀏覽器及系統標識)
## MOD Version: 1.0.0 
## Example:http://www.firefox.net.cn/newforum/viewtopic.php?t=1953
## Installation Level: Easy 
## Installation Time: 2 Minutes 
## Files To Edit: includes/functions_post.php
##		  viewtopic.php
##		  templates\subSilver\viewtopic_body.tpl
## Included Files: (n/a) 
############################################################## 
############################################################## 
## MOD History: 
## 
##   2005-01-20 - Version 1.0.0 
##      - Initial Release 
##   
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##安裝之前請先備份你的論壇。
############################################################## 

#
#Mysql數據庫執行:
#
ALTER TABLE `phpbb_posts_text` ADD `user_agent` VARCHAR( 255 ) NOT NULL ;



#
#打開 includes/functions_post.php
#

#
#找到:--------------------------------------------------
#
$sql = ($mode != 'editpost') ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ($post_id, '$post_subject', '$bbcode_uid', '$post_message')" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '$post_message',  bbcode_uid = '$bbcode_uid', post_subject = '$post_subject' WHERE post_id = $post_id";

#
#替換為:------------------------------------------------
#

$UA=$_SERVER['HTTP_USER_AGENT'];
$sql = ($mode != 'editpost') ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text,USER_AGENT) VALUES ($post_id, '$post_subject', '$bbcode_uid', '$post_message','$UA' )" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '$post_message',  bbcode_uid = '$bbcode_uid', post_subject = '$post_subject' WHERE post_id = $post_id";

#
#打開 viewtopic.php
#

#
#找到:-------------------------------------------------
#
 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt

#
#替換為:-------------------------------------------------
#
 , pt.user_agent  FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt

#
#找到:------------------------------------------------
#
 'MESSAGE' => $message,

#
#之後加上:-------------------------------------------
#
'UA'=>htmlspecialchars($postrow[$i]['user_agent']),

#
#打開:templates\subSilver\viewtopic_body.tpl
#

#
#找到:---------------------------------------------
#
<td class="{postrow.ROW_CLASS}" width="100%" height="28" valign="bottom" nowrap="nowrap"><table cellspacing="0" cellpadding="0" border="0" height="18" width="18">

#
#替換為:--------------------------------------------
#
<td class="{postrow.ROW_CLASS}" width="100%" height="28" valign="bottom" nowrap="nowrap"><span class="gensmall" style='color: #9a9a9a;'>{postrow.UA}</span><table cellspacing="0" cellpadding="0" border="0" height="18" width="18">

#
#完畢。
#
主題已鎖定

回到「非官方認證外掛」