aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-09-22 15:09:09 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-09-22 15:09:09 +0000
commit782d680b540b3aebb65d50b4063d1b10a9c76365 (patch)
treea508d2df12b0ecaf7b3fe7b2afd5b029ed05944e
parent90e11876019b063000843c424052d96524caa5a9 (diff)
downloadforums-782d680b540b3aebb65d50b4063d1b10a9c76365.tar
forums-782d680b540b3aebb65d50b4063d1b10a9c76365.tar.gz
forums-782d680b540b3aebb65d50b4063d1b10a9c76365.tar.bz2
forums-782d680b540b3aebb65d50b4063d1b10a9c76365.tar.xz
forums-782d680b540b3aebb65d50b4063d1b10a9c76365.zip
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
-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';
}
}