#!/usr/bin/perl ############################################################ # ------------ # # | Refer Me | # # ------------ # # # # This script is copyright deadlock Design 1998. # # All rights reserved. # # # # You may use and hack at this code on two conditions: # # # # 1. The notes in this box remain intact. # # 2. You do yourself a big favour and visit # # "The Art Of Business Web Site Promotion" # # http://deadlock.com/promote/ # # # # Jim Rhodes / deadlock Design accepts no responsibility # # for consequences arising from use of this script. Use # # it at your own risk. # # # # You can email Jim at scripts@deadlock.com # # # ############################################################ ############################################################################## # Start editing now... ### URLs $cgiurl = "http://adrr.com/cgi-bin/refer.pl"; $home = "http://adrr.com/"; ### HTML # $width will set the width of
lines and tables # where necessary. If your $graphic is a banner, it's # nice to set the $width to match the banner width. $width = "557"; $graphic = "

ADR &\; Mediation Resources

"; # If you want to offer this script to your users, set # $offer_download to 1 - if not, put 0 $offer_download = 1; # If you've set $offer_download to 1, you'll need to show # the URL where it can be downloaded from (either http or ftp). $download_url = "ftp://adrr.com/pub/refer.zip"; ### Mail $mailprog = '/usr/lib/sendmail'; $send_webmaster_mail = 1; $send_referral_mail = 1; $webmaster = 'referral@adrr.com'; # You shouldn't need to edit anything past this line for the script to work. ############################################################################## # Get the input 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; if ($allow_html != 1) { $value =~ s/<([^>]|\n)*>//g; } $FORM{$name} = $value; } # Print Errors &no_email unless $FORM{'senderemail'}; &no_name unless $FORM{'sendername'}; ###################################### # Mail ################### # Webmaster message if ($send_webmaster_mail eq '1') { open (MAIL, "|$mailprog $webmaster") || die "Can't open $mailprog!\n"; print MAIL "From: $FORM{'sendername'} <$FORM{'senderemail'}>\n"; print MAIL "Reply-to: $FORM{'sendername'} <$FORM{'senderemail'}>\n"; print MAIL "Subject: Referral\n\n\n"; print MAIL "Sender: $FORM{'sendername'} <$FORM{'senderemail'}>\n"; if ( $FORM{'newname'} ){ print MAIL "Friend: $FORM{'newname'} "; } if ( $FORM{'newemail'} ){ print MAIL "<$FORM{'newemail'}>\n"; } else { print MAIL "\n"; } if ( $FORM{'newname1'} ){ print MAIL "Friend: $FORM{'newname1'} "; } if ( $FORM{'newemail1'} ){ print MAIL "<$FORM{'newemail1'}>\n"; } else { print MAIL "\n"; } if ( $FORM{'newname2'} ){ print MAIL "Friend: $FORM{'newname2'} "; } if ( $FORM{'newemail2'} ){ print MAIL "<$FORM{'newemail2'}>\n"; } else { print MAIL "\n"; } if ( $FORM{'newname3'} ){ print MAIL "Friend: $FORM{'newname3'} "; } if ( $FORM{'newemail3'} ){ print MAIL "<$FORM{'newemail3'}>\n"; } else { print MAIL "\n"; } if ( $FORM{'newname4'} ){ print MAIL "Friend: $FORM{'newname4'} "; } if ( $FORM{'newemail4'} ){ print MAIL "<$FORM{'newemail4'}>\n"; } else { print MAIL "\n"; } if ( $FORM{'newname5'} ){ print MAIL "Friend: $FORM{'newname5'} "; } if ( $FORM{'newemail5'} ){ print MAIL "<$FORM{'newemail5'}>\n"; } else { print MAIL "\n"; } if ( $FORM{'newname6'} ){ print MAIL "Friend: $FORM{'newname6'} "; } if ( $FORM{'newemail6'} ){ print MAIL "<$FORM{'newemail6'}>\n"; } else { print MAIL "\n"; } close (MAIL); } ################## # Referral message if ($send_referral_mail eq '1') { open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n"; # Decide whose name will appear in the To: field if ( $FORM{'newemail1'} ){ print MAIL "To: $FORM{'newname1'} <$FORM{'newemail1'}>\n"; } elsif ( $FORM{'newemail2'} ){ print MAIL "To: $FORM{'newname2'} <$FORM{'newemail2'}>\n"; } elsif ( $FORM{'newemail3'} ){ print MAIL "To: $FORM{'newname3'} <$FORM{'newemail3'}>\n"; } elsif ( $FORM{'newemail4'} ){ print MAIL "To: $FORM{'newname4'} <$FORM{'newemail4'}>\n"; } elsif ( $FORM{'newemail5'} ){ print MAIL "To: $FORM{'newname5'} <$FORM{'newemail5'}>\n"; } elsif ( $FORM{'newemail6'} ){ print MAIL "To: $FORM{'newname6'} <$FORM{'newemail6'}>\n"; } else { print MAIL "To: $FORM{'newname'} <$FORM{'newemail'}>\n"; } # Start the spam :) print MAIL "CC: "; if ( $FORM{'newemail2'} ){ print MAIL "$FORM{'newemail2'},"; } if ( $FORM{'newemail3'} ){ print MAIL "$FORM{'newemail3'},"; } if ( $FORM{'newemail4'} ){ print MAIL "$FORM{'newemail4'},"; } if ( $FORM{'newemail5'} ){ print MAIL "$FORM{'newemail5'},"; } if ( $FORM{'newemail6'} ){ print MAIL "$FORM{'newemail6'},"; } print MAIL "\nFrom: $FORM{'sendername'} <$FORM{'senderemail'}>\n"; print MAIL "Subject: Invitation From $FORM{'sendername'}\n\n"; # Decide whose name will appear as the salutation if ( $FORM{'newname'} ){ print MAIL "Hello $FORM{'newname'},\n"; } elsif ( $FORM{'newname1'} ){ print MAIL "Hello $FORM{'newname1'},\n"; } elsif ( $FORM{'newname2'} ){ print MAIL "Hello $FORM{'newname2'},\n"; } elsif ( $FORM{'newname3'} ){ print MAIL "Hello $FORM{'newname3'},\n"; } elsif ( $FORM{'newname4'} ){ print MAIL "Hello $FORM{'newname4'},\n"; } elsif ( $FORM{'newname5'} ){ print MAIL "Hello $FORM{'newname5'},\n"; } elsif ( $FORM{'newname6'} ){ print MAIL "Hello $FORM{'newname6'},\n"; } else { print MAIL "Hello,\n"; } print MAIL "\n"; print MAIL "$FORM{'sendername'} has sent you this note direclty from my site\n"; print MAIL "because they think the site is good enough to recommend to you.\n"; print MAIL "\n"; print MAIL "My site is: ADR & Mediation Resources.\n"; print MAIL "It is a detailed collection of mediation materials and essays\n"; print MAIL "\n"; print MAIL "Regards,\n"; print MAIL "\n"; print MAIL "\n"; print MAIL "Stephen R. Marsh\n"; print MAIL "ADR & Mediation Resources\n"; print MAIL "http://adrr.com/\n"; print MAIL "free on-line newsletters at http://adrr.com/adr9/mediation.htm\n"; print MAIL "\n"; close (MAIL); } ####################### # Print second form &more_friends; ####################### # Subroutines sub no_email { print "Content-type: text/html\n\n"; print "\n\n"; print "\n\n"; print "Oops! No Email!\n\n"; print "\n\n"; print "\n\n"; print "
\n\n"; print "$graphic"; print "
\n\n"; print "

Oops! No Email!

\n\n"; print "
\n\n"; print "
\n\n"; print "
\n"; print "I'm sure you don't want to send your friend spam. If you put\n"; print "your email address, they'll know who sent it...\n"; print "
\n\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
NameEmail
You:$FORM{'sendername'}
Your Friend:$FORM{'newname'}$FORM{'newemail'}

\n"; print "


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

\n\n"; print "\n"; exit; } sub no_name { print "Content-type: text/html\n\n"; print "\n\n"; print "\n\n"; print "Oops! No Name!\n\n"; print "\n\n"; print "\n\n"; print "
\n\n"; print "$graphic"; print "
\n\n"; print "

Oops! No Name!

\n\n"; print "
\n\n"; print "
\n\n"; print "
\n"; print "I'm sure you don't want to send your friend spam. If you put\n"; print "your name, they'll know who sent it...\n"; print "
\n\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
NameEmail
You:$FORM{'senderemail'}
Your Friend:$FORM{'newname'}$FORM{'newemail'}

\n"; print "


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

\n\n"; print "\n"; exit; } sub more_friends { print "Content-Type: text/html\n\n"; print "\n\n"; print "\n\n"; print "Got Any More Friends?\n\n"; print "\n\n"; print "\n\n"; print "
\n\n"; print "$graphic"; print "
\n\n"; print "

Thanks $FORM{'sendername'}

\n\n"; print "
\n\n"; print "
\n\n"; print "
\n"; print "I bet you have more than one friend though, am I right?\n"; print "See if you can fill in the whole set below. They'll all\n"; print "know it's from you, so you won't be annoying them with spam.\n"; print "
\n\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 "
NameEmail
You:$FORM{'sendername'}$FORM{'senderemail'}
Another Friend:
Another Friend:
Another Friend:
Another Friend:
Another Friend:
Another Friend:

\n"; print "


\n"; print "
\n\n"; print "
\n"; print "
\n"; print "
All done? Home

\n"; print "\n"; print "The Perl script used for this referral system was written by\n"; print "Jim Rhodes at The Art\n"; print "Of Business Web Site Promotion.\n"; if ($offer_download eq '1') { print "If you know how to use it, please help yourself:

\n"; print "

download refer.zip
\n"; } print "\n"; print "
\n\n"; print "

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