Example of how to password protect your web area
The following is an example of how to password protect your web area. USE WITH CAUTION
#!/usr/bin/perl# Utility to give password access to html doc directories# Preparation: # Edit your httpd's access.conf (or httpd.conf if access.conf is no # longer used) and alter # "AllowOverride" in <Directory (** html doc home **)> </Directory># block to be "AllowOverride AuthConfig"# NOTE: make sure that httpd.conf has all of the# ServerNames listed, e.g.:# ServerName pd1.cfmc.com# ServerName www.survey1.cfmc.com# This will keep the password screen from coming up multiple times.# Place this file in any directory in your $PATH (e.g., "/usr/local/bin")# Usage:# "webpass <subdirectory off of main html document directory>"# or# "webpass" (and follow the prompts)## Once this is run for a particular directory, it does not have to be run again# Merely replace documents in or copy new documents into the # passworded web document directory## 10/05/04 - Consistently no "/" before the directory name# 10/05/04 - put in check for htpasswd locationrequire "/cfmc/cfg/webinfo";$docloc = $html_doc_home; # change this to your main html doc loc $authname = "Password Protected Location"; # Appears on username/pass screen$passfile = ".htpasswd"; #Name of file for passwords, will be in document directory#################### Start of script # ###################if ( -e "/usr/bin/htpasswd") {$htpasswd = "/usr/bin/htpasswd";} elsif ( -e "/usr/sbin/htpasswd") {$htpasswd = "/usr/sbin/htpasswd";} else {die "ERROR: The program htpasswd does not exist in either the /usr/sbin/ or n /usr/bin/ directories, please talk to your system manager about n making sure at least a symbolic link to htpasswd exists in one n of these directories.n";}($subloc) = @ARGV;if (index(`pwd`,$docloc)==0) {chomp($defsubloc = substr(`pwd`,length($docloc)));# print "DEBUG:$defsubloc:n";<STDIN>; }until ( $subloc ) {print " WEBPASSn";print " =======nn";print " This utility will setup password access to files on an n";print " Apache Web Server (version 1.3.2 or higher)nn";print " NOTE: Preliminary, one-time-only setting up has to be done n";print " before you get to this point!n";print " See the beginning of this script for details.n";print "n";print " Usage: "webpass <subdirectory off of main html document directory>"n";print " or "webpass" (and follow the prompts)nn";print "ANOTHER NOTE:n";print " Once this is run for a particular directory, it does not have to be run againn";print " Merely replace documents in or copy new documents into the n";print " passworded web document directory.nn";print "Your main html document directory is $docloc.n";print "Enter the subdirectory where you want your document to existn";print "(e.g., 'bank/tables'),n";print " or press enter for $defsublocn" if ( $defsubloc );print " or type "q" to quitn";print "==>";chomp($subloc = <STDIN>);$subloc = $defsubloc if ($defsubloc and ! $subloc );exit(0) if ( $subloc eq "q");}@wssplit = split(///,$subloc);$mloc = "$docloc/";foreach(@wssplit) {$mloc = "$mloc$_/";(mkdir("$mloc",0755)