Hello again all,
I wrote the little page below to check if everything was passing properly.
Everything works as it should and prints out what I expect to see.
However, when I run check_password, I get nada out of it when it hits the last statement before the sub.
Am I doing the return wrong or can you spot something else that I FUBAR'd?
As always, thanks for reading and I appreciate any suggestions.
Jim
I wrote the little page below to check if everything was passing properly.
Everything works as it should and prints out what I expect to see.
However, when I run check_password, I get nada out of it when it hits the last statement before the sub.
Am I doing the return wrong or can you spot something else that I FUBAR'd?
As always, thanks for reading and I appreciate any suggestions.
Jim
Code:
#!/usr/bin/perl
require "WAccessLib.pl";
my($flogin, $fpass, $flevel, $fpage, $Cpw);
&ReadParse(*input);
my $mode = "guest";
my $file = $MEMBER_FILE;
my $login = $input{'login'};
my $password = $input{'pass'};
my $page = $input{'page'};
if (($input{'ac'} eq "chpass") && (! $input{'BT_Exit'})) {
&change_password($login, $password, %input);
exit;
}
print "content-type:text/html\n\n";
print "Login: $login - Password: $password - Mode: $mode - File: $file<p />\n";
open(PASSWORD, "$PASSWORD_FILE") || &Error("Cannot open password file: $PASSWORD_FILE, Error: $!",1);
@PassFile = <PASSWORD>;
close(PASSWORD);
&check_password($mode,$login,$password);
$Cpw = &CryptPassword($password);
print "<b>Cpw: $Cpw<P /></b>\n";
foreach (@PassFile) {
($Fname, $Fpw, $Flevel, $Ffile) = split(/\s+/);
print "Fname: $Fname, Fpw: $Fpw, Flevel: $Flevel, Ffile: $Ffile<br>\n";
if ($Cpw eq $Fpw) {
$match = YES;
} else {
$match = No;
}
print "<b>MATCH?: $match<P /></b>\n";
}
print "<p /><b>$flogin - $fpass - $flevel<P /></b>\n";
sub check_password {
$mode=$input{'mode'};
$login=$input{'login'};
$password=$input{'password'};
my($flogin, $fpass, $flevel);
open(PASSWORD, $PASSWORD_FILE) or die "$!";
@pass = <PASSWORD>;
close password;
foreach (@pass) {
($flogin, $fpass, $flevel)= split(/\s+/);
if (($flogin eq $login) && ($fpass eq &CryptPassword($password))){
return ($flogin, $fpass, $flevel);
}
return 0;
}
}