#!/usr/bin/perl ############################################################################## # Cliff's Tell Your Friends Script Version 1.5 # # Copyright 1998 Shaven Ferret Productions # # Created 6/9/98 Last Modified 10/20/98 # # Available at http://www.shavenferret.com/scripts # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1998 Shaven Ferret Productions All Rights Reserved. # # # # This script can be used\modified free of charge as long as you don't # # change this header, the part that generates the return link, or the part # # that mentions where this script comes from in the e-mail. If you really # # need to remove these, go to # # http://www.shavenferret.com/scripts/register.shtml . By using this script # # you agree to indemnify me from any liability that might arise from its use.# # In simple English, if this script somehow makes your computer run amuck # # and kill the pope, it's not my fault. # # # # Redistributing\selling the code for this program without prior written # # consent is expressly forbidden. # ############################################################################## # Enter the location of sendmail. $mailprogram = "/usr/lib/sendmail"; # How many people should I give your visitors the option of telling? $tell = 4; # The stuff between the next line and the line that reads IMDONEWRITING # is what will be mailed to your visitors friends. $message = <<'IMDONEWRITING'; Hi! I thought you might be interested in this site because it has some info that I thought might be of interest to you. The name of the site is Mind Training.net , you can find it at http://www.mindtraining.net IMDONEWRITING ############################################################################## # Congratulations! You've finished defining the variables. If you want to, # # you can continue screwing with the script, but it isn't necessary. # ############################################################################## print "Content-type: text/html\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } if ($FORM{'send'}) { $temp1 = $FORM{'yemail'}; $temp2 = $FORM{'email1'}; $temp1 =~ s/_/a/g; $temp2 =~ s/_/a/g; $temp1 =~ s/-/a/g; $temp2 =~ s/-/a/g; unless ($temp1 =~ /\w+@\w+.\w+/) { &bademail($FORM{'yemail'}); } unless ($temp2 =~ /\w+@\w+.\w+/) { &bademail($FORM{'email1'}); } if ($FORM{'yname'}) { $from = "\"$FORM{'yname'}\" <$FORM{'yemail'}>"; } else { $from = $FORM{'yemail'}; } for ($i = 1; $i <= $tell; $i++) { $temp1 = "email" . $i; $temp2 = $FORM{$temp1}; $temp2 =~ s/_/a/g; $temp2 =~ s/-/a/g; unless ($temp2 =~ /\w+@\w+.\w+/) { next } $temp2 = "name" . $i; if ($FORM{$temp2}) { $sendto = "\"$FORM{$temp2}\" <$FORM{$temp1}>"; } else { $sendto = $FORM{$temp1}; } open (MAIL,"|$mailprogram -t"); print MAIL "To: $sendto\n"; print MAIL "From: $from\n"; print MAIL "Subject: A note from a friend...\n\n"; print MAIL "$message\n\n"; } print "Thank you!\n"; print "

\n"; print "Thank you!

The message has been sent to your friend(s).\n"; print "\n"; exit; } else { &make_page(""); } sub bademail { $bad = shift(@_); $alert = "

\n"; $alert .= "
\n"; $alert .= "
I'm sorry, but the e-mail\n"; $alert .= ""$bad" is invalid. Please try again.
\n"; &make_page($alert); } sub make_page { $alert = shift(@_); print "Tell your friends!\n"; print "

\n"; print "
Tell your friends!

You can use this handy\n"; print "form to tell your friends about my web site.
Just enter\n"; print "your e-mail address and your friend's e-mail address, \n"; print "and click Submit!
\n"; print "$alert\n"; print "
\n"; print "
\n"; print "\n"; for ($i = 1; $i <= $tell; $i++) { print "\n"; } print "
Your name:
\n"; print "
*\n"; print "Your e-mail
\n"; print "
Friend #$i" . "'s name:
\n"; $temp = "name" . $i; print "
\n"; print ""; if ($i == 1) { print "*"; } $temp = "email" . $i; print "Friend #$i" . "'s e-mail:
\n"; print "
\n"; print "
\n"; print "Fields marked with \n"; print "*'s are required.\n"; print "
Your friend(s) will be sent the following:

\n"; print "$message

\n"; print "
\n"; exit; }