This is what I have now.
#!C:/Perl/bin/perl.exe -w
###############################
# Written by William S. Lyles
# July 9 2002
#
# The purpose of this program
# is to generate a random username
# and password, then write the
# username and password to a
# database file and .htpasswd file
# and display it on the screen
# for the user to copy down
###############################
# Here we define the variables
my $htpasswd = 'c:\apache\htdocs\members\.htpasswd';
my $database = 'c:\apache\members.db';
print "Content-type: text/html\n\n";
print 'Please write this down as it will not be emaild ', "\n";
print 'for your own security ', "\n";
# Here is the random gereration string.
my ($username, $password) = (random_string(), random_string());
print "Username: $username\n";
print "Password: $password\n";
sub random_string {
my($string) = '';
my($length) = 8;
my(@chars) = ('A' .. 'Z', 'a' .. 'z', 0 .. 9);
while (length($string) != $length) {
$string .= $chars[ rand @chars ];
}
return($string);
}
# get the date now!
&get_date;
# everything ok, let's write to database.
open (DATABASE, ">>$database");
flock (DATABASE, 2);
print DATABASE "$username|$password|$date\n";
flock (DATABASE, 8);
close (DATABASE);
# everything ok, now we write to the password file.
my $uselog = 1;
if ($uselog eq '1') {
open (LOG, ">>$htpasswd");
print LOG "$username:$password\n";
close (LOG);
}
sub get_date {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
@months =
("01","02","03","04","05","06","07","08","09","10","11","12");
@digits = split(//,$sec);
$size = @digits;
if ($size == 1) {
$sec = "0$sec";
}
@digits = split(//,$min);
$size = @digits;
if ($size == 1) {
$min = "0$min";
}
$year=$year+1900;
$date = "$months[$mon]/$mday/$year";
}
The only problem seems to be the
use strict; directive
if I take this out it works fine
So I guess I need to know if the use strict; directive is really
necessary and if so how do I get around it?
Thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]