Viewing file: login.pl (5.59 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/perl
###########################################################################
# login.pl - starting place for AtDot
###########################################################################
require "common.pl";
if ($button eq $cancel_button) {
&cancel;
}
if($button eq "") {
&print_header;
print $query->startform($method, $login_pl, $CGI::URL_ENCODED);
print "<TABLE BORDER=\"0\"><TR><TD>";
print $username_input;
print "</TD><TD>";
print $query->textfield('USERNAME', '', 24);
print "</TD></TR>\n";
if($feature_pop == 1 && $feature_forward == 1){
print "<TR><TD>";
print $popserv_input;
print "</TD><TD>";
print $query->textfield('POPSERVER', '', 24);
print "</TD></TR>\n";
} else {
print "<TR><TD>";
print $adpass_input;
print "</TD><TD>";
print $query->password_field('PASSWORD', '', 24);
print "</TD></TR>\n";
}
if($feature_forward == 1) {
print "<TR><TD>";
print $poppass_input;
print "</TD><TD>";
print $query->password_field('POPPASS', '', 24);
print "</TD></TR>";
}
print "</TABLE>\n";
print $query->submit('BUTTON', $login_button);
if($feature_pop == 0 || $feature_forward == 0){
print $query->submit('BUTTON', $forgot_button);
}
print $query->submit('BUTTON', $cancel_button);
print $query->reset($reset_button);
print $query->endform;
} elsif ($button eq $login_button){
###########################################################################
# login - Validates user login and presents user with options
###########################################################################
&print_header;
###########################################################################
# Verify the user name
###########################################################################
dbmopen(%pass, $passdb, 0600) || die "Error opening db $passdb";
$stored = $pass{$username};
$hashed = crypt($password, $stored);
if (!$pass{$username}){
###########################################################################
# Nonexistant user
###########################################################################
print "$bad_login_info";
} elsif ($hashed eq $stored) {
###########################################################################
# Login OK, display a list of things to do
###########################################################################
$sessionid = $username . " " . time;
$a = time;
chop($a);
srand($a);
$one = int(rand($a)) + 1;
$two = int(rand($a)) + 1;
$salt = "$one$two";
$sid = crypt($sessionid, $salt);
$cryptpass = pack("u*", $poppass);
$cryptsess = pack("u*", $sessionid);
$remip = pack("u*", $fromip);
dbmopen(%sess, $sessiondb, 0600) || die "Error opening db $sessiondb";
$sess{$sid} = $cryptsess . "\0" . $cryptpass . "\0" . $remip;
dbmclose(%sess);
print "$good_login_info";
&print_options;
} else {
###########################################################################
# Wrong password
###########################################################################
print "$bad_login_info";
}
###########################################################################
# Close the password database
###########################################################################
dbmclose(%pass);
###########################################################################
# Done
###########################################################################
&update_sess;
} elsif ($button eq $forgot_button) {
###########################################################################
# hint - Show the user the hint for their password
###########################################################################
&print_header;
###########################################################################
# Open the hint database
###########################################################################
dbmopen(%hints, $hintdb, 0600) || die "Error opening db $hintdb";
if (!$hints{$username}){
###########################################################################
# No hint!
###########################################################################
print "$hint_none_info";
} else {
###########################################################################
# Get the hint
###########################################################################
$hint = $hints{$username};
###########################################################################
# Display the hint
###########################################################################
print $hint_info;
print $query->h2($hint);
print $query->startform($method, $login_pl, $CGI::URL_ENCODED);
print $query->hidden('USERNAME', $username);
print "<TABLE WIDTH=0><TR><TD>";
print $username_input;
print "</TD><TD>";
print $username;
print "</TD></TR><TR><TD>";
print $pass_input;
print "</TD><TD>";
print $query->password_field('PASSWORD', '', 24);
print "</TD></TR><TR><TD>";
print $poppass_input;
print "</TD><TD>";
print $query->password_field('POPPASS', '', 24);
print "</TD></TR></TABLE>";
print $query->submit('BUTTON', $login_button);
print $query->reset($reset_button);
print $query->endform;
}
###########################################################################
# Close the hint database
###########################################################################
dbmclose(%hints);
}
###########################################################################
# Done
###########################################################################
&print_footer;
|