|< 1 2 >| | 16 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
sub validate_login{
# ---- usage
# if( validate_login( $query->{usn}, $query->{pwd} ) ){ print "Login ok!\n"; }
# ---- requirements
# modul: Crypt::PasswdMD5
# $passfile -> File mit USN|PWD(cryptedBy: Crypt::PasswdMD5)\n
my ($usn, $pwd) = @_;
my $return = 0;
open(DAT, $passfile) || die "$! ($passfile)";
flock DAT, 1 if UNIX;
my @passfile = <DAT>;
close(DAT);
foreach ( @passfile ){
chomp $_;
if( $usn eq (split /\|/,$_)[0] ){
if (unix_md5_crypt($pwd, (split /\|/,$_)[1])
eq (split /\|/,$_)[1] ) {
# Passwort in Ordnung
$return = 1;
}else{
$return = 0;
}
}else{
$return = 0;
}
}
return $return;
}
# --------------------------------------------------------
sub validate_session{
# ---- usage
# if( validate_session( $sessionDataToValidate ) ){ print "Session Ok!\n"; }
# ----
# prüfen, ob gültige sid: a)muster b)haltbarkeit
my $session = $_[0];
my $return = 0;
if( $session =~ /\d{10}XY\d*PT\d{10}/
and (split /XY/, $session)[0] > time() - SESSION_TIME ){
$return = 1;
}
return $return;
}
# --------------------------------------------------------
1
2
3
4
5
package MeinPaket;
use Exporter;
our @ISA = ('Exporter');
our @EXPORT_OK = qw(validate_login validate_session);
return 1;
|< 1 2 >| | 16 Einträge, 2 Seiten |