-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-name-servers.php
executable file
·44 lines (35 loc) · 1.28 KB
/
check-name-servers.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
<?php
use evan_klein\ek as ek;
try{
if(
!isset($argv[1])
||
!isset($argv[2])
) throw new Exception("Usage: check-name-servers.php <domain> <name_servers_file_path>", 400);
require_once('ek.php');
$domain = $argv[1];
$name_servers_file_path = $argv[2];
$name_servers = ek\readJSONFile($name_servers_file_path);
if( !isset($name_servers[$domain]) ) throw new Exception("Domain not found in '$name_servers_file_path'", 404);
$name_servers_expected = ek\arrayToLower($name_servers[$domain]);
$name_servers_actual = ek\getNameServers($domain);
$name_servers_diff = ek\diffArrays($name_servers_expected, $name_servers_actual);
$php_eol = PHP_EOL;
$php_eol2 = "$php_eol$php_eol";
$console_red = "\033[31m";
$console_green = "\033[32m";
$console_clear = "\033[0m";
if($name_servers_diff['arrays_are_equal']){
echo $console_green . "✅ Name servers for $domain match!$console_clear$php_eol2";
}
else{
echo $console_red . "⚠️ Name servers for $domain do NOT match!$console_clear$php_eol2";
echo "\tWhat they should be:$php_eol\t" . implode("$php_eol\t", $name_servers_expected) . $php_eol2;
echo "$console_red\tWhat they are:$php_eol\t" . implode("$php_eol\t", $name_servers_actual) . "$console_clear$php_eol2";
}
}
catch(Exception $e){
echo $e->getMessage();
exit(1);
}
?>