Subversion Repositories vgwhois

Rev

Rev 4 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
#!/usr/bin/perl
2
 
3
#
4
#  generic Whois - gh subprogram
5
#
6
#  (c) 2015 by Daniel Marschall, ViaThinkSoft <www.viathinksoft.de>
7
#
8
#  Distribution, usage etc. pp. regulated by the current version of GPL.
9
#
10
#
11
#
12
# History:
13
# 2015-05-15  mar   Initial release
14
#
15
 
16
use warnings;
17
use strict;
18
use utf8;
19
 
20
use FindBin;
21
use lib "$FindBin::Bin/../../lib/";
22
use GWhoIs::Core;
23
 
24
if (defined $ARGV[0]) {
25
	$_ = join(' ', @ARGV);
26
} else {
27
	# If no parameter is given, await an input from STDIN
28
	$_ = <>;
29
	chomp;
30
}
31
 
32
my $query = $_;
33
 
34
my ($dom,$sld) = $query =~ /(.*?)\.(com|org|gov|edu|mil)\.gh$/;
35
 
36
if (!defined $sld) {
37
	# no second level domain, e.g. yellowpages.gh
38
	($dom) = $query =~ /(.*?)\.gh$/;
39
	$sld = '';
40
}
41
 
42
my $host = 'http://www.nic.gh'; # TODO: https?
43
 
44
my ($protocol, $hostname) = GWhoIs::Utils::splitProtocolHost($host);
45
 
46
#print "Querying $hostname with $protocol.\n";
47
 
48
# TODO: !defined $dom
49
my ($text, $exitcode) = GWhoIs::Core::doquery('','cgipost',"$host/customer/result_c.php","r_cdm=$dom&r_dom_slvl=$sld&Submit=Search");
50
if ($exitcode) {
51
	# print STDERR "Query to web server failed.\n";
52
	print $text;
53
	exit $exitcode;
54
}
55
 
56
if ( $text =~ m|(customer/displayresult_c.php\?id=\d+)|s ) {
57
	print "Match found. Now querying for the domain data.\n\n";
58
	($text, $exitcode) = GWhoIs::Core::doquery($query,'cgi',"$host/$1");
59
	print $text;
60
} else {
61
	print "No match found. This probably means that this domain does not exist.\n";
62
}
63
 
64
if ($exitcode) {
65
	# print STDERR "Query to web server failed.\n";
66
}
67
 
68
exit $exitcode;
69