-
-
Save billionaire/362401c06eb1942e4f7eaae12701e58b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# demo | |
var_dump(isComDomainAvailable('aaaa.com')); | |
var_dump(isComDomainAvailable('askdhbfjasdfbh.com')); | |
# job | |
foreach (getDomainName() as $domainName) { | |
if (isComDomainAvailable($domainName)) { | |
echo $domainName.PHP_EOL; | |
} | |
} | |
function isComDomainAvailable(string $domainName): bool { | |
$fp = fsockopen('whois.crsnic.net', 43); | |
if (!$fp) { | |
echo $domainName." - Connection error!\n"; | |
return false; | |
} | |
fputs($fp, "$domainName\r\n"); | |
$string = ''; | |
while (!feof($fp)) { | |
$string .= fgets($fp, 128); | |
} | |
fclose($fp); | |
if (stripos($string, 'No match for ') !== false) { | |
return true; | |
} | |
return false; | |
} | |
function getDomainName() { | |
$filename = './domain.list.txt'; | |
$domainArray = file_exists($filename)?file($filename, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES):[]; | |
foreach ($domainArray as $domainName) { | |
yield $domainName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment