#!/usr/bin/perl
##############################################################################
# MTVWebdesign MailPage Version 2.0
# mailpage.cgi: The main script
# Copyright 1999-2000 Maarten Veerman mtveerman@mindless.com
# MTVWebdesign: http://mtvwebdesign.hypermart.net/ (http://mtvwebdesign.hypermart.net/scripts/)
##############################################################################
# COPYRIGHT NOTICE
# Copyright 1999-2000 Maarten Veerman All Rights Reserved.
#
# MailPage may be used and modified so long as this
# copyright notice and the comments above remain intact. By using this
# code you agree to indemnify Maarten Veerman from any liability that
# might arise from its use.
##############################################################################
#
# Script tested locally:
# Pentium 400Mhz, 128MB RAM, Windows 98, Apache 1.3.4 (win32), Perl, MS Internet Explorer 5.0, Netscape 4.05.
#
##############################################################################
# Please do not remove the following lines:
$scriptname = "MailPage";
$version = "2.0";
##############################################################################
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("$ENV{'HTTP_USER_AGENT'}");
use CGI::Carp qw(fatalsToBrowser); # Provides you with fatal error message if they occur.
use CGI qw/:standard/;
require '/home/httpd/saveourbay.org/html/5thcolumn/cgi-bin/mailpage/mailpage.conf';
require $mtvwebdesignlib;
main: {
&getinput;
&GetCookies;
if (lc $FORM{'action'} eq "send") { &getbase($FORM{'url'}); &send; }
elsif (lc $FORM{'action'} eq "privacy") {&privacy;}
else { &moreinfo }
exit;
}
sub moreinfo {
$FORM{'url'} = $ENV{'HTTP_REFERER'} unless $FORM{'url'};
if ($FORM{'url'} !~ m/^http/ ) { $FORM{'url'} = $ENV{'HTTP_REFERER'}; }
print "Content-type: text/html\n\n";
&pageheader("We need more info!");
foreach $line (@temptoken) {
if ($line =~ m/$token/i) {
print qq~
Oscar Braun - Executive Director Environmental Justice
~;
}
print "$line";
}
#&powered_by("nologout");
exit;
}
sub send_email {
if ($FORM{'how'} eq "body") { &send_body; }
elsif ($FORM{'how'} eq "attachement") { &send_attached; }
else { &send_plain; }
}
sub send_plain {
open MAIL, "$mailprog" || die "Cannot open $mailprog so I cannot sent email";
print MAIL "To: $FORM{'recipientemail'} ($FORM{'recipient'})\n";
print MAIL "From: $FORM{'senderemail'} ($FORM{'sendername'})\n";
print MAIL "Subject: $FORM{'sendername'} wants you to have a look at a page!!\n\n";
print MAIL qq~
Dear $FORM{'recipient'},
$FORM{'sendername'} would appreciate your time to take a look at the following 5th Column Vs US (Enemies In Our Midst) page:
$FORM{'url'}
~;
if ($FORM{'message'}) {
print MAIL qq~
$FORM{'sendername'} also had this additional message:
$FORM{'message'}
~;
}
print MAIL qq~
The 5th Column Vs US environmental justice resource website is a California Watershed Posse Wise Use project. We respect your privacy. Your email address has not been captured or added to any mailing lists. We encourage all to visit http://www.5thcolumnvs.us and $servicelocation and have a voice in these important public forums.
~;
close MAIL;
}
sub send_body {
$req = new HTTP::Request 'GET' => $FORM{'url'};
$res = $ua->request($req);
if ($res->is_success) {
#print "Content-type: image/gif\n\n";
#print $res->content;
$header = "Dear $FORM{'recipient'}, $FORM{'sendername'} has sent you this email, including a webpage which you can also visit by clicking here! ";
if ($FORM{'message'}) { $header .= "$FORM{'sendername'} also wanted to tell you this: $FORM{'message'}"; }
$header .= "
\n";
open MAIL, "$mailprog" || die "Cannot open $mailprog so I cannot sent email";
print MAIL "To: $FORM{'recipientemail'} ($FORM{'recipient'})\n";
print MAIL "From: $FORM{'senderemail'} ($FORM{'sendername'})\n";
print MAIL "Subject: $FORM{'sendername'} has sent you a page!!\n";
print MAIL "Content-type: text/html\n\n";
foreach $line ($res->content) {
if ($line =~ /\/\$header/ig;}
if ($line =~ /\//ig;}
print MAIL $line;
}
close MAIL;
}
else {
&send_plain;
}
}
sub send_attached {
$req = new HTTP::Request 'GET' => $FORM{'url'};
$res = $ua->request($req);
if ($res->is_success) {
#print "Content-type: image/gif\n\n";
#print $res->content;
open MAIL , "$mailprog" || die "Cannot open $mailprog";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-type: multipart/mixed; boundary=\"----=_MAARTEN.ATT\"\n";
print MAIL "To: $FORM{'recipientemail'} ($FORM{'recipient'})\n";
print MAIL "From: $FORM{'senderemail'} ($FORM{'sendername'})\n";
print MAIL "Subject: $FORM{'sendername'} has sent you a page!!\n\n";
print MAIL qq~
------=_MAARTEN.ATT
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=US-ASCII
Dear $FORM{'recipient'},
$FORM{'sendername'} wants you to take a look at the following page:
$FORM{'url'}
~;
if ($FORM{'message'}) {
print MAIL qq~
$FORM{'sendername'} also wanted to tell you this:
$FORM{'message'}
~;
}
print MAIL qq~
This email was send using $servicename, located here: $servicelocation
Script by MTVWebdesign, http://mtvwebdesign.hypermart.net
~;
print MAIL "------=_MAARTEN.ATT\n";
print MAIL "Content-Type: text/html\;name=\"test.html\"\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL "Content-Disposition: attachment\;filename=\"test.html\"\n\n";
foreach $line ($res->content) {
if ($line =~ /\//ig;}
print MAIL $line;
}
print MAIL "\n";
print MAIL "\n------=_MAARTEN.ATT--\n";
close MAIL;
}
else {
&send_plain;
}
}
sub privacy {
print "Content-type: text/html\n\n";
&pageheader("Privacy Policy");
foreach $line (@temptoken) {
if ($line =~ m/$token/i) {
print qq~
Privacy Policy
~;
open FILE, $privacy_file || die "Cannot open $privacy_file";
flock(FILE, 2) if $use_flock;
@lines = ;
flock(FILE, 8) if $use_flock;
close FILE;
print @lines;
}
print "$line";
}
#&powered_by("nologout");
}
sub getbase {
local($baseurl) = @_;
if ($baseurl =~ /\.html?$/i) {
@items = split(/\//,$baseurl);
$n = scalar @items;
$n--;
for($i=0;$i<$n;$i++) {
$base .= @items[$i] . "/";
}
}
else { $base = $baseurl; }
}
sub errors {
local($errors) = @_;
&expires_header("now");
print "Content-type: text/html\n\n";
&pageheader('An error occured');
foreach $line (@temptoken) {
if ($line =~ m/$token/i) {
if ($errors eq 'with the email address you gave') {
print qq~
Invalid email address
The following email address is invalid: $invalidmail
Please press the back button and try again.
Oscar Braun - Executive Director Environmental Justice
~;
}
# If the error type was not found:
else {
print qq~
Error Undefined! Please contact $webmasteremail and be detailed in what you did what caused the error.
~;
}
# Back button:
print qq~
~;
}
print "$line";
}
#&powered_by("nologout");
exit; # Exit the script when an error occured.
}