#!/usr/bin/perl
#
# Author: Peter Keel <killer@discordia.ch>
#
# Produces dom-reg form out of whois-query
#
die "Usage: $0 domain\n"       unless($ARGV[0]);

$domain = @ARGV[0];
$tld = (split(/\.\b/,$domain))[1];
if ($tld eq "ch" || $tld eq "li") { $server="whois.nic.ch" }
    elsif ($tld eq "com" || $tld eq "net" || $tld eq "org") { $server="whois.internic.net" }
else { die "Unknown TLD\n" };

die "Sorry, foreign domains not implemented" unless ($server eq "whois.nic.ch");

chomp(@whois = qx!/usr/bin/whois.real -h $server $domain!);

print "*******************************************************************\n";
print "Start of Domain Name Registration Template for Switzerland (*.ch)\n";
print "Revision: Application_04 (please submit this banner with the form).\n"; 
print "*******************************************************************\n";
print "\n";
print "# part 1: type of request\n";
print "# (N) register new domain name,\n";
print "# (M) modify domain information,\n"; 
print "# (D) delete domain information\n";
print "requesttype (specify N, M or D)....:M\n";
print "\n";
    foreach $_ (@whois) {
	if (/domainname/) {
	    $x= (split(/\:\s+/))[1];
	    print "domainname.........................:$x\n";
	}
    }
print "\n";
print "# requested status of domain\n";
print "# (A) active (for immediate usage),\n";
print "# (I) inactive domain \n";
print "#    (for later usage, reservation)\n";
print "domaintype (specify A or I)........:A\n";
print "\n";
print "# holder of secondlevel domain name\n";
print "# (O) organization, \n";
print "# (P) private person\n";
    foreach $_ (@whois) {
	if (/ownertype/) {
	    $x= (split(/\:\s+/))[1];
	    print "ownertype (specify O or P).........:$x\n";
	}
    }
print "\n";
print "# part 2: organization information \n";
print "# (for organizations only)\n";
    foreach $_ (@whois) {
	if (/org-name/) {
	    $x= (split(/\:\s+/))[1];
	    print "org-name...........................:$x\n";
	}          
    }
    foreach $_ (@whois) {
	if (/org-address/) {
	    $x= (split(/\:\s+/))[1];
	    print "org-address........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/org-zipcode/) {
	    $x= (split(/\:\s+/))[1];
	    print "org-zipcode........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/org-city/) {
	    $x= (split(/\:\s+/))[1];
	    print "org-city...........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/org-country/) {
	    $x= (split(/\:\s+/))[1];
	    print "org-country........................:$x\n";
	}
    }
print "\n";
print "# part 3: administrative contact \n";
print "# (contact responsible for domain)\n";
    foreach $_ (@whois) {
	if (/adm-name/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-name...........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/adm-address/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-address........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/adm-zipcode/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-zipcode........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/adm-city/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-city...........................:$x\n";
	}
    }

    foreach $_ (@whois) {
	if (/adm-country/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-country........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/adm-phone/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-phone..........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/adm-fax/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-fax............................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/adm-email/) {
	    $x= (split(/\:\s+/))[1];
	    print "adm-email..........................:$x\n";
	}
    }
print "\n";
print "# part 4: technical contact \n";
print "# (technical contact address)\n";
print "tec-name...........................:Beat Tinner\n";
print "tec-address........................:Cyberlink Internet Services AG\n";
print "tec-address........................:Richard Wagnerstrasse 6\n";
print "tec-zipcode........................:8002\n";
print "tec-city...........................:Zuerich\n";
print "tec-country........................:Switzerland\n";
print "tec-phone..........................:+41 1 287 29 92\n";
print "tec-fax............................:+41 1 287 29 91\n";
print "tec-email..........................:admin\@cyberlink.ch\n";
print "\n";
print "# part 5: billing contact \n";
print "# (address used for invoices)\n";
    foreach $_ (@whois) {
	if (/bil-org/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-org............................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/bil-name/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-name...........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/bil-address/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-address........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/bil-zipcode/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-zipcode........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/bil-city/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-city...........................:$x\n";
	}
    }

    foreach $_ (@whois) {
	if (/bil-country/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-country........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/bil-phone/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-phone..........................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/bil-fax/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-fax............................:$x\n";
	}
    }
    foreach $_ (@whois) {
	if (/bil-email/) {
	    $x= (split(/\:\s+/))[1];
	    print "bil-email..........................:$x\n";
	}
    }


print "# part 6: \n";
print "# primary name server information \n";
print "# (mandatory for active domains)\n";
print "nserver host name..................:dns.cyberlink.ch\n";
print "nserver netaddress.................:193.246.253.10\n";
print "\n";
print "# part 7: \n";
print "# secondary name server information \n";
print "# (mandatory for active domains)\n";
print "nserver host name..................:dns2.cyberlink.ch\n";
print "nserver netaddress.................:193.246.253.15\n";
print "\n";
print "# part 8: \n";
print "# additional name server information \n";
print "# (optional for active domains)\n";
print "nserver host name..................:\n";
print "nserver netaddress.................:\n";
print "\n";
print "# part 9: \n";
print "# additional name server information \n";
print "# (optional for active domains)\n";
print "nserver host name..................:\n";
print "nserver netaddress.................:\n";
print "\n";
print "***************************************************************\n";
print "End of Domain Name Registration Template for Switzerland (*.ch)\n";
print "***************************************************************\n";
print "(C) Copyright 1995-1997, SWITCH\n";

