Subversion Repositories vgwhois

Rev

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 "fj"
6
#
7
#  (c) 2018 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
# 2018-04-05  mar   Initial release
15
#
16
 
17
# Alternatively, you can query whois.nic.fj , but it does not show the full address
18
 
19
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php';
20
 
21
$domain = isset($argv[1]) ? $argv[1] : '';
22
 
23
list($namewotld, $tld) = explode('.', $domain, 2);
24
 
25
if ($tld == 'fj') {
26
	echo "Whois for .fj is not possible. Please use a 2nd level TLD like .com.fj\n";
27
	exit;
28
}
29
 
30
$cont = file_get_contents2('http://domains.fj/public/whois.php?searchDomainName='.urlencode($namewotld).'&searchTopLevel='.urlencode($tld).'&submitSearch=Search');
31
 
32
if (strpos($cont, 'does not exist,<br><br>') !== false) {
33
	echo "Domain $domain does not exist\n";
34
	exit;
35
}
36
 
37
if (preg_match('@<div class="errorBox">(.+)</div>@ismU', $cont, $m)) {
38
	$cont = $m[1];
39
	$cont = str_replace(', please choose one from the drop down list', '', $cont);
40
} else if (preg_match('@<table border=\'0\'>(.+)</table>@ismU', $cont, $m)) {
41
	$cont = $m[1];
42
}
43
 
44
$cont = str_replace('<br>', "\n", $cont);
45
$cont = html_entity_decode($cont);
46
$cont = strip_tags($cont);
47
$cont = explode("\n", $cont);
48
foreach ($cont as &$line) $line = trim($line);
49
$cont = implode("\n", $cont);
50
$cont = str_replace("\n\n", "\n", $cont);
51
$cont = trim($cont);
52
 
53
echo "$cont\n";