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