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 ""; print "
"; print ""; print ""; print ""; } ############################################################################### ############################ Incomplete Error ############################### ############################################################################### sub notcomplete { select(STDOUT); print ""; print ""; print ""; print ""; print ""; exit; } ############################################################################### ############################ Incomplete Error ############################### ############################################################################### sub notcompleteinternal { select(STDOUT); print ""; print "