From: Meik S. <acy...@ph...> - 2009-09-22 15:09:24
|
Author: acydburn Date: Tue Sep 22 16:09:09 2009 New Revision: 10178 Log: Fix getting host for situations where the name/IP is not resolvable. Related to Bug #41025 Related revisions: r9387 and r10158 Modified: branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php branches/phpBB-3_0_0/phpBB/includes/session.php Modified: branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php (original) --- branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php Tue Sep 22 16:09:09 2009 *************** *** 1134,1140 **** global $user; $err_msg = ''; ! $local_host = (function_exists('php_uname') && function_exists('gethostbyaddr') && function_exists('gethostbyname')) ? gethostbyaddr(gethostbyname(php_uname('n'))) : $user->host; // If we are authenticating through pop-before-smtp, we // have to login ones before we get authenticated --- 1134,1157 ---- global $user; $err_msg = ''; ! ! // 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 Modified: branches/phpBB-3_0_0/phpBB/includes/session.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/session.php (original) --- branches/phpBB-3_0_0/phpBB/includes/session.php Tue Sep 22 16:09:09 2009 *************** *** 182,188 **** else { // Set to OS hostname or localhost ! $host = (function_exists('php_uname') && function_exists('gethostbyaddr') && function_exists('gethostbyname')) ? gethostbyaddr(gethostbyname(php_uname('n'))) : 'localhost'; } } --- 182,188 ---- else { // Set to OS hostname or localhost ! $host = (function_exists('php_uname')) ? php_uname('n') : 'localhost'; } } |