# # Simple Voting System # password.pl - authenticates the user # Uses a file called svs.passwd for authentication # # 0.1 Markku Reunanen 3.10.2000 # # Checks the username and password # $_[0] = Username # $_[1] = Password # Returns 1 on success, 0 on error sub password_check { my $pass; # Do not allow empty password or username unless($_[0] && $_[1]) { return 0; } # Open PW file unless(open(PWFILE, "svs.passwd")) { return 0; } @lines = (); @lines = ; close(PWFILE); # Compare username + password. If found, return 1. foreach $_ (@lines) { $/ = "\n"; chomp; ($name,$pass) = split(/:/,$_); if(($name eq $_[0]) && ($pass eq $_[1])) { return 1; } } # Authentication failure 0; } 1; # EOS