接上級(jí)要求論壇需要記錄用戶的源端口信息,現(xiàn)將實(shí)現(xiàn)該功能的方法貼上來(lái)以供參考,先說(shuō)明一下我測(cè)試的環(huán)境是Disciz X3.
一、簡(jiǎn)單的插件安裝法
進(jìn)論壇管理后臺(tái)依次點(diǎn)擊“應(yīng)用” 應(yīng)用中心,在應(yīng)用中心中搜索日志,本人安裝的是 dzsup用戶登錄日志(該日志僅記錄用戶登錄的信息,上級(jí)安裝發(fā)貼也要有記錄).
還有一個(gè)是“端口日志” 該插件只記錄發(fā)貼的IP和端口(上級(jí)要求記錄用戶登錄的源端口)所以這兩個(gè)都安裝就可以了.
二、有權(quán)限的用戶可以修改數(shù)據(jù)庫(kù)、程序、以及模板來(lái)自己設(shè)置,因?yàn)槟壳斑@兩個(gè)插件還是免費(fèi)的,但如果收費(fèi)的話我們就要另想辦法、要不就出錢購(gòu)買.
步驟如下:
1、修改數(shù)據(jù)庫(kù)
a.增加會(huì)員狀態(tài)表字段,端口IP端口、最后訪問(wèn)端口、類型CHAR 長(zhǎng)度 6
- ALTER TABLE `pre_common_member_status` ADD `regipport` CHAR( 6 ) NOT NULL DEFAULT '0' AFTER `lastip` ,
- ADD `lastipport` CHAR( 6 ) NOT NULL DEFAULT '0' AFTER `regipport`
b.增加帖子表字段、發(fā)貼時(shí)的端口
- ALTER TABLE `pre_forum_post` ADD `useport` CHAR( 6 ) NOT NULL DEFAULT '0' AFTER `useip`
2. 修改程序文件
2.1. 修改用戶注冊(cè)時(shí)的程序文件
source/class/tab/table_common_member.php 292行 搜索 'lastip' => (string) $Ip 下面增加兩行:
- 'regipport' => (int) $_SERVER['REMOTE_PORT'],
- 'lastipport' => (int) $_SERVER['REMOTE_PORT'],
2.2 source/class/class_member.php 121行
搜索:C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' =>TIMESTAMP, 'lastactivity' => TIMESTAMP));
改為:
- C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'],'lastipport'=>$_SERVER['REMOTE_PORT'], 'lastvisit' =>TIMESTAMP, 'lastactivity' => TIMESTAMP));
2.3 source/class/model/model_forum_post.php 139行 在 'status' => $status, 后面增加 'useport' => (int) $_SERVER['REMOTE_PORT'],改后為:
- $this->pid = insertpost(array(
- 'fid' => $this->forum['fid'],
- 'tid' => $this->thread['tid'],
- 'first' => '0',
- 'author' => $this->member['username'],
- 'authorid' => $this->member['uid'],
- 'subject' => $this->param['subject'],
- 'dateline' => $this->param['timestamp'] ? $this->param['timestamp'] : getglobal('timestamp'),
- 'message' => $this->param['message'],
- 'useip' => $this->param['clientip'] ? $this->param['clientip'] : getglobal('clientip'),
- 'invisible' => $pinvisible,
- 'anonymous' => $this->param['isanonymous'],
- 'usesig' => $usesig,
- 'htmlon' => $htmlon,
- 'bbcodeoff' => $bbcodeoff,
- 'smileyoff' => $smileyoff,
- 'parseurloff' => $parseurloff,
- 'attachment' => '0',
- 'status' => $status,
- 'useport' => (int) $_SERVER['REMOTE_PORT'], //Dusion 2013/6/25增加
- ));
2.4 source/class/model/model_forum_thread.php 同2.3 202行,代碼如下:
- $this->pid = insertpost(array(
- 'fid' => $this->forum['fid'],
- 'tid' => $this->tid,
- 'first' => '1',
- 'author' => $this->member['username'],
- 'authorid' => $this->member['uid'],
- 'subject' => $this->param['subject'],
- 'dateline' => $this->param['publishdate'],
- 'message' => $this->param['message'],
- 'useip' => $this->param['clientip'] ? $this->param['clientip'] : getglobal('clientip'),
- 'invisible' => $this->param['pinvisible'],
- 'anonymous' => $this->param['isanonymous'],
- 'usesig' => $this->param['usesig'],
- 'htmlon' => $this->param['htmlon'],
- 'bbcodeoff' => $this->param['bbcodeoff'],
- 'smileyoff' => $this->param['smileyoff'],
- 'parseurloff' => $this->param['parseurloff'],
- 'attachment' => '0',
- 'tags' => $this->param['tagstr'],
- 'replycredit' => 0,
- 'status' => $this->param['pstatus'],
- 'useport' => (int) $_SERVER['REMOTE_PORT'], //Dusion 2013/6/25增加 //Vevb.com
- ));
到此,程序部分就改完了,暫時(shí)還看不到效果.
3 修改模板文件
3.1 template/default/home/space_profile_body.htm 154 行:
- </em>$space[regip] 后面增加:<!--{if $space[regipport] != 0}-->$space[regipport]<!--{/if}-->
- </em>$space[lastip] 后面增加:<!--{if $space[lastipport] != 0}-->$space[lastipport]<!--{/if}-->
該文件是用戶詳細(xì)信息的模板.
3.2 template/default/forum/topicadmin_getip.htm 在<b>$member[useip] 后面增加:
<!--{if $member[useport] != 0}-->$member[useport]<!--{/if}-->
至此所有工作都完成了,下面上一些測(cè)試的結(jié)果圖片.
如果是管理員的話在用戶名下方的IP上點(diǎn)右鍵可以看到IP以及端口,該處的內(nèi)容是通過(guò) 修改程序來(lái)實(shí)現(xiàn)的,帖子下方的IP和端口(蓋著IP的地方)是通過(guò)插件來(lái)實(shí)現(xiàn)的.
該圖是管理員查看用戶的詳細(xì)資料時(shí)看到的信息 IP后跟著的就是端口號(hào)。
該圖是通過(guò)后臺(tái)安裝的插件用戶登錄日志1.0.1來(lái)看到的效果
希望對(duì)有用的人有幫助,目前端口日志1.1是臨時(shí)免費(fèi)時(shí)間,應(yīng)該還有一個(gè)多月如果要安裝的話就抓緊了,如果你是一個(gè)phper也可 以自己修改程序來(lái)實(shí)現(xiàn).
新聞熱點(diǎn)
疑難解答
圖片精選