-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.php
54 lines (34 loc) · 1.28 KB
/
create.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require("load_func.php");
/*
https://www.php.net/manual/en/function.dns-get-record.php
$dnsr = dns_get_record('php.net', DNS_A + DNS_NS);
$dnsr = dns_get_record('php.net', DNS_ALL - DNS_PTR);
*/
header('Content-Type: application/json');
# Webs service with JSON to show/write list of nameservice many domains in: domain_list.json
try {
load_func([
'https://php.letjson.com/let_json.php',
'https://php.defjson.com/def_json.php',
'https://php.eachfunc.com/each_func.php',
], function () {
$domain_list = $_POST["domains"];
if (empty($domain_list)) {
throw new Exception("domain list is empty");
}
$domain_nameserver_list = each_func($domain_list, function ($domain) {
$records = dns_get_record($domain, DNS_NS);
$nameserver_list[$domain] = each_func($records, function ($record) {
if (empty($record)) return null;
if ($record["type"] !== 'NS') return null;
return $record["target"];
});
if (empty($nameserver_list)) return null;
return $nameserver_list;
});
echo def_json('', $domain_nameserver_list);
});
} catch (Exception $e) {
echo def_json('', ['error' => $e->getMessage()]);
}