http://phpbb-tw.net/phpbb/viewtopic.php?t=30422
小弟裝載2.0.11上面測試正常(應該算蠻實用的)
原文英文,小弟已經把它中文化了(可能中文化會有錯誤,請指教)
安裝注意事項
安裝時必須特別注意,請先執行SQL輸入
adaim_bord.php編輯完後先到後台設定數值(兩個都先設大於1就對了,整個編輯完畢後,數值要改再改)
-------------------------------------------------------------------------------------
那兩個數值千萬不能空白(空白系統認為是0)
"登入後"的系統管理員則不受限(版主的我沒測)
代碼: 選擇全部
##############################################################
## MOD Title: Max sessions
## MOD Author: Niels < ncr@db9.dk > (Niels Chr. R鷣) http://mods.db9.dk
## MOD Description: This mod will prevent users of connecting
## to the site, if there is currently the
## maximal accepted connections.
## MOD Version: 0.9.2
## MOD Compatibility: 2.0.2->2.0.6
##
## Installation Level: Easy
## Installation Time: 5 Minutes (1mn by EasyMOD of Nuttzy)
## Files To Edit: 4
## admin/admin_board.php
## includes/sessions.php
## language/lang_english/lang_admin.php
## templates/subSilver/admin/board_config.tpl
##
## Included Files: 1
## max_sessions_db_update.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/
##
## Official last version link
## -----------
## Meanwhile the phpBB group validation and as the MOD is not yet
## in the phpBB MOD database, check this official link for updates...
## http://mods.db9.dk/viewtopic.php?t=704
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
NOTE:
安裝時必須特別注意,請先執行SQL輸入
adaim_bord.php編輯完後先到後台設定數值(兩個都先設2就對了,整個編輯完畢後,數值要改再改)
-------------------------------------------------------------------------------------
那兩個數值千萬不能空白(空白系統認為是0)
"登入後"的系統管理員則不受限
#
#-----[ COPY ]------------------------------------------------
#
copy max_sessions_db_update.php to max_sessions_db_update.php
# Please, do it NOW! Before editing phpBB files by EM or manually!!!
# Otherwise, you may have an error message during your next
# connection.
#
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------------
#
"L_ENABLE_PRUNE" =>
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start add - Max sessions MOD
'L_MAX_SESSIONS' => $lang['Max_sessions'],
'L_MAX_SESSIONS_EXPLAIN' => $lang['Max_sessions_explain'],
'L_MAX_SESSIONS_IP' => $lang['Max_sessions_ip'],
'L_MAX_SESSIONS_IP_EXPLAIN' => $lang['Max_sessions_ip_explain'],
// End add - Max sessions MOD
#
#-----[ FIND ]------------------------------------------------
#
"PRUNE_NO" =>
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start add - Max sessions MOD
'MAX_SESSIONS' => $new['max_sessions'],
'MAX_SESSIONS_IP' => $new['max_sessions_ip'],
// End add - Max sessions MOD
#
#-----[ OPEN ]------------------------------------------------ \r
#
includes/sessions.php
#
#-----[ FIND ]------------------------------------------------
#
if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start add - Max sessions MOD
$sql = "SELECT user_id FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE s.session_time >= ".( time() - 90 ) . "
AND u.user_id = s.session_user_id
GROUP BY s.session_ip, u.username";
if( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_MESSAGE, '無法獲得用戶 / 線上 資訊。', '', __LINE__, __FILE__, $sql);
}
$total_users = $db->sql_numrows($result);
if ( $total_users >= $board_config['max_sessions'] )
{
message_die(CRITICAL_MESSAGE, sprintf('論壇已達人數上限 (%d人) 請稍後再登入',$board_config['max_sessions']), '', __LINE__, __FILE__, $sql);
}
$sql = "SELECT session_user_id FROM ".SESSIONS_TABLE."
WHERE session_time >= ".( time() - 90 ) . "
AND session_ip='".$user_ip."'". (($user_id == ANONYMOUS) ? "" :" AND session_user_id='".$user_id."'" ) ;
if( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_MESSAGE, '無法獲得用戶線上資訊。'.$sql, '', __LINE__, __FILE__, $sql);
}
$total_users = $db->sql_numrows($result);
if ( $total_users >= $board_config['max_sessions_ip'] )
{
message_die(CRITICAL_MESSAGE, sprintf('您使用過多的連線連進本論壇 (%d線) </br>請勿使用多視窗瀏覽 and 勿猛按重新整理',$board_config['max_sessions_ip']), '', __LINE__, __FILE__, $sql);
}
// End add - Max sessions MOD
#
#-----[ OPEN ]------------------------------------------------
#
language/你的語言/lang_admin.php
#
#-----[ FIND ]------------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
// Start add - Max sessions MOD
$lang['Max_sessions'] = '論壇最大線上人數'; //原文Max sessions allowed
$lang['Max_sessions_explain'] = '請你設定一個適合自己的數值'; //原文This is the max number of sessions, the forum accept
$lang['Max_sessions_ip'] = '相同IP連線數(通常設1或2)'; //原文Max sessions allowed per IP
$lang['Max_sessions_ip_explain'] = '容許一人有幾個相同IP連進'; //原文This is the max number of sessions per IP, the forum accept
// End add - Max sessions MOD
#
#-----[ OPEN ]------------------------------------------------
#
# Make sure to edit this file for every theme your admin uses
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
{S_DISABLE_BOARD_YES} ......還有東西
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- Start add - Max sessions MOD -->
<tr>
<td class="row1">{L_MAX_SESSIONS}<br /><span class="gensmall">{L_MAX_SESSIONS_EXPLAIN}</span></td>
<td class="row2"><input type="text" size="6" maxlength="5" name="max_sessions" value="{MAX_SESSIONS}" /></td>
</tr> \r
<tr>
<td class="row1">{L_MAX_SESSIONS_IP}<br /><span class="gensmall">{L_MAX_SESSIONS_IP_EXPLAIN}</span></td>
<td class="row2"><input type="text" size="6" maxlength="5" name="max_sessions_ip" value="{MAX_SESSIONS_IP}" /></td>
</tr>
<!-- End add - Max sessions MOD -->
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM