#!/usr/bin/perl -w ############################################################################## # Set Variables ############################################################################## $date_command = "/usr/bin/date"; # Get the Date for Entry $shortdate = `$date_command +"%D %T %Z"`; chop($shortdate); $mail = 1; # 1 = Yes; 0 = No $mailprog = '/usr/sbin/sendmail'; $sendemail=""; $subjectline = "This just in from TopTenBooks.net!"; $datafile = "mailed.lst"; $header_file ="header.txt"; $footer_file ="footer.txt"; # Referrer #---------- foreach $key (sort keys(%ENV)) { if ($key =~ /REF/){ $pagelink = $ENV{$key}; } } ########################### # This file mails stories # # 8 February, 1999 # ########################### $path =$ENV{SCRIPT_FILENAME}; $path =~ s/sendfriend\.cgi/\/homepage\/browse.txt/ig; $browsefile = $path; # # format ampersand to web # if ($ENV{'REQUEST_METHOD'} eq 'GET') { # Split the name-value pairs @pairs = split(/&/, $ENV{'QUERY_STRING'}); print "Content-type: text/html\n\n"; &printHeader(); 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 "
Send the page you were just on to a friend.
\n"; print "
Just enter your email address and
the address of the recipient.
From:
To:
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; &printFooter(); exit; } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); } foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $tempvar ="$name: $value\n"; if ($name =~ m@(urllink)@ig) { $urllink = $value; } if ($name =~ m@(sent_to)@ig) { $recipient = $value; if ($recipient !~ m@(\@)@ig) { print "Content-type: text/html\n\n"; # # header file # &printHeader(); print "\n"; print "
\n"; print "
\n"; print "
Bad Email Address

\n"; print "ALL fields must be filled out properly
\n"; print "before you can successfully submit
\n"; print "the form. Did you leave out an \@ symbol\?
\n"; print "Please return to the Fill Out Form and try again.
\n"; print "



\n"; # # footer file # &printFooter(); exit; } } if ($name =~ m@(email)@ig) { $sendemail = $value; #no at symbol ! if ($sendemail !~ m@(\@)@ig) { print "Content-type: text/html\n\n"; # # header file # &printHeader(); print "\n"; print "
\n"; print "

\n"; print "
Bad Email Address

\n"; print "ALL fields must be filled out properly
\n"; print "before you can successfully submit
\n"; print "the form. Did you leave out an \@ symbol\?
\n"; print "Please return to the Fill Out Form and try again.
\n"; print "



\n"; # # footer file # &printFooter(); exit; } } push @temp, $tempvar; } splitlines(); # # Get Referrer # #spam check if ($sendemail =~ /mitigation/i){ print "Content-type: text/html\n\n"; print "Spam! from $rhostvar\n\n"; exit; } #spam check if ($sendemail =~ /apache/i){ print "Content-type: text/html\n\n"; print "Spam! from $rhostvar\n\n"; exit; } #spam check if ($recipient =~ /\,/i){ print "Content-type: text/html\n\n"; print "Spam! from $rhostvar\n\n"; exit; } # # Mail to organization # if ($mail eq '1') { open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n"; print MAIL "To: $recipient\n"; print MAIL "From: $sendemail\n"; print MAIL "Subject: $subjectline\n\n"; print MAIL "------------------------------------------------------\n"; print MAIL "$sendemail requested the following link be sent to you.\n"; print MAIL "View the Top Ten Books.net site by clicking on the link below, or cutting and pasting it into your browser.\n"; print MAIL "\n"; print MAIL "\n"; print MAIL "$urllink\n"; print MAIL "\n"; print MAIL "\n"; print MAIL "\n"; print MAIL "Top Ten Books.net\n"; print MAIL "http://www.toptenbooks.net\n"; print MAIL "\n"; print MAIL "\n"; close (MAIL); } # # Write the Archive # open(i,"<$datafile") || die "Can't open $_ "; while (!eof(i)) { $line = ; push @temp2, $line; } close(i); splitlines2(); open(o,">$datafile"); foreach (@lines2) { print o "$_\n"; } print o "$sendemail|$recipient|$urllink|$shortdate\n"; close(o); # Set file attribute # Finish... print "Content-type: text/html\n\n"; # # header file # &printHeader(); print "\n"; print "\n"; print "
\n"; print "\n"; print "

\n"; print "


\n"; print "


\n"; print "


\n"; print "Thank you for your interest!\n"; print "


\n"; print "


\n"; print "


\n"; print "


\n"; print "


\n"; print "


\n"; print "

\n"; # # Footer file # &printFooter(); exit; sub printHeader { print "\n"; print "\n"; print "\n"; print "The Top Ten\: Writers Pick Their Favorite Books\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 "
\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 "
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; } # # footer file # sub printFooter { print "


\n"; print "


\n"; print "

\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "
\n"; print "
\n"; print "
\n"; print "All Material Copyright ©\; 2007 Not for use without permission \n"; print "
\n"; print "

\n"; print "
\n"; print "\n"; print "\"buy\n"; print "\"about\n"; print "\"your\n"; print "\"about\n"; print "\"the\n"; print "\"for\n"; print "\n"; print "\n"; print "\n"; print "\n"; } sub splitlines { @lines = (); foreach(@temp) { $line = $_; push @lines, split(/\n/, $line); } @temp = (); } sub splitlines2 { @lines = (); foreach(@temp2) { $line = $_; push @lines2, split(/\n/, $line); } @temp = (); }