Subversion Repositories vgwhois

Rev

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