Rev 11 | 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: tt TLD whois |
2 | daniel-mar | 7 | # |
149 | daniel-mar | 8 | # (c) 2011-2024 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 | |||
149 | daniel-mar | 15 | ini_set('default_charset', 'UTF-8'); |
16 | |||
2 | daniel-mar | 17 | $domain = isset($argv[1]) ? $argv[1] : ''; |
18 | |||
19 | $url = "https://www.nic.tt/cgi-bin/search.pl"; |
||
20 | $post = "name=$domain"; |
||
21 | |||
22 | $res = "% Parsing via regex from '$url' with post parameters '$post'\n\n"; |
||
23 | |||
24 | $x = file_get_contents2($url, $post); |
||
25 | |||
149 | daniel-mar | 26 | preg_match_all('|<div class="main">(.*)<div id="foot">|ismU', $x, $m); |
27 | if (!isset($m[1][0])) { |
||
28 | echo "Error while parsing the web content (RegEx failed).\n"; |
||
29 | exit(1); |
||
30 | } |
||
2 | daniel-mar | 31 | |
32 | $x = $m[1][0]; |
||
33 | |||
149 | daniel-mar | 34 | $x = str_replace("under <a href='https://www.nic.tt/cgi-bin/status.pl'>Retrieve->Domain Details</a>", "here: https://www.nic.tt/cgi-bin/status.pl", $x); |
35 | |||
2 | daniel-mar | 36 | # The Domain Name <font color=red>nia.tt</font> is available. |
37 | $x = str_replace('<font color=red>', '', $x); |
||
38 | $x = str_replace('</font>', '', $x); |
||
39 | |||
149 | daniel-mar | 40 | # Entferne, wenn möglich: |
2 | daniel-mar | 41 | # Domain Search Form |
42 | # Enter Domain Name: |
||
43 | $bry = explode('</form>', $x, 2); |
||
44 | $x = $bry[count($bry)-1]; |
||
45 | |||
46 | $x = str_replace('>', ">\n", $x); |
||
47 | |||
48 | $x = strip_tags($x); |
||
49 | |||
50 | #   -> -- did they really do this? yeah... |
||
51 | $x = preg_replace('| (?!;)|ismU', ' ', $x); |
||
52 | |||
53 | // You might wonder why trim(html_entity_decode(' ')); doesn't reduce the string to an |
||
54 | // empty string, that's because the ' ' entity is not ASCII code 32 |
||
55 | // (which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 8859-1 characterset. |
||
56 | $x = str_replace(" ", " ", $x); |
||
57 | |||
58 | $x = html_entity_decode($x); |
||
59 | |||
60 | $x = preg_replace("| +|", ' ', $x); |
||
61 | $x = preg_replace("|\n *|", "\n", $x); |
||
62 | $x = preg_replace("|\n+|", "\n", $x); |
||
63 | |||
64 | $special_words = array( |
||
65 | 'Domain Name', |
||
66 | 'Registrant Name', |
||
67 | 'Registrant Address', |
||
68 | 'DNS Hostnames', |
||
69 | 'DNS IP Addresses', |
||
149 | daniel-mar | 70 | 'Registration Date', |
2 | daniel-mar | 71 | 'Expiration Date', |
72 | 'Administrative Contact', |
||
73 | 'Technical Contact', |
||
74 | 'Billing Contact' |
||
75 | ); |
||
76 | |||
77 | foreach ($special_words as $s) { |
||
149 | daniel-mar | 78 | $x = str_replace("\n$s\n", "\n\n".mb_strtoupper($s)."\n\n", $x); |
2 | daniel-mar | 79 | } |
80 | |||
81 | $x = trim($x); |
||
82 | |||
83 | echo $res.trim_each_line($x)."\n"; |