Rev 5 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perl
#
# VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois)
# Subprogram: gh TLD whois
#
# (c) 2015 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de>
#
# License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2)
#
use warnings;
use strict;
use utf8;
use FindBin;
use lib "$FindBin::RealBin/../../lib/";
use VGWhoIs::Core;
if (defined $ARGV[0]) {
$_ = join(' ', @ARGV);
} else {
# If no parameter is given, await an input from STDIN
$_ = <>;
chomp;
}
my $query = $_;
my ($dom,$sld) = $query =~ /(.*?)\.(com|org|gov|edu|mil)\.gh$/;
if (!defined $sld) {
# no second level domain, e.g. yellowpages.gh
($dom) = $query =~ /(.*?)\.gh$/;
$sld = '';
}
my $host = 'http://www.nic.gh'; # TODO: https?
my ($protocol, $hostname) = VGWhoIs::Utils::splitProtocolHost($host);
#print "Querying $hostname with $protocol.\n";
# TODO: !defined $dom
my ($text, $exitcode) = VGWhoIs::Core::doquery('','cgipost',"$host/customer/result_c.php","r_cdm=$dom&r_dom_slvl=$sld&Submit=Search");
if ($exitcode) {
# print STDERR "Query to web server failed.\n";
print $text;
exit $exitcode;
}
if ( $text =~ m|(customer/displayresult_c.php\?id=\d+)|s ) {
print "Match found. Now querying for the domain data.\n\n";
($text, $exitcode) = VGWhoIs::Core::doquery($query,'cgi',"$host/$1");
print $text;
} else {
print "No match found. This probably means that this domain does not exist.\n";
}
if ($exitcode) {
# print STDERR "Query to web server failed.\n";
}
exit $exitcode;