Rev 5 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 11 | ||
---|---|---|---|
1 | #!/usr/bin/php |
1 | #!/usr/bin/php |
2 | <?php |
2 | <?php |
3 | 3 | ||
4 | # |
4 | # |
5 | # VWhois (ViaThinkSoft WHOIS, a fork of generic Whois / gwhois) |
5 | # VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois) |
6 | # Subprogram: fj TLD whois |
6 | # Subprogram: fj TLD whois |
7 | # |
7 | # |
8 | # (c) 2018 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
8 | # (c) 2018 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
9 | # |
9 | # |
10 | # License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2) |
10 | # License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2) |
11 | # |
11 | # |
12 | 12 | ||
13 | # Alternatively, you can query whois.nic.fj , but it does not show the full address |
13 | # Alternatively, you can query whois.nic.fj , but it does not show the full address |
14 | 14 | ||
15 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
15 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
16 | 16 | ||
17 | $domain = isset($argv[1]) ? $argv[1] : ''; |
17 | $domain = isset($argv[1]) ? $argv[1] : ''; |
18 | 18 | ||
19 | list($namewotld, $tld) = explode('.', $domain, 2); |
19 | list($namewotld, $tld) = explode('.', $domain, 2); |
20 | 20 | ||
21 | if ($tld == 'fj') { |
21 | if ($tld == 'fj') { |
22 | echo "Whois for .fj is not possible. Please use a 2nd level TLD like .com.fj\n"; |
22 | echo "Whois for .fj is not possible. Please use a 2nd level TLD like .com.fj\n"; |
23 | exit; |
23 | exit; |
24 | } |
24 | } |
25 | 25 | ||
26 | $cont = file_get_contents2('http://domains.fj/public/whois.php?searchDomainName='.urlencode($namewotld).'&searchTopLevel='.urlencode($tld).'&submitSearch=Search'); |
26 | $cont = file_get_contents2('http://domains.fj/public/whois.php?searchDomainName='.urlencode($namewotld).'&searchTopLevel='.urlencode($tld).'&submitSearch=Search'); |
27 | 27 | ||
28 | if (strpos($cont, 'does not exist,<br><br>') !== false) { |
28 | if (strpos($cont, 'does not exist,<br><br>') !== false) { |
29 | echo "Domain $domain does not exist\n"; |
29 | echo "Domain $domain does not exist\n"; |
30 | exit; |
30 | exit; |
31 | } |
31 | } |
32 | 32 | ||
33 | if (preg_match('@<div class="errorBox">(.+)</div>@ismU', $cont, $m)) { |
33 | if (preg_match('@<div class="errorBox">(.+)</div>@ismU', $cont, $m)) { |
34 | $cont = $m[1]; |
34 | $cont = $m[1]; |
35 | $cont = str_replace(', please choose one from the drop down list', '', $cont); |
35 | $cont = str_replace(', please choose one from the drop down list', '', $cont); |
36 | } else if (preg_match('@<table border=\'0\'>(.+)</table>@ismU', $cont, $m)) { |
36 | } else if (preg_match('@<table border=\'0\'>(.+)</table>@ismU', $cont, $m)) { |
37 | $cont = $m[1]; |
37 | $cont = $m[1]; |
38 | } |
38 | } |
39 | 39 | ||
40 | $cont = str_replace('<br>', "\n", $cont); |
40 | $cont = str_replace('<br>', "\n", $cont); |
41 | $cont = html_entity_decode($cont); |
41 | $cont = html_entity_decode($cont); |
42 | $cont = strip_tags($cont); |
42 | $cont = strip_tags($cont); |
43 | $cont = explode("\n", $cont); |
43 | $cont = explode("\n", $cont); |
44 | foreach ($cont as &$line) $line = trim($line); |
44 | foreach ($cont as &$line) $line = trim($line); |
45 | $cont = implode("\n", $cont); |
45 | $cont = implode("\n", $cont); |
46 | $cont = str_replace("\n\n", "\n", $cont); |
46 | $cont = str_replace("\n\n", "\n", $cont); |
47 | $cont = trim($cont); |
47 | $cont = trim($cont); |
48 | 48 | ||
49 | echo "$cont\n"; |
49 | echo "$cont\n"; |