2 # DX cluster user routines
4 # Copyright (c) 1998 - Dirk Koopman G1TLH
14 use MLDBM qw(DB_File);
21 # hash of valid elements and a simple prompt
24 alias => '0,Real Callsign',
27 lat => '0,Latitude,slat',
28 long => '0,Longitude,slong',
30 email => '0,E-mail Address',
31 priv => '9,Privilege Level',
32 lastin => '0,Last Time in,cldatetime',
33 passwd => '9,Password',
34 addr => '0,Full Address',
35 sort => '0,Type of User', # A - ak1a, U - User, S - spider cluster, B - BBS
36 xpert => '0,Expert Status,yesno',
38 node => '0,Home Node',
39 lockout => '9,Locked out?,yesno', # won't let them in at all
40 dxok => '9,DX Spots?,yesno', # accept his dx spots?
41 annok => '9,Announces?,yesno', # accept his announces?
42 reg => '0,Registered?,yesno', # is this user registered?
50 return if $name =~ /::DESTROY$/;
53 die "Non-existant field '$AUTOLOAD'" if !$valid{$name};
55 $self->{$name} = shift;
58 return $self->{$name};
62 # initialise the system
68 die "need a filename in User" if !$fn;
69 $dbm = tie %u, MLDBM, $fn, O_CREAT|O_RDWR, 0666 or die "can't open user file: $fn ($!)";
84 # new - create a new user
89 my ($pkg, $call) = @_;
90 die "can't create existing call $call in User\n!" if $u{$call};
93 $self->{call} = $call;
102 # get - get an existing user - this seems to return a different reference everytime it is
108 my ($pkg, $call) = @_;
113 # get an existing either from the channel (if there is one) or from the database
115 # It is important to note that if you have done a get (for the channel say) and you
116 # want access or modify that you must use this call (and you must NOT use get's all
117 # over the place willy nilly!)
122 my ($pkg, $call) = @_;
123 my $dxchan = DXChannel->get($call);
124 return $dxchan->user if $dxchan;
135 my $call = $self->{call};
140 # del - delete a user
146 my $call = $self->{call};
151 # close - close down a user
157 $self->{lastin} = time;
162 # return a list of valid elements
171 # return a prompt for a field
176 my ($self, $ele) = @_;
181 # enter an element from input, returns 1 for success
186 my ($self, $ele, $value) = @_;
187 return 0 if (!defined $valid{$ele});
189 return 0 if $value eq "";
190 if ($ele eq 'long') {
191 my ($longd, $longm, $longl) = $value =~ /(\d+) (\d+) ([EWew])/;
192 return 0 if (!$longl || $longd < 0 || $longd > 180 || $longm < 0 || $longm > 59);
193 $longd += ($longm/60);
194 $longd = 0-$longd if (uc $longl) eq 'W';
195 $self->{'long'} = $longd;
197 } elsif ($ele eq 'lat') {
198 my ($latd, $latm, $latl) = $value =~ /(\d+) (\d+) ([NSns])/;
199 return 0 if (!$latl || $latd < 0 || $latd > 90 || $latm < 0 || $latm > 59);
201 $latd = 0-$latd if (uc $latl) eq 'S';
202 $self->{'lat'} = $latd;
204 } elsif ($ele eq 'qra') {
205 $self->{'qra'} = UC $value;
208 $self->{$ele} = $value; # default action
214 # some variable accessors
218 @_ ? $self->{sort} = shift : $self->{sort} ;