mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
IP related updates
git-svn-id: file:///svn/phpbb/trunk@2560 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
ab8d9f1978
commit
f6c6628509
5 changed files with 36 additions and 44 deletions
|
@ -127,7 +127,7 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
$email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
|
||||
$email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
|
||||
$email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
|
||||
$email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\r\n";
|
||||
$email_headers .= 'X-AntiAbuse: User IP - ' . $user_ip . "\r\n";
|
||||
|
||||
$emailer->use_template('admin_send_email');
|
||||
$emailer->email_address($board_config['board_email']);
|
||||
|
|
|
@ -33,7 +33,7 @@ if( !empty($setmodules) )
|
|||
//
|
||||
// Load default header
|
||||
//
|
||||
$phpbb_root_path = "../";
|
||||
$phpbb_root_path = '../';
|
||||
require($phpbb_root_path . 'extension.inc');
|
||||
require('pagestart.' . $phpEx);
|
||||
|
||||
|
@ -42,9 +42,9 @@ require('pagestart.' . $phpEx);
|
|||
//
|
||||
if( isset($HTTP_POST_VARS['submit']) )
|
||||
{
|
||||
$user_bansql = "";
|
||||
$email_bansql = "";
|
||||
$ip_bansql = "";
|
||||
$user_bansql = '';
|
||||
$email_bansql = '';
|
||||
$ip_bansql = '';
|
||||
|
||||
$user_list = array();
|
||||
if( isset($HTTP_POST_VARS['ban_user']) )
|
||||
|
@ -60,11 +60,11 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
$ip_list = array();
|
||||
if( isset($HTTP_POST_VARS['ban_ip']) )
|
||||
{
|
||||
$ip_list_temp = explode(",", $HTTP_POST_VARS['ban_ip']);
|
||||
$ip_list_temp = explode(',', $HTTP_POST_VARS['ban_ip']);
|
||||
|
||||
for($i = 0; $i < count($ip_list_temp); $i++)
|
||||
{
|
||||
if( preg_match("/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/", trim($ip_list_temp[$i]), $ip_range_explode) )
|
||||
if( preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/', trim($ip_list_temp[$i]), $ip_range_explode) )
|
||||
{
|
||||
//
|
||||
// Don't ask about all this, just don't ask ... !
|
||||
|
@ -79,10 +79,10 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
|
||||
if($ip_2_counter == 0 && $ip_2_end == 254)
|
||||
{
|
||||
$ip_2_counter = 255;
|
||||
$ip_2_fragment = 255;
|
||||
$ip_2_counter = 256;
|
||||
$ip_2_fragment = 256;
|
||||
|
||||
$ip_list[] = encode_ip("$ip_1_counter.255.255.255");
|
||||
$ip_list[] = "$ip_1_counter.256.256.256";
|
||||
}
|
||||
|
||||
while($ip_2_counter <= $ip_2_end)
|
||||
|
@ -92,10 +92,10 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
|
||||
if($ip_3_counter == 0 && $ip_3_end == 254 )
|
||||
{
|
||||
$ip_3_counter = 255;
|
||||
$ip_3_fragment = 255;
|
||||
$ip_3_counter = 256;
|
||||
$ip_3_fragment = 256;
|
||||
|
||||
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.255.255");
|
||||
$ip_list[] = "$ip_1_counter.$ip_2_counter.256.256";
|
||||
}
|
||||
|
||||
while($ip_3_counter <= $ip_3_end)
|
||||
|
@ -105,15 +105,15 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
|
||||
if($ip_4_counter == 0 && $ip_4_end == 254)
|
||||
{
|
||||
$ip_4_counter = 255;
|
||||
$ip_4_fragment = 255;
|
||||
$ip_4_counter = 256;
|
||||
$ip_4_fragment = 256;
|
||||
|
||||
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.$ip_3_counter.255");
|
||||
$ip_list[] = "$ip_1_counter.$ip_2_counter.$ip_3_counter.256";
|
||||
}
|
||||
|
||||
while($ip_4_counter <= $ip_4_end)
|
||||
{
|
||||
$ip_list[] = encode_ip("$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter");
|
||||
$ip_list[] = "$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter";
|
||||
$ip_4_counter++;
|
||||
}
|
||||
$ip_3_counter++;
|
||||
|
@ -123,7 +123,7 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
$ip_1_counter++;
|
||||
}
|
||||
}
|
||||
else if( preg_match("/^([\w\-_]\.?){2,}$/is", trim($ip_list_temp[$i])) )
|
||||
else if( preg_match('/^([\w\-_]\.?){2,}$/is', trim($ip_list_temp[$i])) )
|
||||
{
|
||||
$ip = gethostbynamel(trim($ip_list_temp[$i]));
|
||||
|
||||
|
@ -131,13 +131,13 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
{
|
||||
if( !empty($ip[$j]) )
|
||||
{
|
||||
$ip_list[] = encode_ip($ip[$j]);
|
||||
$ip_list[] = $ip[$j];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( preg_match("/^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$/", trim($ip_list_temp[$i])) )
|
||||
else if( preg_match('/^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$/', trim($ip_list_temp[$i])) )
|
||||
{
|
||||
$ip_list[] = encode_ip(str_replace("*", "255", trim($ip_list_temp[$i])));
|
||||
$ip_list[] = str_replace('*', '256', trim($ip_list_temp[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
$email_list = array();
|
||||
if(isset($HTTP_POST_VARS['ban_email']))
|
||||
{
|
||||
$email_list_temp = explode(",", $HTTP_POST_VARS['ban_email']);
|
||||
$email_list_temp = explode(',', $HTTP_POST_VARS['ban_email']);
|
||||
|
||||
for($i = 0; $i < count($email_list_temp); $i++)
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
// contained in the annotated php manual at php.com (ereg
|
||||
// section)
|
||||
//
|
||||
if( eregi("^(([[:alnum:]\*]+([-_.][[:alnum:]\*]+)*\.?)|(\*))@([[:alnum:]]+([-_]?[[:alnum:]]+)*\.){1,3}([[:alnum:]]{2,6})$", trim($email_list_temp[$i])) )
|
||||
if( eregi('^(([[:alnum:]\*]+([-_.][[:alnum:]\*]+)*\.?)|(\*))@([[:alnum:]]+([-_]?[[:alnum:]]+)*\.){1,3}([[:alnum:]]{2,6})$', trim($email_list_temp[$i])) )
|
||||
{
|
||||
$email_list[] = trim($email_list_temp[$i]);
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
|
||||
$current_banlist = $db->sql_fetchrowset($result);
|
||||
|
||||
$kill_session_sql = "";
|
||||
$kill_session_sql = '';
|
||||
for($i = 0; $i < count($user_list); $i++)
|
||||
{
|
||||
$in_banlist = false;
|
||||
|
@ -184,7 +184,7 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
|
||||
if(!$in_banlist)
|
||||
{
|
||||
$kill_session_sql .= ( ($kill_session_sql != "") ? " OR " : "" ) . "session_user_id = $user_list[$i]";
|
||||
$kill_session_sql .= ( ($kill_session_sql != '') ? ' OR ' : '' ) . "session_user_id = " . $user_list[$i];
|
||||
|
||||
$sql = "INSERT INTO " . BANLIST_TABLE . " (ban_userid)
|
||||
VALUES (" . $user_list[$i] . ")";
|
||||
|
@ -208,16 +208,9 @@ if( isset($HTTP_POST_VARS['submit']) )
|
|||
|
||||
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_ip_sql = ( preg_match('/256/s') ) ? "session_ip LIKE '" . preg_replace('/(256)/s', '%', $ip_list[$i]) . "'" : "session_ip = '" . $ip_list[$i] . "'";
|
||||
|
||||
$kill_session_sql .= ( ($kill_session_sql != "") ? " OR " : "" ) . $kill_ip_sql;
|
||||
$kill_session_sql .= ( ($kill_session_sql != '') ? ' OR ' : '' ) . $kill_ip_sql;
|
||||
|
||||
$sql = "INSERT INTO " . BANLIST_TABLE . " (ban_ip)
|
||||
VALUES ('" . $ip_list[$i] . "')";
|
||||
|
@ -438,7 +431,7 @@ else
|
|||
|
||||
if ( !empty($banlist[$i]['ban_ip']) )
|
||||
{
|
||||
$ban_ip = str_replace('255', '*', decode_ip($banlist[$i]['ban_ip']));
|
||||
$ban_ip = str_replace('256', '*', $banlist[$i]['ban_ip']);
|
||||
$select_iplist .= '<option value="' . $ban_id . '">' . $ban_ip . '</option>';
|
||||
$ipban_count++;
|
||||
}
|
||||
|
|
|
@ -443,7 +443,7 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' )
|
|||
$row_color = ( $registered_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
|
||||
$row_class = ( $registered_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
|
||||
|
||||
$reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
|
||||
$reg_ip = $onlinerow_reg[$i]['session_ip'];
|
||||
|
||||
$template->assign_block_vars("reg_user_row", array(
|
||||
"ROW_COLOR" => "#" . $row_color,
|
||||
|
@ -535,7 +535,7 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' )
|
|||
$row_color = ( $guest_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
|
||||
$row_class = ( $guest_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
|
||||
|
||||
$guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
|
||||
$guest_ip = $onlinerow_guest[$i]['session_ip'];
|
||||
|
||||
$template->assign_block_vars("guest_user_row", array(
|
||||
"ROW_COLOR" => "#" . $row_color,
|
||||
|
|
|
@ -294,19 +294,18 @@ $nav_links['author'] = array (
|
|||
//
|
||||
if( getenv('HTTP_X_FORWARDED_FOR') != '' )
|
||||
{
|
||||
$client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
|
||||
$user_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
|
||||
|
||||
if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip_list) )
|
||||
{
|
||||
$private_ip = array('/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10..*/', '/^224..*/', '/^240..*/');
|
||||
$client_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
|
||||
$user_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
|
||||
$user_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
|
||||
}
|
||||
$user_ip = encode_ip($client_ip);
|
||||
|
||||
//
|
||||
// Setup forum wide options, if this fails
|
||||
|
|
|
@ -831,7 +831,7 @@ switch( $mode )
|
|||
message_die(GENERAL_MESSAGE, $lang['No_such_post']);
|
||||
}
|
||||
|
||||
$ip_this_post = decode_ip($post_row['poster_ip']);
|
||||
$ip_this_post = $post_row['poster_ip'];
|
||||
$ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? gethostbyaddr($ip_this_post) : $ip_this_post;
|
||||
|
||||
$poster_id = $post_row['poster_id'];
|
||||
|
@ -877,7 +877,7 @@ switch( $mode )
|
|||
continue;
|
||||
}
|
||||
|
||||
$ip = decode_ip($row['poster_ip']);
|
||||
$ip = $row['poster_ip'];
|
||||
$ip = ( $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
|
||||
|
||||
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
|
||||
|
|
Loading…
Add table
Reference in a new issue