diff options
Diffstat (limited to 'Postman')
-rw-r--r-- | Postman/PostmanUtils.php | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php index 8c7081f..7a443de 100644 --- a/Postman/PostmanUtils.php +++ b/Postman/PostmanUtils.php @@ -447,7 +447,7 @@ class PostmanUtils { } public static function getServerName() { - $result = 'localhost.localdomain'; + $host = 'localhost.localdomain'; if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) { $host = $_SERVER['SERVER_NAME']; @@ -459,9 +459,18 @@ class PostmanUtils { // as final option - if ip returned or hostname without extension (not valid dns name) $extension = pathinfo( $host, PATHINFO_EXTENSION ); - if ( filter_var( $result, FILTER_VALIDATE_IP ) || empty( $extension ) ) { + if ( filter_var( $host, FILTER_VALIDATE_IP ) || empty( $extension ) ) { $siteurl = get_bloginfo('url'); - $host = parse_url($siteurl, PHP_URL_HOST); + $temp_host = parse_url( $siteurl, PHP_URL_HOST); + + $dnsr = dns_get_record( $temp_host, DNS_A ); + $ip = gethostbyname( $temp_host ); + + foreach ( $dnsr as $record ) { + if ( $record['host'] == $temp_host && $record['ip'] == $ip ) { + $host = $temp_host; + } + } } return str_replace('www.', '', $host ); |