Subversion Repositories vgwhois

Rev

Rev 2 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
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
#  generic Whois - Subprogram "vu"
6
#  Subprogram: vu TLD whois
6
#
7
#
7
#  (c) 2014 by Daniel Marschall, ViaThinkSoft <www.viathinksoft.de>
8
#  (c) 2014 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
8
#
9
#
9
#  Distribution, usage etc. pp. regulated by the current version of GPL.
10
#  License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
10
#
-
 
11
#
-
 
12
#
-
 
13
# History:
-
 
14
# 2014-02-02  mar   Initial release
-
 
15
#
11
#
16
 
12
 
17
/*
13
/*
18
 
14
 
19
Official whois server is: vunic.vu
15
Official whois server is: vunic.vu
20
 
16
 
21
But the page http://www.vunic.vu/whoiss/whois.php
17
But the page http://www.vunic.vu/whoiss/whois.php
22
contains following additional information:
18
contains following additional information:
23
- EMail
19
- EMail
24
- Date modified
20
- Date modified
25
- Registrar
21
- Registrar
26
 
22
 
27
*/
23
*/
28
 
24
 
29
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
25
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
30
 
26
 
31
$domain = isset($argv[1]) ? $argv[1] : '';
27
$domain = isset($argv[1]) ? $argv[1] : '';
32
 
28
 
33
if (preg_match('@(.*)((|\.com|\.edu|\.net|\.org)(\.vu))@isU', $domain, $m)) {
29
if (preg_match('@(.*)((|\.com|\.edu|\.net|\.org)(\.vu))@isU', $domain, $m)) {
34
	$domain_wotld = $m[1];
30
	$domain_wotld = $m[1];
35
	$tld = $m[2];
31
	$tld = $m[2];
36
} else {
32
} else {
37
	echo "'$domain' is not a valid .vu domain.\n";
33
	echo "'$domain' is not a valid .vu domain.\n";
38
	exit(2);
34
	exit(2);
39
}
35
}
40
 
36
 
41
$url = 'http://www.vunic.vu/whoiss/process_whois.php';
37
$url = 'http://www.vunic.vu/whoiss/process_whois.php';
42
 
38
 
43
$post = 'domain='.rawurlencode($domain_wotld).'&ext='.rawurlencode($tld);
39
$post = 'domain='.rawurlencode($domain_wotld).'&ext='.rawurlencode($tld);
44
 
40
 
45
$cont = file_get_contents2($url, $post);
41
$cont = file_get_contents2($url, $post);
46
 
42
 
47
$cont = str_replace('</tr>', "\n", $cont);
43
$cont = str_replace('</tr>', "\n", $cont);
48
 
44
 
49
$cont = html_entity_decode(strip_tags($cont));
45
$cont = html_entity_decode(strip_tags($cont));
50
 
46
 
51
// Remove whitespaces at the beginning of each line
47
// Remove whitespaces at the beginning of each line
52
$cont = preg_replace('@([\r\n])[ \t]+(\S)@isU', '\\1\\2', $cont);
48
$cont = preg_replace('@([\r\n])[ \t]+(\S)@isU', '\\1\\2', $cont);
53
$cont = trim($cont);
49
$cont = trim($cont);
54
 
50
 
55
$cont = str_replace("\r", '', $cont);
51
$cont = str_replace("\r", '', $cont);
56
 
52
 
57
$ary = explode("\n", $cont);
53
$ary = explode("\n", $cont);
58
$cont = '';
54
$cont = '';
59
foreach ($ary as $a) {
55
foreach ($ary as $a) {
60
	$a = trim($a);
56
	$a = trim($a);
61
	if ($a == '') continue;
57
	if ($a == '') continue;
62
	$cont .= "$a\n";
58
	$cont .= "$a\n";
63
}
59
}
64
 
60
 
65
$cont = preg_replace('@^(Domain|Registrar|Date Created|Date Modified|Expiry Date)\n@ismU', '$1: ', $cont);
61
$cont = preg_replace('@^(Domain|Registrar|Date Created|Date Modified|Expiry Date)\n@ismU', '$1: ', $cont);
66
 
62
 
67
$cont = str_replace('DNS Server',
63
$cont = str_replace('DNS Server',
68
                    "\nDNS Server\n", $cont);
64
                    "\nDNS Server\n", $cont);
69
 
65
 
70
$cont = str_replace('Registrant',
66
$cont = str_replace('Registrant',
71
                    "\nRegistrant\n", $cont);
67
                    "\nRegistrant\n", $cont);
72
 
68
 
73
$cont = str_replace('Other results you may like',
69
$cont = str_replace('Other results you may like',
74
                    "\nOther results you may like\n\n", $cont);
70
                    "\nOther results you may like\n\n", $cont);
75
 
71
 
76
$cont = preg_replace("@ {0,1}:\n@ismU", ": ", $cont);
72
$cont = preg_replace("@ {0,1}:\n@ismU", ": ", $cont);
77
$cont = str_replace(' : ', ': ', $cont);
73
$cont = str_replace(' : ', ': ', $cont);
78
 
74
 
79
# ---
75
# ---
80
 
76
 
81
$puburl = 'http://www.vunic.vu/whoiss/whois.php';
77
$puburl = 'http://www.vunic.vu/whoiss/whois.php';
82
 
78
 
83
echo "Information about $domain extracted from $puburl:\n\n";
79
echo "Information about $domain extracted from $puburl:\n\n";
84
echo $cont."\n";
80
echo $cont."\n";