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