equal
deleted
inserted
replaced
3 use strict; |
3 use strict; |
4 use warnings; |
4 use warnings; |
5 use base 'Exporter'; |
5 use base 'Exporter'; |
6 use Carp; |
6 use Carp; |
7 |
7 |
8 our @EXPORT_OK = qw(unseen getDBDir getDBs connectDB); |
8 our @EXPORT_OK = qw(unseen getDBDir connectDB getDefault); |
9 our %EXPORT_TAGS = ( |
9 our %EXPORT_TAGS = ( |
10 all => \@EXPORT_OK, |
10 all => \@EXPORT_OK, |
11 ); |
11 ); |
12 our $VERSION = '2.0'; |
12 our $VERSION = '2.0'; |
13 |
13 |
73 if (not exists $h{$key}) { |
73 if (not exists $h{$key}) { |
74 $h{$key} = "$now $now 0\0"; |
74 $h{$key} = "$now $now 0\0"; |
75 return 'yes'; |
75 return 'yes'; |
76 } |
76 } |
77 |
77 |
78 my ($created, undef, $count) = split ' ', $h{$key}; |
78 my ($created, undef, $count) = split /[ \0]/, $h{$key}; |
79 |
79 |
80 # we know the client, but last contact was recently (too fast) |
80 # we know the client, but last contact was recently (too fast) |
81 if ($now - $created < $delay) { |
81 if ($now - $created < $delay) { |
82 return 'yes'; |
82 return 'yes'; |
83 } |
83 } |
115 my ($item, $h) = @_; |
115 my ($item, $h) = @_; |
116 my $key = "$item\0"; |
116 my $key = "$item\0"; |
117 |
117 |
118 return 0 if not exists $h->{$key}; |
118 return 0 if not exists $h->{$key}; |
119 |
119 |
120 my ($t0, undef, $cnt, $flag) = split ' ', $h->{$key}; |
120 my ($t0, undef, $cnt, $flag) = split /[ \0]/, $h->{$key}; |
121 $h->{$key} = join(' ' => $t0, time, ++$cnt, $flag ? $flag : ()) . "\0"; |
121 $h->{$key} = join(' ' => $t0, time, ++$cnt, $flag ? $flag : ()) . "\0"; |
122 |
122 |
123 return 1; |
123 return 1; |
124 } |
124 } |
125 |
125 |