Tengo el siguiente script en CGI:
Using perl Syntax Highlighting
- #!/usr/bin/perl
- #(C) Gustavs Avotins, 2002
- do 'sessions.cgi';
- do 'sendemailfunc.cgi';
- $DAYSDELAY = 0; # allow emailing once every $DAYSDELAY or more days, >= 0
- $ALLOWONLYPAIDMEMBERS = 0; # allow only paid members to use this script. 1=yes, 0=no
- # (set to 1 only if PaidMembers addon is installed)
- # The text below will be added at the end of all messages when sent in TEXT format.
- # By default contains unsubscribe info. To use the default, change root\@localhost
- # to your support email. %ID% will be substituted to recipient's user ID#
- $ADMINNOTE_TEXT = qq~
- -------------------------------------------------------------------------
- This message was sent to you by the member of your ReferClub upline.
- To unsubscribe & terminate your ReferClub membership, please login into
- your account and use 'Delete Account' or send an email to root\@localhost
- with 'remove (ID#: %ID%)' in the subject line.
- Best regards,
- ReferClub admin
- $SiteURL/
- ~;
- # Same for HTML format emails
- $ADMINNOTE_HTML = qq~
- <BR><BR>
- -------------------------------------------------------------------------<BR>
- This message was sent to you by the member of your ReferClub upline.<BR>
- To unsubscribe & terminate your ReferClub membership, please login into<BR>
- your account and use 'Delete Account' or send an email to root\@localhost<BR>
- with 'remove (ID#: %ID%)' in the subject line.<BR>
- <BR>
- Best regards,<BR>
- ReferClub admin<BR>
- <BR>
- $SiteURL/
- ~;
- if ( $ENV{REQUEST_METHOD} eq 'POST' ) {
- read( STDIN, $buffer, $ENV{'CONTENT_LENGTH'} );
- }
- else { $buffer = $ENV{QUERY_STRING} }
- @pairs = split( /&/, $buffer );
- foreach $pair (@pairs) {
- ( $name, $value ) = split( /=/, $pair, 2 );
- $value =~ tr/+/ /;
- $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
- $in{$name} = $value;
- }
- print "Content-type:text/html\n\n";
- $session = $in{'session'};
- unless ( VerifySession($session) ) { SessionExpired() }
- $session =~ /:(\d+)/;
- $userid = $1; #get Userid
- @user = ReadRecord($userid);
- if ( $ALLOWONLYPAIDMEMBERS == 1 ) {
- if ( $user[$DBStatus] != 1 ) {
- print "Error: free members are not allowed to use this feature!";
- exit;
- }
- }
- print qq~
- <html><head>
- <meta http-equiv="Content-Language" content="en-us">
- <meta http-equiv="Content-Type"
- content="text/html; charset=windows-1252">
- </head>
- <body background="$SiteURL/bg.jpg">
- ~;
- $subject = $in{'subject'};
- $message = $in{'message'};
- $format = $in{'format'};
- if ( $format ne undef ) {
- if ( $subject eq "" ) { print "Error: you haven't entered a subject!"; exit }
- if ( $message eq "" ) { print "Error: you haven't entered a message!"; exit }
- $from = "$user[$DBName] <$user[$DBEmail]>";
- LockedCodeBegin();
- @ids = ReadDownline( $userid, 1 );
- $dayspassed = int( ( time() - $ids[0] ) / 86400 );
- if ( $ids[0] eq undef ) { print "Error: you have no downline!"; exit }
- if ( ( $ids[0] != 0 ) and ( $dayspassed < $DAYSDELAY ) ) { print "Intrusion detected!"; exit }
- #update sending time for this user before sending
- $ids[0] = time;
- open( FH, ( ">$DownlineDir/" . substr( $userid, -1, 1 ) . "/$userid" ) )
- or die "Error opening downline info! $!\n";
- WriteLock( *FH, 0, 0 ) or die "Error write locking downline info! $!\n";
- my $buffer = join( ',', @ids );
- syswrite( FH, $buffer, length($buffer) );
- close(FH) or die "Error closing downline info! $!\n";
- LockedCodeEnd();
- if ( $format eq 'html' ) { $subject .= "\nContent-type: text/html" }
- #send emails
- my $sig = "";
- for ( $i = 1; $i < @ids; $i++ ) {
- if ( $format eq 'text' ) {
- $sig = $ADMINNOTE_TEXT;
- }
- else {
- $sig = $ADMINNOTE_HTML;
- }
- @tempuser = ReadRecord( $ids[$i] );
- $name = $tempuser[$DBName];
- $email = $tempuser[$DBEmail];
- $password = $tempuser[$DBPassword];
- $msg = $message;
- $subj = $subject;
- $msg =~ s/%NAME%/$name/g;
- $subj =~ s/%NAME%/$name/g;
- $sig =~ s/%ID%/$ids[$i]/g;
- if ( $password ne "" ) {
- if ( !SendEmail( $from, $email, $subj, "\n" . $msg . $sig, "-oi -t" ) ) {
- print "Error sending email to member# $ids[$i]! Stopped sending";
- exit;
- }
- }
- }
- print qq~
- <table border="0" width="100%" cellpadding="0" cellspacing="0" height="95%">
- <tr>
- <td width="100%" height="100%">
- <h2 align="center">Your message has been sent to all your downline</h2>
- </td>
- </tr>
- </table>
- </body></html>
- ~;
- exit;
- }
- print "<CENTER><H2>Email to direct downline</H2>";
- if ( $DAYSDELAY > 0 ) {
- print "<H3><FONT color=red><B>Status:</B></FONT> ";
- my $lasttime = ( ReadDownline( $userid, 1 ) )[0];
- if ( $lasttime eq undef ) { print "<B>You have no downline!</B></H3>"; exit }
- $dayspassed = int( ( time() - $lasttime ) / 86400 );
- if ( ( $lasttime == 0 ) or ( $dayspassed >= $DAYSDELAY ) ) {
- print "<FONT color=green><B>Allowed</B></FONT></H3>";
- }
- else {
- $days = $DAYSDELAY - $dayspassed;
- if ( $days == 1 ) { $days .= " day" }
- else { $days .= " days" }
- print "<B>$days remaining before you may post again!</B></H3>";
- exit;
- }
- }
- $email = "$user[$DBName] <$user[$DBEmail]>";
- print qq~
- <h4>Note: you can use personalization code %NAME% in subject and message<BR>
- (%NAME% will be replaced with your downline member name)</h2>
- <form action="emaildownline.cgi" method="POST">
- <table border="1" cellpadding="1" cellspacing="0" bgcolor="#FFFFCC">
- <TR><TD>From:</TD><TD>$email</TD></TR>
- <TR><TD>Subject:</TD><TD><INPUT type="text" NAME="subject" SIZE="60"></TD></TR>
- <TR><TD>Format:</TD><TD><INPUT type="radio" NAME="format" value="text" CHECKED>Text <INPUT type="radio" NAME="format" value="html">HTML</TD></TR>
- <TR><th colspan="2" height="144" align="left">
- <textarea rows="12" name="message" cols="65"></textarea></th></TR>
- <INPUT type="hidden" name="session" value="$session">
- </tr><tr><td colspan="2" align="center"><BR>
- <input type="submit" value="Send" name="submit" style="font-size: 17px"><BR><BR>
- </td></tr></table></form>
- <FONT color=red>After clicking the 'Send' button please wait until the process completes!</FONT>
- </CENTER>
- </BODY></HTML>
- ~;
Coloreado en 0.007 segundos, usando GeSHi 1.0.8.4
Es para enviar correos a varios prospectos a la vez.
Cuando lo ejecuto no me manda los email y la pantalla se queda en blanco.
Cuando adquirí el script me ponía que el tiempo de ejecución Perl tenía que ser alto.
He adquirido el hosting en hostgator.
¿Quée puedo hacer para mandar los emails?
Un saludo,
Julian Gutierrez
Valladolid