fix sh/registered
[spider.git] / cmd / show / registered.pl
1 #
2 # show/registered
3 #
4 # show all registered users 
5 #
6 # Copyright (c) 2001 Dirk Koopman G1TLH
7 #
8 #
9 #
10
11 my ($self, $line) = @_;
12 return (1, $self->msg('e5')) unless $self->priv >= 9;
13
14 my @out;
15 my @val;
16
17 use DB_File;
18
19 if ($line) {
20         $line =~ s/[^\w\-\/]+//g;
21         $line = "\U\Q$line";
22 }
23
24 my %call = ();
25 $call{$_} = 1 for split /\s+/, $line;
26 delete $call{'ALL'};
27
28 my ($action, $count, $key, $data) = (0,0,0,0);
29 unless (keys %call) {
30         for ($action = DXUser::R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = DXUser::R_NEXT) {
31                 if ($data =~ m{registered}) {
32                         $call{$key} = 1;       # possible candidate
33                 }
34         }
35 }
36
37 foreach $key (sort keys %call) {
38         my $u = DXUser::get_current($key);
39         if ($u && $u->registered) {
40                 push @val, $key;
41                 ++$count;
42         }
43 }
44
45 my @l;
46 foreach my $call (@val) {
47         if (@l >= 5) {
48                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
49                 @l = ();
50         }
51         push @l, $call;
52 }
53 if (@l) {
54         push @l, "" while @l < 5;
55         push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
56 }
57
58 push @out, $self->msg('rec', $count);
59 return (1, @out);
60
61