#!/usr/bin/perl -w use strict; $|++; use CGI qw/:all /; use CGI::Carp qq/fatalsToBrowser/; my ($q, $basedir, $q_brieftitle, @stored, @output, $line, $rights); my ($dir_usr_specific, $rights_usr_specific, $filetypes_usr_specific, $domain_usr_specific); $q = CGI->new(); print $q->header(); print $q->start_html(); #####Create Perl upload script $basedir = ".."; $q_brieftitle = "/cgi-bin"; # user sepcific definitions go here $rights = '$basedir = "/home/sites/stuff/users/'.$dir_usr_specific.'";'; $rights .= '$allowall = "'.$rights_usr_specific.'";'; $rights .= '$theext = ".'.$filetypes_usr_specific.'";'; $rights .= '$donepage = "'.$domain_usr_specific.'";'; # end user sepcific definitions open (FILE, ">$basedir$q_brieftitle/upload.cgi") || die "blah"; #flock(FILE, 2); # process @stored = ; foreach $line (@stored) { push @output, $line; if ($line =~ /^\# usr_spec_def/i) { foreach $_ (split (";", $rights)) { push @output, $_.";\n"; } } } print FILE @output; close FILE; print $q->code(pre(@output)), end_html(); # the folllowing DATA section could also be somewhere in a file __DATA__ #!/usr/bin/perl use strict; $|++; use CGI qw/:all/; my ($basedir, $allowall, $theext, $donepage, $req, $onnum); ## DO NOT EDIT OR COPY ABOVE THIS LINE :-) ## # usr_spec_def ## DO NOT EDIT OR COPY BELOW THIS LINE## $req = CGI->new(); $onnum = 1; while ($onnum != 11) { my ($bytesread, $buffer, $filenotgood); my $file = $req->param("FILE$onnum"); if ($file) { my $fileName = $file; $fileName =~ s!^.*(\|\/)!!; my $newmain = $fileName; if ($allowall ne "yes") { if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext) { $filenotgood = "yes"; } } if ($filenotgood ne "yes") { open (OUTFILE, ">$basedir/$fileName") || die "failed"; print $req->p("$basedir/$fileName"); while ($bytesread = read($file, $buffer, 1024)) { print OUTFILE $buffer; } close OUTFILE; } } $onnum++; } print $req->redirect($donepage);