#!/usr/bin/perl
#
# Author: Peter Keel <killer@discordia.ch>
# Intelligent whois. Gets whois-server automatically from TLD.
# Furthermore has hooks for postprocessing the output.
#
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.internic.net" || $server eq "whois.nic.ch");

if ($server eq "whois.nic.ch") { 
    chomp(@whois = qx!/usr/bin/whois.real -h $server $domain!);
	foreach $_ (@whois) {
    	    if (/No entries found/) { 
		$noentry=1; 
		print STDERR "No entries found\n";
	    }
	}
	if (!$noentry) { &swisswhois; };
    }

elsif ($server eq "whois.internic.net") {
    chomp(@whois = qx!/usr/bin/whois.real -h $server $domain!);
	foreach $_ (@whois) {
    	    if (/No entries found/) {
		$noentry=1;
		print STDERR "No entries found\n";
	    }
	}
	if (!$noentry) { &inicwhois; };
    }



sub swisswhois {
if (! $noentry) { 

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 "\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";

    }
}

sub inicwhois {

if (!$noentry) { 

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

print "******* Please DO NOT REMOVE Version Number or Sections A-Q ********\n";
print "\n";
print "Domain Version Number: 4.0\n";
print "\n";
print "******* Email completed agreement to hostmaster\@internic.net *******\n";
print "\n";
print "        NETWORK SOLUTIONS, INC.\n";
print "\n";
print "        DOMAIN NAME REGISTRATION AGREEMENT\n";
print "\n";
print "\n";
print "A.      Introduction. This domain name registration agreement\n";
print "(\"Registration Agreement\") is submitted to NETWORK SOLUTIONS, INC.\n";
print "(\"NSI\") for the purpose of applying for and registering a domain name\n";
print "on the Internet. If this Registration Agreement is accepted by NSI,\n";
print "and a domain name is registered in NSI's domain name database and\n";
print "assigned to the Registrant, Registrant (\"Registrant\") agrees to be\n";
print "bound by the terms of this Registration Agreement and the terms of\n";
print "NSI's Domain Name Dispute Policy (\"Dispute Policy\") which is\n";
print "incorporated herein by reference and made a part of this Registration\n";
print "Agreement. This Registration Agreement shall be accepted at the\n";
print "offices of NSI. \n";
print "\n";
print "B. Fees and Payments.\n";
print "\n";
print "1) Registration or renewal (re-registration) date through March 31, 1998:\n";
print "Registrant agrees to pay a registration fee of One Hundred United States\n";
print "Dollars (US$100) as consideration for the registration of each new domain\n";
print "name or Fifty United States Dollars (US$50) to renew (re-register) an\n";
print "existing registration.\n";
print "2) Registration or renewal date on and after April 1, 1998:  Registrant\n";
print "agrees to pay a registration fee of Seventy United States Dollars (US$70) \n";
print "as consideration for the registration of each new domain name or the \n";
print "applicable renewal (re-registration) fee (currently Thirty-Five United \n";
print "States Dollars (US$35)) at the time of renewal (re-registration).\n";
print "3) Period of Service:  The non-refundable fee covers a period of two (2)\n";
print "years for each new registration, and one (1) year for each renewal, \n";
print "and includes any permitted modification(s) to the domain name record\n";
print "during the covered period.\n";
print "4) Payment:  Payment is due to Network Solutions within thirty (30) \n";
print "days from the date of the invoice.\n";
print "\n";
print "C.      Dispute Policy. Registrant agrees, as a condition to\n";
print "submitting this Registration Agreement, and if the Registration\n";
print "Agreement is accepted by NSI, that the Registrant shall be bound by\n";
print "NSI's current Dispute Policy. The current version of the Dispute\n";
print "Policy may be found at the InterNIC Registration Services web site:\n";
print "\"https://www.netsol.com/rs/dispute-policy.html\". \n";
print "\n";
print "D.      Dispute Policy Changes or Modifications. Registrant agrees\n";
print "that NSI, in its sole discretion, may change or modify the Dispute\n";
print "Policy, incorporated by reference herein, at any time. Registrant\n";
print "agrees that Registrant\'s maintaining the registration of a domain name\n";
print "after changes or modifications to the Dispute Policy become effective\n";
print "constitutes Registrant\'s continued acceptance of these changes or\n";
print "modifications. Registrant agrees that if Registrant considers any such\n";
print "changes or modifications to be unacceptable, Registrant may request\n";
print "that the domain name be deleted from the domain name database. \n";
print "\n";
print "E.      Disputes. Registrant agrees that, if the registration of its\n";
print "domain name is challenged by any third party, the Registrant will be\n";
print "subject to the provisions specified in the Dispute Policy. \n";
print "\n";
print "F.      Agents. Registrant agrees that if this Registration Agreement\n";
print "is completed by an agent for the Registrant, such as an ISP or\n";
print "Administrative Contact/Agent, the Registrant is nonetheless bound as a\n";
print "principal by all terms and conditions herein, including the Dispute\n";
print "Policy. \n";
print "\n";
print "G.      Limitation of Liability. Registrant agrees that NSI shall have\n";
print "no liability to the Registrant for any loss Registrant may incur in\n";
print "connection with NSI\'s processing of this Registration Agreement, in\n";
print "connection with NSI\'s processing of any authorized modification to the\n";
print "domain name\'s record during the covered period, as a result of the\n";
print "Registrant\'s ISP's failure to pay either the initial registration fee\n";
print "or renewal fee, or as a result of the application of the provisions of\n";
print "the Dispute Policy. Registrant agrees that in no event shall the\n";
print "maximum liability of NSI under this Agreement for any matter exceed\n";
print "Five Hundred United States Dollars (US$500). \n";
print "\n";
print "H.      Indemnity. Registrant agrees, in the event the Registration\n";
print "Agreement is accepted by NSI and a subsequent dispute arises with any\n";
print "third party, to indemnify and hold NSI harmless pursuant to the terms\n";
print "and conditions contained in the Dispute Policy. \n";
print "\n";
print "I.      Breach. Registrant agrees that failure to abide by any\n";
print "provision of this Registration Agreement or the Dispute Policy may be\n";
print "considered by NSI to be a material breach and that NSI may provide a\n";
print "written notice, describing the breach, to the Registrant. If, within\n";
print "thirty (30) days of the date of mailing such notice, the Registrant\n";
print "fails to provide evidence, which is reasonably satisfactory to NSI,\n";
print "that it has not breached its obligations, then NSI may delete\n";
print "Registrant\'s registration of the domain name. Any such breach by a\n";
print "Registrant shall not be deemed to be excused simply because NSI did\n";
print "not act earlier in response to that, or any other, breach by the\n";
print "Registrant. \n";
print "\n";
print "J.      No Guaranty. Registrant agrees that, by registration of a\n";
print "domain name, such registration does not confer immunity from objection\n";
print "to either the registration or use of the domain name. \n";
print "\n";
print "K.      Warranty. Registrant warrants by submitting this Registration\n";
print "Agreement that, to the best of Registrant\'s knowledge and belief, the\n";
print "information submitted herein is true and correct, and that any future\n";
print "changes to this information will be provided to NSI in a timely manner\n";
print "according to the domain name modification procedures in place at that\n";
print "time. Breach of this warranty will constitute a material breach. \n";
print "\n";
print "L.      Revocation. Registrant agrees that NSI may delete a\n";
print "Registrant\'s domain name if this Registration Agreement, or subsequent\n";
print "modification(s) thereto, contains false or misleading information, or\n";
print "conceals or omits any information NSI would likely consider material\n";
print "to its decision to approve this Registration Agreement. \n";
print "\n";
print "M.      Right of Refusal. NSI, in its sole discretion, reserves the\n";
print "right to refuse to approve the Registration Agreement for any\n";
print "Registrant. Registrant agrees that the submission of this Registration\n";
print "Agreement does not obligate NSI to accept this Registration Agreement.\n";
print "Registrant agrees that NSI shall not be liable for loss or damages\n";
print "that may result from NSI's refusal to accept this Registration\n";
print "Agreement. \n";
print "\n";
print "N.      Severability. Registrant agrees that the terms of this\n";
print "Registration Agreement are severable. If any term or provision is\n";
print "declared invalid, it shall not affect the remaining terms or\n";
print "provisions which shall continue to be binding. \n";
print "\n";
print "O.      Entirety. Registrant agrees that this Registration Agreement\n";
print "and the Dispute Policy is the complete and exclusive agreement between\n";
print "Registrant and NSI regarding the registration of Registrant's domain\n";
print "name. This Registration Agreement and the Dispute Policy supersede all\n";
print "prior agreements and understandings, whether established by custom,\n";
print "practice, policy, or precedent. \n";
print "\n";
print "P.      Governing Law. Registrant agrees that this Registration\n";
print "Agreement shall be governed in all respects by and construed in\n";
print "accordance with the laws of the Commonwealth of Virginia, United\n";
print "States of America. By submitting this Registration Agreement,\n";
print "Registrant consents to the exclusive jurisdiction and venue of the\n";
print "United States District Court for the Eastern District of Virginia,\n";
print "Alexandria Division. If there is no jurisdiction in the United States\n";
print "District Court for the Eastern District of Virginia, Alexandria\n";
print "Division, then jurisdiction shall be in the Circuit Court of Fairfax\n";
print "County, Fairfax, Virginia. \n";
print "\n";
print "Q.      This is Domain Name Registration Agreement Version\n";
print "Number 4.0. This Registration Agreement is only for registrations\n";
print "under top-level domains: COM, ORG, NET, and EDU. By completing\n";
print "and submitting this Registration Agreement for consideration and\n";
print "acceptance by NSI, the Registrant agrees that he/she has read and\n";
print "agrees to be bound by A through P above. \n";
print "\n";
print "\n";
print "Authorization\n";
print "0a.  (N)ew (M)odify (D)elete....:N\n";
print "0b.  Auth Scheme................:\n";
print "0c.  Auth Info..................:\n"; 
print "\n";
print "1.   Comments...................: \n";
print "\n";
    foreach $_ (@whois) {
    if (/Domain Name/) {
	$x= (split(/\:\s+/))[1];
	    print "2.   Complete Domain Name.......:$x\n";
	}
    }
print "\n";
print "Organization Using Domain Name\n";
print "\n";
print "3a.  Organization Name..........: \n";
print "3b.  Street Address.............: \n";
print "3c.  City.......................: \n";
print "3d.  State......................: \n";
print "3e.  Postal Code................: \n";
print "3f.  Country....................:Switzerland\n";
print "\n";
print "Administrative Contact\n";
print "4a.  NIC Handle (if known)......:\n";
print "4b.  (I)ndividual (R)ole........:I\n";
print "4c.  Name (Last, First).........:\n";
print "4d.  Organization Name..........:\n";
print "4e.  Street Address.............:\n";
print "4f.  City.......................:\n";
print "4g.  State......................:\n";
print "4h.  Postal Code................:\n";
print "4i.  Country....................:Switzerland\n";
print "4j.  Phone Number...............:+41 1 \n";
print "4k.  Fax Number.................:+41 1 \n";
print "4l.  E-Mailbox..................:\n";
print "\n";
print "Technical Contact\n";
print "5a. NIC Handle (if known).......:BT1832\n";
print "5b. (I)ndividual (R)ole.........:I\n";
print "5c. Name........................:Beat Tinner\n";
print "5d. Organization Name...........:Cyberlink Internet Services AG\n";
print "5e. Street Address..............:Richard Wagnerstrasse 6\n";
print "5f. City........................:Zuerich\n";
print "5g. State.......................:\n";
print "5h. Postal Code.................:8002\n";
print "5i. Country Code................:CH\n";
print "5j. Phone Number................:+41 1 287 2992\n";
print "5k. Fax Number..................:+41 1 287 2991\n";
print "5l. E-Mailbox...................:admin\@cyberlink.ch\n";
print "\n";
print "Billing Contact\n";
print "6a.  NIC Handle (if known)......:\n";
print "6b.  (I)ndividual (R)ole........:I\n";
print "6c.  Name (Last, First).........:\n";
print "6d.  Organization Name..........:\n";
print "6e.  Street Address.............:\n";
print "6f.  City.......................:\n";
print "6g.  State......................:\n";
print "6h.  Postal Code................:\n";
print "6i.  Country....................:Switzerland\n";
print "6j.  Phone Number...............:+41 1 \n";
print "6k.  Fax Number.................:+41 1 \n";
print "6l.  E-Mailbox..................:\n";
print "\n";
print "Prime Name Server\n";
print "7a.  Primary Server Hostname....: dns.cyberlink.ch\n";
print "7b.  Primary Server Netaddress..: 193.246.253.10\n";
print "\n";
print "Secondary Name Server(s)\n";
print "\n";
print "8a.  Secondary Server Hostname..: dns2.cyberlink.ch\n";
print "8b.  Secondary Server Netaddress: 193.246.253.15\n";
print "\n";
print "\n";
print "END OF AGREEMENT\n";
print "\n";
print "\n";


#Registrant:
#CyberLink, Incorporated (CYBERLINK7-DOM)
#   213 South Main Street
#   South Bend, IN 46601
#
#   Domain Name: CYBERLINK.COM
#
#   Administrative Contact:
#      Yakym, Rudy  (RY253)  rudy@CYBERLINK.COM
#      219-235-1400 (FAX) 219-235-1599
#   Technical Contact, Zone Contact:
#      Admin, CyberLink  (ZW29)  admin@CYBERLINK.COM
#      (219) 235-1400 (FAX) (219) 235-1599
#   Billing Contact:
#      Yakym, Rudy  (RY253)  rudy@CYBERLINK.COM
#      219-235-1400 (FAX) 219-235-1599
#

    }
}

