Subversion Repositories vgwhois

Rev

Rev 5 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
#!/usr/bin/php
2
<?php
3
 
4
#
5
#  generic Whois - Subprogram "tt"
6
#
7
#  (c) 2011 by Daniel Marschall, ViaThinkSoft <www.viathinksoft.de>
8
#
9
#  Distribution, usage etc. pp. regulated by the current version of GPL.
10
#
11
#
12
#
13
# History:
14
# 2011-06-07  mar   Initial release
15
#
16
 
17
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
18
 
19
$domain = isset($argv[1]) ? $argv[1] : '';
20
 
21
$url = "https://www.nic.tt/cgi-bin/search.pl";
22
$post = "name=$domain";
23
 
24
$res = "% Parsing via regex from '$url' with post parameters '$post'\n\n";
25
 
26
$x = file_get_contents2($url, $post);
27
 
28
preg_match_all('|<div id="main">(.*)<div id="foot">|ismU', $x, $m);
29
 
30
$x = $m[1][0];
31
 
32
# The Domain Name <font color=red>nia.tt</font> is available.
33
$x = str_replace('<font color=red>', '', $x);
34
$x = str_replace('</font>', '', $x);
35
 
36
# Entferne, wenn möglich:
37
# Domain Search Form
38
# Enter Domain Name:
39
$bry = explode('</form>', $x, 2);
40
$x = $bry[count($bry)-1];
41
 
42
$x = str_replace('>', ">\n", $x);
43
 
44
$x = strip_tags($x);
45
 
46
# &nbsp -> &nbsp;   -- did they really do this? yeah...
47
$x = preg_replace('|&nbsp(?!;)|ismU', '&nbsp;', $x);
48
 
49
// You might wonder why trim(html_entity_decode('&nbsp;')); doesn't reduce the string to an
50
// empty string, that's because the '&nbsp;' entity is not ASCII code 32
51
// (which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.
52
$x = str_replace("&nbsp;", " ", $x);
53
 
54
$x = html_entity_decode($x);
55
 
56
$x = preg_replace("| +|", ' ', $x);
57
$x = preg_replace("|\n *|", "\n", $x);
58
$x = preg_replace("|\n+|", "\n", $x);
59
 
60
$special_words = array(
61
	'Domain Name',
62
	'Registrant Name',
63
	'Registrant Address',
64
	'DNS Hostnames',
65
	'DNS IP Addresses',
66
	'Expiration Date',
67
	'Administrative Contact',
68
	'Technical Contact',
69
	'Billing Contact'
70
);
71
 
72
foreach ($special_words as $s) {
73
	$x = str_replace("\n$s\n", "\n\n".strtoupper($s)."\n\n", $x);
74
}
75
 
76
$x = trim($x);
77
 
78
echo $res.trim_each_line($x)."\n";