1  sub Authenticate{
2           #
3           # DATE/TIME STAMP CHECK 
4           #
5      &parse_form;
6      open(ORG_DATA,"$basedir/$orgdir/orgdata.txt") || &error(orgdata_file);
7      $currentlastmod = <ORG_DATA>;
8      close(ORG_DATA);
9      ($cull, $currentlastmod) = split(/=/,$currentlastmod,2);
10     $currentlastmod =~ s/\n//g;
11     $vlastmod = $FORM{'lastmod'};
12     $vlastmod =~ s/\cM//g;
13     $vlastmod =~ s/\n//g;
14     if (!($currentlastmod eq $vlastmod)) {
15        &error(bad_date);
16     }
17          #
18          # USERNAME/PASSWORD CHECK
19          #
20     &writedatafile(tempdata);
21     open(PASSWD,"$basedir/$orgdir/passwd.txt") || &error(passwd_file);
22     $passwd_line = <PASSWD>;
23     chop($passwd_line) if $passwd_line =~ /\n$/;
24     close(PASSWD);
25
26     ($username,$passwd) = split(/:/,$passwd_line);
27
28     $test_passwd = crypt($FORM{'password'}, substr($passwd, 0, 2));
29     if ($test_passwd ne $passwd || $FORM{'username'} ne $username) {
30        open(FAIL,">$basedir/$orgdir/passwdfail.txt");
31        close(FAIL);
32        &error(bad_combo);
33     }
34  }