summaryrefslogtreecommitdiff
path: root/Postman/PostmanUtils.php
diff options
context:
space:
mode:
authoryehuda <yehuda@myinbox.in>2019-03-06 11:15:29 +0200
committeryehuda <yehuda@myinbox.in>2019-03-06 11:15:29 +0200
commit43f74c1f1e4667cff46e11f024565280dbd9c5d3 (patch)
treea4811a237b3c540fa590d90ba2d6453cbeabe792 /Postman/PostmanUtils.php
parent83f12e99e595b97c72f4eb77833ca652d5219b6b (diff)
downloadPost-SMTP-43f74c1f1e4667cff46e11f024565280dbd9c5d3.zip
Another try to optimize the hostname query
Diffstat (limited to 'Postman/PostmanUtils.php')
-rw-r--r--Postman/PostmanUtils.php15
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 );