#!/usr/bin/perl ############################################################################# # Online Administrative Feedback Form (v1.0) # # Created 5/97 # # # # Copyright 1997 Randy Jae Weinstein. All Rights Reserved. # # Randy Jae Weinstein # # Author EMail: rw263@NYU.EDU # # Author HomePage: http://homepages.NYU.EDU/~rw263/ # # # # New features in this version: # # -Paginated guestbook entries (10 entries/page) # # -admin can delete entries via check-box online form # # -admin can ban/unban ips # # # # In the works for next version: # # -allow admin to set maximum number of entries, and have the early # # entries deleted when that limit is reached # # -editable guestbook style (GBML Tags) via a name/pwd of administrator # # GBML Tags allow - a type of template as to how the output should be # # displayed stands for GuestBook Markup Language :-) # # -Multiple Guestbooks # # Auto creation/deletion of guestbooks # # # ### Modified From ########################################################### # Guestbook Version 2.3.1 # # Created 4/21/95 Last Modified 10/29/95 # # # # WWWBoard Admin Version 2.0 ALPHA 2 # # Created 10/21/95 Last Modified 11/25/95 # # # # Copyright 1996 Matt Wright mattw@worldwidemart.com # # Scripts Archive at: http://www.worldwidemart.com/scripts/ # # Copyright 1996 Matthew M. Wright All Rights Reserved. # ############################################################################# # Set Variables $baseDir = "../www"; # 'mesgFile' is located in this dir # IMPORTANT: 'chmod 600 mesgFile' $baseUrl = "http://Your.Host.COM"; # URL of above directory $cgiUrl = "$baseUrl/cgi-bin/feedback.cgi"; # where is this script placed? # IMPORTANT: 'chmod 755 thisCgiScript' $mesgFile = "$baseDir/entries"; # contents of the starter 'mesgFile': # default Name/Pwd: WebAdmin/WebBoard # # # $mailProg = '/usr/lib/sendmail -t'; # where is your sendmail located $recipient = 'you@Where.COM'; # Your EMail Address $recipientName = 'Your Full Name'; # Your Full Name $allowHtml = 1; # 1 = Yes; 0 = No ############################### Done Editing! ############################### ######################## Actual Script Starts Here!! ######################## ############################################################################# # Retrieve Date ############################################################################# &getDate; $query = $ENV{'QUERY_STRING'}; $command = ''; $page = 1; $USER = ''; $PWD = ''; if ($query) { if ($query =~ /&/) { @queryString = split(/&/,$query); foreach $qString (@queryString) { if ($qString =~ m/Page=(\d+)/) { $page = $1; } elsif ($qString =~ m/User=(.*)/) { $USER = $1; } elsif ($qString =~ m/Pwd=(.*)/) { $PWD = $1; } else { $command = $qString; } } } elsif ($query =~ /Page=(\d+)/) { $page = $1; } else { $command = $query; } } else { &parseForm; } ############################################################################# # Remove # Using this method allows you to delete all messages posted before # a certain date. ############################################################################# if ($command eq 'Remove') { &header('Remove Unwanted Entries From Your Suggestion Box'); print "
\n"; print "

Remove Unwanted Entries

\n"; print " Select entries you wish to remove an then click the button below.
\n"; print " You may also delete IPs in a similar manner.
\n"; print " (It's possible to delete/ban multiple entries)\n"; print "
\n"; print "
\n"; print " \n"; print " \n"; print " \n"; open(MESG,"$mesgFile") || &error(mesgFile); @lines = ; $size = @lines; close(MESG); #Number,IP,Name,URL,URL,Date,Comments $totalPage = int(($size-3)/10 + .95); $totalPage = 1 unless ($totalPage > 0); if ($page > $totalPage) { $page = 1; } $pageEntryMin = ($page-1)*10; $pageEntryMax = ($page*10)+1; $entry = -3; # Init to -3, since 3 starter lines print " \n"; print " \n"; $entryPlural = "Entr" . ($size-3 != 1 ? "ies" : "y"); $pagePlural = "Page" . ($totalPage != 1 ? "s" : ""); print " \n"; print " \n"; print "

Info: ",$size-3," $entryPlural on $totalPage $pagePlural · Current Page: $page

\n"; print " \n"; foreach $line (@lines) { $entry++; next if ($line =~ m//); next if ($line =~ m//); next if ($line =~ m//); next if (($entry<=$pageEntryMin) || ($entry>=$pageEntryMax)); @entry = split(/\cR/, $line); $EntryNumber{$line} = $entry[0]; $IP{$line} = $entry[1]; $Name{$line} = $entry[2]; $EMail{$line} = $entry[3]; $URL{$line} = $entry[4]; $Date{$line} = $entry[5]; $Comments{$line} = $entry[6]; print " \n"; print " \n"; print " \n"; print " \n"; push(@usedValues,$EntryNumber{$line}); } print "

\n"; print " From: $Name{$line} (IP: $IP{$line})
\n"; if ($EMail{$line}) { print " EMail: $EMail{$line}
\n"; } if ($URL{$line}) { print " URL: $URL{$line}
\n"; } print " Date: $Date{$line}
\n"; print "
\n"; print " $Comments{$line}"; print "



\n"; print "

\n"; print " \n"; print "

\n"; print " \n"; if (($totalPage<=1) || ($page==1)) { print " \n"; } else { print " \n"; } print " \n"; if (($totalPage<=1) || ($page==$totalPage)) { print " \n"; } else { print " \n"; } print "
Previous PagePrevious Page\n"; print " \n"; print " \n"; print " Next PageNext Page
\n"; print "



\n"; print " [Suggestion Box] [Supervisor's Page]\n"; print "
\n"; print " \n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# # Remove Action # This portion is used by the method remove ############################################################################# elsif ($FORM{'action'} eq 'Remove') { &checkPasswd; @usedValues = split(/\s/,$FORM{'usedValues'}); foreach $usedValue (@usedValues) { if ($FORM{'remove'.$usedValue}) { push(@REMOVE, $usedValue); } if ($FORM{'ban'.$usedValue}) { push(@BAN, $FORM{'ban'.$usedValue}); } } open(MESG,"$mesgFile") || &error(mesgFile); @lines = ; close(MESG); foreach $line (@lines) { next if ($line =~ m//); if ($line =~ m//) { $curIPs = $1; foreach $single (@BAN) { $curIPs .= ','.$single; } $line = '\n"; $line =~ s/ ,/ /g; } next if ($line =~ m//); @TempData = split(/\cR/, $line); foreach $single (@REMOVE) { if ($TempData[0] eq "$single") { $line = ''; } } } open(MESG,">$mesgFile") || &error(noEntryChange); print MESG @lines; close(MESG); &returnHtml(Remove); } ############################################################################# # IP Editing ############################################################################# elsif ($command eq 'IPAccess') { &header('Ban/Unban IP Addresses From Your Suggestion Box'); print "
\n"; print "

Ban/UnBan IP Addresses

\n"; print "

Bans a given site from future access to the Feedback Form/Suggestion Box.
\n"; print " The IP address can be specified in the form of x.x.x.x to ban a specific machine,
\n"; print " or as x.x. or x.x.x. to ban an entire domain or subnet.\n"; print "



\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; open(MESG,"$mesgFile") || &error(mesgFile); @ipLines = ; close(MESG); $lineNum = 0; foreach $line (@ipLines) { if ($line =~ m//) { @IPs = split(/,/, $1); @sortedIPs = (sort { $a <=> $b } @IPs); foreach $ipEntry (@sortedIPs) { $lineNum++; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; push(@usedFormValues,$ipEntry); } } } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "

Ban

UnBanIP Address
 $ipEntry
x 
\n"; print "
\n"; print "

\n"; print "

\n"; print " \n"; print "
\n"; print "



\n"; print " [Suggestion Box] [Supervisor's Page]\n"; print "
\n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# # IPAccess Action ############################################################################# elsif ($FORM{'action'} eq 'IPAccess') { &checkPasswd; @usedValues = split(/\s/,$FORM{'usedValues'}); $lineNum = 0; foreach $usedValue (@usedValues) { $lineNum++; if ($FORM{'unban'.$lineNum}) { push(@IP, $usedValue); } } open(MESG,"$mesgFile") || &error(mesgFile); @IPs = ; close(MESG); foreach $line (@IPs) { if ($line =~ m//) { $curIPs = $1; foreach $ip (@IP) { $curIPs =~ s/$ip//; } $line = '\n"; if ($FORM{'ban'}) { if (($FORM{'ban'} =~ /(\d+)\.(\d+)\./) || ($FORM{'ban'} =~ /(\d+)\.(\d+)\.(\d+)\./) || ($FORM{'ban'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/)) { $line = '\n"; } } $line =~ s/ ,/ /g; $line =~ s/,,/,/g; $line =~ s/,-/-/; } } open(MESG,">$mesgFile") || &error(noEntryChange); print MESG @IPs; close(MESG); &returnHtml(IPAccess); } ############################################################################# # Change Password # By calling this section of the script, the admin can change his or # her password. ############################################################################# elsif ($command eq 'changePassword') { &header('Change Admin Password'); print "
\n"; print "

Change Admin Password

\n"; print " Fill out the form below completely to change your password and user name.
\n"; print " If new username is left blank, your old one will be assumed.\n"; print "


\n"; print "

\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
New Username:
New Password:
Re-type New Password:
\n"; print "
\n"; print " \n"; print "
\n"; print "
\n"; print "



\n"; print " [Suggestion Box] [Supervisor's Page]\n"; print "
\n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# # Change Password ############################################################################# elsif ($FORM{'action'} eq 'changePassword') { open(MESG,"$mesgFile") || &error(mesgFile); @passwdLines = ; close(MESG); foreach $line (@passwdLines) { if ($line =~ m//) { $username = $1; $passwd = $2; srand(time ^ $$); # random seed @saltchars = ('a'..'z','A'..'Z',0..9,'.','/'); # valid salt chars $salt = $saltchars[int(rand($#saltchars+1))]; # first random salt char $salt .= $saltchars[int(rand($#saltchars+1))]; # second random salt char $newPasswd = crypt($FORM{'passwd1'}, $salt); if ($FORM{'newUsername'}) { $newUsername = $FORM{'newUsername'}; } else { $newUsername = $FORM{'USER'}; } $line =~ s/$username:$passwd/$newUsername:$newPasswd/; } } if (($FORM{'passwd1'} ne $FORM{'passwd2'}) || (length($FORM{'passwd1'})<5)) { &error(notSame); } if (($FORM{'PWD'} eq $passwd) && ($FORM{'USER'} eq $username)) { open(PASSWD,">$mesgFile") || &error(noPasswdChange); print PASSWD @passwdLines; close(PASSWD); } else { &error(badCombo); } &returnHtml(changePassword); } ############################################################################### # Enter Password ############################################################################### elsif ($FORM{'action'} eq 'enterPasswd') { open(MESG,"$mesgFile") || &error(mesgFile); @passwdLines = ; close(MESG); foreach $line (@passwdLines) { if ($line =~ m//) { $username = $1; $passwd = $2; } } if ($FORM{'USER'} && $FORM{'PWD'}) { if (!(($FORM{'PWD'} eq $passwd) && ($FORM{'USER'} eq $username))) { &error(badCombo); } } else { $testPasswd = crypt($FORM{'password'}, substr($passwd, 0, 2)); if (!(($testPasswd eq $passwd) && ($FORM{'username'} eq $username))) { &error(badCombo); } } $USER = $username; $PWD = $testPasswd; &returnHtml(enterPasswd); } ############################################################################# # Wants to goto Admin Options ############################################################################# elsif ($command eq 'Supervisor') { &header('Supervisor Page'); print "
\n"; print "

Supervisor Page

\n"; print "


\n"; print "

\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
Username:
Password:

\n"; print " Ban/UnBan IPs

\n"; print " Change Admin Password

\n"; print " Remove Entries from Suggestion Box

\n"; print "

\n"; print " \n"; print " \n"; print "
\n"; print "
\n"; print "



\n"; print " [Suggestion Box]\n"; print "
\n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# # Print out a nice header. Will prob change for every Feedback Form ############################################################################# elsif ($command eq 'Feedback') { &getAccess; &header('Feedback Form'); print <Feedback
Name:

Email:

Home Page:

Submit any comments you like: suggestions, criticisms, personal greetings, random musings, whatever you want. I'll only remove comments that are illegal, or non-constructive (intended only to annoy other people)

Comments:
Suggestion Box
Supervisor Page

Online Administrative Feedback Form script created by Randy Jae Weinstein
FeedbackForm exit; } ############################################################################# # Add to Suggestion Box ############################################################################# elsif ($FORM{'action'} eq 'add') { &getAccess; # Print the Blank Response Subroutines &noNameOrNoComment unless $FORM{'Comments'}; &noNameOrNoComment unless $FORM{'Name'}; # Begin the Editing of the Guestbook File open(MESG,"$mesgFile") || &error(mesgFile); @lines = ; close(MESG); $size = @lines; if (!(&checkEmail($FORM{'EMail'}))) { $FORM{'EMail'} = ""; } if ($FORM{'URL'} eq 'http://' || $FORM{'URL'} !~ /^(f|ht)tp:\/\/\w+\.\w+/) { $FORM{'URL'} = ""; } # Open Link File to Output open(MESG,">$mesgFile") || &error(noEntryChange); for ($i=0; $i<=$size; $i++) { $_ = $lines[$i]; if (//) { $EntryNumber = $1; $EntryNumber++; print MESG "\n"; print MESG "$EntryNumber\cR$ENV{'REMOTE_ADDR'}\cR$FORM{'Name'}\cR$FORM{'EMail'}\cR$FORM{'URL'}\cR$date\cR$FORM{'Comments'}\n"; } else { print MESG $_; } } close (MESG); # Print Out Thank You message &thankYou; } ############################################################################# # Actual Suggestion Box ############################################################################# else { &getAccess; open(MESG,"$mesgFile") || &error(mesgFile); @lines = ; close(MESG); $size = @lines; $totalPage = int(($size-3)/10 + .95); $totalPage = 1 unless ($totalPage > 0); if ($page > $totalPage) { $page = 1; } $pageEntryMin = ($page-1)*10; $pageEntryMax = ($page*10)+1; $entry = -3; # Init to -3, since 3 starter lines $entryPlural = "Entr" . ($size-3 != 1 ? "ies" : "y"); $pagePlural = "Page" . ($totalPage != 1 ? "s" : ""); &header('Suggestion Box'); print "
Suggestion Box
\n"; print "
\n\n"; print "
\n"; print " Info: ",$size-3," $entryPlural on $totalPage $pagePlural · Current Page: $page\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " Here's your chance to say whatever's on your mind concerning me. Please\n"; print " though, don't write anything intended solely to annoy or cause\n"; print " offense, I'll only have to remove it. All other comments, including\n"; print " constructive criticism, are welcome. Needless to say, none of these\n"; print " comments necessarily reflect my opinion on anything.\n"; print " \n"; print " Submit a comment\n"; print "
\n\n"; print "
\n"; print "
\n\n"; foreach $line (@lines) { $entry++; next if ($line =~ m//); next if ($line =~ m//); next if ($line =~ m//); next if (($entry<=$pageEntryMin) || ($entry>=$pageEntryMax)); @entry = split(/\cR/, $line); $EntryNumber{$line} = $entry[0]; $IP{$line} = $entry[1]; $Name{$line} = $entry[2]; $EMail{$line} = $entry[3]; $URL{$line} = $entry[4]; $Date{$line} = $entry[5]; $Comments{$line} = $entry[6]; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; if ($URL{$line}) { print " $Name{$line}"; } else { print " $Name{$line}"; } if ($EMail{$line}) { print " ($EMail{$line})
\n"; } else { print "
\n"; } print "
$Date{$line}
\n"; print " $Comments{$line}"; print "

\n\n"; } print "
\n"; if ($totalPage <= 1) { print " Previous Page | Next Page\n"; } elsif ($page == 1) { print " Previous Page | Next Page\n"; } elsif ($page == $totalPage) { print " Previous Page | Next Page\n"; } else { print " Previous Page | Next Page\n"; } print "
\n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# ################################ Subroutines ################################ ############################################################################# # Are they allowed access? ############################################################################# sub getAccess { open(MESG,"$mesgFile") || &error(mesgFile); @IPs = ; close(MESG); foreach $line (@IPs) { next unless $line; if ($line =~ m//) { @IPs = split(/,/, $1); foreach $ip (@IPs) { if ($ENV{'REMOTE_ADDR'}) { if ($ENV{'REMOTE_ADDR'} =~ /$ip/) { &error(noAccess); } } } } } } ############################################################################# # Get the Date for Entry ############################################################################# sub getDate { @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday', 'Saturday'); @months = ('January','February','March','April','May','June','July', 'August','September','October','November','December'); (undef,$min,$hour,$mDay,$mon,$year,$wDay,undef,undef) = localtime(time); $year = substr($year, 1, 2); # $year = substr($year, 2); if ($hour == 0) { $hour = 12; $ampm = "am"; } elsif ($hour == 12) { $ampm = "pm"; } elsif ($hour > 12) { $hour -= 12; $ampm = "pm"; } else { $ampm = "am";} if ($min < 10) { $min = "0$min"; } $date = "$days[$wDay], $mDay $months[$mon] `$year at $hour\:$min$ampm"; } ############################################################################# # Print out a nice header. Will prob change for every Feedback Form ############################################################################# sub header { print < $_[0] Header } ############################################################################# # A Name or a Comment was left out of the Feedback Form ############################################################################# sub noNameOrNoComment { &header('Feedback Form'); print "
Feedback
\n"; print "
\n"; print "
\n"; print "
\n"; print "

Form error

\n"; print " Some of the required fields were missing from the form you submitted.
\n"; print " Please fill in all the boxes and re-send.

\n"; print "
\n\n"; print " \n"; print " \n"; print " \n"; print "
Return to formSuggestion Box
\n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# # Thank You ############################################################################# sub thankYou { &header('Feedback Form'); print "
Feedback
\n"; print "
\n"; print "

Thanks!

\n"; print " You have submitted the following comments to the suggestion box:
\n"; print "

\n\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; if ($FORM{'URL'}) { print " $FORM{'Name'}"; } else{ print " $FORM{'Name'}"; } if ($FORM{'EMail'}) { print " ($FORM{'EMail'})
\n"; } else { print "
\n"; } print "
$date
\n"; print " $FORM{'Comments'}"; print "

\n\n"; print "
\n\n"; print " \n"; print " \n"; print "
See Suggestion Box
\n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# # Parse it ############################################################################# sub parseForm { # Get the input $FORM{'action'} = ''; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $value =~ s/\"/"/g; $value =~ s/&/&/g; $value =~ s/\n/
/g; if ($allowHtml != 1) { $value =~ s/<([^>]|\n)*>//g; } $FORM{$name} = $value; } } ############################################################################# # return information from the html ############################################################################# sub returnHtml { $type = $_[0]; if ($type eq 'Remove') { if ($FORM{'prevNext'}) { print "Location: $cgiUrl\?Remove&Page=$FORM{'prevNext'}&User=$FORM{'USER'}&Pwd=$FORM{'PWD'}\n\n"; } else { print "Location: $cgiUrl\?Remove&Page=1&User=$FORM{'USER'}&Pwd=$FORM{'PWD'}\n\n"; } } elsif ($type eq 'IPAccess') { print "Location: $cgiUrl\?IPAccess&User=$FORM{'USER'}&Pwd=$FORM{'PWD'}\n\n"; } elsif ($type eq 'enterPasswd') { if ($FORM{'command'}) { if ($FORM{'command'} eq 'Remove') { print "Location: $cgiUrl\?Remove&Page=1&User=$USER&Pwd=$PWD\n\n"; } else { print "Location: $cgiUrl\?$FORM{'command'}&User=$USER&Pwd=$PWD\n\n"; } } else { print "Location: $cgiUrl\?Page=1\n\n"; } } elsif ($type eq 'changePassword') { open(MAIL, "|$mailProg") || &error(mailProg); print MAIL "To: $recipient\n"; print MAIL "From: $recipient ($recipientName)\n"; print MAIL "Subject: Suggestion Box: Password Change\n\n"; print MAIL "Your Password for Administration has been changed! Results are below:\n"; print MAIL "-----------------------------------------------------------------------------\n"; print MAIL "New Username: $newUsername\n"; print MAIL "New Password: $FORM{'passwd1'}\n\n"; print MAIL "-$date\n"; print MAIL "-----------------------------------------------------------------------------\n"; print MAIL "Do not forget these, since they are now encoded in a file, and not readable!\n\n"; close (MAIL); &header('Admin Password Changed'); print "
\n"; print "

Admin Password Changed

\n"; print " Your Password for Admin has been changed! Results are below:


\n"; print " New Username: $newUsername

\n"; print " New Password: $FORM{'passwd1'}

\n"; print "


\n"; print " Do not forget these, since they are now encoded in a file, and not readable!\n"; print "



\n"; print " [Suggestion Box] [Supervisor's Page]\n"; print "
\n\n"; print "\n"; print "\n"; exit; } } ############################################################################# # Password Error ############################################################################# sub error { $error = $_[0]; if ($error eq 'badCombo') { &header('Bad Username - Password Combination'); print "
\n"; print "

Bad Username - Password Combination

\n"; print "


\n"; print " You entered and invalid username password pair.\n"; print "


\n"; print " Try Again\n"; print "

\n\n"; print "

Online Administrative Feedback Form script created by Randy Jae Weinstein
\n\n"; print "\n"; print "\n"; exit; } elsif ($error eq 'notSame') { &header('Incorrect Password Type-In'); print "
\n"; print "

Incorrect Password Type-In

\n"; print "


\n"; print " The passwords you typed in for your new password were not the same.
\n"; print " (NOTE: Passwords must be atleast five character)
\n"; print " You may have mistyped it.\n"; print "


\n"; print " Try Again\n"; print "

\n\n"; print "\n"; print "\n"; exit; } elsif ($error eq 'noAccess') { &header('403 Forbidden'); print "

403 Forbidden

\n"; print " Your client does not have permission to get URL $ENV{'SCRIPT_NAME'} from this server.\n\n"; print "\n"; print "\n"; exit; } elsif ($error eq 'mailProg') { &header('Mail Program Setup Wrong'); print "
\n"; print "

Mail Program Setup Wrong

\n"; print "


\n"; print " Please contact $recipientName as to what you may have done to cause this error.
\n"; print " (Error Message: $!)\n"; print "

\n"; &passwdTrailer; } elsif ($error eq 'mesgFile') { &header('Could Not Open Comment File For Reading'); print "
\n"; print "

Could Not Open Comment File For Reading

\n"; print "


\n"; print " Could not open the password file for reading!
\n"; print " (Error Message: $!)\n"; print "

\n"; &passwdTrailer; } elsif ($error eq 'AccessFile') { &header('Could Not Open Access File For Reading'); print "
\n"; print "

Could Not Open Access File For Reading

\n"; print "


\n"; print " Could not open the access file for reading!
\n"; print " (Error Message: $!)\n"; print "

\n"; &passwdTrailer; } elsif ($error eq 'noEntryChange') { &header('Could Not Open Comment File For Writing'); print "
\n"; print "

Could Not Open Comment File For Writing

\n"; print "


\n"; print " Could not open the password file for writing!
\n"; print " Password not changed!
\n"; print " (Error Message: $!)\n"; print "

\n"; &passwdTrailer; } elsif ($error eq 'noPasswdChange') { &header('Could Not Open Password File For Writing'); print "
\n"; print "

Could Not Open Password File For Writing

\n"; print "


\n"; print " Could not open the password file for writing!
\n"; print " Password not changed!
\n"; print " (Error Message: $!)\n"; print "

\n"; &passwdTrailer; } exit; } ############################################################################# # Stuff to print at the end ############################################################################# sub passwdTrailer { print "


\n"; print "

Try Again
\n\n"; print "\n"; print "\n"; exit; } ############################################################################# # Check the Password ############################################################################# sub checkPasswd { open(MESG,"$mesgFile") || &error(mesgFile); @passwdLines = ; close(MESG); foreach $line (@passwdLines) { if ($line =~ m//) { $username = $1; $passwd = $2; } } if ($FORM{'USER'} && $FORM{'PWD'}) { if (!(($FORM{'PWD'} eq $passwd) && ($FORM{'USER'} eq $username))) { &error(badCombo); } } else { $testPasswd = crypt($FORM{'password'}, substr($passwd, 0, 2)); if (!(($testPasswd eq $passwd) && ($FORM{'username'} eq $username))) { &error(badCombo); } } } ############################################################################# # Check EMail Subroutine ############################################################################# sub checkEmail { # Initialize local email variable with input to subroutine. $email = $_[0]; # If the e-mail address contains: if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || # the e-mail address contains an invalid syntax. Or, if the # syntax does not match the following regular expression pattern # it fails basic syntax verification. $email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { # Basic syntax requires: one or more characters before the @ sign, # followed by an optional '[', then any number of letters, numbers, # dashes or periods (valid domain/IP characters) ending in a period # and then 2 or 3 letters (for domain suffixes) or 1 to 3 numbers # (for IP addresses). An ending bracket is also allowed as it is # valid syntax to have an email address like: user@[255.255.255.0] # Return a false value, since the e-mail address did not pass valid # syntax. return 0; } else { # Return a true value, e-mail verification passed. return 1; } } ################################ End Of File ################################