]> gb7djk.dxcluster.net Git - spider.git/blob - cmd/show/registered.pl
add timing stats to cmd spawn_cmd
[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
16 use DB_File;
17
18 if ($line) {
19         $line =~ s/[^\w\-\/]+//g;
20         $line = "^\U\Q$line";
21 }
22
23 @out = $self->spawn_cmd(sub {
24                                                         my @out;
25                                                         my @val;
26                                                         
27
28                                                         my ($action, $count, $key, $data) = (0,0,0,0);
29                                                         eval qq{for (\$action = DXUser::R_FIRST, \$count = 0; !\$DXUser::dbm->seq(\$key, \$data, \$action); \$action = DXUser::R_NEXT) {
30         if (\$data =~ m{registered}) {                                  
31                 if (!\$line || (\$line && \$key =~ /^$line/)) {
32                         my \$u = DXUser::get_current(\$key);
33                         if (\$u && \$u->registered) {
34                                 push \@val, \$key;
35                                 ++\$count;
36                         }
37                 }
38         }
39 } };
40                                                         my @l;
41                                                         foreach my $call (@val) {
42                                                                 if (@l >= 5) {
43                                                                         push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
44                                                                         @l = ();
45                                                                 }
46                                                                 push @l, $call;
47                                                         }
48                                                         if (@l) {
49                                                                 push @l, "" while @l < 5;
50                                                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
51                                                         }
52
53                                                         push @out, $@ if $@;
54                                                         push @out, , $self->msg('rec', $count);
55                                                         return @out;
56                                                 });
57
58 return (1, @out);
59
60