in reply to Password Protection for Web Page.
You seem to have two questions here.
These are two completely separate issues. It appears that you have a problem (don't want your hard drive filled up) and you are asking how to implement your solution. That's kind of like asking how to peel potatos with a cheese grater. You can do it, but it's not really what you're looking for :)
Question 1: you can use CGI::Safe to conveniently set a max post size for your uploads (you'll want to read the documentation on how to allow uploads). Then, when you save the file, you'll want to check that the file size plus the current directory size doesn't exceed the max directory size that you have set. From "CGI Programming with Perl", 2nd Edition (by O'Reilly):
use constant MAX_DIR_SIZE => 100 * 1_048_576; # max of 100 MB use constant UPLOAD_DIR => "/path/to/upload/dir"; # later if ( dir_size( UPLOAD_DIR ) + $ENV{CONTENT_LENGTH} > MAX_DIR_SIZE ) { # don't allow the upload } # later sub dir_size { my $dir = shift; my $dir_size = 0; opendir DIR, $dir or die "Unable to open $dir: $!"; while ( readdir DIR ) { $dir_size += -s "$dir/$_"; } return $dir_size; }
As for password protecting your pages, there are many ways to do this. You could use .htaccess files (but those don't allow a timeout), but make sure you use them over an encrypted connection. There are other ways, too. I'm sure some other monks can help you here. I need to get back to work :)
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Ovid) Re: Password Protection for Web Page.
by augamecock (Novice) on Dec 14, 2001 at 01:29 UTC |