Fix all the DXUser API changes to use JSON
[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 return (1, "I can't image why you want to use this command other than as a DoS attack", "DO NOT USE!!!");
15
16 my @dxchan;
17 my @out;
18 my $dxchan;
19
20 for ( map {uc $_ } split /\s+/, $line ) {
21         if (($dxchan = DXChannel::get($_)) && $dxchan->is_node) {
22                 push @dxchan, $dxchan;
23         } else {
24                 push @out, $self->msg('e10', $_);
25         }
26 }
27 return (1, @out) if @out;
28
29 use DB_File;
30         
31 my ($action, $count, $key, $data);
32 for ($action = R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = R_NEXT) {
33         if ($data =~ m{(?:lat|long) =>}) {
34                 my $u = DXUser::get_current($key);
35                 if ($u) {
36                         my $lat = $u->lat;
37                         my $long = $u->long;
38                         my $latlong = DXBearing::lltos($lat, $long) if $lat && $long;
39                         if ($latlong) {
40                                 #push @out, $key;
41                                 for (@dxchan) {
42                                         my $s = DXProt::pc41($key, 3, $latlong);
43                                         $s =~ s{H\d+\^~$}{H1^~};
44                                         $dxchan->send($s);
45                                 }
46                                 ++$count;
47                         }
48                 }
49         }
50 }
51 return(1, @out, $self->msg('rec', $count));