-
Notifications
You must be signed in to change notification settings - Fork 0
/
whois.php
48 lines (39 loc) · 1.04 KB
/
whois.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
<?php
$uri = @$_SERVER['REQUEST_URI'];
if ($uri){
$uri = strtolower($uri);
$uri = rtrim($uri, '/');
$uri = substr($uri, 0, strpos($uri, '?')?:strlen($uri));
while (str_contains($uri, "//"))
$uri = str_replace("//","/",$uri);
$uri = explode("/", $uri);
}else{
$cliMode = true;
$uri = $argv;
}
$domainName = end($uri);
if(isset($domainName)){
$TDL = @end(explode(".",$domainName));
$server = $TDL.".whois-servers.net";
if(preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $domainName)){
$server = "COM.whois-servers.net";
}
$port=43;
if(@($whoisInfo = fsockopen($server,$port)) == true)
{
$output = "";
fputs($whoisInfo,"$domainName\r\n");
while(!feof($whoisInfo))
$output .= fgets($whoisInfo,128);
fclose($whoisInfo);
}else{$error = 'This domain is wrong or not supported!';}
if(@$cliMode && @$error){
fwrite(STDERR, $error);
}elseif(@$cliMode && @$output){
fwrite(STDOUT, $output);
}else{
echo "<pre>" . (@$output?:$error) . "</pre>";
}
}
## Whois server list === https://www.nirsoft.net/whois-servers.txt
?>