Output buffering complications with a a sleep 30; command
by Nicholas P. Semenkovich other posts by this author
Aug 30 2001 1:17AM messages near this date
view in the new Beta List Site
Re: finance::quotehist::yahoo
|
Re: Upgrading to Activestate's latest build
Hi -=0D
I have this script below that I would like to have output buffered.=0D
I set $|=3D1; at the top.=0D
I had a previous version of this script which was slightly less complex tha=
t worked fine.=0D
The purpose is so that someone can purchase a script, then an original vers=
ion of that=0D
script is copied, and they have 30 secs. to download it. After 30 secs, th=
e copied version=0D
is deleted, so the url cannot be published. $| is defined in my(); in the =
valid sub, but I do not think that that is the problem.=0D
I have tried removing the section that gets form posts, but that was not th=
e problem.=0D
=0D
Get strings should look like http://www.syndetics.net/files/buyit.cgi?x=3D2=
&seed=3D9225&cbpop=3D5FLMESGS&cbreceipt=3DVPRQ7MB1=0D
if you try to run this script.=0D
=0D
What really matters is the sub complete.=0D
This contains the sleep 30; command which makes the script wait, but output=
buffering=0D
does not seem to function...=0D
=0D
Any ideas??=0D
=0D
=0D
#!/usr/bin/perl=0D
use CGI qw(:standard);=0D
$|=3D1;=0D
=0D
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});=0D
@pairs=3Dsplit(/&/,$temp);=0D
foreach $item(@pairs)=0D
{=0D
($key,$content)=3Dsplit(/=3D/,$item,2);=0D
$content=3D~tr/+/ /;=0D
$content=3D~s/%(..)/pack("c",hex($1))/ge;=0D
$fields{$key}=3D$content;=0D
}=0D
if ($fields{'file'}) {=0D
&verandsend; }=0D
=0D
sub valid=0D
{ ### Copyright Keynetics Inc. Patents pending.=0D
my($a,$b,$c,$h,$e,$i,$l,$q,$w,$x,$y,$z,@s,@v);=0D
=0D
###############################=0D
$a=3D'XXXXXXXXXXXXX'; # not for your eyes=0D
###############################=0D
=0D
$q=3D'&'.substr($ENV{'QUERY_STRING'},0,256);=0D
$q=3D~/\Wseed=3D(\w+)/; $b=3D$1;=0D
$q=3D~/\Wcbpop=3D(\w+)/; $c=3D$1;=0D
$q=3D~/\Wcbreceipt=3D(\w+)/; $e=3D$1;=0D
=0D
return 0 unless $a&&$b&&$c&&$e;=0D
=0D
$h=3D0x80000000; $l=3D0x7fffffff;=0D
$q=3D''; $w=3Duc "$a $b"; $x=3D$y=3D$z=3D17;=0D
@v=3Dunpack("C*",$w); $n=3D1+$#v;=0D
for($i=3D0;$i<256;$i++)=0D
{ $w=3D(($x&$l)+($y&$l))^(($x^$y)&$h);=0D
$w=3D($w<<$z)|($w> >(32-$z));=0D
$w=3D(($w&$l)+$v[$i%$n])^($w&$h);=0D
$s[$i&7]+=3D$w&31; $z=3D$y&31; $y=3D$x; $x=3D$w;=0D
}=0D
=0D
for ($i=3D0;$i<8;$i++)=0D
{ $q.=3Dsubstr('0123456789BCDEFGHJKLMNPQRSTVWXYZ',$s[$i]&31,1); }=0D
=0D
$rece=3D$e;=0D
=0D
if ($c eq $q) {=0D
open(FILE, "scriptlog.txt");=0D
while(defined($lastone=3D<FILE> )) {=0D
if ($lastone eq $rece) {=0D
&denied2;=0D
exit;=0D
}=0D
close(FILE);=0D
}=0D
}=0D
=0D
if ($c eq $q) {=0D
open(CHKFILE, "> scriptlog.txt");=0D
print CHKFILE "$rece";=0D
close(CHKFILE);=0D
}=0D
=0D
return 1; # normally this line says $c eq $q, but it's set to one for n=
ow, to allow all inputs=0D
}=0D
=0D
$receipt=3Dparam("cbreceipt");=0D
=0D
&verify;=0D
=0D
sub verify {=0D
if (&valid =3D=3D 1) {;=0D
&almost_there;=0D
} else {=0D
&denied1;=0D
} }=0D
=0D
sub denied1 {=0D
print "Content-type: text/html\n\n";=0D
print "<html> <head><title>Access Denied</title></head><body><center><h3>Acc=
ess Denied</h3> <h4>Your IP of $ENV{'REMOTE_ADDR'} Has Been Logged</h4>=0D
This action is taken very seriously. We will contact you, and possibly you=
r ISP or employer on this issue. Your username of $user has been logged.<b=
r> =0D
If you believe that this is a mistake, please click <a href=3D\"http://www.=
syndetics.net/contactus.shtml\"> here</a> to contact us.<br>=0D
When you contact us, please tell us violation number <b> 1</b> and receipt <=
b> $receipt</b>.<br><br><input type=3D\"button\" value=3D\" Close Window \" =
onclick=3D\"self.close()\"> </center></body></html>";=0D
exit;=0D
}=0D
=0D
sub denied2 {=0D
print "Content-type: text/html\n\n";=0D
print "<html> <head><title>Access Denied</title></head><body><center><h3>Acc=
ess Denied</h3> <h4>Your IP of $ENV{'REMOTE_ADDR'} Has Been Logged</h4>=0D
This action is taken very seriously. We will contact you, and possibly you=
r ISP or employer on this issue. Your username of $user has been logged.<b=
r> =0D
If you believe that this is a mistake, please click <a href=3D\"http://www.=
syndetics.net/contactus.shtml\"> here</a> to contact us.<br>=0D
When you contact us, please tell us violation number <b> 2</b> and receipt <=
b> $receipt</b>.<br><br><input type=3D\"button\" value=3D\" Close Window \" =
onclick=3D\"self.close()\"> </center></body></html>";=0D
exit;=0D
}=0D
=0D
sub almost_there {=0D
$script=3Dparam("s");=0D
$cannon=3Dparam("x");=0D
if ($script) {=0D
if ($script =3D=3D 1) {=0D
$filename =3D "Banner Manager Script";=0D
$code=3D"sc1";=0D
} elsif ($script =3D=3D 2) {=0D
$filename =3D "Download Manager Script";=0D
$code=3D"sc2";=0D
} elsif ($script =3D=3D 3) {=0D
$filename =3D "Recommender Script";=0D
$code=3D"sc3";=0D
} elsif ($script =3D=3D 4) {=0D
$filename =3D "Random File Script";=0D
$code=3D"sc4";=0D
} elsif ($script =3D=3D 5) {=0D
$filename =3D "In-Site Redirect Script";=0D
$code=3D"sc5";=0D
} elsif ($script =3D=3D 6) {=0D
$filename =3D "Variable Based Redirection Script";=0D
$code=3D"sc6";=0D
} elsif ($script =3D=3D 7) {=0D
$filename =3D "Simple Password Protection Script";=0D
$code=3D"sc7";=0D
} &complete; } else {=0D
if ($cannon =3D=3D 1) {=0D
&plans; }=0D
if ($cannon =3D=3D 4) {=0D
&plans; }=0D
if ($cannon =3D=3D 7) {=0D
&plans; }=0D
if ($cannon =3D=3D 10) {=0D
&plans; }=0D
if ($cannon =3D=3D 13) {=0D
&plans; }=0D
&other;=0D
&process; }}=0D
=0D
sub plans {=0D
if ($cannon =3D=3D 1) {=0D
$filename=3D"Basic Cannon Plans";=0D
$code=3D"pl1";=0D
} elsif ($cannon =3D=3D 4) {=0D
$filename=3D"Portable Cannon Plans";=0D
$code=3D"pl2";=0D
} elsif ($cannon =3D=3D 7) {=0D
$filename=3D"SuperCannon I Plans";=0D
$code=3D"pl3";=0D
} elsif ($cannon =3D=3D 10) {=0D
$filename=3D"SuperCannon II Plans";=0D
$code=3D"pl4";=0D
} elsif ($cannon =3D=3D 13) {=0D
$filename=3D"group of all plans";=0D
$code=3D"pl5"; }=0D
&complete;=0D
}=0D
=0D
sub other {=0D
if ($cannon =3D=3D 2) {=0D
$filename=3D"Basic Cannon Kit"; } elsif ($cannon =3D=3D 3) {=0D
$filename=3D"Assembled Basic Cannon"; } elsif ($cannon =3D=3D 5) {=0D
$filename=3D"Portable Cannon Kit"; } elsif ($cannon =3D=3D 6) {=0D
$filename=3D"Assembled Portable Cannon"; } elsif ($cannon =3D=3D 8) {=0D
$filename=3D"SuperCannon I Kit"; } elsif ($cannon =3D=3D 9) {=0D
$filename=3D"Assembled SuperCannon I"; } elsif ($cannon =3D=3D 11) {=0D
$filename=3D"SuperCannon II Kit"; } elsif ($cannon =3D=3D 12) {=0D
$filename=3D"Assembled SuperCannon II"; } elsif ($cannon =3D=3D 14) {=0D
$filename=3D"group of all kits"; }=0D
}=0D
=0D
sub process {=0D
print "Content-type: text/html\n\n";=0D
print "<html> <head><title>Transaction Details</title></head></body><center>=
\n";=0D
print "Processing order $receipt...<br> Order is for the $filename...<br>All=
fields except for Address 2 are required.<br> \n";=0D
print "Please fill out the following form regarding shipping:<br> \n";=0D
print "<form action=3D\"http://www.syndetics.net/files/buyit.cgi\" method=
=3D\"post\"> <input type=3D\"hidden\" name=3D\"file\" value=3D\"$cannon\"><i=
nput type=3D\"hidden\" name=3D\"rec\" value=3D\"$receipt\"> \n";=0D
print "Full Name: <input type=3D\"text\" name=3D\"name\"> <br>Address 1: <in=
put type=3D\"text\" name=3D\"ad1\"> <br>Address 2: <input type=3D\"text\" na=
me=3D\"ad2\"> <br>\n";=0D
print "City: <input type=3D\"text\" name=3D\"city\"> State: <input type=3D\=
"text\" name=3D\"state\" size=3D\"2\"> Zip: <input type=3D\"text\" name=3D\=
"zip\" size=3D\"5\"> <br>\n";=0D
print "Email: <input type=3D\"text\" name=3D\"email\"> <br><input type=3D\"S=
ubmit\"> </form></center></body></html>\n";=0D
exit;=0D
}=0D
=0D
sub verandsend {=0D
$cannon=3D$fields{'file'};=0D
$receipt=3D$fields{'rec'};=0D
&other;=0D
if ($fields{'file'} && $fields{'rec'} && $fields{'name'} && $fields{'ad1'} =
&& $fields{'city'} && $fields{'state'} && $fields{'zip'} && $fields{'email'=
}) { } else {=0D
$addon=3D$filename;=0D
$filename=3D$addon . "...<br> You did not fill in all required fields";=0D
&process; }=0D
$mailprog=3D"/usr/lib/sendmail -t";=0D
$date=3Dlocaltime(time);=0D
=0D
open (BL,"| $mailprog");=0D
print BL "To: webmaster\@syndetics.net\n";=0D
print BL "From: Purchase\n";=0D
print BL "Subject: ItemPurchased\n";=0D
print BL <<_BL_;=0D
On Syndetics=0D
At $date=0D
=46rom IP $ENV{'REMOTE_ADDR'}=0D
=46rom Browser $ENV{'HTTP_USER_AGENT'}=0D
=46rom Host $ENV{'REMOTE_HOST'}=0D
A user purchased the $filename=0D
Receipt $receipt=0D
----------------=0D
Send the $filename to:=0D
$fields{'name'}=0D
$fields{'ad1'}=0D
$fields{'ad2'}=0D
$fields{'city'}, $fields{'state'} $fields{'zip'}=0D
=0D
$fields{'email'}=0D
---------------------------------------------------------------------------=
---=0D
_BL_=0D
close (BL);=0D
print "Content-type: text/html\n\n";=0D
print "<html> <body><center>Thank you. Your order is being processed now.<br=
> You will receive an email when your order ships.</center></body></html>";=
=0D
exit;=0D
}=0D
=0D
sub complete {=0D
$rand=3Dint(rand(999999));=0D
print `cp $code.zip $rand.zip`;=0D
print "Content-type: text/html\n\n";=0D
print "<html> <head><title>Transaction Complete</title><META HTTP-EQUIV=3DRe=
fresh CONTENT=3D\"10; URL=3Dhttp://www.syndetics.net/files/$rand.zip\"> </he=
ad> <body><center>=0D
Processing order $receipt...<br> Order is for the $filename...<br>Transactio=
n Verified...<br> =0D
Click <a href=3D\"http://www.syndetics.net/files/$rand.zip\" target=3D\"_bl=
ank\"> here</a> to download the file.<br>Thank You.</center></body></html>";=
=0D
$mailprog=3D"/usr/lib/sendmail -t";=0D
$date=3Dlocaltime(time);=0D
=0D
open (BL,"| $mailprog");=0D
print BL "To: webmaster\@syndetics.net\n";=0D
print BL "From: Purchase\n";=0D
print BL "Subject: ItemPurchased\n";=0D
print BL <<_BL_;=0D
On Syndetics=0D
At $date=0D
=46rom IP $ENV{'REMOTE_ADDR'}=0D
=46rom Browser $ENV{'HTTP_USER_AGENT'}=0D
=46rom Host $ENV{'REMOTE_HOST'}=0D
A user purchased the $filename=0D
Receipt $receipt=0D
---------------------------------------------------------------------------=
---=0D
_BL_=0D
close (BL);=0D
sleep 30;=0D
print `rm $rand.zip`;=0D
exit;=0D
}=0D
exit;=0D
Attachments:
unknown1
unknown1
|