Envíe Infosenyal
#!/usr/bin/perl # Location of perl on your server. # © 2000 Bandley3 Software - Licensing Agreement Below Variables # yes or no variables below must be lowercase. # Valid Referer - prevents other sites from running your script. (yes recommended) $vref="yes"; # Valid Referer Address (if yes to above) - your domain. # Don't forget the .com, .net, etc. And don't include a trailing slash following .com $vrefcom="www.senyal.com"; # Are you using this script as a Server-Side Include? # IMPORTANT: This must be set according to how you will be using this script. # If set improperly, the sent mail will contain a bad link or no link at all. $SSINC="yes"; # The full URL to this script, including script name. $THISSCRIPT="http://www.senyal.com/cgi-bin/alert/envio.cgi"; # Root path to sendmail application on your server. $SENDMAIL="/usr/sbin/sendmail"; # Root path to aaflogit.dat and aafip.dat - no trailing slash. $LOGPATH="/home/webadmin/www/cgi-bin/alert"; # Your email address for error messages. Must have backslash BEFORE the at symbol. $YOUREMAIL="josepcasa\@senyal.com"; $FONTFACE="verdana"; # Separate secondary fonts by commas. $FONTSIZE="1"; $FONTCOLOR="black"; $PAGECOLOR="#FFCC66"; # Non-SSI - for form. SSI/Non SSI - for redirect page. $VLINKC="purple"; # Visited link color for pause page failure or if auto-redirect not used. $TITLE="my page"; # Non-SSI - title bar for form page. SSI - for pause page. $HEADTEXT="Envíe INFOSENYAL a un amigo!"; # Text/graphic above form. $RETMESS="yes"; # SSI - Message upon return to sent page? Non-SSI - set to no. $RETTEXT="Envío realizado!"; # SSI - return message/graphic. Non-SSI - for pause page. $TOTEXT="E-mail de su amigo: "; # 'Mail To' Text/graphic. $FROMTEXT="Su e-mail: "; # 'Mail From' Text/graphic. $MAXNAME="35"; # Maximum characters in email addresses. $MESSAGEBOX="yes"; # Do you want a message box for personal note? $COMMTEXT="Si desea añadir una nota personal, escriba aquí:"; # If YES above, text/graphic above message box. $BUTTON="Enviar"; # Submit Button text. Text Only. $TABLECOLOR="#ffcc00"; # Background color for table. - hex ok $TBORDER="0"; # Border around the table. $TCELL="3"; # Padding around elements in table. $STACK="no"; # Stack elements in table? $USEAT="no"; # Time in mail cleaned up by Bandley3's ActualTime? $timech="0"; # Hours from server. Up to +12 and -11. (No + needed, but - needed) $ACTZONE="PT"; # Time zone text. Just text, does not affect time stamping. $AUTORE="yes"; # Automatically redirect user back to the page they sent? $REFRTIME="4"; # If YES above, seconds to pause. (Best results under 10) $REFAIL="yes"; # If YES above, do you want link if redirect fails? $DOLOG="yes"; # Log sent pages? If YES, read IMPORTANT LOG NOTE below. # IMPORTANT NOTE FOR LAST VARIABLE - # No quotation marks. Periods and commas ok. # To add more links to the mail, other than the sent page link, just type a url. # example - http://www.senyal.com/infosenyal/index.htm # TIP: If you would like carriage returns in your message, use a # backslash and the letter n. # example - \n for a single return. $MAILTEXT="Enviado desde INFOSENYAL\n\nhttp://www.senyal.com/infosenyal. \n\nSENYAL Internet Multimedia. Todos los derechos reservados."; ### End Of Variables # IMPORTANT LOG NOTE: If you will be using this script on a large number of pages, you may # want to set this variable to NO. The script could slow down substantially if you were to try # logging for, say, 100 pages. We suggest developers, using alot of pages, test to make sure # the logging feature doesn't slow down your server. # FUN NOTE: Except for the variables $MAILTEXT, $BUTTON, and $ACTZONE, where you are # prompted to specify text messages, you may place your text within bold tags. # You may also use an image tag within these same text variables. Make sure your image # tags DO NOT contain quotation marks. In general, it's probably best to use full URL to # your images. # example - # Copyright and Licensing Agreement # # Bandley3.com's Alert-A-Friend v1.0 # UNIX (Debian Linux) tested # Copyright 2000 Bandley3.com # http://bandley3.com # cfs@mac.com # ########## # # Licensing Agreement # # Installing this script constitutes acceptance of the licensing agreement found # at Bandley3.com and in the LICENSE document packaged with this script. # Although Alert-A-Friend is a free script, all copyright laws apply. This script is # not to be sold, redistributed, or repackaged in any way. # Bandley3.com's Alert-A-Friend is a licensed product. # # ########## ########## NO EDITING NECESSARY BELOW THIS POINT print "Content-type:text/html\n\n"; ########## checkreferer sub checkreferer { if (($vref eq "yes") && ($ENV{'HTTP_REFERER'} =~m|https?://([^/]*)$vrefcom|i)) { $checkref=1; } elsif ($vref eq "no") { $checkref=1; } else { &errorref; } } ########## if (($RETMESS eq "yes") && ($SSINC eq "yes")) { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time); open (IPDAT, "<$LOGPATH/aafip.dat") || &error("Didn't send. Couldn't open file.

possible chmod 777 of log .dat file."); @ipdat=; close (IPDAT); $ieipfix="$ENV{'REMOTE_ADDR'}$mday"; for $ipdat(@ipdat) { chomp($ipdat); if ($ipdat eq $ieipfix) { $iefix=1; } } } $sendit="sendit"; $senditssi="senditssi"; if (!$ENV{'QUERY_STRING'}) { if ($SSINC eq "no") { &ssino; } else { &ssiyes; } } elsif ($ENV{'QUERY_STRING'} eq $sendit) { &parseform; &sendit; } elsif ($ENV{'QUERY_STRING'} eq $senditssi) { &parseform; $FORM{'page'}=$ENV{'HTTP_REFERER'}; &sendit; } else { &errorload; } ########## ssino sub ssino { if ($STACK eq "yes") { print "$TITLE\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($MESSAGEBOX eq "yes") { print "\n"; } print "
\n"; print "$HEADTEXT
$TOTEXT
$FROMTEXT
$COMMTEXT
\n"; print "
\n"; print "
\n"; exit; } else { print "$TITLE\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($MESSAGEBOX eq "yes") { print "\n"; } print "
\n"; print "$HEADTEXT
$TOTEXT
$FROMTEXT
$COMMTEXT
\n"; print "
\n"; print "
\n"; exit; } } ########## ssiyes sub ssiyes { if ($STACK eq "yes") { print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($MESSAGEBOX eq "yes") { print "\n"; } if ($RETMESS eq "yes") { if ($iefix eq "1") { print "\n"; } } print "
\n"; print "$HEADTEXT
$TOTEXT
$FROMTEXT
$COMMTEXT
\n"; print "
$RETTEXT\n"; print "
\n"; print "
\n"; print "
\n"; exit; } else { print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($MESSAGEBOX eq "yes") { print "\n"; } if ($RETMESS eq "yes") { if ($iefix eq "1") { print "\n"; } } print "
\n"; print "$HEADTEXT
$TOTEXT
$FROMTEXT
$COMMTEXT
\n"; print "
$RETTEXT\n"; print "
\n"; print "
\n"; print "
\n"; exit; } } ########## sendit sub sendit { &checkreferer; if ($FORM{'sendto'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ || $FORM{'sendto'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { &errormail("Invalid Mail To Address"); } if ($FORM{'sendfrom'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ || $FORM{'sendfrom'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { &errormail("Invalid Mail From Address"); } $tolong=length($FORM{'sendto'}); if ($tolong > $MAXNAME) { &errormail("Invalid Mail To Address

Too many characters."); } $fromlong=length($FORM{'sendfrom'}); if ($fromlong > $MAXNAME) { &errormail("Invalid Mail From Address

Too many characters."); } if ($SSINC eq "yes") { $logit=$ENV{'HTTP_REFERER'}; } else { $logit=$FORM{'page'}; } if ($DOLOG eq "yes") { open (LOGDAT, "<$LOGPATH/aaflogit.dat") || &error("Didn't send. Couldn't open file.

possible chmod 777 of log .dat file."); @logdat=; close (LOGDAT); foreach $logfind(@logdat) { if ($logfind =~ m/$logit/) { $logdoer="yes"; } } open (LOGGER, ">$LOGPATH/aaflogit.dat") || &error("Didn't send. Couldn't open file.

possible chmod 777 of log .dat file"); foreach $logger(@logdat) { chomp($logger); @logcut=split('\|\|', $logger); if ($logcut[0] =~ m/$logit/) { $lognew=$logcut[1] + 1; print LOGGER "$logcut[0]\|\|$lognew\n"; } else{ print LOGGER "$logger\n"; } } if ($logdoer ne "yes") { print LOGGER "$logit\|\|1\n"; } close (LOGGER); } open(MAIL, "|$SENDMAIL -t") || &error("Didn't send"); print MAIL "To: $FORM{'sendto'}\n"; print MAIL "From: $FORM{'sendfrom'}\n"; print MAIL "Subject: $FORM{'sendfrom'} te ha enviado una página.\n"; print MAIL "\n$FORM{'note'}\n\n"; if ($USEAT eq "yes") { &getnewstamp; print MAIL "The page below was sent on $wday $monptbac $mdaypbac, $year2bac at $hourpbac:$minbac $hourabac $ACTZONE "; print MAIL "from $FORM{'sendfrom'}.\n\n"; } else { $time=localtime(time); print MAIL "Esta página de INFOSENYAL ha sido enviada el $time por $FORM{'sendfrom'}.\n\n"; } print MAIL "mediante el servicio de ENVIA UN EMAIL A UN AMIGO: Pulsa en la dirección que aparece al final para verla.\n\n"; #print MAIL "\n";# #print MAIL "$FORM{'page'}\n\n\n";# print MAIL "$MAILTEXT\n"; close(MAIL); if (($RETMESS eq "yes") && ($SSINC eq "yes")) { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time); open (IPDAT, ">$LOGPATH/aafip.dat") || &error("Didn't send. Couldn't open file.

possible chmod 777 of log .dat file."); print IPDAT "$ENV{'REMOTE_ADDR'}$mday"; close (IPDAT); } if (($AUTORE eq "yes") && ($SSINC eq "yes")) { if ($REFAIL eq "yes") { print "\n"; print "\n"; print "$TITLE\n"; print "\n"; print "
\n"; print "

$RETTEXT

\n"; print "$ENV{'HTTP_REFERER'}\n"; print "
\n"; print "\n"; exit; } else { print "\n"; print "\n"; print "$TITLE\n"; print "\n"; print "\n"; print "\n"; } exit; } if (($AUTORE eq "yes") && ($SSINC eq "no")) { if ($REFAIL eq "yes") { print "\n"; print "\n"; print "$TITLE\n"; print "\n"; print "
\n"; print "

$RETTEXT

\n"; print "$FORM{'page'}\n"; print "
\n"; print "\n"; exit; } else { print "\n"; print "\n"; print "$TITLE\n"; print "\n"; print "\n"; print "\n"; } exit; } if ($SSINC eq "yes") { print "\n"; print "$TITLE\n"; print "\n"; print "
\n"; print "

$RETTEXT

\n"; print "$ENV{'HTTP_REFERER'}\n"; print "
\n"; print "\n"; exit; } else { print "\n"; print "$TITLE\n"; print "\n"; print "
\n"; print "

$RETTEXT

\n"; print "$FORM{'page'}\n"; print "
\n"; print "\n"; } exit; } ##########parseform sub parseform { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); 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; $FORM{$key} = $value; } } 1; ##########error sub error { print "$TITLE\n"; print "
\n"; print "

Can't send.\n"; print "

Report this error to $YOUREMAIL\n"; print "

$_[0]
\n"; print "\n"; exit; } ##########errorref sub errorref { print "$TITLE\n"; print "
\n"; print "

This script cannot be called from other sites.\n"; print "

Invalid Referer.\n"; print "
\n"; print "\n"; exit; } ##########errormail sub errormail { print "$TITLE\n"; print "
\n"; print "

Can't send mail.\n"; print "

$_[0]

\n"; print "
\n"; print "
\n"; print "\n"; exit; } ##########errorload sub errorload { print "$TITLE\n"; print "
\n"; print "

Invalid call to this script.\n"; print "
\n"; print "\n"; exit; } ########## uactualtime start ##########getnewstamp sub getnewstamp { ############################ SERVERTIME ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time); $min=sprintf ("%02d", $min); $sec=sprintf ("%02d", $sec); $year2=$year + 1900; $monp=$mon +1; ########## INCREMENT SERVERTIME $hourmov=$hour + $timech; ############################ DAILY ROLLOVERS if ($hourmov >= 24) { $mdayp=$mday +1; $moveplus="yes"; } elsif ($hourmov < 0) { $mdayp=$mday -1; $moveminus="yes"; } else { $mdayp=$mday; } ########## DEFINE LEAPYEARS @feb=(2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056, 2060, 2064, 2068, 2072, 2076, 2080, 2084, 2088, 2092, 2096); ########## MONTH/DAY/YEAR/WEEKDAY ROLLOVERS GET DEFINED if ($moveminus eq "yes") { if ($wday eq "1") { $wday="Domingo" } if ($wday eq "2") { $wday="Lunes" } if ($wday eq "3") { $wday="Martes" } if ($wday eq "4") { $wday="Miercoles" } if ($wday eq "5") { $wday="Jueves" } if ($wday eq "6") { $wday="Viernes" } if ($wday eq "0") { $wday="Sabado" } if ($mdayp eq "0") { if ($monp eq "1") { $monp=12; $mdayp=31; $year2=$year2 -1; } elsif ($monp eq "2") { $monp=1; $mdayp=31; } elsif ($monp eq "3") { $monp=2; $mdayp=28; foreach $leapyear (@feb) { if ($year2 eq $leapyear) { $monp=2; $mdayp=29; } } } elsif ($monp eq "4") { $monp=3; $mdayp=31; } elsif ($monp eq "5") { $monp=4; $mdayp=30; } elsif ($monp eq "6") { $monp=5; $mdayp=31; } elsif ($monp eq "7") { $monp=6; $mdayp=30; } elsif ($monp eq "8") { $monp=7; $mdayp=31; } elsif ($monp eq "9") { $monp=8; $mdayp=31; } elsif ($monp eq "10") { $monp=9; $mdayp=30; } elsif ($monp eq "11") { $monp=10; $mdayp=31; } elsif ($monp eq "12") { $monp=11; $mdayp=30; } } } if ($moveplus eq "yes") { if ($wday eq "1") { $wday="Martes" } if ($wday eq "2") { $wday="Miercoles" } if ($wday eq "3") { $wday="Jueves" } if ($wday eq "4") { $wday="Viernes" } if ($wday eq "5") { $wday="Sabado" } if ($wday eq "6") { $wday="Domingo" } if ($wday eq "0") { $wday="Lunes" } if (($monp eq "1") && ($mdayp eq "32")) { $monp=2; $mdayp=1; } if (($monp eq "2") && ($mdayp eq "30")) { $monp=3; $mdayp=1; } if (($monp eq "2") && ($mdayp eq "29")) { $monp=3; $mdayp=1; foreach $leapyear (@feb) { if ($year2 eq $leapyear) { $monp=2; $mdayp=29; } } } if (($monp eq "3") && ($mdayp eq "32")) { $monp=4; $mdayp=1; } if (($monp eq "4") && ($mdayp eq "31")) { $monp=5; $mdayp=1; } if (($monp eq "5") && ($mdayp eq "32")) { $monp=6; $mdayp=1; } if (($monp eq "6") && ($mdayp eq "31")) { $monp=7; $mdayp=1; } if (($monp eq "7") && ($mdayp eq "32")) { $monp=8; $mdayp=1; } if (($monp eq "8") && ($mdayp eq "32")) { $monp=9; $mdayp=1; } if (($monp eq "9") && ($mdayp eq "31")) { $monp=10; $mdayp=1; } if (($monp eq "10") && ($mdayp eq "32")) { $monp=11; $mdayp=1; } if (($monp eq "11") && ($mdayp eq "31")) { $monp=12; $mdayp=1; } if (($monp eq "12") && ($mdayp eq "32")) { $monp=1; $mdayp=1; $year2=$year2 +1; } } ############################ INCREMENTED TIME DEFINED if ($hour eq "0") { $hourz=24; } else { $hourz=$hour; } $houry=$hourz + $timech; if ($houry eq "0") { $hourp=12; $houra="am"; } elsif ($houry eq "24") { $hourp=12; $houra="am"; } elsif ($houry eq "12") { $hourp=12; $houra="pm"; } elsif ($houry < 0) { $hourp=$houry + 24; } elsif (($houry > 0) && ($houry < 12)) { $hourp=$houry; $houra="am"; } elsif (($houry > 12) && ($houry < 24)) { $hourp=$houry; } elsif ($houry > 24) { $hourp=$houry - 24; $houra="am"; } if ($hourp eq "13") { $hourp=1; $houra="pm"; } elsif ($hourp eq "14") { $hourp=2; $houra="pm"; } elsif ($hourp eq "15") { $hourp=3; $houra="pm"; } elsif ($hourp eq "16") { $hourp=4; $houra="pm"; } elsif ($hourp eq "17") { $hourp=5; $houra="pm"; } elsif ($hourp eq "18") { $hourp=6; $houra="pm"; } elsif ($hourp eq "19") { $hourp=7; $houra="pm"; } elsif ($hourp eq "20") { $hourp=8; $houra="pm"; } elsif ($hourp eq "21") { $hourp=9; $houra="pm"; } elsif ($hourp eq "22") { $hourp=10; $houra="pm"; } elsif ($hourp eq "23") { $hourp=11; $houra="pm"; } ############################ DEFINE DAY NAMES if UNCHANGED if ($wday eq "1") { $wday="Lunes"; } if ($wday eq "2") { $wday="Martes"; } if ($wday eq "3") { $wday="Miercoles"; } if ($wday eq "4") { $wday="Jueves"; } if ($wday eq "5") { $wday="Viernes"; } if ($wday eq "6") { $wday="Sabado"; } if ($wday eq "0") { $wday="Domingo"; } ############################ CONVERT MONTH NUMBERS to TEXT if ($monp eq "1") { $monpt="Enero"; } if ($monp eq "2") { $monpt="Febrero"; } if ($monp eq "3") { $monpt="Marzo"; } if ($monp eq "4") { $monpt="Abril"; } if ($monp eq "5") { $monpt="Mayo"; } if ($monp eq "6") { $monpt="Junio"; } if ($monp eq "7") { $monpt="Julio"; } if ($monp eq "8") { $monpt="Agosto"; } if ($monp eq "9") { $monpt="Septiembre"; } if ($monp eq "10") { $monpt="Octubre"; } if ($monp eq "11") { $monpt="Noviembre"; } if ($monp eq "12") { $monpt="Diciembre"; } $wdaybac=$wday; $monpbac=$monp; $monptbac=$monpt; $mdaypbac=$mdayp; $year2bac=$year2; $hourpbac=$hourp; $minbac=$min; $hourabac=$houra; } ##########uactualtime end