diff options
author | yehuda <yehuda@myinbox.in> | 2019-03-04 16:40:35 +0200 |
---|---|---|
committer | yehuda <yehuda@myinbox.in> | 2019-03-04 16:40:35 +0200 |
commit | e33f6bd6bce974ec0d9836e1589ea1facf159841 (patch) | |
tree | 5dc30b48323d8379a858326ab728c94e6455eba5 /Postman/PostmanUtils.php | |
parent | 18c7ae6216c4705a2942b07081469c4c0f1059fd (diff) | |
download | Post-SMTP-e33f6bd6bce974ec0d9836e1589ea1facf159841.zip |
* Added support for our new chrome notification extension.
* few fixes
Diffstat (limited to 'Postman/PostmanUtils.php')
-rw-r--r-- | Postman/PostmanUtils.php | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php index 8d5cd46..5405b79 100644 --- a/Postman/PostmanUtils.php +++ b/Postman/PostmanUtils.php @@ -445,37 +445,21 @@ class PostmanUtils { $result = 'localhost.localdomain'; if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) { - $result = $_SERVER['SERVER_NAME']; + $host = $_SERVER['SERVER_NAME']; } elseif (function_exists('gethostname') and gethostname() !== false) { - $result = gethostname(); + $host = gethostname(); } elseif (php_uname('n') !== false) { - $result = php_uname('n'); + $host = php_uname('n'); } - if ( $result !== 'localhost.localdomain' ) { - // get the current result ip - $ip = gethostbyname($result); - - // dns query failed - if ( $ip == $result ) { - return $result; - } - - // get the current ip hostname - reverse dns - $host = gethostbyaddr($ip); - - // dns query failed - if ( $host == $ip ) { - return $result; - } - - // if hostname is not equal to the result set the ptr - if ( $result !== $host ) { - $result = $host; - } - } + // 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 ) ) { + $siteurl = get_bloginfo('url'); + $host = parse_url($siteurl, PHP_URL_HOST); + } - return $result; + return str_replace('www.', '', $host ); } public static function getHost( $url ) { |