forked from tldev-de/find-short-domains
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathde.php
49 lines (42 loc) · 1.54 KB
/
de.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
<?php
require(__DIR__ . '/vendor/autoload.php');
define('DE_CANDIDATES_FILE', 'de_candidates.txt');
$allowedChars = array_merge(
range('a', 'z'),
range(0, 9),
['-']
);
// generate all three chars candidates
if (!is_file(DE_CANDIDATES_FILE)) {
foreach ($allowedChars as $char1) {
foreach ($allowedChars as $char2) {
foreach ($allowedChars as $char3) {
$domain = $char1 . $char2 . $char3 . '.de';
if (preg_match('/^[a-z0-9][1-z0-9\-]+[a-z0-9]\.de$/', $domain)) {
file_put_contents(DE_CANDIDATES_FILE, $domain . "\n", FILE_APPEND);
}
}
}
}
}
// check candidates for availability
$candidates = file(DE_CANDIDATES_FILE);
$whois = new Whois();
$whois->deepWhois = false; // query only one whois server
foreach ($candidates as $key => $candidate) {
$candidate = trim($candidate); // remove newline
echo 'next candidate: ' . $candidate . ' - ' . ($key + 1) . ' / ' . count($candidates) . PHP_EOL;
// since whois queries are very slow we use dns queries to speed things up ;)
if (gethostbyname($candidate) !== $candidate) {
echo '... skip ' . $candidate . ' due to dns' . PHP_EOL;
usleep(50000);
continue;
}
$result = $whois->lookup($candidate, false);
if ($result['regrinfo']['registered'] !== 'no') {
echo '... skip ' . $candidate . ' due to whois' . PHP_EOL;
usleep(500000);
continue;
}
file_put_contents('free_de_domains.txt', $candidate . PHP_EOL, FILE_APPEND);
}