您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何限制访问者的ip(PHPBB的代码)_PHP教程

2025/10/13 12:28:50发布10次查看
如何限制访问者的ip(phpbb的代码)code: sql_query($sql)) )
{
message_die(general_error, couldn't obtain banlist information, , __line__, __file__, $sql);
}
$current_banlist = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$kill_session_sql = '';
for($i = 0; $i {
$in_banlist = false;
for($j = 0; $j {
if ( $user_list[$i] == $current_banlist[$j]['ban_userid'] )
{
$in_banlist = true;
}
}
if ( !$in_banlist )
{
$kill_session_sql .= ( ( $kill_session_sql != '' ) ? ' or ' : '' ) . session_user_id = . $user_list[$i];
$sql = insert into . banlist_table . (ban_userid)
values ( . $user_list[$i] . );
if ( !$db->sql_query($sql) )
{
message_die(general_error, couldn't insert ban_userid info into database, , __line__, __file__, $sql);
}
}
}
for($i = 0; $i {
$in_banlist = false;
for($j = 0; $j {
if ( $ip_list[$i] == $current_banlist[$j]['ban_ip'] )
{
$in_banlist = true;
}
}
if ( !$in_banlist )
{
if ( preg_match('/(ff\.)|(\.ff)/is', chunk_split($ip_list[$i], 2, '.')) )
{
$kill_ip_sql = session_ip like ' . str_replace('.', '', preg_replace('/(ff\.)|(\.ff)/is', '%', chunk_split($ip_list[$i], 2, .))) . ';
}
else
{
$kill_ip_sql = session_ip = ' . $ip_list[$i] . ';
}
$kill_session_sql .= ( ( $kill_session_sql != '' ) ? ' or ' : '' ) . $kill_ip_sql;
$sql = insert into . banlist_table . (ban_ip)
values (' . $ip_list[$i] . ');
if ( !$db->sql_query($sql) )
{
message_die(general_error, couldn't insert ban_ip info into database, , __line__, __file__, $sql);
}
}
}
//
// now we'll delete all entries from the session table with any of the banned
// user or ip info just entered into the ban table ... this will force a session
// initialisation resulting in an instant ban
//
if ( $kill_session_sql != '' )
{
$sql = delete from . sessions_table .
where $kill_session_sql;
if ( !$db->sql_query($sql) )
{
message_die(general_error, couldn't delete banned sessions from database, , __line__, __file__, $sql);
}
}
for($i = 0; $i {
$in_banlist = false;
for($j = 0; $j {
if ( $email_list[$i] == $current_banlist[$j]['ban_email'] )
{
$in_banlist = true;
}
}
if ( !$in_banlist )
{
$sql = insert into . banlist_table . (ban_email)
values (' . str_replace(', '', $email_list[$i]) . ');
if ( !$db->sql_query($sql) )
{
message_die(general_error, couldn't insert ban_email info into database, , __line__, __file__, $sql);
}
}
}
$where_sql = '';
if ( isset($http_post_vars['unban_user']) )
{
$user_list = $http_post_vars['unban_user'];
for($i = 0; $i {
if ( $user_list[$i] != -1 )
{
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $user_list[$i];
}
}
}
if ( isset($http_post_vars['unban_ip']) )
{
$ip_list = $http_post_vars['unban_ip'];
for($i = 0; $i {
if ( $ip_list[$i] != -1 )
{
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $ip_list[$i];
}
}
}
if ( isset($http_post_vars['unban_email']) )
{
$email_list = $http_post_vars['unban_email'];
for($i = 0; $i {
if ( $email_list[$i] != -1 )
{
$where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $email_list[$i];
}
}
}
if ( $where_sql != '' )
{
$sql = delete from . banlist_table .
where ban_id in ($where_sql);
if ( !$db->sql_query($sql) )
{
message_die(general_error, couldn't delete ban info from database, , __line__, __file__, $sql);
}
}
$message = $lang['ban_update_sucessful'] . '
' . sprintf($lang['click_return_banadmin'], '', '') . '
' . sprintf($lang['click_return_admin_index'], '', '');
message_die(general_message, $message);
}
else
{
$template->set_filenames(array(
'body' => 'admin/user_ban_body.tpl')
);
$template->assign_vars(array(
'l_ban_title' => $lang['ban_control'],
'l_ban_explain' => $lang['ban_explain'],
'l_ban_explain_warn' => $lang['ban_explain_warn'],
'l_ip_or_hostname' => $lang['ip_hostname'],
'l_email_address' => $lang['email_address'],
'l_submit' => $lang['submit'],
'l_reset' => $lang['reset'],
's_banlist_action' => append_sid(admin_user_ban.$phpex))
);
$template->assign_vars(array(
'l_ban_user' => $lang['ban_username'],
'l_ban_user_explain' => $lang['ban_username_explain'],
'l_ban_ip' => $lang['ban_ip'],
'l_ban_ip_explain' => $lang['ban_ip_explain'],
'l_ban_email' => $lang['ban_email'],
'l_ban_email_explain' => $lang['ban_email_explain'])
);
$userban_count = 0;
$ipban_count = 0;
$emailban_count = 0;
$sql = select b.ban_id, u.user_id, u.username
from . banlist_table . b, . users_table . u
where u.user_id = b.ban_userid
and b.ban_userid 0
and u.user_id . anonymous .
order by u.user_id asc;
if ( !($result = $db->sql_query($sql)) )
{
message_die(general_error, 'could not select current user_id ban list', '', __line__, __file__, $sql);
}
$user_list = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$select_userlist = '';
for($i = 0; $i {
$select_userlist .= '' . $user_list[$i]['username'] . '';
$userban_count++;
}
if( $select_userlist == '' )
{
$select_userlist = '' . $lang['no_banned_users'] . '';
}
$select_userlist = '' . $select_userlist . '';
$sql = select ban_id, ban_ip, ban_email
from . banlist_table;
if ( !($result = $db->sql_query($sql)) )
{
message_die(general_error, 'could not select current ip ban list', '', __line__, __file__, $sql);
}
$banlist = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$select_iplist = '';
$select_emaillist = '';
for($i = 0; $i {
$ban_id = $banlist[$i]['ban_id'];
if ( !empty($banlist[$i]['ban_ip']) )
{
$ban_ip = str_replace('255', '*', decode_ip($banlist[$i]['ban_ip']));
$select_iplist .= '' . $ban_ip . '';
$ipban_count++;
}
else if ( !empty($banlist[$i]['ban_email']) )
{
$ban_email = $banlist[$i]['ban_email'];
$select_emaillist .= '' . $ban_email . '';
$emailban_count++;
}
}
if ( $select_iplist == '' )
{
$select_iplist = '' . $lang['no_banned_ip'] . '';
}
if ( $select_emaillist == '' )
{
$select_emaillist = '' . $lang['no_banned_email'] . '';
}
$select_iplist = '' . $select_iplist . '';
$select_emaillist = '' . $select_emaillist . '';
$template->assign_vars(array(
'l_unban_user' => $lang['unban_username'],
'l_unban_user_explain' => $lang['unban_username_explain'],
'l_unban_ip' => $lang['unban_ip'],
'l_unban_ip_explain' => $lang['unban_ip_explain'],
'l_unban_email' => $lang['unban_email'],
'l_unban_email_explain' => $lang['unban_email_explain'],
'l_username' => $lang['username'],
'l_look_up' => $lang['look_up_user'],
'l_find_username' => $lang['find_username'],
'u_search_user' => append_sid(search.$phpex?mode=searchuser&popup=1&menu=1),
's_unban_userlist_select' => $select_userlist,
's_unban_iplist_select' => $select_iplist,
's_unban_emaillist_select' => $select_emaillist,
's_ban_action' => append_sid(admin_user_ban.$phpex))
);
}
$template->pparse('body');
include('./page_footer_admin.'.$phpex);
?>
http://www.bkjia.com/phpjc/314527.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/314527.htmltecharticle如何限制访问者的ip(phpbb的代码)code:?php /*************************************************************************** * admin_user_ban.php * ------------------- * begin...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product