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 "ac"
6
#
7
#  (c) 2011-2014 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
# 2014-11-30  mar   Fixed
16
#
17
 
18
require_once __DIR__ . '/../../../shared/php_includes/common_functions.inc.php';
19
 
20
$domain = isset($argv[1]) ? $argv[1] : '';
21
 
22
$url = "http://www.nic.ac/cgi-bin/whois?query=$domain";
23
 
24
$res = "% Parsing via regex from '$url'\n\n";
25
 
26
$x = file_get_contents2($url);
27
 
28
preg_match_all('|<div class="mainboxBody">(.*)<div class="mainboxFoot">|ismU', $x, $m);
29
 
30
if (!isset($m[1][0])) {
31
	fwrite(STDERR, "Cannot parse page (mainboxBody missing). Please report this bug.\n");
32
	exit(1);
33
}
34
 
35
$x = $m[1][0];
36
 
37
$x = strip_tags($x);
38
 
39
$x = preg_replace('|:\s*([^\s])|ismU', ': $1', $x);
40
$x = preg_replace('|^\s*([^\s])|ismU', '$1', $x);
41
 
42
$x = html_entity_decode($x);
43
 
44
$special_words = array(
45
	'Domain Information',
46
	'Admin Contact',
47
	'Technical Contact',
48
	'Billing Contact',
49
	'Primary Nameserver',
50
	'Secondary Nameserver'
51
);
52
 
53
foreach ($special_words as $s) {
54
	$x = str_replace($s, "\n".strtoupper($s)."\n", $x);
55
}
56
 
57
$x = make_tabs($x);
58
 
59
$x = trim($x);
60
 
61
$x = str_replace(' - CLICK TO BUY', '', $x);
62
 
63
echo $res.trim_each_line($x)."\n";