fix sh/425 to point to new server
[spider.git] / cmd / show / 425.pl
1 #
2 # Query the 425 Database server for a callsign
3 #
4 # from an idea by Leo,IZ5FSA and 425DxNews Group
5 #
6 #
7 #
8 my ($self, $line) = @_;
9 my @list = map {uc} split /\s+/, $line;               # generate a list of callsigns
10 my $op;
11 my $call = $self->call;
12 my @out;
13
14 return (1, $self->msg('e24')) unless $Internet::allow;
15 return (1, "SHOW/425 <callsign>\nSHOW/425 CAL\nSHOW/425 BULL <bulletin number>\n e.g. SH/425 IQ5BL, SH/425 CAL, SH/425 BUL 779\n") unless @list;
16
17 my $target = "www.ariscandicci.it";
18 my $port = 80;
19 my $url = "http://www.ariscandicci.it";
20
21 use Net::Telnet;
22 my $t = new Net::Telnet;
23 eval {$t->open( Host     => $target,
24                 Port     => $port,
25                 Timeout  => 30);
26 };
27
28 if (!$t || $@) {
29         push @out, $self->msg('e18', 'Open(ARI.org)');
30 } else {
31         dbg($list[0]."|".$list[1]) if isdbg('425');
32         if ($list[0] eq "CAL") {
33                 $op="op=cal";
34         }
35         elsif ($list[0] eq "BULL") {
36                 $op="op=bull&query=".$list[1];
37         }
38         else {
39                 $op="op=search&query=".$list[0];
40         }
41         my $s = "GET /425dxn/spider.php?$op HTTP/1.1\n"
42         ."User-Agent:DxSpider;$main::version;$main::build;$^O;$main::mycall;$call;$list[0]\nHost: $target\n\n";
43         dbg($s) if isdbg('425');
44         $t->print($s);
45         Log('call', "$call: show/425 \U$op");
46         my $state = "blank";
47         my $count = 1;
48                 my @timeout = qw(Timeout 30);
49         while (my $result = eval { $t->getline(@timeout) } || $@) {
50                 dbg($result) if isdbg('425') && $result;
51                 dbg($@) if isdbg('425') && $@;
52                 ++$count;
53                 if ($count > 9) {
54                                                 last if $@;
55                         push @out, $result;
56                 }
57                                 @timeout = qw(Timeout 2);
58         }
59         $t->close;
60         push @out, $self->msg('e3', 'Search(ARI.org)', uc $op) unless @out;
61 }
62
63 return (1, @out);