[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] OFF TOPIC : Quid Pro Quo : CGI script



I got QPQ to work!!!  Now I can't get my cgi script to work though.  I
wrote it with MacPerl.  Do I need to save as runtime version or is it
something else?  Thanks everyone for your continuous support and answers.

DD



#!/usr/bin/perl

BEGIN
{
	push(@INC, "/cgi-bin");
}

$| = 1; #Set perl to flush the buffer immediately
require "cgi-lib.pl";

&ReadParse(*input);
print "Content-type: text/html\n\n";
print "<HTML><HEAD>\n";
print "<TITLE>Registration Complete!!!</TITLE>\n";
print "<META HTTP-EQUIV="Refresh" CONTENT="10; ";
print "URL=http://www.americanauction.com/index.html>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR="#FFFFFF">\n";

$fname = &Sanitize($input{FName}); #Call subroutine to strip out dangerous
$lname = &Sanitize($input{LName}); #characters.
$email = &Sanitize($input{eMail});

$fname = uc($fname); #Upper case
$lname = uc($lname);

$lname = substr($lname, 0, 2);
$fname1 = substr($fname, 0, 1);
$fname2 = substr($fname, 1, 1);
$fname1 = &Inc2($fname1);
$fname2 = &Inc2($fname2);

$password =  "$lname$fname1$fname2";
open(PWD, "password.txt") || die "Can't open file: $!\n";
@pwd = <PWD>;
close(PWD);
$count = 1;
foreach $line (@pwd)
{
	if ($line =~ m/$password(\d)/)
	{
		$count = $1 + 1;
	}
}
$password .= $count;
open(PWD, ">>password.txt") || die "Can't write to file: $!\n";
print PWD "$password\n";
close(PWD);
print "<BR><BR>\n";
print "<CENTER><H1>Thank you for registering with
AmericanAuction.com!!!</H1><P>\n";
print "<H3>You password shoud arrive at the e-mail address that you
specified shortly.  \n";
print "In the meantime you will be redirected to the homepage.  \n";
print "Thanks again for registering.</H3>\n";
print "<BR><BR><BR>\n";
print "<H5>The Managers,<BR>\n";
print "Richard Duff<BR>\n";
print "Dakota Duff</H5></CENTER>\n";
open(MAIL, "|/usr/bin/Mail -s 'New registration added' rbuff\@ruraltel.net,
$email");
print MAIL "Thank you for registering.  Your password is:\n";
print MAIL "$password.\n";
close(MAIL);
print "</BODY></HTML>\n";

sub Inc2
{
	my $letter = shift(@_);
	my $tmp = ord($letter);
	$tmp += 2;
	$letter = chr($tmp);
	return $letter;
}

sub Sanitize {
	my $param = shift(@_);
	if ($param =~ m/;|\||\'|\`|\*|\<|\>|\&|\^|\(|\)|\$|\!/)
	{
		die "Illegal character!\n";
	}
	if (length($param) > 200)
	{
		die "Parameter too long!\n";
	}
	$param =~ s/^\s+//;
	$param =~ s/\s+$//;
	return $param;
}



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch