#!/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/waterforfighting/sendtoafriend/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~
 
Support this CWP Wise Use Project

E-Mail a Water For Fighting page to a friend
Please fill out the form below then press the Submit Query button to send $FORM{'url'} to someone you know.
Click here to read our privacy policy
Please enter your name:
Please enter your email:
Please enter the name of the person receiving this email
Please enter the email of the person receiving this email:
Would you like to include a personal message? If so, type it here:
How would you like to send this page?
Visit H2o Shed Watch
Return to Homepage

Oscar Braun - Executive Director Environmental Justice

Visit California Watershed Posse Homepage

Support This CWPosse Wise Use Project

voice 650-867-5779       fax 866-756-3101
.

Add This CWP Site to Your Favorites List

~; } print "$line"; } #&powered_by("nologout"); exit; } sub send { &check_email($FORM{'senderemail'}); &check_email($FORM{'recipientemail'}); &send_email; &SetCookies("name",$FORM{'sendername'},"email",$FORM{'senderemail'}); print "Content-type: text/html\n\n"; &pageheader("Send!"); foreach $line (@temptoken) { if ($line =~ m/$token/i) { print qq~
 
Support this CWP Wise Use Project

Your page has been sent!

The Water For Fighting page has been e-mailed to $FORM{'recipient'}. Please click the back button below to return to the page you were on.

Visit H2o Shed Watch
Return to Homepage

Oscar Braun - Executive Director Environmental Justice

Visit California Watershed Posse Homepage

Support This CWPosse Wise Use Project

voice 650-867-5779       fax 866-756-3101
.

Add This CWP Site to Your Favorites List

~; } 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 to share Water For Fighting!\n\n"; print MAIL qq~ Dear $FORM{'recipient'}, $FORM{'sendername'} would appreciate your time to take a look at the following Water For Fighting page: $FORM{'url'} ~; if ($FORM{'message'}) { print MAIL qq~ $FORM{'sendername'} also had this additional message: $FORM{'message'} ~; } print MAIL qq~ Water For Fighting campaign is a California Watershed Posse 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.cwposse.org 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 Water For Fighting webpage which you can also view online by clicking here!
"; if ($FORM{'message'}) { $header .= "$FORM{'sendername'} also had this message for you:
$FORM{'message'}"; } $header .= "

This email was sent to you by someone visiting Water For Fighting"; $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'} wants to share Water For Fighting!\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'} wants to share Water For Fighting!\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 sent to you by someone visiting Water For Fighting ~; 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~
 
Support this CWP Wise Use Project

Invalid email address

The following email address is invalid: $invalidmail
Please press the back button and try again.
Visit H2o Shed Watch
Return to Homepage

Oscar Braun - Executive Director Environmental Justice

Visit California Watershed Posse Homepage

Support This CWPosse Wise use Project

voice 650-867-5779       fax 866-756-3101
.

Add This CWP Site to Your Favorites List

~; } # 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. }