#!/usr/local/bin/perl ######################################################################## # HTPASSWD Password generator and manager - Version 1.0 - 11/4/2002 # The original htpass script writen by Tony Awtrey has been modified # by Mike Hansen of the National Federation of the Blind of Nebraska # (http://nfbn.inebraska.com). Building on the htpasswd ver. 0.9 script # writen by Tony Awtrey the following features and bug fixes were added. # -- Ability to add custom headers and footers # -- Users and Groups are know sorted Alpahbeticaly # -- Appropriate HTML tags were added to make the forms blind friendly # -- A bug was corrected that would prevent you from assigning a user to # to a group that currently had no members # -- A bug was corrected that would cause strange things to happen if the # Admin form was refreshed through the browser # -- Format of listings of group members was changed to better fit on a page ###################################################################### # HTPASSWD Password generator and manager - Version 0.9 - 7/13/98 # Copyright 1998 Anthony Awtrey # # This application is licensed under the GNU Public License. # For more information see: http://www.gnu.org/copyleft/gpl.html # # This HTML will set up a form to return the correct line for an # .htpasswd file. But Wait There's More! # #

# # User Name:
# Password:
#    #

# # If you want to let it, the program will maintain the .htpasswd file # for you. This is as secure as the .htaccess security is itself. # (Read: Not Very Secure At All!! Do not rely on it completely!!) # Set up a directory specifically for .htpasswd and .htgroup files. # Include an .htaccess file to restrict access to the directory. # Use the script and form above to get a username / passwd line for # and add it in manually. Now, go to the URL of the script like this: # # http://www.domain.com/cgi-bin/htpass.cgi?admin # # The ?admin will cause the script to bring up a screen to allow you # create and delete user accounts, add and remove groups and change # group membership. The form is pretty straight-forward. If you have # any questions on the script please go to the http://www.awtrey.com/ # website and leave a WebBoard message. I will answer any questions # you have. ###################################################################### #Program Vars $cgidir = "http://your.domain.com/cgi-bin/htpass"; $cgifile = "htpass.cgi"; $cgiurl = "$cgidir/$cgifile"; $htaccess_dir = "/server/path/to/directory/containing/.htpaswd/and/.htgroup"; $htpasswd_file = ".htpasswd"; $htgroup_file = ".htgroup"; ################################### #HTML Vars $site_title = "Your Homepage"; $title = "User and Group Manager"; $stylesheet = "../style.css"; $bgcolor = "#FFFFFF"; # If you would like to use a header file set the next value to 1 and # specify the path to the header file, other wise set it to 0. $header = 1; $headerpath = "/server/path/to/header_file"; # If you would like to use a footer file set the next value to 1 and # specify the path to the footer file, other wise set it to 0. $footer = 1; $footerpath = "/server/path/to/footer_file"; #Do NOT Touch below this point ################################### #Forms HTML Code. $pw_form = qq{



}; $au_form1 = qq{
Add New User










  
}; $dg_form = qq{

Delete Group






  
}; ################################### ################################### #Start Main Prog if ($ENV{'QUERY_STRING'} eq "admin") { &admin; } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { &form_vars; if ($FORM{'formtype'} eq 'password') { &password_it; exit; } elsif ($FORM{'formtype'} eq 'adduser') { &auser; exit; } elsif ($FORM{'formtype'} eq 'deluser') { &duser; exit; } elsif ($FORM{'formtype'} eq 'addgroup') { &agroup; exit; } elsif ($FORM{'formtype'} eq 'delgroup') { &dgroup; exit; } elsif ($FORM{'formtype'} eq 'member') { &mgroup; exit; } else { &error_response(badcgi); } } else { &getpass; } exit; #End Main Prog ################################### ################################### #Forms Subroutines sub getpass { $title = "Get Password"; &print_html_header; print "$pw_form\n"; &print_html_footer; } sub password_it { &make_pass; $title = "The Survey Says..."; &print_html_header; print "

The entry in the .htpasswd file should be:
\n"; print "$user\:$passwdcrypt

"; &print_html_footer; } sub admin { &getgroups; &getusers; $title = "User and Group Manager"; &print_html_header; print "

User Manager

\n"; print "

Users:

\n"; print "
\n";
    foreach $user (@users) {
        print "$user\n";
    }
    print "
\n"; print "
\n"; print "

Group Manager

\n"; print "

Groups:

\n"; print "
\n";
    foreach $group (@groups) {
        print "$group: ";
	$memnum = 1;
        foreach $member (@$group) {
            if ($memnum == 9){
		$memnum = 1;
		print "\n$group Cont.: ";
	    }
	    print "$member ";
	    $memnum++;
    }
    print "\n";
    }
    print "
\n"; print "\n"; print "$au_form1\n"; foreach $group (@groups) { print "