#!/usr/bin/perl # change the above to your path to perl # Enter the location of sendmail. $mailprogram = "/usr/sbin/sendmail"; # By default, BlueSend uses the page it was called from # as the url sent in email. If you only want a specific # url sent, then un-comment and use the following line. $the_url = 'http://www.playasdecastellon.com/'; # the signature printed on the bottom of each email $sig = "Website a visitar sin falta."; #### Advanced setup options (optional) ### # Email address of person to notify when a page is sent. # Remove the comment and change this line to your email # address to enable this feature. (added by R. Betts) $notify = 'info@playasdecastellon.com'; # The server path (NOT the url) and filename to the # logfile to log all pages sent. Remove the comment # from the following line to enable this feature. (added by R. Betts) #$logfile = '/home/sites/www.playasdecastellon.com/web/recomendar/logfile.txt'; ### Credits ############################ # BlueSend created by: # # Robert Fogt webmaster@bluesparks.com # # # # Additional code: # # Gilnei Moraes gm199@fenomeno.com # # # # Logging and email noticing added: # # Robert Betts, bob@marinelifemag.com # # http://marinelifemag.com # # # # Send your code additions to: # # bluesend@bluesparks.com # ######################################## # version 3 print "Content-type: text/html\n\n"; &parse_form; if (!$the_url) { if ($formdata{'url'}) { $the_url = $formdata{'url'} } else { $the_url = $ENV{'HTTP_REFERER'}; } } if ($formdata{'send'}) { &check_email($formdata{'toemail'}); &check_email($formdata{'fromemail'}); $sendto = ''; $from = ''; if ($formdata{'toname'} ne '') {$sendto = $formdata{'toname'} . '<' . $formdata{'toemail'} . '>';} else {$sendto = $formdata{'toemail'};} if ($formdata{'fromname'} ne '') {$from = $formdata{'fromname'} . '<' . $formdata{'fromemail'} . '>';} else {$from = $formdata{'fromemail'};} open (MAIL,"|$mailprogram -t"); print MAIL "To: $sendto\n"; print MAIL "From: $from\n"; print MAIL "Subject: Sitio recomendado.\n\n"; if ($formdata{'toname'} ne '') { print MAIL "$formdata{'toname'},\n\n"; } print MAIL "Un amigo suyo, $formdata{'fromname'} \($formdata{'fromemail'}\)\n"; print MAIL "le surgiere que visite este sitio:\n\n"; print MAIL "$the_url\n\n"; if ($sig ne '') { print MAIL "--\n$sig\n\n"; } close(MAIL); if ($notify ne "") { # betts add Notify of page sent open (MAIL,"|$mailprogram -t"); print MAIL "To: $notify\n"; print MAIL "From: $from\n"; print MAIL "Subject: Recomendación hecha.\n\n"; print MAIL "Su sitio web ($the_url) ha sido recomendado por:\n"; print MAIL "$formdata{'fromname'} \($formdata{'fromemail'}\)\n\n"; print MAIL "a:\n"; print MAIL "$formdata{'toname'} \($formdata{'toemail'}\)\n\n"; print MAIL "--\n"; print MAIL "Con la cortesia de INDEXCOM (http://www.indexcom.net)"; close(MAIL); } if ($logfile ne "") { # betts add: do logging $date=localtime(time); if (open (MYLOG,">> $logfile")){ $logline = "$date\|$the_url\|$sendto\|$from"; print MYLOG "$logline\n"; close (MYLOG); } } &make_page('Gracias. Puede recomendar a otro amigo si lo desee.'); exit; } else { &make_page(''); } sub make_page { my $temp = shift; if ($temp ne '') {$temp = '

' . $temp . '

';} print < Recomiende este sitio

Rellene este formulario para enviar esta página a un amigo

$temp
Su nombre:
Su e-mail: *
Nombre del amigo:
E-mail del amigo: *
* Campos obligatorios

ENDMAKEPAGE exit; } # checks email address is valid sub check_email { $MyEmail = shift; if ($MyEmail =~ tr/;<>*|`&$!#()[]{}:'"//) { &make_page("Error de SEGURIDAD: No usar simbolos."); } unless ($MyEmail =~/.*\@.*\..*/) { &make_page("E-mail incorecto: '$MyEmail' Intente de nuevo."); } } sub parse_form { 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); if ($ENV{'QUERY_STRING'}) { @getpairs = split(/&/, $ENV{'QUERY_STRING'}); push(@pairs, @getpairs); } } foreach $pair (@pairs) { ($key, $value) = split(/=/, $pair); $key =~ tr/+/ /; $key =~ 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; $formdata{$key} = $value; } }