#!/usr/bin/perl 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/sites/site19/web/edition1/cgi/email2/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~
 

Enviar Articulo
$FORM{'url'}
Su Nombre
Su Email
A Nombre
A Email
Comentario
  
~; } print "$line"; } 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~ ~; } print "$line"; } 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'} te invita ver a la pagina web de Sur Press Magazine\n\n"; print MAIL qq~ $FORM{'recipient'}, $FORM{'sendername'} quire que mires el siguiente articulo: $FORM{'url'} ~; if ($FORM{'message'}) { print MAIL qq~ $FORM{'sendername'} quiere dicirle: $FORM{'message'} ~; } print MAIL qq~ Sur Press Magazine es una revista online sobre LatinoAmerica. Este email no es spam, ha sido enviado por $FORM{'recipient'} de $servicelocation ~; 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 = ""; if ($FORM{'message'}) { $header .= ""; } $header .= ""; $header .= ""; 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: From $FORM{'sendername'}, Invites you to Sur Press Magazine\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'} Te manda un articulo de surpress.com!\n\n"; print MAIL qq~ ------=_MAARTEN.ATT Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=US-ASCII Dear $FORM{'recipient'}, $FORM{'sendername'} quiere que mires la siguiente pagina: $FORM{'url'} ~; if ($FORM{'message'}) { print MAIL qq~ $FORM{'sendername'} Su mensaje: $FORM{'message'} ~; } print MAIL qq~ Este email no es spam, ha sido mandado por $FORM{'recipient'} from $servicelocation ~; 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~
 

 

Error de Email

 

~; } # Back button: print qq~ ~; } print "$line"; } exit; # Exit the script when an error occured. }