mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Fix getting host for situations where the name/IP is not resolvable. Related to Bug #41025
Related revisions: r9387 and r10158 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10178 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
90e1187601
commit
782d680b54
2 changed files with 19 additions and 2 deletions
|
@ -1134,7 +1134,24 @@ class smtp_class
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$err_msg = '';
|
$err_msg = '';
|
||||||
$local_host = (function_exists('php_uname') && function_exists('gethostbyaddr') && function_exists('gethostbyname')) ? gethostbyaddr(gethostbyname(php_uname('n'))) : $user->host;
|
|
||||||
|
// Here we try to determine the *real* hostname (reverse DNS entry preferrably)
|
||||||
|
$local_host = $user->host;
|
||||||
|
|
||||||
|
if (function_exists('php_uname'))
|
||||||
|
{
|
||||||
|
$local_host = php_uname('n');
|
||||||
|
|
||||||
|
// Able to resolve name to IP
|
||||||
|
if (($addr = @gethostbyname($local_host)) !== $local_host)
|
||||||
|
{
|
||||||
|
// Able to resolve IP back to name
|
||||||
|
if (($name = @gethostbyaddr($addr)) !== $addr)
|
||||||
|
{
|
||||||
|
$local_host = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we are authenticating through pop-before-smtp, we
|
// If we are authenticating through pop-before-smtp, we
|
||||||
// have to login ones before we get authenticated
|
// have to login ones before we get authenticated
|
||||||
|
|
|
@ -182,7 +182,7 @@ class session
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set to OS hostname or localhost
|
// Set to OS hostname or localhost
|
||||||
$host = (function_exists('php_uname') && function_exists('gethostbyaddr') && function_exists('gethostbyname')) ? gethostbyaddr(gethostbyname(php_uname('n'))) : 'localhost';
|
$host = (function_exists('php_uname')) ? php_uname('n') : 'localhost';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue