#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use strict; use vars qw($fileattachment $ct @allfields @reqfields $fieldname $size $bld $label $bold $line %bold $sendmail $mailserver $o $cctype $in $username $password $basepath %in @in $htmlurl $htmlpath $cgiurl $cgipath $exportdir $formdir $attachdir $efooter $exporturl %cookie); $basepath = './'; # # Version: 2.01 - 030803 # ##################################################################### # # # Copyright © 1999-2000 CGISCRIPTS.NET - All Rights Reserved # # # ##################################################################### # # # THIS COPYRIGHT INFORMATION MUST REMAIN INTACT # # AND MAY NOT BE MODIFIED IN ANY WAY # # # ##################################################################### # # When you downloaded this script you agreed to accept the terms # of this Agreement. This Agreement is a legal contract, which # specifies the terms of the license and warranty limitation between # you and CGISCRIPTS.NET. You should carefully read the following # terms and conditions before installing or using this software. # Unless you have a different license agreement obtained from # CGISCRIPTS.NET, installation or use of this software indicates # your acceptance of the license and warranty limitation terms # contained in this Agreement. If you do not agree to the terms of this # Agreement, promptly delete and destroy all copies of the Software. # # Versions of the Software # Only one copy of the registered version of CGISCRIPTS.NET # may used on one web site. # # License to Redistribute # Distributing the software and/or documentation with other products # (commercial or otherwise) or by other than electronic means without # CGISCRIPTS.NET's prior written permission is forbidden. # All rights to the CGISCRIPTS.NET software and documentation not expressly # granted under this Agreement are reserved to CGISCRIPTS.NET. # # Disclaimer of Warranty # THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND # WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER # WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE # AND SOFTWARE ENVIRONMENTS INTO WHICH CGISCRIPTS.NET MAY BE USED, NO WARRANTY # OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE # ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF CGISCRIPTS.NET WILL BE # LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE. # IN NO CASE SHALL CGISCRIPTS.NET BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR # CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS # OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE # BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT, # NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF # CGISCRIPTS.NET IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL # CGISCRIPTS.NET' LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID # BY LICENSEE TO CGISCRIPTS.NET. # # Credits: # Andy Angrick - Programmer - angrick@cgiscript.net # Mike Barone - Design - mbarone@cgiscript.net # # For information about this script or other scripts see # http://www.cgiscript.net # # Thank you for trying out our script. # If you have any suggestions or ideas for a new innovative script # please direct them to suggest@cgiscript.net. Thanks. ######################################################################## # Config Variables # ######################################################################## require("$basepath/setup.cgi"); ######################################################################## # End Config Variables # ######################################################################## (!$htmlurl)&&($htmlurl = $cgiurl); (!$htmlpath)&&($htmlpath = $cgipath); $in{'cgiurl'} = $cgiurl . 'CSMailto.cgi'; $exportdir = $htmlpath . '/export'; $formdir = $htmlpath . '/forms'; $attachdir = $htmlpath . '/attach'; $exporturl = $htmlurl . '/export'; $in{'formurl'} = $htmlurl . '/forms'; $in{'htmlurl'} = $htmlurl; $efooter = "\n\n----------------------------------------\nForm Created with CSMailto, another www.cgiscript.net product"; require("$basepath/libs.cgi"); $| = 1; &main; exit; sub main{ ($ENV{'PATH_INFO'} =~ /csv$/)&&(&DoExport()); print "Content-type: text/html\n\n"; ($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/i)?(&getdata(1)):(&getdata()); &checkmethods; ($in{'command'} eq "mailform")&&(&MailForm); ($in{'command'} eq "")&&($in{'form-name'})&&(&MailForm); ($in{'command'} eq "showform")&&(&ShowForm); ($in{'command'} eq 'login')&&(&Login); &GetLogin; ($in{'command'} eq "")&&(&ListForm); ($in{'command'} eq "showadd")&&(&ShowAdd); ($in{'command'} eq "createform")&&(&CreateForm); ($in{'command'} eq "manage")&&(&ListForm); ($in{'command'} eq "delete")&&(&DeleteForm); ($in{'command'} eq "modify")&&(&ModifyForm); ($in{'command'} eq "setcolor")&&(&SetColor); ($in{'command'} eq "showcolor")&&(&ShowColor); ($in{'command'} eq "showlinks")&&(&ShowLinks); ($in{'command'} eq "showupload")&&(&ShowUpload); ($in{'command'} eq "upload")&&(&Upload); ($in{'command'} eq "deleteudf")&&(&DeleteUDF); ($in{'command'} eq "moveup")&&(&Move('up')); ($in{'command'} eq "movedown")&&(&Move('down')); } sub DoExport{ &GetCookies; $in{'UserName'} = $cookie{'UserName'}; $in{'PassWord'} = $cookie{'PassWord'}; (($in{'UserName'} ne $username)||(($in{'PassWord'} ne $password)))&&(exit); my $rn = &GetRealName($ENV{'PATH_INFO'}); $rn =~ s/\.\.//; my $rn2 .= "$rn.cgi"; (! -e "$exportdir/$rn2")&&(exit); print "Content-type: application/msexcel\n"; print "Content-disposition: inline; filename=\"$rn\"\n\n"; my $sfile = &CheckSafe("$exportdir/$rn2"); open(EXP,"$sfile"); while(){ print; } close EXP; exit; } sub ShowForm{ $in{'form'} =~ s/\.\.//g; (! -e "$formdir/$in{'form'}.htm")&&(&PError("Error. Invalid form name")); my $sfile = &CheckSafe("$formdir/$in{'form'}.htm"); open(OUT,"$sfile")||print "$!: $sfile
"; while(){ my $o = $_; $o =~ s/\r//g; $o =~ s/\"/\\"/g; $o =~ s/(scr)(ipt)/$1\"\+\"$2/gsi; my @mylines = split(/\r*\n/,$o); foreach my $q (@mylines){ print qq|document.write("$q\\n");\n|; } } close OUT; exit; } sub DeleteUDF{ my ($c); for my $i (1..$in{'items'}){ if($in{'id'} ne $i){ $c++; $in{"capudf$c"} = $in{"capudf$i"}; $in{"fnudf$c"} = $in{"fnudf$i"}; $in{"tsizeudf$c"} = $in{"tsizeudf$i"}; $in{"taheightudf$c"} = $in{"taheightudf$i"}; $in{"tawidthudf$c"} = $in{"tawidthudf$i"}; $in{"dsizeudf$c"} = $in{"dsizeudf$1"}; $in{"optionsudf$c"} = $in{"optionsudf$i"}; $in{"useudf$c"} = $in{"useudf$i"}; $in{"requdf$c"} = $in{"requdf$i"}; $in{"maxsudf$c"} = $in{"maxsudf$i"}; $in{"fextudf$c"} = $in{"fextudf$i"}; $in{"typeudf$c"} = $in{"typeudf$i"}; } } $in{'items'} --; if($in{'items'} == 0){ $in{"capudf1"} = ''; $in{"fnudf1"} = ''; $in{"tsizeudf1"} = ''; $in{"taheightudf1"} = ''; $in{"tawidthudf1"} = ''; $in{"dsizeudf1"} = ''; $in{"optionsudf1"} = ''; $in{"useudf1"} = ''; $in{"requdf1"} = ''; $in{"maxsudf1"} = ''; $in{"fextudf1"} = ''; $in{"typeudf1"} = ''; } &ShowAdd('modify'); } sub Move{ my($t) = @_; my($i1,$i2); if($t eq 'up'){ $i1 = $in{'id'}; $i2 = $in{'id'}-1; ($i2 < 1)&&($i2 = 1); } else{ $i1 = $in{'id'}; $i2 = $in{'id'}+1; ($i2 > $in{'items'})&&($i2=$in{'items'}); } my $a1 = $in{"capudf$i1"}; my $a2 = $in{"fnudf$i1"}; my $a3 = $in{"tsizeudf$i1"}; my $a4 = $in{"taheightudf$i1"}; my $a5 = $in{"tawidthudf$i1"}; my $a6 = $in{"dsizeudf$i1"}; my $a7 = $in{"optionsudf$i1"}; my $a8 = $in{"useudf$i1"}; my $a9 = $in{"requdf$i1"}; my $a10 = $in{"maxsudf$i1"}; my $a11 = $in{"fextudf$i1"}; my $a12 = $in{"typeudf$i1"}; my $b1 = $in{"capudf$i2"}; my $b2 = $in{"fnudf$i2"}; my $b3 = $in{"tsizeudf$i2"}; my $b4 = $in{"taheightudf$i2"}; my $b5 = $in{"tawidthudf$i2"}; my $b6 = $in{"dsizeudf$i2"}; my $b7 = $in{"optionsudf$i2"}; my $b8 = $in{"useudf$i2"}; my $b9 = $in{"requdf$i2"}; my $b10 = $in{"maxsudf$i2"}; my $b11 = $in{"fextudf$i2"}; my $b12 = $in{"typeudf$i2"}; $in{"capudf$i1"} = $b1; $in{"fnudf$i1"} = $b2; $in{"tsizeudf$i1"} = $b3; $in{"taheightudf$i1"} = $b4; $in{"tawidthudf$i1"} = $b5; $in{"dsizeudf$i1"} = $b6; $in{"optionsudf$i1"} = $b7; $in{"useudf$i1"} = $b8; $in{"requdf$i1"} = $b9; $in{"maxsudf$i1"} = $b10; $in{"fextudf$i1"} = $b11; $in{"typeudf$i1"} = $b12; $in{"capudf$i2"} = $a1; $in{"fnudf$i2"} = $a2; $in{"tsizeudf$i2"} = $a3; $in{"taheightudf$i2"} = $a4; $in{"tawidthudf$i2"} = $a5; $in{"dsizeudf$i2"} = $a6; $in{"optionsudf$i2"} = $a7; $in{"useudf$i2"} = $a8; $in{"requdf$i2"} = $a9; $in{"maxsudf$i2"} = $a10; $in{"fextudf$i2"} = $a11; $in{"typeudf$i2"} = $a12; &ShowAdd('modify'); } sub Login{ &PageOut("$cgipath/t_login.htm"); exit; } sub GetLogin{ &GetCookies; $in{'UserName'} = $cookie{'UserName'}; $in{'PassWord'} = $cookie{'PassWord'}; if(!$in{'UserName'}){ &PageOut("$cgipath/t_login.htm"); exit; } else{ (($in{'UserName'} ne $username)||(($in{'PassWord'} ne $password)))&&(&PError("Error. Invalid username or password")); } } sub Upload{ (!$in{'file'})&&(&PError("Error. Please select a file.")); ($in{'id'} == 1)&&($in{'id'} = ''); my $rn = &GetRealName($in{'file'}); &SaveFile($in{'file'},"$attachdir/$rn"); print <<"EOF"; EOF } sub ShowUpload{ &PageOut("$cgipath/t_upload.htm"); exit; } sub ShowColor{ $in{'c'.$in{'cc'}} = 'checked'; &PageOut("$cgipath/color_selector.htm"); exit; } sub SetColor{ print <<"EOF"; EOF } sub ModifyForm{ undef $/; my $datafile = $in{'page'}; $datafile =~ s/\.htm//; if(-e "$formdir/$datafile.cgi"){ $in{'page'} = "$datafile.cgi"; } my $sfile = &CheckSafe("$formdir/$in{'page'}"); open(DB,"$sfile"); my $all = ; close DB; $/ = "\n"; my ($in) = $all =~ /\/; ###get data input variables. my($loc,$key,$val); my @in = split(/&/,$in); foreach my $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Convert %XX from hex numbers to alphanumeric $in[$i] =~ s/%(..)/pack("c",hex($1))/ge; # Split into key and value. $loc = index($in[$i],"="); $key = substr($in[$i],0,$loc); $val = substr($in[$i],$loc+1); $in{$key} .= '\0' if (defined($in{$key})); # - is the multiple separator $in{$key} .= $val; } &ShowAdd('modify'); } sub DeleteForm{ my $datafile = $in{'page'}; $datafile =~ s/\.htm//; unlink("$formdir/$in{'page'}"); unlink("$formdir/$datafile.cgi"); print <<"EOF"; EOF } sub ListForm{ my $sfile = &CheckSafe("$formdir"); opendir(FORM,"$sfile")||die print "$!: $formdir"; my @forms = grep(/.htm$/, readdir(FORM)); closedir(FORM); foreach my $i (sort (@forms)){ undef $/; $sfile = &CheckSafe("$formdir/$i"); open(DB,"$sfile")||print "$formdir/$i - $!
"; my $all = ; close DB; $/ = "\n"; next if ($all !~ /\/); my ($heading) = $all =~ /\/; (!$heading)&&($heading = "(no heading)"); $in{'line'} .= " $i $heading "; } &PageOut("$cgipath/t_List_Form.htm")||die print "$!: ${cgipath}/t_List_Form.htm"; } sub MailForm{ my (@tmpf,$ff); if(!$in{'command'}){ (!$in{'form-name'})&&(&PError("Error. Invalid form.")); foreach my $i (sort keys %in){ next if($i eq 'cgiurl'); next if($i eq 'command'); next if($i eq 'form-name'); next if($i eq 'formurl'); next if($i eq 'htmlurl'); push(@tmpf,"$i~$i"); } $ff = 1; } &getfieldsfromform; if($ff){ $in{'form-allfields'} = join(",",@tmpf); } $in{'Date'} = &ctime(time); $in{'REMOTE_ADDR'} = $ENV{'REMOTE_ADDR'}; $in{'HTTP_HOST'} = $ENV{'HTTP_HOST'}; $in{'HTTP_USER_AGENT'} = $ENV{'HTTP_USER_AGENT'}; $in{'HTTP_REFERRER'} = $ENV{'HTTP_REFERRER'}; foreach my $i (%in){ $in{$i} =~ s/&#(\d+);/pack("c",$1)/ge; $in{$i} =~ s/\\n/\n/g; } my @fields = split(",",$in{'form-allfields'}); my @req = split(",",$in{'form-reqfields'}); my (%rq,$c,$fn); foreach my $i (@fields){ ($c,$fn) = split("~",$i); $rq{$fn} = $c; } foreach my $i (@req){ (!$in{$i})&&($rq{$i})&&(&PError("Error. Field $rq{$i} is required")); } ##validate email field if exists ($in{'Email'})&&(!&check_email($in{'Email'}))&&(&PError("Error. Invalid email address")); ($in{'VEmail'})&&($in{'VEmail'} ne $in{'Email'})&&(&PError("Error. Please retype email address.")); if($in{'form-results'}){ $in{'form-results'} =~ s/FORM\(([\w\-\_]+)\)/$in{$1}/g; } else{ $in{'form-results'} = "Form Submission\nThe following information was submitted on $in{'Date'}:\n\n"; foreach my $i (@fields){ ($c,$fn) = split("~",$i); $in{'form-results'} .= "$c: $in{$fn}\n"; } $in{'form-results'} .= $efooter; } if($in{'form-reply'}){ $in{'form-reply'} =~ s/FORM\(([\w\-\_]+)\)/$in{$1}/g; } else{ $in{'form-reply'} = "Thank you for submitting the following information:\n\n"; foreach my $i (@fields){ ($c,$fn) = split("~",$i); $in{'form-reply'} .= "$c: $in{$fn}\n"; } $in{'form-reply'} .= $efooter; } ##send out email message ($in{'form-resultshtml'} eq 'checked')&&($cctype="\nContent-type: text/html"); ($in{'form-bcc'})&&($o = "\nBCC: $in{'form-bcc'}"); ($in{'form-cc'})&&($o .= "\nCC: $in{'form-cc'}"); ($in{'Email'})&&($in{'form-from'} = $in{'Email'}); &AddResultAttachment; $in{'form-subject'} =~ s/FORM\(([\w\-\_]+)\)/$in{$1}/g; $in{'form-to'} =~ s/FORM\(([\w\-\_]+)\)/$in{$1}/g; if($sendmail){ my $sfile = &CheckSafe("$sendmail"); open(MAIL,"|$sfile -t"); print MAIL <<"EOF"; To: $in{'form-to'}$o From: $in{'form-from'} Subject: $in{'form-subject'}$cctype $in{'form-results'} EOF close MAIL; } else{ require "$basepath/sendmail.cgi"; &SendMail("$in{'form-to'}",$in{'form-from'},"$in{'form-subject'}$cctype",$in{'form-results'},$mailserver,$in{'form-cc'},$in{'form-bcc'}); } ($in{'form-autohtml'} eq 'checked')&&($cctype ="\nContent-type: text/html"); if($in{'form-attachment'}){ &AddAttachment; } $in{'form-replysubject'} =~ s/FORM\(([\w\-\_]+)\)/$in{$1}/g; ###send out autoresponse if(($in{'form-autoresponse'} eq "YES")&&($in{'Email'})){ if($sendmail){ my $sfile = &CheckSafe("$sendmail"); open(MAIL,"|$sfile -t"); print MAIL<<"EOF"; To: $in{'Email'} From: $in{'form-replyfrom'} Subject: $in{'form-replysubject'}$cctype $in{'form-reply'} EOF close MAIL; } else{ require "$basepath/sendmail.cgi"; &SendMail("$in{'Email'}",$in{'form-replyfrom'},"$in{'form-replysubject'}$cctype",$in{'form-reply'},$mailserver); } } ###export data to file if($in{'form-extfile'} eq "YES"){ my (@af); ##export fields first if file doesn't exist if(! -e "$exportdir/$in{'form-name'}.csv.cgi"){ my $sfile = &CheckSafe("$exportdir/$in{'form-name'}.csv.cgi"); open(TAB,">$sfile"); foreach my $i (@fields){ ($c,$fn) = split("~",$i); $fn = "\"$fn\""; push(@af,$fn); } print TAB join(",",@af)."\n"; close TAB; } ##export the record undef @af; my $sfile = &CheckSafe("$exportdir/$in{'form-name'}.csv.cgi"); open(TAB,">>$sfile"); foreach my $i (@fields){ ($c,$fn) = split("~",$i); my $encap = "\"$in{$fn}\""; push(@af,$encap); } print TAB join(",",@af)."\n"; close TAB; } if($in{'form-redirect'}){ print <<"EOF"; EOF } elsif($in{'form-redirecttext'}){ $in{'form-redirecttext'} =~ s/FORM\(([\w\-\_]+)\)/$in{$1}/g; print $in{'form-redirecttext'}; } else{ print "

Form Confirmation

Thank you for submitting the following information:
"; foreach my $i (@fields){ ($c,$fn) = split("~",$i); print "\n"; } print "
$c: $in{$fn}

Return to Form"; } exit; } sub CreateForm{ ($in{'B1'} eq "Add New Field")&&(&ShowAdd); my(@udfs,$fieldnum,$maxudf,@atmts,@options); (!$in{'formname'})&&(&PError("Error. Please enter a name for your form.")); ($in{'formname'} =~ /[\W]/)&&(&PError("Error. Invalid form name.")); ($in{'autoresponse'} eq "YES")&&(!$in{'replyfrom'})&&(&PError("Error. Please enter a from address for the autoresponser.")); ($in{'autoresponse'} eq "YES")&&(!$in{'replysubject'})&&(&PError("Error. Please enter a subject for the autoresponser.")); (!$in{'sfr'})&&(&PError("Error. Please enter an email address to send form to.")); (!$in{'sff'})&&($in{'sff'}=$in{'sfr'}); ##check to see if we have header or footer if(($in{'header'})&&(-e "$in{'header'}")){ my $sfile = &CheckSafe("$in{'header'}"); open(HEAD,"$sfile"); while(){ $in{'theader'} .= $_; } close HEAD; } if(($in{'footer'})&&(-e "$in{'footer'}")){ my $sfile = &CheckSafe("$in{'footer'}"); open(HEAD,"$sfile"); while(){ $in{'tfooter'} .= $_; } close HEAD; } (($in{'backgnd'})||($in{'backcolortxt'}))&&($in{'backgndurl'} = ""); $line = ''; my @field = split(/\\0/,$in{'field'}); my @req = split(/\\0/,$in{'req'}); foreach my $i (@req){ ($in{$i})?($bold{$in{$i}} = ""):($bold{$i} = ""); ($in{$i})?(push(@reqfields,$in{$i})):(push(@reqfields,$i)); } my($comment,$contact,$file); for my $i (0..$#field){ $size=''; $bld =''; $label=''; $fieldname=''; ($field[$i] eq "FirstName")&&(&MakeField('First Name','FirstName',26)); ($field[$i] eq "LastName")&&(&MakeField('Last Name','LastName',26)); ($field[$i] eq "Company")&&(&MakeField('Company','Company',26)); ($field[$i] eq "Address1")&&(&MakeField('Address 1','Address1',26)); ($field[$i] eq "Address2")&&(&MakeField('Address 2','Address2',26)); ($field[$i] eq "City")&&(&MakeField('City','City',26)); ($field[$i] eq "State")&&(&MakeField('State/Province','State',4)); ($field[$i] eq "Zip")&&(&MakeField('Zip Code','Zip',26)); ($field[$i] eq "Country")&&(&MakeField('Country','Country',26)); ($field[$i] eq "WebSite")&&(&MakeField('Web Site','WebSite',26)); ($field[$i] eq "Email")&&(&MakeField('Email Address','Email',26)); ($field[$i] eq "VEmail")&&($bold{'VEmail'} = "")&&(push(@reqfields,'VEmail')); ($field[$i] eq "VEmail")&&(&MakeField('Verify Email','VEmail',26)); ($field[$i] eq "ICQ")&&(&MakeField('ICQ Address','ICQ',26)); ($field[$i] eq "HomePhone")&&(&MakeField('Home Phone','HomePhone',13)); ($field[$i] eq "BusinessPhone")&&(&MakeField('Business Phone','BusinessPhone',13)); ($field[$i] eq "FaxPhone")&&(&MakeField('Fax','FaxPhone',13)); ($field[$i] eq "Comments")&&($comment=1); ($field[$i] eq "Contact")&&($contact=1); ($field[$i] eq "file")&&($file=1); } ###do user defined fields foreach my $i (sort keys(%in)){ ($i =~ /^useudf.*/)&&(push(@udfs,$i)); } ##sort foreach my $i (@udfs){ ($fieldnum) = $i =~ /^useudf(.*)/; ($fieldnum > $maxudf)&&($maxudf=$fieldnum); } foreach my $x (1..$maxudf){ my $i = "useudf$x"; $bold = ''; $line = ''; next if ($in{$i} ne "checked"); ($fieldnum) = $i =~ /^useudf(.*)/; ($in{'requdf'.$fieldnum} eq 'checked')&&($bold='')&&($bold{$in{'fnudf'.$fieldnum}} = '')&&(push(@reqfields,$in{'fnudf'.$fieldnum})); ($in{'typeudf'.$fieldnum} ne "HTML")&&(!$in{'fnudf'.$fieldnum})&&(&PError("Error. Please enter a field name for user defined field number $fieldnum")); ($in{'typeudf'.$fieldnum} eq "TEXT")&&(&MakeField($in{'capudf'.$fieldnum},$in{'fnudf'.$fieldnum},$in{'tsizeudf'.$fieldnum})); ($in{'typeudf'.$fieldnum} eq "TEXTAREA")&&(&TextArea($in{'capudf'.$fieldnum},$in{'fnudf'.$fieldnum},$in{'tawidthudf'.$fieldnum},$in{'taheightudf'.$fieldnum})); if($in{'typeudf'.$fieldnum} eq "HTML"){ $line = " ". $in{'optionsudf'.$fieldnum} ." "; } if($in{'typeudf'.$fieldnum} eq "UPLOAD"){ &FUpload($in{'capudf'.$fieldnum},$in{'fnudf'.$fieldnum}); push(@atmts,"$in{'fnudf'.$fieldnum}~$in{'maxsudf'.$fieldnum}~$in{'fextudf'.$fieldnum}"); } if ($in{'typeudf'.$fieldnum} eq "CHECKBOX"){ push(@allfields,"$in{'capudf'.$fieldnum}~$in{'fnudf'.$fieldnum}"); $line = " $bold $in{'capudf'.$fieldnum}: "; @options = split(/\r*\n/,$in{'optionsudf'.$fieldnum}); foreach $i (@options){ $line .= "$i
\n"; } $line .= "
"; } if ($in{'typeudf'.$fieldnum} eq "DROPDOWN"){ push(@allfields,"$in{'capudf'.$fieldnum}~$in{'fnudf'.$fieldnum}"); $line = " $bold $in{'capudf'.$fieldnum}:
"; $line .= "\n"; } if ($in{'typeudf'.$fieldnum} eq "RADIO"){ push(@allfields,"$in{'capudf'.$fieldnum}~$in{'fnudf'.$fieldnum}"); $line = " $bold $in{'capudf'.$fieldnum}: "; @options = split(/\r*\n/,$in{'optionsudf'.$fieldnum}); foreach $i (@options){ $line .= "$i
"; } $line .="\n"; } $in{'formline'} .=$line; } ($comment)&&(&TextArea('Comments','Comments',40,6)); ($contact)&&(&Radio('Contact Required','Contact','Yes','No')); ($file)&&(&FUpload('File Upload','file')); $in{'allfields'} = join(",",@allfields); $in{'reqfields'} = join(",",@reqfields); $in{'uploadfields'} = join("»",@atmts); $in{'results'} =~ s/\r*\n/\\n/g; $in{'results'} =~ s/([^\w\s])/'&#'.ord($1).';'/ge; $in{'reply'} =~ s/\r*\n/\\n/g; $in{'reply'} =~ s/([^\w\s])/'&#'.ord($1).';'/ge; $in{'redirecttext'} =~ s/\r*\n/\\n/g; $in{'redirecttext'} =~ s/([^\w\s])/'&#'.ord($1).';'/ge; $in{'in'} = $in; if($in{'overwrite'}){ my $sfile = &CheckSafe("${cgipath}/t_Form.htm"); open(OUT,"$sfile"); $sfile = &CheckSafe("${formdir}/$in{'formname'}.htm"); open(SAVE,">$sfile") || (&PError($!)); while(){ $_ =~ s/in\(([\w\-\_]+)\)/$in{$1}/g; print SAVE; } close OUT; close SAVE; } my $sfile = &CheckSafe("${formdir}/$in{'formname'}.cgi"); open(OUT,">$sfile"); print OUT <<"EOF"; EOF print <<"EOF"; EOF } sub TextArea{ my($lbl,$fldnm,$cols,$rows) = @_; push(@allfields,"$lbl~$fldnm"); $in{'formline'} .= " $bold{$fldnm}$lbl: "; } sub Radio{ my($lbl,$fldnm,@options) = @_; push(@allfields,"$lbl~$fldnm"); $in{'Contact'} = 'YES'; $in{'formline'} .= " $bold{$fldnm}$lbl: Yes No "; } sub FUpload{ my($lbl,$fldnm,@options) = @_; push(@allfields,"$lbl~$fldnm"); $in{'formline'} .= " $bold{$fldnm}$lbl: "; } sub MakeField{ my($lbl,$fldnm,$sz) = @_; push(@allfields,"$lbl~$fldnm"); $label = $lbl; $fieldname=$fldnm; $size = $sz; $in{'formline'} .= " $bold{$fldnm}$label: "; } sub ShowAdd{ my ($type) = @_; my @field = split(/\\0/,$in{'field'}); my @req = split(/\\0/,$in{'req'}); foreach my $i (@field){ $in{"f$i"}="checked"; } foreach my $i (@req){ $in{"r$i"}="checked"; } (!$in{'items'})&&($in{'items'} = 1); ($in{'B1'} eq "Add New Field")&&($in{'items'}++); $in{'tcommand'} = "createform"; ($type eq 'modify')?($in{'button'} = " Save Changes "):($in{'button'} = " Create Form "); foreach my $i (1..$in{'items'}){ $in{'newudf'} .= &GetUDF($i); } ##default values (!$in{'hfontface'})&&($in{'hfontface'} = 'verdana,arial,helvetica'); (!$in{'hfontsize'})&&($in{'hfontsize'} = '2'); (!$in{'fontface'})&&($in{'fontface'} = 'verdana,arial,helvetica'); (!$in{'fontsize'})&&($in{'fontsize'} = '2'); (!$in{'fontcolortxt'})&&($in{'fontcolortxt'} = '000000'); (!$in{'backcolortxt'})&&($in{'backcolortxt'} = 'FFFFFF'); (!$in{'hfontcolortxt'})&&($in{'hfontcolortxt'} = '000000'); ($in{'autoresponse'} eq "YES")&&($in{'autoYES'} = 'checked'); (-e "$exportdir/$in{'formname'}.csv")&&($in{'expview'} = "[view]"); (-e "$exportdir/$in{'formname'}.csv.cgi")&&($in{'expview'} = "[view]"); &PageOut("$cgipath/t_Mailto_Form.htm"); exit; } sub GetUDF{ my($i) = @_; my($u1,$u2,$u3,$u4,$u5,$u6,$u7,$u8,$u9,$u10,$u11,$u12,$u13,$u14,$u15,$u16,$u17,$u18); $u1 = $in{"capudf$i"}; $u2 = $in{"fnudf$i"}; $u3 = $in{"tsizeudf$i"}; $u4 = $in{"taheightudf$i"}; $u5 = $in{"tawidthudf$i"}; $u6 = $in{"dsizeudf$i"}; $u7 = $in{"optionsudf$i"}; $u8 = $in{"useudf$i"}; $u9 = $in{"requdf$i"}; $u17 = $in{"maxsudf$i"}; $u18 = $in{"fextudf$i"}; ($in{"typeudf$i"} eq 'TEXT')&&($u10 = 'checked'); ($in{"typeudf$i"} eq 'TEXTAREA')&&($u11 = 'checked'); ($in{"typeudf$i"} eq 'CHECKBOX')&&($u12 = 'checked'); ($in{"typeudf$i"} eq 'DROPDOWN')&&($u13 = 'checked'); ($in{"typeudf$i"} eq 'RADIO')&&($u14 = 'checked'); ($in{"typeudf$i"} eq 'UPLOAD')&&($u15 = 'checked'); ($in{"typeudf$i"} eq 'HTML')&&($u16 = 'checked'); my $a = " Use  Req.  User-defined field #$i [Move Up] [Move Down] [Delete]  Caption: Fieldname:
Field Type 
Text
Text Area
Checkbox 
Dropdown
Radio
Upload
Max Size (KB)
Allowed Extensions
HTML
Enter HTML in the optional parameters field.
Size:
Height: Width:
Rows:
Option Parameters (list all the options, each on separate line)
Example, if the form was asking what your favorite color was. Type it like this in the box to the right:
Red
Blue
Green
"; return $a; } sub ShowLinks{ my $ssiurl = $in{'formurl'}; $ssiurl =~ s/http:\/\/.*?\//\//i; $ssiurl =~ s/\/\//\//g; $in{'disurl'} = ""; $in{'dirurl'} = "$in{'formurl'}/$in{'form'}"; $in{'dirurl'} =~ s/([^:])\/\//$1\//g; my $rn = &GetRealName($in{'form'}); $rn =~ s/\.htm//g; $in{'jsurl'} = qq||; &PageOut("$cgipath/t_show_links.htm"); exit; } sub GetRealName{ my ($filename) = @_; my(@array,$real_name); if ($filename =~ /\//) { @array = split(/\//, $filename); $real_name = pop(@array); } elsif ($filename =~ /\\/) { @array = split(/\\/, $filename); $real_name = pop(@array); } else { $real_name = "$filename"; } return $real_name; } sub getfieldsfromform{ my($formname); #clear out the fields: $in{'form-allfields'} = ''; $in{'form-reqfields'} = ''; $in{'form-to'} = ''; $in{'form-from'} = ''; $in{'form-subject'} = ''; $in{'form-results'} = ''; $in{'form-extfile'} = ''; $in{'form-autoresponse'} = ''; $in{'form-replyfrom'} = ''; $in{'form-replysubject'} = ''; $in{'form-reply'} = ''; $in{'form-hfontsize'} = ''; $in{'form-hfontcolor'} = ''; $in{'form-hfontface'} = ''; $in{'form-fontsize'} = ''; $in{'form-fontcolor'} = ''; $in{'form-fontface'} = ''; $in{'form-redirect'} = ''; $in{'form-redirecttext'} = ''; $in{'form-contact'} = ''; $in{'form-attachment'} = ''; $in{'form-attachment2'} = ''; $in{'form-attachment3'} = ''; $in{'form-attachment4'} = ''; $in{'form-attachment5'} = ''; $in{'form-attachment6'} = ''; $in{'form-attachment7'} = ''; $in{'form-attachment8'} = ''; $in{'form-resultshtml'} = ''; $in{'form-autohtml'} = ''; $in{'form-cc'} = ''; $in{'form-bcc'} = ''; $in{'form-backgnd'} = ''; $in{'form-header'} = ''; $in{'form-footer'} = ''; $in{'form-maxsize'} = ''; $in{'form-uploads'} = ''; if(-e "$formdir/$in{'form-name'}.cgi"){ $formname = "$in{'form-name'}.cgi"; } else{ $formname = "$in{'form-name'}.htm"; } my $sfile = &CheckSafe("$formdir/$formname"); open(FILE,"$sfile")||(&PError("Error. Invalid form!")); while(){ if($_ =~ //){ $in{'form-allfields'} = $1; } if($_ =~ //){ $in{'form-reqfields'} = $1; } if($_ =~ //){ $in{'form-to'} = $1; } if($_ =~ //){ $in{'form-from'} = $1; } if($_ =~ //){ $in{'form-subject'} = $1; } if($_ =~ //s){ $in{'form-results'} = $1; } if($_ =~ //){ $in{'form-extfile'} = $1; } if($_ =~ //s){ $in{'form-autoresponse'} = $1; } if($_ =~ //){ $in{'form-replyfrom'} = $1; } if($_ =~ //){ $in{'form-replysubject'} = $1; } if($_ =~ //s){ $in{'form-reply'} = $1; } if($_ =~ //){ $in{'form-formheading'} = $1; } if($_ =~ //){ $in{'form-hfontsize'} = $1; } if($_ =~ //){ $in{'form-hfontcolor'} = $1; } if($_ =~ //){ $in{'form-hfontface'} = $1; } if($_ =~ //){ $in{'form-fontsize'} = $1; } if($_ =~ //){ $in{'form-fontcolor'} = $1; } if($_ =~ //){ $in{'form-fontface'} = $1; } if($_ =~ //){ $in{'form-redirect'} = $1; } if($_ =~ //){ $in{'form-redirecttext'} = $1; } if($_ =~ //){ $in{'form-contact'} = $1; } if($_ =~ //){ $in{'form-attachment'} = $1; } if($_ =~ //){ $in{'form-attachment2'} = $1; } if($_ =~ //){ $in{'form-attachment3'} = $1; } if($_ =~ //){ $in{'form-attachment4'} = $1; } if($_ =~ //){ $in{'form-attachment5'} = $1; } if($_ =~ //){ $in{'form-attachment6'} = $1; } if($_ =~ //){ $in{'form-attachment7'} = $1; } if($_ =~ //){ $in{'form-attachment8'} = $1; } if($_ =~ //){ $in{'form-resultshtml'} = $1; } if($_ =~ //){ $in{'form-autohtml'} = $1; } if($_ =~ //){ $in{'form-cc'} = $1; } if($_ =~ //){ $in{'form-bcc'} = $1; } if($_ =~ //){ $in{'form-backgnd'} = $1; } if($_ =~ //){ $in{'form-header'} = $1; } if($_ =~ //){ $in{'form-footer'} = $1; } if($_ =~ //){ $in{'form-maxsize'} = $1; } if($_ =~ //){ $in{'form-uploads'} = $1; } } close FILE; } sub checkmethods{ if ($ENV{'REQUEST_METHOD'} eq "GET") { ($in{'command'} eq "mailform")&&(&PError("Invalid Request Method!")); ($in{'command'} eq "upload")&&(&PError("Invalid Request Method!")); ($in{'command'} eq "setcolor")&&(&PError("Invalid Request Method!")); ($in{'command'} eq "createform")&&(&PError("Invalid Request Method!")); ($in{'command'} eq "")&&($in{'form-name'})&&(&PError("Invalid Request Method!")); } } sub CheckSafe{ my ($file) = @_; ($file =~ /\.\./)&&(&PError("Error. Invalid filename")); ($file =~ /\|/)&&(&PError("Error. Invalid filename")); return $file; }