diff --git a/assets/js/scripts.min.js b/assets/js/scripts.min.js index 774a714..1938021 100644 --- a/assets/js/scripts.min.js +++ b/assets/js/scripts.min.js @@ -265,6 +265,35 @@ $(document).on("click", "#addDomainBTN", function () { $("#addSharedHosting").removeClass("show"); }); +$(document).on("click", "#fillIpv4", function () { + var host_name = $('#hostname').val(); + if (host_name) { + $.ajax({ + type: "GET", + url: "get_ip.php", + data: {"type" : "dns_search", "hostname": host_name, "type": "A"}, + success: function (result) { + $('#ipv4').val(result); + } + }); + //Now wait 3 seconds before checking AAAA + setTimeout(function(){ + $.ajax({ + type: "GET", + url: "get_ip.php", + data: {"type" : "dns_search", "hostname": host_name, "type": "AAAA"}, + success: function (result) { + if (result != ''){ + $('#ipv6').val(result); + } else { + $('#ipv6').val(''); + } + } + }); + }, 3000); + } +}); + function modalServerEdit(id) { $.ajax({ type: "GET", diff --git a/calls.php b/calls.php index 0b71e8d..d6b5490 100644 --- a/calls.php +++ b/calls.php @@ -36,6 +36,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } elseif ($_GET['value'] == 'domain') { $idle->viewMoreDomainModal($_GET['id']);//View more details modal } + } elseif ($_GET['type'] == 'dns_search') { + $idle->getIpForDomain($_GET['hostname'], $_GET['type']); } } } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { diff --git a/class.php b/class.php index 7fe5198..5cdabd3 100644 --- a/class.php +++ b/class.php @@ -1666,6 +1666,7 @@ class idlers extends helperFunctions $this->tagOpen('div', 'input-group'); $this->inputPrepend('Hostname'); $this->textInput('hostname', '', 'form-control', true, 1, 124); + $this->outputString('
'); $this->tagClose('div', 2); $this->colOpen('col-12 col-md-4'); $this->tagOpen('div', 'input-group'); @@ -2787,6 +2788,17 @@ class idlers extends helperFunctions $this->tagClose('div', 2); } + public function getIpForDomain(string $domain, string $type = 'A'): string + {//Gets IP from A record for a domain + $data = json_decode(file_get_contents("https://whatsmydns.net/api/details?server=428&type=$type&query=$domain"), true); + if (isset($data['data'][0]['response'][0])) { + if (strlen($data['data'][0]['response'][0]) > 6) { + return $data['data'][0]['response'][0]; + } + } + return "";//Doesnt exist/null/empty/invalid + } + } class itemInsert extends idlers