The following need to be edited: (Click on the hyperlinked lines to see editing comments)
#!/usr/bin/perl5
require 'cgi-lib.pl';
# Set all your permissions for created files to -rw-rw-rw-
umask (011);
# Location of your header file for generated error pages
$errorhead="../../errhead.html";
# Location of your footer file for generated error pages
$errorfoot="../../errfoot.html";
# Location of the file to record uses of this script
$logfile="reclog.txt";
&ReadParse(*in);
# Build a hash for all the recipients to send the recommendation to
%eaddresses = (
$in{'recipients_name_1'} => $in{'recipients_email_1'},
$in{'recipients_name_2'} => $in{'recipients_email_2'},
$in{'recipients_name_3'} => $in{'recipients_email_3'}
);
# If someone tries calling just the CGI, print a default version
&Verify_Source;
&check_required;
&valid_address;
# Path to your mail prog;
$mailprog = '/usr/sbin/sendmail';
# URL for the page to be displayed after cform submission;
$redirect=$in{'sa'};
# The subject of your mail (In the HIDDEN tag in your form's HTML);
$subject=", Check out this site!";
print &PrintHeader;
&process_mail;
&process_log;
print "<Meta HTTP-EQUIV=\"Refresh\" Content=\"0\;URL=$redirect\">";
sub check_required
{
return unless( $in{'required'} );
my @missing;
my @required = split( /\,/, $in{'required'} );
foreach ( @required ) {
if (($in{'recipients_email_1'} eq '') && ($in{'recipients_email_2'} eq '') && ($in{'recipients_email_3'} eq '')) {
&missing_fields("You must enter at least one recipient!");
}
elsif ($in{'sender_name'} eq undef) {
&missing_fields("You must enter your name!")
}
elsif ($in{'sender_email'} eq undef) {
&missing_fields("You must enter your email address!")
}
}
if( @missing ) { missing_fields( @missing ) }
}
sub missing_fields
{
print &PrintHeader;
open (FRMERR, $errorhead) || &CgiError("Unable to open errorhead for reading $errorhead");
while (<FRMERR>) {
print $_;
}
close FRMERR;
my $err = join( ", ", @_ );
print <<"__STOP__";
The following required fields were either left blank <BR>or not filled out correctly:<P>
<B>$err</B><P>
Please use your browser's <B>BACK</B> button to return <BR>to the Submission Form and correct them. Thanks a lot!
</FONT>
</P>
__STOP__
open (FRMERR, $errorfoot) || &CgiError("Unable to open errorfoot for reading $errorfoot");
while (<FRMERR>) {
print $_;
}
close FRMERR;
exit
}
sub valid_address
{
$testmail = $in{'sender_email'};
if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$testmail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
&missing_fields("Your email address is not a valid email address!");
}
else
{
return 1;
}
}
sub process_mail {
while (($name,$address) = each(%eaddresses)) {
if ($name eq "" || $address eq "") {next;}
open(MAIL,"|$mailprog -t");
print MAIL "To: $address ($name)\n";
print MAIL "From: $in{'sender_email'} ($in{'sender_name'})\n";
print MAIL "Subject: $name$subject\n";
print MAIL <<END_OF_MAIL;
Hi $name!
I've just found a great site, $in{'sn'}! Click on this link for some useful CGI's::
http://$in{'sa'}
$in{'message'}
-----------------------------------------
END_OF_MAIL
close (MAIL);
}
}
sub process_log {
open (MLLOG, ">>$logfile") || &CgiError("Unable to open database for reading $datain");
print MLLOG"$in{'sn'} | $in{'sa'} | $in{'sender_name'} | $in{'sender_email'} | $in{'recipients_name_1'} | $in{'recipients_email_1'} | $in{'recipients_name_2'} | $in{'recipients_email_2'} | $in{'recipients_name_3'} | $in{'recipients_email_3'} | $in{'recipients_name_4'} | $in{'recipients_email_4'} | $in{'recipients_name_5'} | $in{'recipients_email_5'} | $in{'recipients_name_6'} | $in{'recipients_email_6'} | $in{'recipients_name_7'} | $in{'recipients_email_7'} | $in{'recipients_name_8'} | $in{'recipients_email_8'} | $in{'recipients_name_9'} | $in{'recipients_email_9'} | $in{'recipients_name_10'} | $in{'recipients_email_10'}\n";
close MLLOG;
}
sub ProcessTemplate {
print &PrintHeader;
local (@matches);
$count=0;
$tmpl = "template.htm";
# Open the template;
open (TEMPLATE, $tmpl) || &CgiError("Unable to open template for reading $tmpl");
# Process each line of the template;
while (<TEMPLATE>) {
$currentline=$_;
if (@matches = /\\(\w+)\\/g) {
# Interpolate each match on this line;
foreach $match ( @matches ) {
$currentline =~ s/\\$match\\/$in{$match}/g;
print $currentline;
}
} else {print $currentline;}
++$count;
}
# Tidy up;
close (TEMPLATE);
}
sub Verify_Source {
if ( $ENV{'REQUEST_METHOD'} ne "POST") {
&ProcessTemplate;
exit;
}
}
Copyright
This script is being distributed as shareware. If you like it, if it saves you time and money, and more importantly, if you continue to use it, please feel send $50 to the address in the comments section of multipass.cgi (Don't need spam bots grabbing the address from here)
Back to MemberManager page