Subversion Repositories vgwhois

Rev

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