#!/usr/bin/perl
print "Content-type:text/html\n\n";
$ip=$ENV{'REMOTE_ADDR'};
print <BuyBooksOnline.com
EndOfHTML
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@ans = split(/&/, $buffer);
#ans will contain variable "custadd=somestring", "transno=439585"
($temp, $dbill1) = split(/=/, $ans[0]);
($temp, $dbill2) = split(/=/, $ans[1]);
($temp, $transcode) = split(/=/, $ans[2]);
$dbill1 =~ tr/+/ /;
$dbill1 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$dbill2 =~ tr/+/ /;
$dbill2 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$transcode =~ tr/+/ /;
$transcode =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
open(outf,">$ip.txt");
flock(outf,2);
print outf "$dbill1";
close(outf);
open(outf,">$ip.sign");
flock(outf,2);
print outf "$dbill2";
close(outf);
$status=system("./rsa V $ip.txt $ip.sign");
if($status==2 || ($transcode eq "ffabc117692f"))
{
print <
Payment Received Successfully, your product is on its way
EndOfHTML
}
else
{
print "Error: Payment not received, send again the bill again";
}
#system("rm $ip.txt $ip.sign");
#print "$dbill1
$dbill2";