[推薦] 紀錄會員的註冊 IP

Officially Approved MODs
由 phpBB Group 官方發展小組認證的 MOD!

版主: 版主管理群

版面規則
請注意!只有發表在 [2.0.x] MOD Database Releases 的外掛,才算是官方認證的外掛。
主題已鎖定
momoC
星球公民
星球公民
文章: 167
註冊時間: 2004-09-15 22:39
聯繫:

[推薦] 紀錄會員的註冊 IP

文章 momoC »

外掛名稱:Log IP Address on Registration
作  者:TerraFrost
功能描述:在使用者註冊時登記 IP 位址
版  本:1.0.0.a
困難程度:中等
所需時間:三分鐘

參考網址:http://www.phpbb.com/phpBB/viewtopic.ph ... er+control

可到原網址下載包裝,不過作者似乎在分享外掛後就沒有再做修改,那十頁的討論內容已經又有人增加了不少功能,有興趣的人可以自己去看看。下面我已經將所有我知道的修改,覺得不錯的功能全加了進來。如果各位照下面方式做的話,會有下面這些功能:

功能 1. 會員註冊時會在系統裡留下 IP (過去舊會員的 IP 保留為 0.0.0.0)
功能 2. 註冊後,使用者會看到您註冊使用的 IP 位址為:xxx.xxx.xxx.xxx
功能 3. 後台會新增顯示所有會員註冊 IP 位址的功能(未中文化,太忙 :-|

功能 1 部分:會員註冊時會在系統裡留下 IP (過去舊會員的 IP 保留為 0.0.0.0)

不會手動改資料庫的人,請先將下面這段程式碼以 db_update.php 為檔名存好,放在 phpbb 根目錄執行。資料庫就改好了。

代碼: 選擇全部

<?php
/***************************************************************************
 *                               db_update.php
 *                            -------------------
 *
 *   copyright            : ?003 Freakin' Booty ;-P & Antony Bailey
 *   project              : http://sourceforge.net/projects/dbgenerator
 *   Website              : http://freakingbooty.no-ip.com/ & http://www.rapiddr3am.net
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//


if( !$userdata['session_logged_in'] )
{
	$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
	header($header_location . append_sid("login.$phpEx?redirect=db_update.$phpEx", true));
	exit;
}

if( $userdata['user_level'] != ADMIN )
{
	message_die(GENERAL_MESSAGE, 'You are not authorised to access this page');
}


$page_title = 'Updating the database';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">';
echo '<tr><th>Updating the database</th></tr><tr><td><span class="genmed"><ul type="circle">';


$sql = array();
$sql[] = "ALTER TABLE " . $table_prefix . "users ADD user_regip CHAR(8) NOT NULL DEFAULT '0'";

for( $i = 0; $i < count($sql); $i++ )
{
	if( !$result = $db->sql_query ($sql[$i]) )
	{
		$error = $db->sql_error();

		echo '<li>' . $sql[$i] . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />';
	}
	else
	{
		echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>Successful</b></font></li><br />';
	}
}


echo '</ul></span></td></tr><tr><td class="catBottom" height="28">&nbsp;</td></tr>';

echo '<tr><th>Installation Complete</th></tr><tr><td><span class="genmed">Please be sure to delete this file now.<br />If you require any further assistance, please visit the <a href="http://www.phpbbhacks.com/forums">phpBBHacks.com Support Forums</a>.</span></td></tr>';
echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">Go back to your index page</a>.</span></td></table>';

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
這段程式是原作者的 install.txt 內容加上網友的建議修改:(此部分請直接照下面指示修改)

代碼: 選擇全部

##############################################################
## MOD Title: Log IP Address on Registration
## MOD Author: TerraFrost < N/A > (Jim Wigginton) 

http://www.frostjedi.com/phpbb
## MOD Description: Logs the IP address of users when they register.
## MOD Version: 1.0.0
##
## Installation Level: Intermediate
## Installation Time: 5 Minutes
##
## Files To Edit: 4
##      includes/usercp_register.php
##      admin/admin_users.php
##      templates/subSilver/admin/user_edit_body.tpl
##      language/lang_english/lang_admin.php
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for 

the
## latest version of this MOD. Downloading this MOD from other sites 

could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support 

for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
##     Although there are a number MODs out there that do this already, 

none of them
##     have been validated by the phpBB MOD Team.  This MOD attempts to 

fill this void.
##
##     Also, since I don't know who the first person to make a MOD like 

this was, I'll
##     just sorta credit Jarf with the idea:
##     http://www.phpbb.com/phpBB/viewtopic.php?t=28580
##
##     The latest version of this mod can be found here:
##     http://www.frostjedi.com/terra/scripts/phpbb/reg_ip.zip
##
##     For support / comments / whatever, visit here:
##     http://www.frostjedi.com/phpbb/viewforum.php?f=33
##
############################################################## 
## MOD History: 
##
##   2005-04-13 - Version 1.0.0
##      - initial release
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files 

Related To This MOD 
##############################################################
#
#-----[ SQL ]-------------------------------------------
#
ALTER TABLE phpbb_users ADD user_regip CHAR(8) NOT NULL DEFAULT '0';
(這行就是改資料庫,已經執行過 db_update.php 的話就不必理會這行}
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]------------------------------------------
# this is only a partial match
#
			$sql = "INSERT INTO " . USERS_TABLE . "
#
#-----[ IN-LINE FIND ]---------------------------------
\n#
 user_icq,
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
 user_regip,
#
#-----[ FIND ]------------------------------------------
# this is only a partial match
#
				VALUES ($user_id,
#
#-----[ IN-LINE FIND ]---------------------------------
#
 . "', '" . str_replace("\'", "''", $icq)
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
 . "', '" . $userdata['session_ip']
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_users.php
#
#-----[ FIND ]------------------------------------------
#
		$icq = $this_userdata['user_icq'];
#
#-----[ BEFORE, ADD ]-----------------------------------
#
		$user_regip = decode_ip($this_userdata['user_regip']);
#
#-----[ FIND ]------------------------------------------
#
\n			'YIM' => $yim,
#
#-----[ BEFORE, ADD ]-----------------------------------
#
			'USER_REGIP' => $user_regip,
#
#-----[ FIND ]------------------------------------------
#
			'L_ICQ_NUMBER' => $lang['ICQ'],
#
#-----[ BEFORE, ADD ]-----------------------------------
#
			'L_REGIP' => $lang['Registration_IP'],
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/user_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	<tr> 
	  <td class="catsides" colspan="2">&nbsp;</td>
	</tr>
	<tr> 
	  <th class="thSides" colspan="2">{L_PROFILE_INFO}</th>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_REGIP}: </span></td>
	  <td class="row2"><span class="gen">{USER_REGIP}</span></td>
	</tr>
#
#-----[ OPEN ]------------------------------------------
#
language/lang_chinese_traditional_taiwan/lang_admin.php
#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
$lang['Install_No_PCRE']
#
#-----[ AFTER, ADD ]------------------------------------
#
$lang['Registration_IP'] = '註冊 IP Address';
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM
網友建議修改下列部分,可讓既有會員(IP 為 0.0.0.0 者)在登入討論區時將登入 IP 記錄下來:(此部分請直接照下面指示修改)

代碼: 選擇全部

############################################################## 
## MOD Title: RecordIP if Zero mod by niko 
## MOD Author: niko < N/A > niko@pchat.mine.nu 
## MOD Description: If user_regip = null then update it at login 
## MOD Version: 1.0.0 
## 
## 
## Installation Level: Easy 
## Installation Time: 2 Minutes 
## 
## Files To Edit: 1 
## login.php 
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for 

the 
## latest version of this MOD. Downloading this MOD from other sites 

could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support 

for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: 
## 
## This will update user_regip on accounts that are null e.g 0.0.0.0 
## at log in. You may wish to optionally change your sites cookie name 
## so users will have to log-in the next time they connect to your site 
## 
## MOD Requires prior installation of TerraFrost's RegIP MOD 
## MOD Author: TerraFrost < N/A > (Jim Wigginton) 

http://www.frostjedi.com/phpbb 
## MOD Description: Logs the IP address of users when they register. 
## MOD Version: 1.0.0a 
## The latest version of this mod can be found here: 
## http://www.frostjedi.com/terra/scripts/phpbb/reg_ip.zip 
## 
## For support / comments / whatever, visit here: 
## http://www.frostjedi.com/phpbb/viewforum.php?f=33 
## 
############################################################## 
## MOD History: 
## 
## 2005-07-30 - Version 1.0.0 - initial release 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files 

Related To This MOD 
############################################################## 
# 
# 
\n#-----[ OPEN ]------------------------------------------ 
# 
login.php 
# 
#-----[ FIND ]------------------------------------------ 
# this is only a partial match 
# 
$sql = "SELECT user_id, 
# 
#-----[ IN-LINE FIND ]--------------------------------- 
# 
user_id, 
# 
#-----[ IN-LINE AFTER, ADD ]--------------------------- 
# 
user_regip, 
# 
#-----[ FIND ]------------------------------------------ 
# 
$session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, 

FALSE, 

$autologin, $admin); 
# 
#-----[ AFTER, ADD ]----------------------------------- 
# 
// Mod:RecordIPifZero mod by niko 
if ( ($row['user_regip']) == '0' ) 
{ 
// non zero user id should never happen 
if ( $row['user_id'] ) 
{ 
$sql = "UPDATE " . USERS_TABLE . " SET user_regip = '$user_ip' WHERE 

user_id = '" . 

$row['user_id'] . "'"; 
if ( !$db->sql_query($sql) ) 
{ 
message_die(CRITICAL_ERROR, "RecordIPifZero mod: Error during update of 

user_regip", 

"", __LINE__, __FILE__); 
} 
} 
} 
// end RecordIPifZero mod by niko 
# 
#-----[ SAVE/CLOSE ALL FILES ]-------------------------- 
# 
# EoM
功能 2 部分:註冊後,使用者會看到「您註冊使用的 IP 位址為:xxx.xxx.xxx.xxx」(此部分請直接照下面指示修改)

代碼: 選擇全部

-[ OPEN ]------------------------------------------ 
# 
includes/usercp_register.php 
# 
#-----[ FIND ]------------------------------------------ 
# 
$message = $lang['Account_added']; 
# 
#-----[ AFTER, ADD ]------------------------------------ 
# 
$message .= "<b>您註冊的 IP address 為:" . decode_ip($userdata

['session_ip']); 

功能 3 部分:後台會新增顯示所有會員註冊 IP 位址的功能(將下面兩段程式各別存檔,放到正確的子目錄下即可)

將下面這段程式碼存為 admin_user_ip.php,放入 phpbb/admin/ 子目錄中即可\r

代碼: 選擇全部

<?php 

define('IN_PHPBB', 1); 

if( !empty($setmodules) ) 
{ 
   $filename = basename(__FILE__); 
   $module['User Data']['User IP Addresses'] = $filename; 
   return; 
} 

$phpbb_root_path = "./../"; 
require($phpbb_root_path . 'extension.inc'); 
require('./pagestart.' . $phpEx); 

$lang['UserIP_Title'] = 'User IP Addresses'; 
$lang['UserIP_Title_Explain'] = 'IP Addresses users were using when they registered.'; 
$lang['UIP_UserID'] = 'User ID'; 
$lang['UIP_Username'] = 'Username'; 
$lang['UIP_IPAddress'] = 'IP Address'; 
$lang['UIP_Activated'] = 'Activated'; 
$lang['UIP_LastOn'] = 'Last Visit'; 
$lang['UIP_Email'] = 'Email'; 

$template->set_filenames(array('body' => 'admin/admin_user_ip.tpl')); 
$template->assign_vars(array( 
   'L_USERIP_TITLE' => $lang['UserIP_Title'], 
   'L_USERIP_EXPLAIN' => $lang['UserIP_Title_Explain'], 
   'L_USERIP_USERID' => $lang['UIP_UserID'], 
   'L_USERIP_USERNAME' => $lang['UIP_Username'], 
   'L_USERIP_IPADDRESS' => $lang['UIP_IPAddress'], 
   'L_USERIP_ACTIVATED' => $lang['UIP_Activated'], 
   'L_USERIP_LASTON' => $lang['UIP_LastOn'], 
   'L_USERIP_EMAIL' => $lang['UIP_Email']) 
); 

$sql = "SELECT user_id, username, user_regip, user_active, user_lastvisit, user_email FROM phpbb_users 
      WHERE user_id > 0 
      ORDER BY user_id"; 

if ( !($result = $db->sql_query($sql)) ) 
{ 
   message_die(GENERAL_ERROR, 'Could not obtain user list.', '', __LINE__, __FILE__, $sql); 
} 

while( $row = $db->sql_fetchrow($result) ) 
{ 
   $user_id = '<a href="' . $board_config['script_path'] . 'profile.php?mode=viewprofile&u=' . $row['user_id'] . '" target="_profile">' . $row['user_id'] . '</a>'; 

   $username = $row['username']; 

   $user_regip = decode_ip($row['user_regip']); 
   if ( $user_regip != '0.0.0.0' ) 
   { 
      $user_regip = '<a href="http://network-tools.com/default.asp?prog=trace&Netnic=whois.arin.net&host=' . $user_regip . '" target=_"ip">' . $user_regip . '</a>'; 
   } 
   else 
   { 
      $user_regip = '<span style="color: red;">' . $user_regip . '</span>'; 
   } 

   $user_active = '<span style="color: green;">Yes</span>'; 
   if ( !$row['user_active'] ) 
   { 
      $user_active = '<span style="color: red;">No</span>'; 
   } 

   $user_laston = '<span style="color: red;">' . $lang['Never'] . '</span>';    
   if ( !empty($row['user_lastvisit']) ) 
   { 
      $user_laston = create_date('M d Y', $row['user_lastvisit'], $board_config['board_timezone']); 
   } 

   $user_email = '<a href=mailto:' . $row['user_email'] . '>' . $row['user_email'] . '</a>'; 

   $template->assign_block_vars('userip_row', array( 
      'USER_ID' => $user_id, 
      'USERNAME' => $username, 
      'USER_REGIP' => $user_regip, 
      'USER_ACTIVE' => $user_active, 
      'USER_LASTON' => $user_laston, 
      'USER_EMAIL' => $user_email)); 
} 

$db->sql_freeresult($result); 

$template->pparse("body"); 

include('./page_footer_admin.'.$phpEx); 
?>
再將下面此段程式碼存為 admin_user_ip.tpl 存入 phpbb/templates/subSilver/admin/ 子目錄即可\r

代碼: 選擇全部

<h1>{L_USERIP_TITLE}</h1> 
<p>{L_USERIP_EXPLAIN}</p> 

<table align="center" cellpadding="3" cellspacing="1" border="0" class="forumline"> 
  <tr> 
   <th>{L_USERIP_USERID}</td> \r
   <th>{L_USERIP_USERNAME}</td> 
   <th>{L_USERIP_IPADDRESS}</td> 
   <th>{L_USERIP_ACTIVATED}</td> 
   <th>{L_USERIP_LASTON}</td> 
   <th>{L_USERIP_EMAIL}</td> 
  </tr> 
<!-- BEGIN userip_row --> 
  <tr> 
    <td class="row1" align="center">{userip_row.USER_ID}</td> 
    <td class="row1">{userip_row.USERNAME}</td> 
    <td class="row1">{userip_row.USER_REGIP}</td> 
    <td class="row1" align="center">{userip_row.USER_ACTIVE}</td> 
    <td class="row1">{userip_row.USER_LASTON}</td> 
    <td class="row1">{userip_row.USER_EMAIL}</td> 
  </tr> 
<!-- END userip_row --> 
</table> 

<br />
應該是很簡單,祝各位順利!若這方式改不出來再問我,我應該是沒弄錯才對。若是對程式功能有疑問,就要請回原出處網址詢問了。我對 php 功能不熟 :oops:

------------------------------------
糟糕...我是不是貼錯版面了,如果不該貼這裡的話,煩勞大大把我踢到別版去,歹勢~
主題已鎖定

回到「官方認證外掛」