Thank you for your kind words about my tutorial. I'm really pleased that it helped you.
Regarding the passwords -- a lot will depend on the structure of the file that you export from Access. This is what I would do:
Export the database with two fields -- username and password -- using a : as a delimiter, like
username1:password1
username2:password2 Save the following as a separate script. Call it
convert.cgi.
Code:
#!/usr/bin/perl
# Change the line above to match the path to Perl on your system
$old_pass_file = "/path/to/your/file.txt"; # This is the file you exported from Access
$new_pass_file = "/path/to/default.pass"; # This is the new password file for DBMan to use
@auth_permissions = (1,1,1,1,0); # The permissions you want all users to have
open (OLD, "<$old_pass_file") or &cgierr("unable to open password file. Reason: $!\n");
@lines = <OLD>;
close OLD;
my $permissions = join (":", @auth_permissions);
foreach $line (@lines) {
@data = split (/:/, $line);
$pw = $data[1];
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($pw, $salt);
$output .= "$data[0]:$encrypted:$permissions\n";
}
open (NEW, ">$new_pass_file") or &cgierr("unable to open password file. Reason: $!\n");
print NEW $output;
close NEW;
&html_print_headers;
print qq|<html><head><title>Passwords converted</title></head>
<body>Your password file has been converted for use with DBMan.</body></html>|;
sub html_print_headers {
# --------------------------------------------------------
# Print out the headers if they haven't already been printed.
if (!$html_headers_printed) {
print "Content-type: text/html\n\n";
$html_headers_printed = 1;
}
}
sub cgierr {
# --------------------------------------------------------
# Displays any errors and prints out FORM and ENVIRONMENT
# information. Useful for debugging.
if (!$html_headers_printed) {
print "Content-type: text/html\n\n";
$html_headers_printed = 1;
}
print "<PRE>\n\nCGI ERROR\n==========================================\n";
$_[0] and print "Error Message : $_[0]\n";
print "\n</PRE>";
exit -1;
}
Upload the file to your DBMan directory -- in ASCII mode! -- and set the permissions to
755. Also save your .txt file from Access to the same directory.
Run the script from your browser, using the URL --
http://server.com/cgi-bin/dbman/convert.cgi If all has gone well, you should have a new default.pass file in your directory. Test it out with several of the username/password combinations you know to make sure it works.
Copy the line from the original default.pass file for the admin login and paste it into the new .pass file. Log in as "admin/admin" and give admin permission to yourself and whoever else you want to have it. Then you can delete the "admin" username.
Understand that I have not tested this, except to check for syntax errors. Be sure you have your old default.pass file somewhere so you can still access the database in case it doesn't work.
If it does work, you can then delete the convert.cgi file and the Access password file from your server.
JPD