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: vu TLD whois |
6 | # Subprogram: vu TLD whois |
7 | # |
7 | # |
8 | # (c) 2014 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
8 | # (c) 2014 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 | /* |
13 | /* |
14 | 14 | ||
15 | Official whois server is: vunic.vu |
15 | Official whois server is: vunic.vu |
16 | 16 | ||
17 | But the page http://www.vunic.vu/whoiss/whois.php |
17 | But the page http://www.vunic.vu/whoiss/whois.php |
18 | contains following additional information: |
18 | contains following additional information: |
19 | 19 | ||
20 | - Date modified |
20 | - Date modified |
21 | - Registrar |
21 | - Registrar |
22 | 22 | ||
23 | */ |
23 | */ |
24 | 24 | ||
25 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
25 | require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
26 | 26 | ||
27 | $domain = isset($argv[1]) ? $argv[1] : ''; |
27 | $domain = isset($argv[1]) ? $argv[1] : ''; |
28 | 28 | ||
29 | if (preg_match('@(.*)((|\.com|\.edu|\.net|\.org)(\.vu))@isU', $domain, $m)) { |
29 | if (preg_match('@(.*)((|\.com|\.edu|\.net|\.org)(\.vu))@isU', $domain, $m)) { |
30 | $domain_wotld = $m[1]; |
30 | $domain_wotld = $m[1]; |
31 | $tld = $m[2]; |
31 | $tld = $m[2]; |
32 | } else { |
32 | } else { |
33 | echo "'$domain' is not a valid .vu domain.\n"; |
33 | echo "'$domain' is not a valid .vu domain.\n"; |
34 | exit(2); |
34 | exit(2); |
35 | } |
35 | } |
36 | 36 | ||
37 | $url = 'http://www.vunic.vu/whoiss/process_whois.php'; |
37 | $url = 'http://www.vunic.vu/whoiss/process_whois.php'; |
38 | 38 | ||
39 | $post = 'domain='.rawurlencode($domain_wotld).'&ext='.rawurlencode($tld); |
39 | $post = 'domain='.rawurlencode($domain_wotld).'&ext='.rawurlencode($tld); |
40 | 40 | ||
41 | $cont = file_get_contents2($url, $post); |
41 | $cont = file_get_contents2($url, $post); |
42 | 42 | ||
43 | $cont = str_replace('</tr>', "\n", $cont); |
43 | $cont = str_replace('</tr>', "\n", $cont); |
44 | 44 | ||
45 | $cont = html_entity_decode(strip_tags($cont)); |
45 | $cont = html_entity_decode(strip_tags($cont)); |
46 | 46 | ||
47 | // Remove whitespaces at the beginning of each line |
47 | // Remove whitespaces at the beginning of each line |
48 | $cont = preg_replace('@([\r\n])[ \t]+(\S)@isU', '\\1\\2', $cont); |
48 | $cont = preg_replace('@([\r\n])[ \t]+(\S)@isU', '\\1\\2', $cont); |
49 | $cont = trim($cont); |
49 | $cont = trim($cont); |
50 | 50 | ||
51 | $cont = str_replace("\r", '', $cont); |
51 | $cont = str_replace("\r", '', $cont); |
52 | 52 | ||
53 | $ary = explode("\n", $cont); |
53 | $ary = explode("\n", $cont); |
54 | $cont = ''; |
54 | $cont = ''; |
55 | foreach ($ary as $a) { |
55 | foreach ($ary as $a) { |
56 | $a = trim($a); |
56 | $a = trim($a); |
57 | if ($a == '') continue; |
57 | if ($a == '') continue; |
58 | $cont .= "$a\n"; |
58 | $cont .= "$a\n"; |
59 | } |
59 | } |
60 | 60 | ||
61 | $cont = preg_replace('@^(Domain|Registrar|Date Created|Date Modified|Expiry Date)\n@ismU', '$1: ', $cont); |
61 | $cont = preg_replace('@^(Domain|Registrar|Date Created|Date Modified|Expiry Date)\n@ismU', '$1: ', $cont); |
62 | 62 | ||
63 | $cont = str_replace('DNS Server', |
63 | $cont = str_replace('DNS Server', |
64 | "\nDNS Server\n", $cont); |
64 | "\nDNS Server\n", $cont); |
65 | 65 | ||
66 | $cont = str_replace('Registrant', |
66 | $cont = str_replace('Registrant', |
67 | "\nRegistrant\n", $cont); |
67 | "\nRegistrant\n", $cont); |
68 | 68 | ||
69 | $cont = str_replace('Other results you may like', |
69 | $cont = str_replace('Other results you may like', |
70 | "\nOther results you may like\n\n", $cont); |
70 | "\nOther results you may like\n\n", $cont); |
71 | 71 | ||
72 | $cont = preg_replace("@ {0,1}:\n@ismU", ": ", $cont); |
72 | $cont = preg_replace("@ {0,1}:\n@ismU", ": ", $cont); |
73 | $cont = str_replace(' : ', ': ', $cont); |
73 | $cont = str_replace(' : ', ': ', $cont); |
74 | 74 | ||
75 | # --- |
75 | # --- |
76 | 76 | ||
77 | $puburl = 'http://www.vunic.vu/whoiss/whois.php'; |
77 | $puburl = 'http://www.vunic.vu/whoiss/whois.php'; |
78 | 78 | ||
79 | echo "Information about $domain extracted from $puburl:\n\n"; |
79 | echo "Information about $domain extracted from $puburl:\n\n"; |
80 | echo $cont."\n"; |
80 | echo $cont."\n"; |