Added fetch IPv4 & IPv6 from domain dns api
Added fetch IPv4 & IPv6 from domain dns api
This commit is contained in:
parent
f53b2bb479
commit
e5c836629b
29
assets/js/scripts.min.js
vendored
29
assets/js/scripts.min.js
vendored
|
@ -265,6 +265,35 @@ $(document).on("click", "#addDomainBTN", function () {
|
||||||
$("#addSharedHosting").removeClass("show");
|
$("#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) {
|
function modalServerEdit(id) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
|
|
@ -36,6 +36,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
} elseif ($_GET['value'] == 'domain') {
|
} elseif ($_GET['value'] == 'domain') {
|
||||||
$idle->viewMoreDomainModal($_GET['id']);//View more details modal
|
$idle->viewMoreDomainModal($_GET['id']);//View more details modal
|
||||||
}
|
}
|
||||||
|
} elseif ($_GET['type'] == 'dns_search') {
|
||||||
|
$idle->getIpForDomain($_GET['hostname'], $_GET['type']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
|
12
class.php
12
class.php
|
@ -1666,6 +1666,7 @@ class idlers extends helperFunctions
|
||||||
$this->tagOpen('div', 'input-group');
|
$this->tagOpen('div', 'input-group');
|
||||||
$this->inputPrepend('Hostname');
|
$this->inputPrepend('Hostname');
|
||||||
$this->textInput('hostname', '', 'form-control', true, 1, 124);
|
$this->textInput('hostname', '', 'form-control', true, 1, 124);
|
||||||
|
$this->outputString('<div class="input-group-append"><span class="input-group-text"><a id="fillIpv4" href="#"><i class="fas fa-search"></i></a></span></div>');
|
||||||
$this->tagClose('div', 2);
|
$this->tagClose('div', 2);
|
||||||
$this->colOpen('col-12 col-md-4');
|
$this->colOpen('col-12 col-md-4');
|
||||||
$this->tagOpen('div', 'input-group');
|
$this->tagOpen('div', 'input-group');
|
||||||
|
@ -2787,6 +2788,17 @@ class idlers extends helperFunctions
|
||||||
$this->tagClose('div', 2);
|
$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
|
class itemInsert extends idlers
|
||||||
|
|
Loading…
Reference in New Issue
Block a user