#!/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";
#
# 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";
#
# 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 "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 "
\n";
print "
\n";
print "
\n";
print "
\n";
print "
\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 = ();
}