#!/usr/local/bin/perl
$| = 1; # output NOT buffered
print "Content-Type:text/html\n\n\n";
chop($date = `/bin/date`);
# for the 'this page created' line at the bottom
$debug = 0;
$host = $ENV{SERVER_NAME};
$ENV{SCRIPT_NAME} =~ s/([a-zA-Z0-9\.\-_]+)$//;
$program = $1;
$scriptpath = $ENV{SCRIPT_NAME};
$readablepath = "/www/httpdocs/";
$datapath = "formgen/";
$compress = "/usr/local/bin/gzip";
$mail = "/usr/bin/mailx -s 'Form Generation Delivery' ";
## formlib stuff.
if ($ENV{REQUEST_METHOD} eq "POST") {
require "./formlib.pl" || print "
Can't find formlib:$!";
&GetFormArgs();
# parse arguments passed from FORM (now in %in)
$ENV{PATH_INFO} ne '' && &GetPathArgs($ENV{PATH_INFO});
if ($debug) {
require "./debugforms.pl";
&debug;
}
$build_doc = $in{BUILD_DOC};
if ($in{BUILD} eq "Begin Document") {
$build_doc =~ s/( |&|\+|\/|\\|,|'|"|!|\$|\*|\(|\))/_/g;
# strip possible danger characters
$build_doc =~ s/\.(html|htm|pl)$//i;
# take html or perl suffix off
$counter = "";
while (-e "$datapath$build_doc$counter.HEAD") {
$counter++;
}
$build_doc .= $counter;
open (DOC, ">$datapath$build_doc.HEAD") || &liedowndie;
print DOC "",
"\n\n$in{TITLE}\n",
"\n\n\n\n",
"\n";
close DOC;
open (LOG, ">>${datapath}${program}.log");
print LOG "$date : $in{EMAIL}\n";
close LOG;
$step = 0;
$table[1] = " CHECKED";
$table = 0;
&toolbar;
} elsif ($in{BUILD} eq "Choose Next Element") {
$table[$in{TABLE_STATUS}] = " CHECKED";
$step = $in{STEP};
$table = $in{TABLE_STATUS};
&toolbar;
} elsif ($in{BUILD} eq "Remove last element") {
# undo last document element created
$in{STEP} -= 1;
open (TARGET, "$datapath$build_doc.$in{STEP}");
print "Removed the following source:
\n";
while () {
s/</g;
s/>/>/g;
s/\n$/
/;
print
}
unlink ("$datapath$build_doc.$in{STEP}");
open (LAST, "$datapath$build_doc".$in{STEP}-1);
while () {
$element = $_
}
close LAST;
if ($element =~ //) {
$in{TABLE_STATUS} = 1
} else {
$in{TABLE_STATUS} = 0
}
&next_element;
} elsif ($in{BUILD} eq "Create Element") {
print "\n",
"Set Element Options\n",
"\n",
"\n",
"Working document: $in{BUILD_DOC}
\n",
"