-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomainAvailabilityChecker.php
More file actions
58 lines (55 loc) · 1.6 KB
/
DomainAvailabilityChecker.php
File metadata and controls
58 lines (55 loc) · 1.6 KB
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
55
56
57
58
<?php
require_once '../app/require.php';
$api = new APIController;
function isDomainAvailable($domain) {
$domainParts = explode('.', $domain);
$extension = end($domainParts);
if (checkdnsrr($domain, 'ANY')) {
return false;
}
return true;
}
// start key
if (isset($_GET['key']))
{
$statusCheck = $api->CheckKey($_GET['key'], $_SERVER['REQUEST_URI']);
// start statusCheck
if ($statusCheck === "valid")
{
// start domain check
if (isset($_GET['domain']))
{
$domain = $_GET['domain'];
$isAvailable = isDomainAvailable($domain);
// start json check
if (isset($_GET['json']))
{
header("Content-Type: application/json");
$api->QueryLog($domain, "DomainAvailability", $_GET['key']);
echo json_encode(["domain" => $domain, "isAvailable" => $isAvailable], JSON_PRETTY_PRINT);
}
else {
echo 'Domain: ' . $domain . ' | Is Available: ' . ($isAvailable ? 'Yes' : 'No') . "\n";
$api->QueryLog($domain, "DomainAvailability", $_GET['key']);
}
// end json check
}
else {
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Content-Type: application/json");
echo json_encode(["error" => "Missing 'domain' parameter"]);
}
// end domain check
}
else {
echo $statusCheck;
}
}
else {
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Content-Type: application/json");
echo json_encode(["error" => "Missing 'key' parameter"]);
}
?>