As I wrote in my last message: "Of course, it will be
very important to stupidity-check the user input, to be certain that a nefarious mean-spirited user doesn't try to create files (or overwrite system files!) outside of the directory." PERL fortunately
caught this security problem.
For more information about PERL's taint checking, see
If you really
really want to force the program to run (NOT suggested unless you really know what you're doing -- this is an insecure program), try the -U flag in the first line that calls perl (that is, begin the program with "#!/usr/bin/perl -U"

. Please use this with caution; I wrote this script only to show one possible approach to the problem -- not as a plug-and-play solution.
This version is just a hair different than the last one I sent you -- I saw at least one more obvious security hole that I left in. It is very easy for security holes to appear in any program that creates or modifies a file depending on a user's unput. Don't even think about using this script on a Windoze server, or allowing the script to be run as an account with write permissions on files or directories that you care about -- that would just be
begging for hackers.
#!/usr/bin/perl
use CGI qw

standard);
$userinput = param("userinput"

;
if (($userinput =~ /\./) || ($userinput =~ /\//)) {
$userinput = "error" ;
}
$filelocation = "/var/
;
$thisfile = "$filelocation$userinput.txt" ;
open (NAMEFILE, ">>$thisfile"

;
print NAMEFILE "$userinput\n" ;
close (NAMEFILE) ;
print "Content-type: text/html\nPragma: no-cache\n\n" ;
print <<END_HTML ;
<HTML>
<HEAD>
<TITLE>RESULTS</TITLE></HEAD>
<H1>Results</H1>
<br>
Wonderful! Thanks for your input.
</HTML>
END_HTML
-- Scott David Gray
reply-to: sgray@sudval.org