#!/usr/bin/perl
# AUTHOR - This script is a modified version of Ben Hare's EmailIt script.
# Modifications Made by Michael Wu on behalf of Spirituality
# & Health Magazine. Please do not use without permission. Ben's copyright is below:
#
# EmailIt! may be used and modified free of charge by anyone so long as this
# copyright notice and copyright notices displayed in all HTML output of the
# program remain intact. This program uses
# several modified routines from Matt Wright's FormMail program - See
# copyright notice for FormMail at end of page.
# By using this code you agree to indemnify Ben Hare from any liability that
# might arise from its use.
require 'variables.pl';
$version = "1.01";
print "Content-type:text/html\n\n";
if (!$ENV{'HTTP_REFERER'}) {
print "
This script cannot be acessed directly.\n";
print "\n";
print "This script cannot be accessed directly.\n";
print "To run the script you need to create a link to it on a web page, then access\n";
print "it via the link. That page will be the page the script sends.\n\n";
exit;
}
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
else {
print "Bad request method\n";
}
foreach $pair (@pairs) {
local($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;
if ($FORM{$name} && $value) {
$FORM{$name} = "$FORM{$name}, $value";
}
elsif ($value) {
$FORM{$name} = $value;
}
}
if ($FORM{'action'} eq "sendit") {
&check_url;
&sendit;
&returnhtml;
}
elsif ($FORM{'action'} eq "refer") {
&check_url;
&main;
}
elsif ($FORM{'action'} eq "README") {
&readme;
}
else {
&check_url;
&main;
}
sub main {
if ($FORM{'url'} eq "") {
$sendpage = $ENV{'HTTP_REFERER'};
}
else {
$sendpage = $FORM{'url'};
}
$namepage = $FORM{'name'};
print <
EOF
;
}
print <