Subversion Repositories vgwhois

Rev

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