#! /usr/bin/perl -w #A scipt to add a name and password to a .htpasswd file #GNU GPL copyleft Jonathan Riddell 2000,2001 #place this in it's own ScriptAlias directory with a .htaccess #file that uses the same .htpasswd file but with #require user myname #rather than letting anybody use it #if I've done this corrrectly you can get away with changing only #the three variables below use CGI qw(:standard); #the name of the .htpasswd file with full path $passwdfile = "/etc/httpd/htpasswd"; #location of this file relative to root of URL $control = "/controled/pass/control"; #what's the page called $title = "30th inverleith's member's area"; ######## print <
Does like it says. If you add a name which already exists it will be updated. Now deletes names as well. Please do not go and delete yourself GNU GPL Copyleft Jonathan Riddell 2000,2001
HEAD if (param()) { #if paramaters passed, check & enter them into .htpasswd file print "" . delete_name(param("name")) . "";
} elsif (param("name") && param("pass")) {
$name = param("name");
$pass = param("pass");
`htpasswd -b $passwdfile $name $pass`;
print "user $name added to password file
\n"; } elsif (!param("name")){ print "No name supplied
\n"; } elsif (!param("pass")){ print "No password supplied or delete box not checked
\n"; } } #print out the form $checked = 'checked="true"' if param("delete"); print <Below is the output from your .htpasswd file.
FORMEND
open(HTPASSWD, "$passwdfile");
while () {
/(.*):.*/;
print $1 . "\n";
}
print " ";
print <