diff options
Diffstat (limited to 'functions')
-rw-r--r-- | functions/connection.php | 13 | ||||
-rw-r--r-- | functions/variables.php | 4 |
2 files changed, 13 insertions, 4 deletions
diff --git a/functions/connection.php b/functions/connection.php index 54f7236..a6049cd 100644 --- a/functions/connection.php +++ b/functions/connection.php @@ -15,7 +15,18 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. function fixed_gethostbyname($host) { - $ip = gethostbyname($host); + $ips = dns_get_record($host, DNS_A + DNS_AAAA); + sort($ips); + foreach ($ips as $key => $value) { + if ($value['type'] === "AAAA") { + $ip = $value['ipv6']; + } elseif ($value['type'] === "A") { + $ip = $value['ip']; + } else { + return false; + } + } + pre_dump($ips); if ($ip != $host) { return $ip; } else { diff --git a/functions/variables.php b/functions/variables.php index a2e1d24..09a794c 100644 --- a/functions/variables.php +++ b/functions/variables.php @@ -50,9 +50,7 @@ function parse_hostname($u_hostname){ $parts[1] = preg_replace('/[^A-Za-z0-9\.\:_-]/', '', $parts[1]); if (filter_var($parts[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) or filter_var($parts[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) { $ip = mb_strtolower($parts[1]); - } else { - $ip = fixed_gethostbyname($hostname); - } + } } else { if (filter_var($hostname, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) { $ip = $hostname; |