#!/usr/local/bin/perl # # CHANGE THE BANG PATH ABOVE IF THIS IS DIFFERENT FROM YOUR PERL LOCATION # guestlist.cgi # Copyright (c) 1996 SurfUtah.Com # written by Rus Berrett # # simple guestlist form in cgi library, customize to your liking # ###### MAKE SURE THIS FILE IS ALSO IN THE DIRECTORY WITH THE SCRIPT require 'util.pl'; $local = 1; # YOU ONLY NEED TO CHANGE THIS ONE ENTRY BELOW HERE WITH YOUR EMAIL ADDRESS # AND UNCOMMENT THE TWO lines @valid_referers and &check_referer(1) to have # the form check to let only your domain use the form. # @valid_referers = ("ENTER YOUR DOMAIN NAME HERE"); # &check_referer(1); # where does everything live $sendmail = "/bin/sendmail"; # check for existence of necessary files unless (-e $sendmail) { &print_header_info("Guestlist Form Error: sendmail not found"); print "
\n";
&print_footer_info();
exit(1);
}
# get the filename of the guestlist, make sure it is valid
$filename = $ENV{'PATH_TRANSLATED'};
$filename = (split(/[;|]/, $filename))[0];
unless (-e $filename) {
&print_header_info("Cannot open $filename");
print < \n";
&print_footer_info();
exit(1);
}
if (($array{'name'} eq "") || ($array{'email'} eq "")) {
# not happy crappy
&print_header_info("Data Incomplete");
print < \n";
&print_footer_info();
exit(0);
}
# check for valid characters in recipient
if ($array{'recipient'} =~ /[^a-zA-z0-9-.\@]/) {
&log_invalid_request("$array{'recipient'}");
$array{'recipient'} =~ s/[^a-zA-z0-9-.\@]//g;
}
# simple profanity check, add more if necessary
if (($array{'comments'} =~ /fuck/) ||
($array{'comments'} =~ /shit/) ||
($array{'comments'} =~ /bastard/) ||
($array{'comments'} =~ /bitch/) ||
($array{'name'} =~ /fuck/) ||
($array{'name'} =~ /shit/) ||
($array{'name'} =~ /bastard/) ||
($array{'name'} =~ /bitch/) ||
($array{'email'} =~ /fuck/) ||
($array{'email'} =~ /shit/) ||
($array{'email'} =~ /bastard/) ||
($array{'email'} =~ /bitch/)) {
# not happy crappy
&print_header_info("Entry Rejected");
print <
ENDERROR
&print_footer_info();
exit(0);
}
# remove line feeds from comments, stinking textarea widgets
$array{'comments'} =~ tr/\015//d;
# disble any html tags in the comments, name, or email
$array{'name'} =~ s/\</g;
$array{'name'} =~ s/\>/>/g;
$array{'email'} =~ s/\</g;
$array{'email'} =~ s/\>/>/g;
$array{'comments'} =~ s/\</g;
$array{'comments'} =~ s/\>/>/g;
# what time is it?
$now = time;
($sec,$min,$hour,$mday,$mon,$yr,$wday,$yday,$isdst) = localtime(time);
$thisday = (Sunday, Monday, Tuesday, Wednesday,
Thursday, Friday, Saturday)[$wday];
$month = (January,February,March,April,May,June,
July,August,September,October,November,December)[$mon];
$year = 1900 + $yr;
# insert the entry into the guestlist
$retval = &add_entry();
if ($retval != 0) {
# not happy crappy
$message =
("", "Guestlist file locked by another process -- Try again later",
"Access to guestlist file, \"$filename\", denied")[$retval];
&print_header_info("Unknown Error", 0);
&return_error("$message");
}
# everything is happy, send message to recipient
# make sure we can open up the mail program
unless (open(MESSAGE, "|$sendmail -t")) {
# not happy crappy
&print_header_info("Failed to open $sendmail");
die &return_error("Cannot open mail executable, $sendmail not found
or permission denied.");
}
# echo the message to the mail program
print MESSAGE < ";
print "Host: $ENV{'REMOTE_HOST'} ";
print GTMP "Host: $ENV{'REMOTE_HOST'}Form Incomplete
\n";
print "The form is incomplete.... no \"recipient\" variable is available.\n";
print "
ENDERROR
if ($array{'name'} eq "") {
print "
\n
";
print "$thisday $month ";
if ($mday < 10) {
print "0";
}
print "$mday, $year ";
if ($hour < 10) {
print "0";
}
print GTMP "$hour:";
if ($min < 10) {
print "0";
}
print "$min:";
if ($sec < 10) {
print "0";
}
print "$sec
";
print "$array{'name'}
$array{'comments'}
";
print GTMP "$thisday $month ";
if ($mday < 10) {
print GTMP "0";
}
print GTMP "$mday, $year ";
if ($hour < 10) {
print GTMP "0";
}
print GTMP "$hour:";
if ($min < 10) {
print GTMP "0";
}
print GTMP "$min:";
if ($sec < 10) {
print GTMP "0";
}
print GTMP "$sec
";
print GTMP "$array{'name'}
$array{'comments'}