Subversion Repositories vgwhois

Rev

Rev 5 | Details | Compare with Previous | Last modification | View Log | RSS feed

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