]> scm.dxcluster.org Git - spider.git/blob - cmd/forward/latlong.pl
added show/ik3qar command
[spider.git] / cmd / forward / latlong.pl
1 #
2 # forward/latlong <node> ...
3 #
4 # send out PC41s toward a node for every user that has a lat/long 
5 #
6 # Copyright (c) 2000 Dirk Koopman G1TLH
7 #
8 #
9 #
10
11 my ($self, $line) = @_;
12 return (1, $self->msg('e5')) unless $self->priv >= 6;
13
14 my @dxchan;
15 my @out;
16 my $dxchan;
17
18 for ( map {uc $_ } split /\s+/, $line ) {
19         if (($dxchan = DXChannel::get($_)) && $dxchan->is_node) {
20                 push @dxchan, $dxchan;
21         } else {
22                 push @out, $self->msg('e10', $_);
23         }
24 }
25 return (1, @out) if @out;
26
27 use DB_File;
28         
29 my ($action, $count, $key, $data);
30 for ($action = R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = R_NEXT) {
31         if ($data =~ m{(?:lat|long) =>}) {
32                 my $u = DXUser::get_current($key);
33                 if ($u) {
34                         my $lat = $u->lat;
35                         my $long = $u->long;
36                         my $latlong = DXBearing::lltos($lat, $long) if $lat && $long;
37                         if ($latlong) {
38                                 #push @out, $key;
39                                 for (@dxchan) {
40                                         my $s = DXProt::pc41($key, 3, $latlong);
41                                         $s =~ s{H\d+\^~$}{H1^~};
42                                         $dxchan->send($s);
43                                 }
44                                 ++$count;
45                         }
46                 }
47         }
48 }
49 return(1, @out, $self->msg('rec', $count));