#!/usr/bin/perl $|=1; ################################################################## # (C)1998 Bignosebird.com Version 1.0 (May 8, 1998) # This software is FREEWARE! Do with it as you wish. It is yours # to share and enjoy. Modify it, improve it, and have fun with it! # It is distributed strictly as a learning aid and bignosebird.com # disclaims all warranties- including but not limited to: # fitness for a particular purpose, merchantability, loss of # business, harm to your system, etc... ALWAYS BACK UP YOUR # SYSTEM BEFORE INSTALLING ANY SCRIPT OR PROGRAM FROM ANY # SOURCE! ################################################################## # CONFIGURATION NOTES # $VALID_DOMAIN: This is to keep the rest of the world from # calling the script from their servers! DO NOT USE THE "WWW.", # just the DOMAINNAME.COM or DOMAINNAME.NET part of the name. # If you don't care, just change it to $VALID_DOMAIN=""; # # $MAIL_PROGRAM is your sendmail program or equivalent. # # $SCRIPT_NAME is the full URL of this script, including the # http part, ie, "http://domainname.com/cgi-bin/refer.cgi"; # # $SITE_NAME is the "name" of your web site. # $SITE_URL is the URL of your site (highest level) # $ENDLINE is the very last line printed in the e-mail. # # $MAXNUM is the number of possible people a person can refer # your URL to at one time. If you call the script using the # GET method, then this is also the number of entry blanks # created for recipient names and addresses. # #*** WARNING *** # If you use any e-mail addresses in the script, always put # a backslash \ before the at-sign.,ie- myname\@here.com # # to customize to your site, just substitute your site's real # domain name for "yourdomain.com", check the path to sendmail # and make sure the SCRIPT_NAME is correct for your server. # # Also, look for the BNB SAYS! #CONFIGURATION SECTION $MAIL_PROGRAM="/usr/lib/sendmail -t"; $VALID_DOMAIN=""; $SCRIPT_NAME="http://www.gameteaser.com/cgi/feedback/feed.cgi"; $SITE_NAME="Gameteaser.com"; $SITE_URL="http://www.Gameteaser.com/"; $ENDLINE="Thank you for sharing!"; $MAXNUM=1; $LOGFILE="reflog.txt"; &test_sendmail; #before proceeding, let's see if sendmail is there. &valid_page; #if script is called from offsite, bounce it! &decode_vars; if ( $ENV{'REQUEST_METHOD'} ne "POST") { &draw_request; exit; } &do_log; &process_mail; print "Location: $JUMP_TO\n\n"; ################################################################## sub process_mail { for ($i=1;$i<$MAXNUM+1;$i++) { $recipname="recipname_$i"; $recipemail="recipemail_$i"; if ($fields{$recipemail} eq "") { next; } if (&valid_address == 0) { next; } open (MAIL_RECIP, "|$MAIL_PROGRAM"); # BNB SAYS! Customize your email # # This is where the e-mail notices are created. # you can edit anything under the line that says: # Subject: # You can of course change the subject, but do not # remove the word "Subject: " # you can edit up until the line containing __STOP_OF_MAIL__ # DO NOT REMOVE THAT LINE! # print MAIL_RECIP <<__STOP_OF_MAIL__; To: $fields{$recipemail} BCC: johnj\@gameteaser.com,johnj\@mtco.com,walt\@head-quarters.net From: $fields{'send_email'} Subject: Suggestion from $fields{'send_name'} Hi $fields{$recipname}, $fields{'send_name'} stopped by $SITE_NAME and suggested that you visit the following URL: $JUMP_TO __STOP_OF_MAIL__ if ($fields{'message'} ne "") { print MAIL_RECIP "Here is their message....\n"; print MAIL_RECIP "$fields{'message'}\n\n"; } print MAIL_RECIP "$SITE_NAME\n"; print MAIL_RECIP "$ENDLINE\n"; print MAIL_RECIP "$SITE_URL\n\n"; close(MAIL_RECIP); } } ################################################################## # # BNB SAYS! Customize your instruction screen. # You can edit below the line that says print <<__REQUEST__; # up until the line containing __REQUEST__ # you can also edit between __STOP_OF_ROW__ and __REQUEST2__ # but use caution! # DO NOT REMOVE THE LINE CONTAINING TYPE="HIDDEN" NAME="call_by" # OR change the names of any of the form fields. # You can remove the
__REQUEST2__ } ################################################################## sub decode_vars { $i=0; if ( $ENV{'REQUEST_METHOD'} ne "POST") { $temp=$ENV{'QUERY_STRING'}; } else { read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); } @pairs=split(/&/,$temp); foreach $item(@pairs) { ($key,$content)=split(/=/,$item,2); $content=~tr/+/ /; $content=~s/%(..)/pack("c",hex($1))/ge; $fields{$key}=$content; } if ($fields{'call_by'} eq "") { $JUMP_TO = $ENV{'HTTP_REFERER'}; } else { $JUMP_TO = $fields{'call_by'}; } } ################################################################## sub valid_address { $testmail = $fields{$recipemail}; if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $testmail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { return 0; } else { return 1; } } ################################################################## sub valid_page { if ($VALID_DOMAIN eq "") {return;} $DN=$ENV{'HTTP_REFERER'}; if ($DN eq "") {return;} $DN=~tr/A-Z/a-z/; $VALID_DOMAIN=~tr/A-Z/a-z/; if ($DN =~ /$VALID_DOMAIN/) {$stayin=1;} else {$stayin=0;} if ($stayin == 0) { print "Content-type: text/html\n\n"; print "

Sorry! You can't run this script from this page!

"; print "$DN\n"; exit; } } ################################################################## sub test_sendmail { @ts=split(/ /,$MAIL_PROGRAM); if ( -e $ts[0] ) { return; } print "Content-type: text/html\n\n"; print "

$ts[0] NOTFOUND. PLEASE CHECK YOUR SCRIPT'S MAIL_PROGRAM VARIABLE

"; exit; } sub do_log { open (ZL,">>$LOGFILE"); $date=localtime(time); for ($i=1;$i<$MAXNUM+1;$i++) { $recipname="recipname_$i"; $recipemail="recipemail_$i"; if ($fields{$recipemail} eq "") { next; } if (&valid_address == 0) { next; } $logline="$date\|$JUMP_TO\|$fields{'send_email'}\|$fields{$recipemail}\|\n"; print ZL $logline; } close(ZL); }