home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 October A
/
Pcwk10a98.iso
/
Lotus
/
NETOBJ
/
T2.Z
/
Forms-Handler.cgi
/
Forms-Handler.cgi.rsrc
/
TEXT_128_!.txt
< prev
next >
Wrap
Text File
|
1998-02-11
|
4KB
|
296 lines
require "MAC_form.cfg";
#The database separator token is --
$TOKEN =" ,";
###################
###################
###################
#This will allow error to pump directly to to client, instead of crashing the server.
select STDOUT;
print "Content-type: text/html\n\n";
#
# This reads in the information sent when the user pressed Submit
#
if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; }
else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
#
# Now, using a little loop, we'll split up the data into name/value
# pairs, which makes them easier to work with.
#
$buffer =~ s/([;<>\*\|`&\$!\#\(\)\[\]\{\}:'"])/\\$1/g;
$buffer =~ tr/\n//d;
$buffer = "$buffer ";
@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;
chop($value);
$FORM{$name} = $value;
}
# Once the name/value pairs have been created, you can work with
# them by referring to the variable names you set up in the
# original HTML, using $FORM{"varname"}.
# First, we make sure that they actually gave an email address
#
#check for error -- REQUIRE on selective basis $FORM{'na'}
¬completeinternal unless $FORM{'fields'} && $FORM{'filename'} && $FORM{'error'} && $FORM{'success'};
$STORAGEFILE = $FORM{'filename'};
$NUMBERARG = $FORM{'fields'};
$COUNTER = 1;
#### Auto #####
$ERRORRESPONSE=$FORM{'error'};
$SUCCESSRESPONSE=$FORM{'success'};
$STORAGE = $STORAGEDIR.$STORAGEFILE;
$ENV{'HTTP_REFERER'} =~ s/\/[^\/]*$/\//g;
while($COUNTER <= $NUMBERARG){
$CONFIG = $COUNTER.a;
¬complete if (($FORM{$COUNTER} eq '') && ($FORM{$CONFIG} eq "TRUE"));
$COUNTER = $COUNTER + 1;
}
&makedat;
&success;
exit;
######################################################################
############################ Make .dat file ######################
######################################################################
sub makedat {
open(NEW,">> $STORAGE") || die "can't open $STORAGE\n";
select(NEW);
$COUNTER = 1;
print NEW "$FORM{$COUNTER}";
$COUNTER = 2;
while($COUNTER <= $NUMBERARG){
print NEW "$TOKEN$FORM{$COUNTER}";
$COUNTER = $COUNTER + 1;
}
print NEW "\n";
close(NEW);
}
###############################################################################
############################ Complete/Success ###############################
###############################################################################
sub success{
select(STDOUT);
print "<html>";
print "<head>";
print "<meta http-equiv=\"Refresh\" content=\"0; URL=$SUCCESSRESPONSE\">";
print "</head>";
print "</html>";
}
###############################################################################
############################ Incomplete Error ###############################
###############################################################################
sub notcomplete {
select(STDOUT);
print "<html>";
print "<head>";
print "<meta http-equiv=\"Refresh\" content=\"0; URL=$ERRORRESPONSE\">";
print "</head>";
print "</html>";
exit;
}
###############################################################################
############################ Incomplete Error ###############################
###############################################################################
sub notcompleteinternal {
select(STDOUT);
print "<html>";
print "<h3>This is a internal error (without configuration variable)</h3>";
print "the following variable are escape out for perl script protection:";
print "<UL>";
print "\;<>\*\|\`\&\$\!\#()[]{}\:\'\"\/ (return character deleted)<br>";
print "</UL>";
print "or one of the following file is not declare in the field:";
print "<UL>";
print "filename (date file name)<br>";
print "fields (# of field)<br>";
print "success(success respond file) <br> ";
print "error(error respond file) <br>";
print "</UL>";
print "</html>";
exit;
}