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: ac TLD whois |
6 | # Subprogram: ac TLD whois |
7 | # |
7 | # |
8 | # (c) 2011-2014 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
8 | # (c) 2011-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 | require_once __DIR__ . '/../../../shared/php_includes/common_functions.inc.php'; |
13 | require_once __DIR__ . '/../../../shared/php_includes/common_functions.inc.php'; |
14 | 14 | ||
15 | $domain = isset($argv[1]) ? $argv[1] : ''; |
15 | $domain = isset($argv[1]) ? $argv[1] : ''; |
16 | 16 | ||
17 | $url = "http://www.nic.ac/cgi-bin/whois?query=$domain"; |
17 | $url = "http://www.nic.ac/cgi-bin/whois?query=$domain"; |
18 | 18 | ||
19 | $res = "% Parsing via regex from '$url'\n\n"; |
19 | $res = "% Parsing via regex from '$url'\n\n"; |
20 | 20 | ||
21 | $x = file_get_contents2($url); |
21 | $x = file_get_contents2($url); |
22 | 22 | ||
23 | preg_match_all('|<div class="mainboxBody">(.*)<div class="mainboxFoot">|ismU', $x, $m); |
23 | preg_match_all('|<div class="mainboxBody">(.*)<div class="mainboxFoot">|ismU', $x, $m); |
24 | 24 | ||
25 | if (!isset($m[1][0])) { |
25 | if (!isset($m[1][0])) { |
26 | fwrite(STDERR, "Cannot parse page (mainboxBody missing). Please report this bug.\n"); |
26 | fwrite(STDERR, "Cannot parse page (mainboxBody missing). Please report this bug.\n"); |
27 | exit(1); |
27 | exit(1); |
28 | } |
28 | } |
29 | 29 | ||
30 | $x = $m[1][0]; |
30 | $x = $m[1][0]; |
31 | 31 | ||
32 | $x = strip_tags($x); |
32 | $x = strip_tags($x); |
33 | 33 | ||
34 | $x = preg_replace('|:\s*([^\s])|ismU', ': $1', $x); |
34 | $x = preg_replace('|:\s*([^\s])|ismU', ': $1', $x); |
35 | $x = preg_replace('|^\s*([^\s])|ismU', '$1', $x); |
35 | $x = preg_replace('|^\s*([^\s])|ismU', '$1', $x); |
36 | 36 | ||
37 | $x = html_entity_decode($x); |
37 | $x = html_entity_decode($x); |
38 | 38 | ||
39 | $special_words = array( |
39 | $special_words = array( |
40 | 'Domain Information', |
40 | 'Domain Information', |
41 | 'Admin Contact', |
41 | 'Admin Contact', |
42 | 'Technical Contact', |
42 | 'Technical Contact', |
43 | 'Billing Contact', |
43 | 'Billing Contact', |
44 | 'Primary Nameserver', |
44 | 'Primary Nameserver', |
45 | 'Secondary Nameserver' |
45 | 'Secondary Nameserver' |
46 | ); |
46 | ); |
47 | 47 | ||
48 | foreach ($special_words as $s) { |
48 | foreach ($special_words as $s) { |
49 | $x = str_replace($s, "\n".strtoupper($s)."\n", $x); |
49 | $x = str_replace($s, "\n".strtoupper($s)."\n", $x); |
50 | } |
50 | } |
51 | 51 | ||
52 | $x = make_tabs($x); |
52 | $x = make_tabs($x); |
53 | 53 | ||
54 | $x = trim($x); |
54 | $x = trim($x); |
55 | 55 | ||
56 | $x = str_replace(' - CLICK TO BUY', '', $x); |
56 | $x = str_replace(' - CLICK TO BUY', '', $x); |
57 | 57 | ||
58 | echo $res.trim_each_line($x)."\n"; |
58 | echo $res.trim_each_line($x)."\n"; |