Merge branch 'ipv6'

This commit is contained in:
Fedor A. Fetisov 2017-05-26 15:42:18 +03:00
commit 568e539e49
2 changed files with 9 additions and 13 deletions

View File

@ -572,8 +572,7 @@ function visitor_from_request()
}
/**
* @return array Return remote host from active request. contains
* (user_id string, user_name string)
* @return string Return remote host from active request
*/
function get_remote_host()
{
@ -581,7 +580,10 @@ function get_remote_host()
$has_proxy = isset($_SERVER['HTTP_X_FORWARDED_FOR'])
&& $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR'];
if ($has_proxy) {
$ext_addr = $_SERVER['REMOTE_ADDR'] . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')';
$ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'], 2);
$ext_addr = (count($ips) > 1)
? $ips[0] . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')'
: $ips[0];
}
return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $ext_addr;

View File

@ -266,11 +266,8 @@ class UsersProcessor extends ClientSideProcessor implements AuthenticationManage
);
// Get user ip
if (preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $thread->remote, $matches) != 0) {
$user_ip = $matches[1];
} else {
$user_ip = false;
}
$user_ip = preg_replace('/^(\S+)(\s.+)?/', '\\1', $thread->remote);
$user_ip = filter_var($user_ip, FILTER_VALIDATE_IP);
// Get thread operartor name
$next_agent = $thread->nextAgent != 0
@ -438,11 +435,8 @@ class UsersProcessor extends ClientSideProcessor implements AuthenticationManage
$user_agent = get_user_agent_version($details['user_agent']);
// Get user ip
if (preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $details['remote_host'], $matches) != 0) {
$user_ip = $matches[1];
} else {
$user_ip = false;
}
$user_ip = preg_replace('/^(\S+)(\s.+)?/', '\\1', $details['remote_host']);
$user_ip = filter_var($user_ip, FILTER_VALIDATE_IP);
// Get invitation info
$row['invited'] = ($row['invitationstate'] == Thread::INVITATION_WAIT);