Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autoresponder to manual responder 1

Status
Not open for further replies.

Perlwannabe

Technical User
Mar 7, 2006
57
IT
Hi everyone,

I have a script that comes with an autoresponder:It sends messages to everyone submits a certan url,instantly;I would prevent that since I would send these messages manually in a second time:How could I "break" the code in order to get this result?

Thanks for any help.

This is the code block:

sub addurl {
&heading;
$noshow = 1;
unless ($FORM{'url'} =~ /http:\/\//) {
&submiterror;
}

if ($FORM{'url'} eq "" || $FORM{'title'} eq "" || $FORM{'email'} eq "" || $FORM{'description'} eq "" || $FORM{'keywords'} eq "") {
#∅
}

unless (open (DATA,"$base")) {die (&error);}
if ($uselock eq '1') {
flock DATA, 2;
seek DATA, 0, 0;
}
@input = <DATA>;
if ($uselock eq '1') {
flock DATA, 8;
}
close (DATA);
$entries = @input;

$urlsearch = "$FORM{'url'}"."::";
$urltemp = $FORM{'url'};
chomp($urltemp);
chop($urltemp);
$urlsearchtwo = "$urltemp"."::";
$urlsearchthree = "$FORM{'url'}"."/::";
$currentline = 0;
until ($currentline == $entries) {
#if ($input[$currentline] =~ /$urlsearch/i) {
# &exists;
#}
#if ($input[$currentline] =~ /$urlsearchtwo/i) {
# &exists;
#}
#if ($input[$currentline] =~ /$urlsearchthree/i) {
# &exists;
#}
++$currentline;
}

$testline = $input[$currentline-1];
$testline2 = $input[$currentline-2];
$testline3 = $input[$currentline-3];
$testline4 = $input[$currentline-4];
$testline5 = $input[$currentline-5];
$testline6 = $input[$currentline-6];
$testline7 = $input[$currentline-7];
$testline8 = $input[$currentline-8];
$testline9 = $input[$currentline-9];
$testline10 = $input[$currentline-10];

#if ($testline =~ /$FORM{'description'}/) {
# &samestuff;
#}

#if ($testline =~ /$FORM{'title'}/) {
# &samestuff;
#}

#if ($testline =~ /$FORM{'keywords'}/) {
# &samestuff;
#}

#if ($testline =~ /$FORM{'email'}/i || $testline2 =~ /$FORM{'email'}/i || $testline3 =~ /$FORM{'email'}/i || $testline4 =~ /$FORM{'email'}/i || $testline5 =~ /$FORM{'email'}/i || $testline6 =~ /$FORM{'email'}/i || $testline7 =~ /$FORM{'email'}/i || $testline8 =~ /$FORM{'email'}/i || $testline9 =~ /$FORM{'email'}/i || $testline10 =~ /$FORM{'email'}/i) {
# &justsubmitted;
#}


$newemail = $FORM{'email'};
if ($FORM{'send'} ne "on") {
$newemail = "X"."$newemail"."X";
}
$newtitle = substr($FORM{'title'},0,$maxtitle);
$newdesc = substr($FORM{'description'},0,$maxdescription);
$newkeywords = substr($FORM{'keywords'},0,$maxkeywords);
$line = join ("::","$FORM{'url'}","$newtitle","$newkeywords","$newemail","$newdesc");

unless (open (DATA,">>$base")) {die (&error);}
if ($uselock eq '1') {
flock DATA, 2;
seek DATA, 0, 2;
}
print DATA "$line\n";
if ($uselock eq '1') {
flock DATA, 8;
}
close (DATA);

print "<center><HR WIDTH=400><FONT $font SIZE=3><b>Submission Received</b></font><p>\n";

if ($userespond eq '1') {
unless (open (DATA,"$respondfile")) {die (&error);}
if ($uselock eq '1') {
flock DATA, 2;
seek DATA, 0, 0;
}
@respondinfo = <DATA>;
if ($uselock eq '1') {
flock DATA, 8;
}
close (DATA);
foreach $respondline (@respondinfo){
$respondmessage = $respondmessage.$respondline;
}

open (MAIL, "|$mailprogram -t");
print MAIL "To: $FORM{'email'}\n";
print MAIL "From: $searchemail\n";
print MAIL "Subject: Got it!\n\n";
print MAIL "Welcome to $sitetitle!\n";
print MAIL "We are located at $searchurl\n\n";
print MAIL "YOUR SUBMISSION:\n";
print MAIL "------------------------------------------------------------------\n";
print MAIL "URL : $FORM{'url'}\n";
print MAIL "Title : $FORM{'title'}\n";
print MAIL "Description : $FORM{'description'}\n";
print MAIL "Keywords : $FORM{'keywords'}\n";
print MAIL "E-mail : $FORM{'email'}\n";
print MAIL "------------------------------------------------------------------\n\n";
print MAIL "$respondmessage";
print MAIL "------------------------------------------------------------------\n\n";
print MAIL "Thanks again,\n";
print MAIL "---------------------------------------------\n";
print MAIL "$sitetitle\n";
print MAIL "$searchemail\n";
print MAIL "$searchurl\n";
print MAIL "---------------------------------------------\n";
print MAIL "Powered by :\n";

print MAIL "---------------------------------------------\n";
close (MAIL);
}
&footer;
 
ugh, code in italics, please use the code tags for posting code, pretty pretty please. :)


Code:
sub addurl {
    &heading;
    $noshow = 1;
    unless ($FORM{'url'} =~ /http:\/\//) {
        &submiterror;
    }

    if ($FORM{'url'} eq "" || $FORM{'title'} eq "" || $FORM{'email'} eq "" || $FORM{'description'} eq "" || $FORM{'keywords'} eq "") {
        #&empty;
    }

    unless (open (DATA,"$base")) {die (&error);}
    if ($uselock eq '1') {
        flock DATA, 2;
        seek DATA, 0, 0;
    }
    @input = <DATA>;
    if ($uselock eq '1') {
        flock DATA, 8;
    }
    close (DATA);
    $entries = @input;

    $urlsearch = "$FORM{'url'}"."::";
    $urltemp = $FORM{'url'};
    chomp($urltemp);
    chop($urltemp);
    $urlsearchtwo = "$urltemp"."::";
    $urlsearchthree = "$FORM{'url'}"."/::";
    $currentline = 0;
    until ($currentline == $entries) {
        #if ($input[$currentline] =~ /$urlsearch/i) {
        #    &exists;
        #}
        #if ($input[$currentline] =~ /$urlsearchtwo/i) {
        #    &exists;
        #}
        #if ($input[$currentline] =~ /$urlsearchthree/i) {
        #    &exists;
        #}
        ++$currentline;
    }  

    $testline = $input[$currentline-1];
    $testline2 = $input[$currentline-2];
    $testline3 = $input[$currentline-3];
    $testline4 = $input[$currentline-4];
    $testline5 = $input[$currentline-5];
    $testline6 = $input[$currentline-6];
    $testline7 = $input[$currentline-7];
    $testline8 = $input[$currentline-8];
    $testline9 = $input[$currentline-9];
    $testline10 = $input[$currentline-10];

    #if ($testline =~ /$FORM{'description'}/) {
    #    &samestuff;
    #}

    #if ($testline =~ /$FORM{'title'}/) {
    #    &samestuff;
    #}

    #if ($testline =~ /$FORM{'keywords'}/) {
    #    &samestuff;
    #}

    #if ($testline =~ /$FORM{'email'}/i || $testline2 =~ /$FORM{'email'}/i || $testline3 =~ /$FORM{'email'}/i || $testline4 =~ /$FORM{'email'}/i || $testline5 =~ /$FORM{'email'}/i || $testline6 =~ /$FORM{'email'}/i || $testline7 =~ /$FORM{'email'}/i || $testline8 =~ /$FORM{'email'}/i || $testline9 =~ /$FORM{'email'}/i || $testline10 =~ /$FORM{'email'}/i) {
    #    &justsubmitted;
    #}


    $newemail = $FORM{'email'};
    if ($FORM{'send'} ne "on") {
        $newemail = "X"."$newemail"."X";    
    }
    $newtitle = substr($FORM{'title'},0,$maxtitle);
    $newdesc = substr($FORM{'description'},0,$maxdescription);
    $newkeywords = substr($FORM{'keywords'},0,$maxkeywords);
    $line = join ("::","$FORM{'url'}","$newtitle","$newkeywords","$newemail","$newdesc");

    unless (open (DATA,">>$base")) {die (&error);}
        if ($uselock eq '1') {
            flock DATA, 2;
            seek DATA, 0, 2;
        }
        print DATA "$line\n";
        if ($uselock eq '1') {
            flock DATA, 8;
        }
    close (DATA);

    print "<center><HR WIDTH=400><FONT $font SIZE=3><b>Submission Received</b></font><p>\n";
    
    if ($userespond eq '1') {
        unless (open (DATA,"$respondfile")) {die (&error);}
            if ($uselock eq '1') {
                flock DATA, 2;
                seek DATA, 0, 0;
            }
            @respondinfo = <DATA>;
            if ($uselock eq '1') {
                flock DATA, 8;
            }
        close (DATA);
        foreach $respondline (@respondinfo){
            $respondmessage = $respondmessage.$respondline;
        }

        open (MAIL, "|$mailprogram -t");
        print MAIL "To: $FORM{'email'}\n";
        print MAIL "From: $searchemail\n";
        print MAIL "Subject: Got it!\n\n";
        print MAIL "Welcome to $sitetitle!\n";
        print MAIL "We are located at $searchurl\n\n";
        print MAIL "YOUR SUBMISSION:\n";
        print MAIL "------------------------------------------------------------------\n";
        print MAIL "URL : $FORM{'url'}\n";
        print MAIL "Title : $FORM{'title'}\n";
        print MAIL "Description : $FORM{'description'}\n";
        print MAIL "Keywords : $FORM{'keywords'}\n";
        print MAIL "E-mail : $FORM{'email'}\n";
        print MAIL "------------------------------------------------------------------\n\n";
        print MAIL "$respondmessage";
        print MAIL "------------------------------------------------------------------\n\n";
        print MAIL "Thanks again,\n";
        print MAIL "---------------------------------------------\n";
        print MAIL "$sitetitle\n";
        print MAIL "$searchemail\n";
        print MAIL "$searchurl\n";
        print MAIL "---------------------------------------------\n";
        print MAIL "Powered by :\n";
        
        print MAIL "---------------------------------------------\n";
        close (MAIL);
    }
    &footer;
 
look here:

Code:
if ($userespond eq '1') {

just set $userespond to any value besides '1' and the autoresponse will not be sent. You could do this if you don't know where to set $userespond:

Code:
$userespond = 0;
if ($userespond eq '1') {
 
Ok,this excludes the autoresponse.
But how to send manually the mail/s trough a proper command?

should I work on

Code:
open (MAIL,"| $mailprogram -t");

or what else?

Thanks again
 
I'm not really sure what you are getting at, but that is the line that opens sendmail and enables you to send an email:

open (MAIL,"| $mailprogram -t");

$mailprogram is a scalar with a value of something like:

/usr/lib/sendmail

which has been previously defined somewhere in the script.

 
Exactly.

So,what if I execute that line with a proper command on a html page,such as a button?
Would it work?
If yes, what should the synthax be?

Thanks
 
hmmm.... once again I am not clear what you are asking. If you want to send the email conditionally, add a parameter to the form data you send to the script, could be as simple as a 1 (one) or 0 (zero). Use that data to know if to send the email or not:

<input type='hidden' name='cmd' value=1>

after you get your form data into your hash: %FORM:

Code:
if ($FORM{'cmd'} == 1) {
  the code to send the email
}

you could maybe just replace this line:

if ($userespond eq '1') {

with:

if ($FORM{'cmd'} == 1) {

and it will do what you want.

you certainly don't want to send the real command in your form data to start a server process, that is very insecure unless you do some good validation on the string before using it. But it's not recommended, use a 'flag' like I showed you:

<input type='hidden' name='cmd' value=1>
 
Ok.I'll try to better explain:

This script sends an automatic response after an url submission;I assume that it executes a code string in order to do this;what I would to do is to locate this code string and execute it manually,trough a proper command,you see?
In other words:
An user submits an url and an e-mail address, but doesn't receive automatically a response;
The webmaster,when he decides,will send the mail by clicking on a button...

Hoping to be clear...

Thanks for the patience...
 
OK, you don't want the automatic email response to happen, I showed you how to stop that, right? So your script will have to save the email addresses to some sort of file to send the emails later when the webmaster wants to send them. That file will need to be opened and send all the pending emails at once or make a list the webmaster can use to select which emails to send. Now this is the line in the script that opens a connection to the sendmail program on the server and sends emails:

open (MAIL, "|$mailprogram -t");

using the data supplied by the script in proper email format, ie:

Code:
        print MAIL "To: $FORM{'email'}\n";
        print MAIL "From: $searchemail\n";
        print MAIL "Subject: Got it!\n\n";
        print MAIL "Welcome to $sitetitle!\n";
        print MAIL "We are located at $searchurl\n\n";
        print MAIL "YOUR SUBMISSION:\n";
        print MAIL "------------------------------------------------------------------\n";
        print MAIL "URL : $FORM{'url'}\n";
        print MAIL "Title : $FORM{'title'}\n";
        print MAIL "Description : $FORM{'description'}\n";
        print MAIL "Keywords : $FORM{'keywords'}\n";
        print MAIL "E-mail : $FORM{'email'}\n";
        print MAIL "------------------------------------------------------------------\n\n";
        print MAIL "$respondmessage";
        print MAIL "------------------------------------------------------------------\n\n";
        print MAIL "Thanks again,\n";
        print MAIL "---------------------------------------------\n";
        print MAIL "$sitetitle\n";
        print MAIL "$searchemail\n";
        print MAIL "$searchurl\n";
        print MAIL "---------------------------------------------\n";
        print MAIL "Powered by :\n";
        
        print MAIL "---------------------------------------------\n";
        close (MAIL);

so you need to write a new script or add onto the existing script a routine that opens the file with the saved email addresses and fires off the emails. Now you could set that up as an html/CGI form and the webmaster clicks the "Send the email responses" button. The form sends the request to the script on the server and the script does what I explained above: "opens the file with the saved email addresses and fires off the emails." I can't explain it any better or simpler to you then that.
 
Ok.So I have to create a command that does the same that the below line,isn't it?

Code:
open (MAIL, "|$mailprogram -t");

If yes,what could be the right synthax for a html button,for example?

Thanks

 
There is no right syntax for an html button. I have already explained it as best I can. I'm not sure if I am not explaining it clearly or you are not understanding my explanation.
 
Ok.Look at it in this way:
What would you do to modify the above subroutine in order to get the mailing function?
 
I already explained that in my last long post. You seemed to have ignored the post.
 
That won't help me. I'm not a programmer at all.I expected a little more collaboration...

Anyway thanks for your partecipation.
 
Well,

Explain me,please,what could I do in order to collaborate?
What are the information you would need to help me?

I understood I have to create a new script or a new subroutine,but I need to know how to start...

If you still want to help me you're welcome...

Thanks, anyway.
 
How do you want it to work? Do you want the webmaster to simply click a button and all the pending emails get sent or something different?
 
Yes.I want to send ALL pending mails at once by clicking a button.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top