From 6970f24676474a0b28d110026e26d441e41fd107 Mon Sep 17 00:00:00 2001 From: Martin Kutschker Date: Fri, 2 Jun 2006 12:08:43 +0000 Subject: [PATCH] * Fix bugs #3326 and #3392: problems with php_uname() git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1501 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 1 + t3lib/class.t3lib_div.php | 44 ++++++++++++++++++++++++++-------- t3lib/class.t3lib_htmlmail.php | 9 +++---- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f25e01f67e6..9a8c06824c9 100755 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * Fix bug #3612: no c-prefix for URL fragment in menus (section index) * Fix bug #2493: TCE-forms don't skins icons / t3skin lacks undo.gif, csv.gif and savedoknew.gif (thanks to Clemens Riccabona for the latter) + * Fix bugs #3326 and #3392: problems with php_uname() 2006-05-31 Ernesto Baschny diff --git a/t3lib/class.t3lib_div.php b/t3lib/class.t3lib_div.php index 0a8c3852cf8..49b3d20115a 100755 --- a/t3lib/class.t3lib_div.php +++ b/t3lib/class.t3lib_div.php @@ -3202,6 +3202,37 @@ class t3lib_div { return $bInfo; } + /** + * Get the fully-qualified domain name of the host. + * Usage: 2 + * + * @param boolean Use request host (when not in CLI mode). + * @return string The fully-qualified host name. + */ + function getHostname($requestHost=TRUE) { + $host = ''; + if ($requestHost && (!defined('TYPO3_cliMode') || !TYPO3_cliMode)) { + $host = $_SERVER['HTTP_HOST']; + } + if (!$host) { + // will fail for PHP 4.1 and 4.2 + $host = @php_uname('n'); + // 'n' is ignored in broken installations + if (strpos($host, ' ')) $host = ''; + } + // we have not found a FQDN yet + if ($host && strpos('.',$host) === FALSE) { + $ip = gethostbyname($host); + // we got an IP address + if ($ip != $host) { + $fqdn = gethostbyaddr($ip); + if ($ip != $fqdn) $host = $fqdn; + } + } + if (!$host) $host = 'localhost.localdomain'; + + return $host; + } @@ -4237,18 +4268,11 @@ class t3lib_div { // for CLI logging name is : if (defined('TYPO3_cliMode') && TYPO3_cliMode) { - // find FQDN - $host = php_uname('n'); - if (strpos($host,'.') === FALSE) { - $ip = gethostbyname($host); - $fqdn = gethostbyaddr($ip); - if ($ip != $fqdn) $host = $fqdn; - } - $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = $TYPO3_CONF_VARS['SYS']['systemLogHost'] = $host.':'.PATH_site; + $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getHostname(FALSE).':'.PATH_site; } - // for Web logging name is :// + // for Web logging name is :/// else { - $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'); + $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); } // init custom logging diff --git a/t3lib/class.t3lib_htmlmail.php b/t3lib/class.t3lib_htmlmail.php index 7ee6dfdcff4..93612d26a42 100755 --- a/t3lib/class.t3lib_htmlmail.php +++ b/t3lib/class.t3lib_htmlmail.php @@ -269,11 +269,8 @@ class t3lib_htmlmail { global $TYPO3_CONF_VARS; // Sets the message id - $host = php_uname('n'); - if (strpos('.',$host) === FALSE) { - $host = gethostbyaddr(gethostbyname($host)); - } - if (!$host || $host == '127.0.0.1' || $host == 'localhost') { + $host = t3lib_div::getHostname(); + if (!$host || $host == '127.0.0.1' || $host == 'localhost' || $host == 'localhost.localdomain') { $host = ($TYPO3_CONF_VARS['SYS']['sitename'] ? preg_replace('/[^A-Za-z0-9_\-]/', '_', $TYPO3_CONF_VARS['SYS']['sitename']) : 'localhost') . '.TYPO3'; } $this->messageid = md5(microtime()) . '@' . $host; @@ -1431,4 +1428,4 @@ class t3lib_htmlmail { if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_htmlmail.php']) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_htmlmail.php']); } -?> \ No newline at end of file +?> -- 2.20.1