aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/functions_messenger.php19
-rw-r--r--phpBB/includes/session.php2
2 files changed, 19 insertions, 2 deletions
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 909609d893..8f4e582b3c 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -1134,7 +1134,24 @@ class smtp_class
global $user;
$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
// have to login ones before we get authenticated
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index d8362d5089..bf41fea7de 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -182,7 +182,7 @@ class session
else
{
// 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';
}
}