#!/usr/local/bin/perl5
# #!/usr/bin/perl
#
##########################
#
# NGUESTBOOK.CGI - Form for Guestbook Input
#
##########################
##
## This is the script I use for logging entries into a guest book.
## It creates the forms page necessary for input to the "naddgues.cgi"
## script, which actually adds the guest to the noted guest page.
##
##########################
#
# Call to this is done by the "nguestbook.shtml" page which has
# on it the following line:
#
#
#
# Where:
# "yourname" is your Best username
# "guestbook" is the name of your guest.html file with a relative
# address,like "./guest.html" if it is in
# "public_html"
# "old_entries" is the name of prior month's entries with a
# relative address, like "./guest_old.html" if it is
# in "public-html"
#
# NOTE: The guestbook and old entries MUST BE in a write-enabled
# directory under "public_html". See the README file
#
#
# EXAMPLE of "nguestbook.shtml" page:
#-----------------------------------
#
My GuestBook
#
#
#
#-----------------------------------
#
#
#################################################################
# Check for arguements from the call
# ARGV[0] is the username,
# ARGV[1] is the guestbook file,
# ARGV[2] is the old entries file
# Missing arguements
if ((!$ARGV[0]) || (!$ARGV[1]) || (!$ARGV[2]))
{
print "Missing info on the call line.
";
print "Calling line is:
";
print "<!-- exec cmd=\"nguestbook.cgi yourname ./guestbook.html ./old_entries.html\"-->";
exit;
}
# guestbook and old guestbook the same
if ($ARGV[1] eq $ARGV[2])
{
print "Guestbook and Old Entries Files are the SAME!!
";
print "Calling line is:
";
print "<!-- exec cmd=\"nguestbook.cgi yourname ./guestbook.html ./old_entries.html\"-->";
exit;
}
# File names don't start with " ./ "
if (($ARGV[1] !~ m#^./#) || ($ARGV[2] !~ m#^./#))
{
print "Filenames MUST start with \" ./ \"!!";
print "
Calling line is:
";
print "<!-- exec cmd=\"nguestbook.cgi yourname ./guestbook.html ./old_entries.html\"-->";
exit;
}
# Check to see if the files exists/are set correctly
if (!(-w $ARGV[1])){
print "Guestbook file, $ARGV[1], doesn't exist or isn't writable!
";
print "Do a touch $ARGV[1];chmod 760 $ARGV[1]";
exit;
}
if (!(-w $ARGV[2])){
print "Old Entries file, $ARGV[2], doesn't exist or isn't writable!
";
print "Do a touch $ARGV[2];chmod 760 $ARGV[2]";
exit;
}
# check for initial use, where the Old Entries file is blank
# if it is, put out initial header for file
open (GOLD, "$ARGV[2]");
$Start = ; # get the first line
close GOLD;
if ($Start !~ /^/)
{ # File doesn't start with ""
open (GOLD, ">$ARGV[2]"); # open for output of lines that follow
print GOLD "OLD Guest Book\n";
print GOLD "\n";
print GOLD "\n";
print GOLD "
\n";
}
# OK, all set up and ready to go.
&GetCountry; # get the country name
$lenctr = length($country); # get length of entry
# if it is a number make it at least 3
if ($lenctr < 3) { $lenctr = 3; }
# Check for AOL, PRODIGY, and NetCruiser and set correct e-mail ending
$User = ""; # blank user value
$EM = $ENV{REMOTE_HOST}; # save some typing
$AOL = "aol.com"; # Look for AOL
if ($EM =~ /$AOL/){$EM = $AOL;}
$PRODIGY = "prodigy.com"; # Look for Prodigy
if ($EM =~ /$PRODIGY/){$EM = $PRODIGY;}
$NETIX = "ix.netcom.com"; # Look for NetCruiser
if ($EM =~ /$NETIX/){$EM = $NETIX;}
$BESTVIP = ".vip.best.com"; # Look for .vip.best.com users
if ($EM =~ /$BESTVIP/)
{
$User = $`; # pick up part before vip.best.com
$EM = "best.com"; # change e-mail
}
#####################################################
# output the form
#####################################################
print <
Welcome to my Guestbook
All the information below is optional, except for your name.
Note: All entries in the guest book are viewable by anyone, and I
may edit or delete them...
No HTML tags, please. They won't do what you think or want...... :)
Thanks for taking the time!
View The Guest Book Instead of
Signing
GUESTPAGE
exit;
#############################################################
# Subroutine to translate extension into country name.
##############
sub GetCountry
##############
{
# looooong string of country names
%countryid = ('edu', 'USA',
'org', 'USA',
'com', 'USA',
'net', 'USA',
'gov', 'USA',
'mil', 'USA',
'us', 'USA',
'um', 'USA',
'af', 'Afghanistan',
'al', 'Albania',
'dz', 'Algeria',
'as', 'American Samoa',
'ad', 'Andorra',
'ao', 'Angola',
'ai', 'Anguilla',
'aq', 'Antarctica',
'ag', 'Antigua and Barbuda',
'ar', 'Argentina',
'am', 'Armenia',
'aw', 'Aruba',
'au', 'Australia',
'at', 'Austria',
'az', 'Azerbaijan',
'bs', 'Bahamas',
'bh', 'Bahrain',
'bd', 'Bangladesh',
'bb', 'Barbados',
'by', 'Belarus',
'be', 'Belgium',
'bz', 'Belize',
'bj', 'Benin',
'bm', 'Bermuda',
'bt', 'Bhutan',
'bo', 'Bolivia',
'ba', 'Bosnia and Herzegowina',
'bw', 'Botswana',
'bv', 'Bouvet Island',
'br', 'Brazil',
'io', 'British Indian Ocean Territory',
'bn', 'Brunei Darussalam',
'bg', 'Bulgaria',
'bf', 'Burkina Faso',
'bi', 'Burundi',
'kh', 'Cambodia',
'cm', 'Cameroon',
'ca', 'Canada',
'cv', 'Cape Verde',
'ky', 'Cayman Islands',
'cf', 'Central African Republic',
'td', 'Chad',
'cl', 'Chile',
'cn', 'China',
'cx', 'Christmas Island',
'cc', 'Cocos (Keeling) Islands',
'co', 'Colombia',
'km', 'Comoros',
'cg', 'Congo',
'ck', 'Cook Islands',
'cr', 'Costa Rica',
'ci', 'Cote d\'Ivoire',
'hr', 'Croatia (Hrvatska)',
'cu', 'Cuba',
'cy', 'Cyprus',
'cz', 'Czech Republic',
'dk', 'Denmark',
'dj', 'Djibouti',
'dm', 'Dominica',
'do', 'Dominican Republic',
'tp', 'East Timor',
'ec', 'Ecuador',
'eg', 'Egypt',
'sv', 'El Salvador',
'gq', 'Equatorial Guinea',
'er', 'Eritrea',
'ee', 'Estonia',
'et', 'Ethiopia',
'fk', 'Falkland Islands',
'fo', 'Faroe Islands',
'fj', 'Fiji',
'fi', 'Finland',
'fr', 'France',
'fx', 'France,',
'gf', 'French Guiana',
'pf', 'French Polynesia',
'tf', 'French Southern Territories',
'ga', 'Gabon',
'gm', 'Gambia',
'ge', 'Georgia',
'de', 'Germany',
'gh', 'Ghana',
'gi', 'Gibraltar',
'gr', 'Greece',
'gl', 'Greenland',
'gd', 'Grenada',
'gp', 'Guadeloupe',
'gu', 'Guam',
'gt', 'Guatemala',
'gn', 'Guinea',
'gw', 'Guinea-Bissau',
'gy', 'Guyana',
'ht', 'Haiti',
'hm', 'Heard and McDonald Islands',
'hn', 'Honduras',
'hk', 'Hong Kong',
'hu', 'Hungary',
'is', 'Iceland',
'in', 'India',
'id', 'Indonesia',
'ir', 'Iran',
'iq', 'Iraq',
'ie', 'Ireland',
'il', 'Israel',
'it', 'Italy',
'jm', 'Jamaica',
'jp', 'Japan',
'jo', 'Jordan',
'kz', 'Kazakhstan',
'ke', 'Kenya',
'ki', 'Kiribati',
'kp', 'Democratic People\'s Republic of Korea',
'kr', 'Republic of Korea',
'kw', 'Kuwait',
'kg', 'Kyrgyzstan',
'la', 'Lao Democratic Republic',
'lv', 'Latvia',
'lb', 'Lebanon',
'ls', 'Lesotho',
'lr', 'Liberia',
'ly', 'Libya',
'li', 'Liechtenstein',
'lt', 'Lithuania',
'lu', 'Luxembourg',
'mo', 'Macau',
'mk', 'Macedonia,',
'mg', 'Madagascar',
'mw', 'Malawi',
'my', 'Malaysia',
'mv', 'Maldives',
'ml', 'Mali',
'mt', 'Malta',
'mh', 'Marshall Islands',
'mq', 'Martinique',
'mr', 'Mauritania',
'mu', 'Mauritius',
'yt', 'Mayotte',
'mx', 'Mexico',
'fm', 'Micronesia',
'md', 'Moldova',
'mc', 'Monaco',
'mn', 'Mongolia',
'ms', 'Montserrat',
'ma', 'Morocco',
'mz', 'Mozambique',
'mm', 'Myanmar',
'na', 'Namibia',
'nr', 'Nauru',
'np', 'Nepal',
'nl', 'Netherlands',
'an', 'Netherlands Antilles',
'nc', 'New Caledonia',
'nz', 'New Zealand',
'ni', 'Nicaragua',
'ne', 'Niger',
'ng', 'Nigeria',
'nu', 'Niue',
'nf', 'Norfolk Island',
'mp', 'Northern Mariana Islands',
'no', 'Norway',
'om', 'Oman',
'pk', 'Pakistan',
'pw', 'Palau',
'pa', 'Panama',
'pg', 'Papua New Guinea',
'py', 'Paraguay',
'pe', 'Peru',
'ph', 'Philippines',
'pn', 'Pitcairn',
'pl', 'Poland',
'pt', 'Portugal',
'pr', 'Puerto Rico',
'qa', 'Qatar',
're', 'Reunion',
'ro', 'Romania',
'ru', 'Russian Federation',
'rw', 'Rwanda',
'kn', 'Saint Kitts and Nevis',
'lc', 'Saint Lucia',
'vc', 'Saint Vincent and the Grenadines',
'ws', 'Samoa',
'sm', 'San Marino',
'st', 'Sao Tome and Principe',
'sa', 'Saudi Arabia',
'sn', 'Senegal',
'sc', 'Seychelles',
'sl', 'Sierra Leone',
'sg', 'Singapore',
'sk', 'Slovakia',
'si', 'Slovenia',
'sb', 'Solomon Islands',
'so', 'Somalia',
'za', 'South Africa',
'gs', 'South Georgia',
'es', 'Spain',
'lk', 'Sri Lanka',
'sh', 'St. Helena',
'pm', 'St. Pierre and Miquelon',
'sd', 'Sudan',
'sr', 'Suriname',
'sj', 'Svalbard and Jan Mayen Islands',
'sz', 'Swaziland',
'se', 'Sweden',
'ch', 'Switzerland',
'sy', 'Syria',
'tw', 'Taiwan',
'tj', 'Tajikistan',
'tz', 'Tanzania',
'th', 'Thailand',
'tg', 'Togo',
'tk', 'Tokelau',
'to', 'Tonga',
'tt', 'Trinidad and Tobago',
'tn', 'Tunisia',
'tr', 'Turkey',
'tm', 'Turkmenistan',
'tc', 'Turks and Caicos Islands',
'tv', 'Tuvalu',
'ug', 'Uganda',
'ua', 'Ukraine',
'ae', 'United Arab Emirates',
'gb', 'United Kingdom',
'uk', 'United Kingdom',
'uy', 'Uruguay',
'uz', 'Uzbekistan',
'vu', 'Vanuatu',
'va', 'Vatican City',
've', 'Venezuela',
'vn', 'Viet Nam',
'vg', 'British Virgin Islands',
'vi', 'US Virgin Islands',
'wf', 'Wallis and Futina Islands',
'eh', 'Western Sahara',
'ye', 'Yemen',
'yu', 'Yugoslavia',
'zr', 'Zaire',
'zm', 'Zambia',
'zw', 'Zimbabwe',
);
# Get the country ID
@ctmp = split(/\./, $ENV{REMOTE_HOST}); # split on "."s
$country = @ctmp[$#ctmp]; # get last value in array
$country =~ tr/A-Z/a-z/; # translate to lower case
$country = $countryid{$country}; # use as index to get long name
}