#!/usr/bin/perl
##############################################################################
# COPYRIGHT NOTICE - EmailIt! Version 1.01 Jan 2000 # # #
# Copyright 1999 Ben Hare http://cgi.upws.com/ #
# #
# 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. #
##############################################################################
#Although you are free to edit this file, no editing is required. All set-up should be done
#in variables.pl. Please do not remove any copyright notices within the script.
require 'variables.pl';
$version = "1.01";
print "Content-type:text/html\n\n";
if (!$ENV{'HTTP_REFERER'}) {
print "
EmailIt 1.0\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";
print "If you are trying to configure this script, view the\n";
print "README information.\n\n";
print "\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'};
}
print <$sitename: Email It!
EOF
;
if ($useheader) {
&header;
}
else {
print <
EOF
;
}
print <EmailIt!
EOF
;
if ($usefooter) {
&footer;
}
else {
print <