#!/usr/local/bin/perl # # Master Form V4 # Version 4.7b # # Version 4.0 based on Master Form version 1.0 (completed May 8, 2000) # through version 2.8 (completed March 9, 2003) # and Master Form V3 version 3.0 (completed May 8, 2003) # through version 3.5m (completed February 1, 2005) # Version 4.0 completed February 4, 2005 # Version 4.6 completed August 19, 2010 # Version 4.7 completed February 14, 2017 (removed plug-in functionality) # Version 4.7a completed February 17, 2017 (CGI.pm single-value workaround) # Version 4.7b completed March 19, 2017 (allow "+" character in name part of email address) # # File MasterFormV4.cgi (file may be renamed if desired) # The form processor. # # Copyright 2000,2001 by William Bontrager. # Copyright 2002-2010 by Bontrager Connection, LLC # Copyright 2012,2017 by Will Bontrager Software LLC # # Programmer: Will Bontrager # Website: http://www.willmaster.com/ # # This custom version downloaded # from: Willmaster.com # for: websites4contractors.com # by: 127.0.0.1 # at: 1627995706 -- Tuesday, August 3, 2021 at 13:01:46 GMT. # ########################################################### use strict; # May be commented out after testing. use MasterFormV4Common; sub Exit { ErrorHTML @_ if @_; goto BOTTOM; } sub GetDateTime { my @Month = split /\t/,$G{MonthList}; my @Mon = split /\t/,$G{MonList}; my @W = split /\t/,$G{WeekdayList}; $Mine{SYSTEMTIME} = $Transfer{Time}; my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime($Mine{SYSTEMTIME}); $year += 1900; $Mine{YEAR} = $year; $year = substr($year,-2); $Mine{YEAR2} = $year; $Mine{SHORTMONTH} = $Mon[$month]; $Mine{LONGMONTH} = $Month[$month]; $month++; $Mine{MONTH} = $month; my $s = $month; $s = "0$s" if length($month) < 2; $Mine{MONTH2} = $s; $Mine{DAY} = $mday; $s = $mday; $s = "0$s" if length($mday) < 2; $Mine{DAY2} = $s; $Mine{WEEKDAY} = $W[$wday]; $Mine{HOUR} = $hour; $s = $hour; $s = "0$s" if length($hour) < 2; $Mine{HOUR2} = $s; $Mine{AMPM} = 'AM'; if($hour >= 12) { $Mine{AMPM} = 'PM'; } if($hour > 12) { $hour -= 12; } $Mine{AMPMHOUR} = $hour; $s = $hour; $s = "0$s" if length($hour) < 2; $Mine{AMPMHOUR2} = $s; $Mine{MINUTE} = $min; $s = $min; $s = "0$s" if length($min) < 2; $Mine{MINUTE2} = $s; $Mine{SECOND} = $sec; $s = $sec; $s = "0$s" if length($sec) < 2; $Mine{SECOND2} = $s; ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = gmtime; $sec = $sec < 10 ? "0$sec" : "$sec"; $min = $min < 10 ? "0$min" : "$min"; $hour = $hour < 10 ? "0$hour" : "$hour"; $year += 1900; my @weekday = qw(Sun Mon Tue Wed Thu Fri Sat); my @month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); $Mine{HEADER_TIME_STAMP} = "$weekday[$wday], $mday $month[$month] $year $hour:$min:$sec -0000"; } # sub GetDateTime sub FlowTo { my $page = ''; ($In{flowto},undef) =~ split /\t/,$In{flowto},2; FixNextPage(\$In{flowto},'name="flowto" value'); RetrievePage($In{flowto},'Form field name="flowto"','',\$page); $page =~ s/]*>//gsi; $page =~ s/ 0 ? 'fields are' : 'field is'; my $s = qq~The following $plural required:
~ . join("\n",@e) . '
'; @e = (); push @e,$s; } if($In{conditionalrequired} =~ /\w/) { my @chunk = split /\t/,$In{conditionalrequired}; for my $chunk (@chunk) { my @te = (); my @list = CommaTabSeparatedList($chunk); next unless $#list > 0; my @check = split / *\:+ */,shift @list; my $more = 1; for my $check (@check) { $check =~ s/^\s*(.*?)\s*$/$1/s; if($check =~ /^(.*?) *\( *(.*?) *\) *$/) { my($n,$v) = ($1,$2); $more = 0 unless $In{$n} eq $v; } else { $more = 0 unless $In{$check} =~ /\S/; } } next unless $more; my $check = '' . $check[0] . ''; if($#check == 1) { $check = '' . $check[0] . ' and ' . $check[1] . ''; } elsif($#check > 1) { for(@check) { $_ = "$_"; } $check[$#check] = "and $check[$#check]"; $check = join ', ',@check; } for(@list) { push @te,$_ unless $In{$_} =~ /\S/; } next unless @te; my $plural1 = $#check > 0 ? 'fields have values,' : 'field has a value,'; my $plural2 = $#te > 0 ? 'fields are' : 'field is'; push @e,qq~When $check $plural1 the following $plural2 required:
~ . join("\n",@te). '
'; } } if($In{emptyrequired} =~ /\w/) { my @chunk = split /\t/,$In{emptyrequired}; for my $chunk (@chunk) { my @te = (); my @list = CommaTabSeparatedList($chunk); next unless $#list > 0; my @check = split / *\:+ */,shift @list; my $more = 1; for (@check) { s/^\s*(.*?)\s*$/$1/s; $more = 0 if $In{$_} =~ /\S/; } next unless $more; my $check = '' . $check[0] . ''; if($#check == 1) { $check = '' . $check[0] . ' and ' . $check[1] . ''; } elsif($#check > 1) { for(@check) { $_ = "$_"; } $check[$#check] = "and $check[$#check]"; $check = join ', ',@check; } for(@list) { push @te,$_ unless $In{$_} =~ /\S/; } next unless @te; my $plural1 = $#check > 0 ? 'fields have no values,' : 'field has no value,'; my $plural2 = $#te > 0 ? 'fields are' : 'field is'; push @e,qq~When $check $plural1 the following $plural2 required:
~ . join("\n",@te). '
'; } } if($In{selectionminimum} =~ /\w/) { my @chunk = split /\t/,$In{selectionminimum}; for my $chunk (@chunk) { my @list = CommaTabSeparatedList($chunk); for my $list (@list) { my @check = split / *\:+ */,$list; my $minimum = pop @check; my $howmany = 0; for(@check) { next unless $In{$_} =~ /\S/; my @ta = split /\t/,$In{$_}; $howmany += @ta; } next unless $howmany < $minimum; my $check = '' . $check[0] . ''; if($#check == 1) { $check = '' . $check[0] . ' and ' . $check[1] . ''; } elsif($#check > 1) { for(@check) { $_ = "$_"; } $check[$#check] = "and $check[$#check]"; $check = join ', ',@check; } my $plural1 = $#check > 0 ? 'Altogether, fields' : 'Field'; my $plural2 = $minimum > 1 ? 's' : ''; my $plural3 = $howmany == 1 ? 'field has' : 'fields have'; push @e,qq~$plural1 $check must have at least $minimum item$plural2 containing a value. Currently, $howmany $plural3 a value.~; } } } if($In{selectionmaximum} =~ /\w/) { my @chunk = split /\t/,$In{selectionmaximum}; for my $chunk (@chunk) { my @list = CommaTabSeparatedList($chunk); for my $list (@list) { my @check = split / *\:+ */,shift @list; my $maximum = pop @check; my $howmany = 0; for(@check) { next unless $In{$_} =~ /\S/; my @ta = split /\t/,$In{$_}; $howmany += @ta; } next unless $howmany > $maximum; my $check = '' . $check[0] . ''; if($#check == 1) { $check = '' . $check[0] . ' and ' . $check[1] . ''; } elsif($#check > 1) { for(@check) { $_ = "$_"; } $check[$#check] = "and $check[$#check]"; $check = join ', ',@check; } my $plural1 = $#check > 0 ? 'Altogether, fields' : 'Field'; my $plural2 = $maximum > 1 ? 's' : ''; my $plural3 = $howmany == 1 ? 'field has' : 'fields have'; push @e,qq~$plural1 $check must have no more than $maximum item$plural2 containing a value. Currently, $howmany $plural3 a value.~; } } } Exit(@e) if @e; } # sub CheckRequiredFields sub CheckEmailFields { return 1 unless $In{emailfields}; my %in = %In; for my $k ( keys %in) { $in{$k} =~ s//>/g; } my $s; my @a = CommaTabSeparatedList($in{emailfields}); for(@a) { RemoveAllWhite \$in{$_}; next unless $in{$_}; $s .= "\n$_\t\($in{$_})" unless ValidEmail($in{$_}); } Exit("The following fields contain an invalid email address:
$s\n
") if $s; } # sub CheckEmailFields sub SplitUploadPlaceholderTokens { my $s = shift; my($m,$o,$n,$d) = (); return ($m,$o,$n,$d) unless $s =~ /\w/; $s =~ s/^[\,\s]*(.*?)[\,\s]*$/$1/; my @a = split /[\,\s]+/,$s; my($fm,$fo,$fn,$fd) = (0,0,0,0); for(@a) { if (/^MAXSIZE\:/i ) { s/^MAXSIZE\://i ; ($fm,$fo,$fn,$fd) = (1,0,0,0); } elsif(/^ONLY\:/i ) { s/^ONLY\://i ; ($fm,$fo,$fn,$fd) = (0,1,0,0); } elsif(/^NEVER\:/i ) { s/^NEVER\://i ; ($fm,$fo,$fn,$fd) = (0,0,1,0); } elsif(/^DIRECTORY\:/i) { s/^DIRECTORY\://i; ($fm,$fo,$fn,$fd) = (0,0,0,1); } if ($fm) { $m .= "$_\t" if $_; } elsif($fo) { $o .= "$_\t" if $_; } elsif($fn) { $n .= "$_\t" if $_; } elsif($fd) { $d .= "$_\t" if $_; } } chop($m,$o,$n,$d); if($m =~ /^([\.\d]+)/) { my $base = $1; $m =~ s/[\d\.\s]//g; if ($m =~ /^k/i) { $base *= 1024 ; } elsif($m =~ /^m/i) { $base *=(1024 * 1024) ; } elsif($m =~ /^g/i) { $base *=(1024 * 1024 * 1024) ; } elsif($m =~ /^t/i) { $base *=(1024 * 1024 * 1024 * 1024) ; } elsif($m =~ /^p/i) { $base *=(1024 * 1024 * 1024 * 1024 * 1024) ; } elsif($m =~ /^e/i) { $base *=(1024 * 1024 * 1024 * 1024 * 1024 * 1024); } $m = $base; } return ($m,$o,$n,$d); } # sub SplitUploadPlaceholderTokens sub SplitFileName { my $f = shift; my $e = ''; if($f =~ /\./) { $f =~ /^(.*)\.(.*?)$/; ($f,$e) = ($1,$2); } return($f,$e); } # sub SplitFileName sub MakeNameNotInHash { my($fn,$hptr) = @_; my $ext = ''; ($fn,$ext) = SplitFileName($fn); $ext = ".$ext" if $ext =~ /\w/; my $counter = 2; while($$hptr{"$fn$counter$ext"}) { $counter++; } return "$fn$counter$ext"; } # sub MakeNameNotInHash sub SendTheEmail { my %filesAlreadyNamed = (); local *HeaderUandL = sub { my $s = shift; my @s = split /\-/,$s; for(@s) { $_ = lc $_; $_ = ucfirst $_; } $s = join '-',@s; return $s; }; my @templatefiles = CommaTabSeparatedList($In{emailtemplate}); my @conditionalAttachments = (); for my $item (split /\t+/,$In{conditionalattachment}) { my @ta = CommaTabSeparatedList($item); push @conditionalAttachments,join "\t",@ta; } my $HijackEmail = ''; for my $tpf (@templatefiles) { if($tpf =~ m!^https?://!i) { my $ttf = lc $tpf; $ttf =~ s!^https?://(?:www\.)?!!i; $ttf =~ s!^([^/:]+):\d+!$1!i; ###~~~### my $ttfc = lc $G{SelfDomain}; $ttfc =~ s/^(?:www\.)//i; $ttfc = quotemeta $ttfc; unless($ttf =~ m!^$ttfc/!) { WebmasterNotification(5); next; } } my $page = ''; RetrievePage($tpf,'Form field name="emailtemplate"','',\$page); next unless $page =~ /\w/; $page =~ s/^\s*//s; ConformLineEndings \$page; for my $item (@conditionalAttachments) { my @list = split /\t/,$item; if($list[0] eq $tpf) { shift @list; for(@list) { $page .= "\n[[ATTACH $_]]"; } } } my @P = split /\n/,$page; { my @p = @P; while($p[0] !~ /\w/) { shift @p; } $p[0] =~ s/^\s*//s; for my $line (@p) { last unless $line =~ /\w/; chomp $line; if($line =~ /(\<\!\-\-|\[\[)(\w+)(\-\-\>|\]\])/) { my($left,$placeholder,$right) = ($1,$2,$3); my $key = $placeholder; RemoveWhiteFromEnds \$key; if($In{$key}) { RemoveWhiteFromEnds \$In{$key}; $line =~ s/\Q$left$placeholder$right\E/$In{$key}/sig; } } if($line =~ /[\n\r]|(?:x|\%)0[ad]|\\0?1[25]/i) { my $env = ''; for (sort keys %ENV) { $env .= "$_ = $ENV{$_}\n"; } $HijackEmail = <)/$In{$_}/sig; } $sendmailappend = $hs; $sendmailappend =~ s/[\<\>]//g; delete $headers{'Return-Path'}; $page =~ s/Return-Path: ?.*?[\r\n]+//si; } while($page =~ /()/m) { my($front,$middle,$filename,$back) = ($1,$2,$3,$4); my $realfilename = $filename; for(keys %In) { $realfilename =~ s/\[\[\Q$_\E\]\]/$In{$_}/g; } $realfilename =~ s/^\s*(.*?)\s*/$1/s; my $p = ''; RetrievePage($realfilename,"\"INSERT\" placeholder in email template file $tpf",'',\$p); $page =~ s/\Q$front$middle$filename$back\E/$p/; } while($page =~ /()/m) { my($front,$middle,$filename,$back) = ($1,$2,$3,$4); my $realfilename = $filename; for(keys %In) { $realfilename =~ s/\[\[\Q$_\E\]\]/$In{$_}/g; } $realfilename =~ s/^\s*(.*?)\s*/$1/s; $page =~ s/\Q$front$middle$filename$back\E/\(\[\~\~\[\(ATTACH $realfilename\)\]\~\~\]\)/; } @P = (); my @ee = (); my $hasattachment = 0; while($page =~ m/(?:\<\!\-\-|\[\[)([^\>\]]+?)\bUPLOAD(?:ED)?\b(.*?)(?:\]\]|\-\-\>)/) { my($a1,$b1) = ($1,$2); my $line = "$a1 $b1"; $line =~ s/^[\s\,]*(.*?)[\s\,]*$/$1/s; my @a = split /[\s\,]+/,$line; unless($Uploaded{$a[0]}) { $page =~ s!(?:\<\!\-\-|\[\[)${a1}UPLOAD(?:ED)?$b1(?:\]\]|\-\-\>)!!sg; next; } my($fieldName,$fileName,$storedfilename) = split /\t/,$Uploaded{$a[0]}; my $ext = $fileName; $ext =~ s/^.*?(\.[^\.]+)$/$1/; my @e = (); my $size = -s $storedfilename; push @e,qq~Regarding file $fileName (uploaded via form field name="$fieldName") did not arrive or it was an empty file.~ if $size < 1; unless(@e) { my($maxsize,$only,$never,$directory) = SplitUploadPlaceholderTokens($line); push @e,qq~Maximum file size for $fileName (uploaded via form field name="$fieldName") is specified as $maxsize bytes. $fileName is too large at $size bytes.~ if $maxsize > 0 and $maxsize < $size; if($only =~ /\S/) { $only = lc $only; my @ta = split /\t/,$only; my %h = (); for(@ta) { $_ = ".$_" unless /\./; $h{$_} = 1; } push @e,qq~Regarding file $fileName (uploaded via form field name="$fieldName"), the file name extension $ext is not on the \"ONLY\" list.~ unless $h{lc($ext)}; } if($never =~ /\S/) { $never = lc $never; my @ta = split /\t/,$never; my %h = (); for(@ta) { $_ = ".$_" unless /\./; $h{$_} = 1; } push @e,qq~Regarding file $fileName (uploaded via form field name="$fieldName"), the file name extension $ext is on the \"NEVER\" list.~ if $h{lc($ext)}; } } # unless (@e) my $rplcemnt = '([~~[(ATTACH ...' . $fileName . '...)]~~])'; $rplcemnt = "\n[" . join(" \n ",@e) . ']' if @e; $page =~ s!(?:\<\!\-\-|\[\[)${a1}UPLOAD(?:ED)?$b1(?:\]\]|\-\-\>)!$rplcemnt!sig; $hasattachment++; } # while($page =~ m/(?:\<\!\-\-|\[\[)([^\>\]]+?)UPLOAD(?:ED)?(.*?)(?:\]\]|\-\-\>)/i) my $Divider = ''; my $ts = ''; if($page =~ /\(\[\~\~\[\(.*?\)\]\~\~\]\)/) { $ts = $Transfer{Time}; $ts .= reverse $ts; $Divider = "MFRM_-${ts}-_MRFM"; $ts = "--$Divider\nContent-Type: $headers{'Content-Type'}\n\n"; $headers{'Content-Type'} = qq~multipart/mixed; boundary="$Divider"~; } if($ts) { my $s = ''; for(keys %headers) { $s .= "${_}: $headers{$_}\n"; } (undef,$page) = split /\n\n/,$page,2; $page = "$s\n$ts$page"; } FixNextPage \$page; my %attachThis = (); while($page =~ s/\(\[\~\~\[\(ATTACH\s(.*?)\)\]\~\~\]\)//) { my $filename = $1; if($filename =~ s/^\.\.\.(.*?)\.\.\.$/$1/) { for(keys %Uploaded) { my($fieldName,$fileName,$storedfilename) = split /\t/,$Uploaded{$_}; $fileName =~ s!^.*/!!; if($filename eq $fileName) { $attachThis{$fileName} = $storedfilename; last; } } } else { my $fn = $filename; $fn =~ s!/*$!!; $fn =~ s!^.*/!!; $fn = 'T' . $Transfer{Time} . 'T' unless $fn; $attachThis{$fn} = $filename; } } # while($page =~ s/\(\[\~\~\[\(ATTACH\s(.*?)\)\]\~\~\]\)//) if($HijackEmail =~ /\w/) { WebmasterNotice $HijackEmail,'ishijack'; return; } else { SendMail \$page,$sendmailappend,\%attachThis,$Divider; } } # for my $tpf (@templatefiles) } # sub SendTheEmail sub StoreUploadedFiles { return unless $In{uploadedfilesaveinfo} =~ /\w/; my $page = ''; RetrievePage($In{uploadedfilesaveinfo},'Form field name="uploadedfilesaveinfo"','',\$page); ConformLineEndings \$page; $page =~ s/(\]\]|\-\-\>).*?(\<\!\-\-|\[\[)/\n/sg; $page =~ s/^[^(\]\]|\-\-\>)]*(\<\!\-\-|\[\[)//s; $page =~ s/(\]\]|\-\-\>)[^(\]\]|\-\-\>)]*$//s; return unless $page =~ /\w/; my @lines = split /\n+/,$page; $page = ''; my @ee = (); #$Uploaded{fieldname} = "fieldname\tfilehandle\tstoredfilename"; } #my $which; #file1name UPLOAD MAXSIZE: 1k DIRECTORY: uploads #file2name UPLOAD DIRECTORY: uploads for my $line (@lines) { next unless $line =~ s/\bUPLOAD(?:ED)?\b//; $line =~ s/^[\s\,]*(.*?)[\s\,]*$/$1/s; my @a = split /[\s\,]+/,$line; next unless $Uploaded{$a[0]}; my($fieldName,$fileName,$storedfilename) = split /\t/,$Uploaded{$a[0]}; $fileName =~ s!^.*/!!; my $size = -s $storedfilename; my $ext = $fileName; $ext =~ s/^.*?(\.[^\.]+)$/$1/; my @e = (); push @e,qq~Regarding file $fileName (uploaded via form field name="$fieldName") did not arrive or it was an empty file.~ if $size < 1; if(@e) { push @ee,@e; next; } my($maxsize,$only,$never,$directory) = SplitUploadPlaceholderTokens($line); push @e,qq~Maximum file size for $fileName (uploaded via form field name="$fieldName") is specified as $maxsize bytes. $fileName is too large at $size bytes.~ if $maxsize > 0 and $maxsize < $size; if($only =~ /\S/) { $only = lc $only; my @ta = split /\t/,$only; my %h = (); for(@ta) { $_ = ".$_" unless /\./; $h{$_} = 1; } push @e,qq~Regarding file $fileName (uploaded via form field name="$fieldName"), the file name extension $ext is not on the \"ONLY\" list.~ unless $h{lc($ext)}; } if($never =~ /\S/) { $never = lc $never; my @ta = split /\t/,$never; my %h = (); for(@ta) { $_ = ".$_" unless /\./; $h{$_} = 1; } push @e,qq~Regarding file $fileName (uploaded via form field name="$fieldName"), the file name extension $ext is on the \"NEVER\" list.~ if $h{lc($ext)}; } if(@e) { push @ee,@e; next; } my $dir = $directory =~ /\w/ ? $directory : '.'; my %filesAlreadyNamed = (); $dir =~ s!^$ENV{DOCUMENT_ROOT}!!; if($dir ne '.' and (! -e $dir)) { my $okay = ''; if($dir =~ m!^/!) { $okay = MakeDirectory $dir; } else { $okay = MakeDirectory $Transfer{ThisDirectory},$dir; } unless($okay) { push @ee,<$fileName") { push @ee,qq~Unable to open "$fileName" (uploaded via form field name="$fieldName") for writing~; next; } # binmode Wment; ### for windows machines only open Rment,"<$storedfilename"; # binmode Rment; ### for windows machines only my $buffer = ''; while(read Rment,$buffer,1024) { print Wment $buffer; } close Wment; close Rment; } if(@ee) { for(@ee) { $_ = " ~~ $_"; } WebmasterNotice 'When attempting to store one or more uploaded files on the server:',@ee; Exit q~There was a problem storing an uploaded file on the server. An email with specifics has been sent to the webmaster.~; } } # sub StoreUploadedFiles sub AppendToFile { my($infiletemplate,$indbfile) = @_; FixNextPage \$indbfile; my $page = ''; trail(12); RetrievePage($infiletemplate,'Form field name="dbfile"','',\$page); ConformLineEndings \$page; local *initCheck = sub { my $pageptr = shift; return '' unless $$pageptr =~ s/^\s*(?:\*+|\[\[) ?INITIALIZE[_ ]?DATABASE[_ ]?WITH[_ ]?FIELD[_ ]?NAMES ?(?:\]\]|\*+) *\n?//is; my $s = $$pageptr; $s =~ s/\[\[//g; $s =~ s/\]\]//g; $s =~ s/\s*$//s; $s .= "\n"; return $s; }; local *overwriteCheck = sub { my $pageptr = shift; return $$pageptr =~ s/^\s*\*+OVERWRITE[ _]?FILE\*+ *\n?//is; }; my $initP = initCheck(\$page); # Before and after overwrite check to allow either one to be first line. overwriteCheck(\$initP) if $initP; my $overwritefile = overwriteCheck(\$page); if($overwritefile and $infiletemplate =~ m!^https?://!i) { my $ttf = lc $infiletemplate; $ttf =~ s!^https?://(?:www\.)?!!; $ttf =~ s!^([^/:]+):\d+!$1!i; ###~~~### my $ttfc = lc $G{SelfDomain}; $ttfc =~ s/^(?:www\.)//; $ttfc = quotemeta $ttfc; unless($ttf =~ m!^$ttfc/!) { my $notice = < 0 ? $In{flattenreplacement} : '
'; $replacement =~ s/^\s*null\s*$//si; $replacement =~ s/\\n/\n/gs; $replacement =~ s/\\t/\t/gs; $replacement =~ s/chr\((\d+)\)/chr($1)/ge; for(@flattenfields) { ConformLineEndings \$In{$_}; $In{$_} =~ s!\n!$replacement!gs; } } $page =~ /^\s*(.)/s; if($1 eq '"') { $page =~ /(.)\s*$/s; if($1 eq '"') { for(keys %In) { $In{$_} =~ s/"/""/g; } ###-### for(keys %In) { $In{$_} =~ s!\,!\\\,!g; } } } FixNextPage \$page,'databasefile'; %In = %in; WriteFile $indbfile,$overwritefile,\$initP,\$page; } # sub AppendToFile sub UpdateDatabases { return unless $In{filetemplate} =~ /\w/ or $In{dbfile} =~ /\w/; unless($In{filetemplate} =~ /\w/ and $In{dbfile} =~ /\w/) { WebmasterNotification(2); return; } my @filetemplate = CommaTabSeparatedList $In{filetemplate}; my @dbfile = CommaTabSeparatedList $In{dbfile}; if($#filetemplate != $#dbfile) { WebmasterNotification(4); return; } for my $indice (0..$#filetemplate) { last if $In{exitnow}; AppendToFile $filetemplate[$indice],$dbfile[$indice]; } } # sub UpdateDatabases sub WebmasterNotification { my($which,@message) = @_; my($e,$we) = (); if($which == 1) { $e = < In your form, the two hidden fields name="filetemplate" and name="dbfile" both have the same value.

Hidden field name="filetemplate" is used to specify the template that Master Form V4 shall use when updating the database file. And name="dbfile" is used to specify the database file itself.

(If both name="filetemplate" and name="dbfile" were to contain the same value, Master Form V4 would use the database file as the template and append the result to the bottom of the template file, thinking it's the database file — which would double the size of the template/database file every time Master Form V4 was used.

Please assign hidden field name="filetemplate" a value different than the value assigned to hidden field name="dbfile"

EEEE $we = <