#!/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 = 3;
# The stuff between the next line and the line that reads IMDONEWRITING
# is what will be mailed to your visitors friends.
$message = <<'IMDONEWRITING';
Hello. I am writing to tell you about a web site I visited
recently. The name of the site is Netprofit.com, and you can
find it at http://www.netprofit.com. It has a great checklist that can improve your site's visibility and targeted traffic.
They also have keyword and paid search engine campaign information.
Check out their e-Visibility services that include Visibility Reviews, Keyword Analysis, Linking and
PPC campaigns, site launches, SEO, posting, Web Ring and award programs and more.
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 MAIL "This is NOT spam. A friend of yours, $FORM{'sender'}\n";
print MAIL "sent this to you using Cliff's Tell Your Friends Script.\n";
print MAIL "If you'd like to add this script to your web page, you can\n";
print MAIL "download it free from http://www.shavenferret.com/scripts\n";
close(MAIL);
}
print "
Thank you!\n";
print "\n";
print "Thank you!
The message has been sent to your friend(s).\n";
print "\n";
exit;
# return the results
print &PrintLocation . "http://www.netprofit.com/" . "\n\n";
}
else {
&make_page("");
}
sub bademail {
$bad = shift(@_);
$alert = "| \n";
$alert .= "I'm sorry, but the e-mail\n";
$alert .= ""$bad" is invalid. Please try again. |
\n";
$alert .= "
\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 this 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 "Fields marked with \n";
print "*'s are required.\n";
print "| Your friend(s) will be sent the following:\n";
print "$message |
\n";
print "
Tell your friends script by Cliff, \n";
print "Shaven Ferret Productions, and available free from Cliff's Perl Script Collection
\n";
print "\n";
exit;
}