#!/usr/local/bin/perl # - Upload in ASCII (text) mode to your cgi-bin directory. # - Chmod 755 WhoIs.pl ### NOTE: It is very important that the name of this script stays WhoIs.pl! ### # To use this script, include this code on your web page: # Click here to see if your domain is taken. # OR to put the form directly on your web page: #
######################################################### # DON'T MODIFY ANYTHING BEYOND THIS LINE! # ######################################################### if ($ENV{'CONTENT_LENGTH'}){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } elsif ($ENV{'QUERY_STRING'}){ $buffer = $ENV{'QUERY_STRING'}; } if ($buffer) { @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ s/\+/ /g; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\+/ /g; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $INPUT{$name} = $value; } } if ($INPUT{'check'} =~ /domain/i) { if (!$INPUT{'domain'}) { &die('You did not enter a domain to check!'); } if ($INPUT{'domain'} !~ /.com|.net|.org/i && !$INPUT{'suffix'}) { &die('You did not enter a domain extension, or the domain extension was invalid'); } if ($INPUT{'domain'} =~ /.com|.net|.org/i) { $search = $INPUT{'domain'}; } elsif ($INPUT{'domain'} !~ /.com|.net|.org/i) { $search = "$INPUT{'domain'}$INPUT{'suffix'}"; } $search =~ s/\s|www.|http:\/\/|ftp:\/\/|ftp.|gopher.|gopher:\/\///g; if ($search !~ /\w|\./) { &die('An error has occurred, please double check your entry and try again.'); } $out = `whois $search`; if ($out =~ /No match for|available/i) { $availability = "1"; } elsif ($out =~ /Registrar:|unavailable/i) { $availability = "0"; } else { &die('Woops, an error occured, please contact webmaster'); } if ($availability eq "1") { &Available; } elsif ($availability eq "0") { if ($INPUT{'view'} =~ /raw_output/i) { &Raw_Output; } else { &Not_Available; } } } else { &Intro; } sub Intro { print "Content-type: text/html\n\n"; print <|
|
|
|