CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Why will this script not work??

 



jasont
Deleted

Aug 18, 2000, 9:09 PM

Post #1 of 3 (481 views)
Why will this script not work?? Can't Post

Can someone please tell me why this script
wont work when it is formatted as it is below?

The script works fine when it is all
on a few lines...but whenever it is
formatted like it is below, it won't work.

Im so lost and I need help Frown

#!/usr/bin/perl

############################################
## ##
## Ezine Subscriber Pro
## by Dale Reardon
## (e-mail dale@howtowriteheadlines.com for installation $20
## ##
## version: 1.2 ##
## last modified: 3 July 2000
## copyright (c) 2000 Dale Reardon ##
## ##
## Discover How To Write Million Dollar Headlines with our downloadable
course
## http://www.howtowriteheadlines.com
## ##
############################################

# COPYRIGHT NOTICE:
#
# Copyright 2000 Dale Reardon. All Rights Reserved.
#
# This program is copyright and may not be resold, distributed or given away
in any form without the prior

# written approval of the owner Dale Reardon
# Obtain permission before redistributing this program
# over the Internet or in any other medium. In all cases copyright
# and header must remain intact.
#
# This program is distributed "as is" and without warranty of any
# kind, either express or implied. (Some states do not allow the
# limitation or exclusion of liability for incidental or consequential
# damages, so this notice may not apply to you.) In no event shall
# the liability of Dale Reardon
# for any damages, losses and/or causes of action exceed the
# total amount paid by the user for this software.
#define the absolute path to your sendmail


$mailprog='/usr/sbin/sendmail ';

#define the page the user will be taken to after submitting the form

$thanku="http://www.howtowriteheadlines.com";

if ($ENV{'QUERY_STRING'} eq "Mailer") {
# &head;
&parse_input;
&process;
# &tail;
} else {
&head;
&print_form;
&tail;
}
sub print_form {
print <<HTMLS;

<title> Select the newsletter - Dale Reardon http://www.howtowriteheadlines.com</title>
<body bgcolor=#ddffdd onLoad="document.f1.email.focus(); ">
<form name=f1 action="subunsub.cgi?Mailer" method=post>
<table align=center border=0 cellpadding=0 bgcolor=#FFdddd>
<tr> <th> # </th> <th> Title </th> <th> Description </th> <th> Subscribe
</th> <th> Unsubscribe </th> </tr>\n\n
HTMLS


print <<HTML;
<tr> <td> 1 </td> <td>Elite Links Newsletter </td> <td> Elite Links is a
free reciprocal links newsletter that helps bring
together Webmasters looking to exchange links. Subscribe now and get a free
copy of Link Trader. This amazing software alerts
you when another Webmaster removes your link! (A \$49.99 value)
</td>
<td align=center> <input type=checkbox name="subscribe1"
value=subscribe onClick="document.f1.unsubscribe1.checked=false; "> </td>
<td align=center> <input type=checkbox name="unsubscribe1"
value=unsubscribe onClick="document.f1.subscribe1.checked=false; "> </td>
<input type=hidden name="nlid[1]" value="0">
<input type=hidden name="nlfrom[1]" value="elitelinks-on\@mail-list.com">
<input type=hidden name="subjectsub[1]" value="subscribe">
<input type=hidden name="subjectuns[1]" value="unsubscribe">
<input type=hidden name="bodysub[1]" value="subscribe">
<input type=hidden name="bodyuns[1]" value="">
</tr>
HTML


open (NL, ".nlistsnew") &#0124; &#0124; print "Could not open news lists file to
read.\n";
$i=1;
while ($line=<NL> ) {
chomp($line);
@fields=split(":", $line);
if (scalar(@fields) == 9) {
if (int($fields[2]) == 1){
$i++;
$chs = ""; $chus = "";
$tmp="subscribe$i";
$tmp1="unsubscribe$i";
if ($FORM{$tmp}) {
$chs="checked"; $chus="";
} elsif ($FORM{$tmp1}) {
$chus="checked"; $chs="";
}
print "<tr> <td> $i </td> <td> $fields[1] </td> <td> $fields[8] </td>
<td align=center> <input type=checkbox name=\"subscribe$i\"
value=subscribe $chs onClick=\"document.f1.unsubscribe$i.checked=false; \">
</td>
<td align=center> <input type=checkbox name=\"unsubscribe$i\"
value=unsubscribe $chus onClick=\"document.f1.subscribe$i.checked=false; \">
</td>
<input type=hidden name=\"nlid[$i]\" value=\"$fields[0]\">
<input type=hidden name=\"nlfrom[$i]\" value=\"$fields[3]\">
<input type=hidden name=\"subjectsub[$i]\" value=\"$fields[4]\">
<input type=hidden name=\"subjectuns[$i]\" value=\"$fields[5]\">
<input type=hidden name=\"bodysub[$i]\" value=\"$fields[6]\">
<input type=hidden name=\"bodyuns[$i]\" value=\"$fields[7]\">
</tr>\n\n";
}

}
}

print <<HTMLS;
<tr> <td colspan=5 align=left> Name: <input type=text name=rname size=43
value=""> </td> </tr>
<tr> <td colspan=5 align=left> Email: <input type=text name=email size=32
value=$Form{'email'} >
<input type=hidden name=thanku value="$thanku">
<input type=hidden name=owner value="Dale Reardon - http://www.howtowriteheadlines.com">
<input type=submit name=submit value="(Un)Subscribe">
</td> <input type=hidden name=max value=$i> </tr>
</table>
</form>

HTMLS
}


sub head {
print "Content-type: text/html\n\n";
print "<html><title>Copyright http://www.howtowriteheadlines.com</title>\n<body bgcolor=#ddffdd>\n";
}
sub tail {

print "</body></html>\n";
}

sub process{
$acted=0;
for ($i=1; $i<=$FORM{'max'}; $i++) {
$tmp = "nlfrom[$i]";
$recipient=$FORM{$tmp};
$from = $FORM{'email'};
if (length($from) < 10) {
&head;
print "<h3 align=center> <font color=#cc3366> Email Address is
Mandatory</font> </h3>\n";
&print_form;
exit (0);
}
$tmp = "rname";
$rname = $FORM{$tmp};
$tmp = "subscribe$i";
$tmp1 = "unsubscribe$i";
if ($FORM{$tmp} eq "subscribe") {
$tmp = "subjectsub[$i]";
$subject = $FORM{$tmp};
$tmp = "bodysub[$i]";
$body = $FORM{$tmp};
# print "Sending mail to $recipient with subject $subject body $body and
appearing from $from. <br>\n";
&sendmail;
} elsif ($FORM{$tmp1} eq "unsubscribe") {
$tmp = "subjectuns[$i]";
$subject = $FORM{$tmp};
$tmp = "bodyuns[$i]";
$body = $FORM{$tmp};
# print "Sending mail to $recipient with subject $subject body $body and
appearing from $from. <br>\n";
&sendmail;
}
}
if ($acted==0) { &head; print "<center> <font color=red size=+2> No
action Performed !! </font> </center>"; &tail; exit 0; }
else { print "Location: $FORM{'thanku'}\n\n"; }
}

sub sendmail {
$acted++;
# print "Sending mail to $recipient with subject $subject body $body and
appearing from $from. <br>\n";
open(MAIL,"|$mailprog -t") &#0124; &#0124; print "Could not open pipe to sendmail.\n";
# open(ML,"> mailfile-$i") &#0124; &#0124; print "Could not open mailfile to write.\n";
print MAIL "To: $recipient\n";
print MAIL "From: $rname \<$from\> \n";
print MAIL "Subject: $subject\n\n";
print MAIL "$body\n";
# print ML "To: $recipient\n";
# print ML "From: $from ($rname)\n";
# print ML "Subject: $subject\n\n";
# print ML "$body\n";
close MAIL;
# close ML;
}

sub parse_input {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$buffer);
foreach $pair (@pairs) {
($name,$value)=split(/=/,$pair);
$value=~ tr/+/ /;
$value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$name=~ tr/+/ /;
$name=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$FORM{$name}=$value;
# print "name is $name and its value is $value<br>\n";
}

}


guysmily
Deleted

Aug 22, 2000, 1:29 PM

Post #2 of 3 (481 views)
Re: Why will this script not work?? [In reply to] Can't Post

Maybe because your logical or >>>&#0124; &#0124;<<<
has a space?

eg:
open(MAIL,"|$mailprog -t") | | print "Could not open pipe to sendmail.\n";

Try removing the space.


Kanji
User / Moderator

Aug 22, 2000, 4:41 PM

Post #3 of 3 (481 views)
Re: Why will this script not work?? [In reply to] Can't Post

The space inbetween &#0124; &#0124; is a product of UBB (what this board runs) and is a known problem.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives