]> ruin.nu Git - ndwebbie.git/blob - memberIntel.pl
more fatal warnings and other cleanup
[ndwebbie.git] / memberIntel.pl
1 #**************************************************************************
2 #   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
3 #                                                                         *
4 #   This program is free software; you can redistribute it and/or modify  *
5 #   it under the terms of the GNU General Public License as published by  *
6 #   the Free Software Foundation; either version 2 of the License, or     *
7 #   (at your option) any later version.                                   *
8 #                                                                         *
9 #   This program is distributed in the hope that it will be useful,       *
10 #   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12 #   GNU General Public License for more details.                          *
13 #                                                                         *
14 #   You should have received a copy of the GNU General Public License     *
15 #   along with this program; if not, write to the                         *
16 #   Free Software Foundation, Inc.,                                       *
17 #   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
18 #**************************************************************************/
19
20 use strict;
21 use warnings FATAL => 'all';
22 use POSIX;
23 our $BODY;
24 our $DBH;
25 our $LOG;
26 my $error;
27
28 $ND::TEMPLATE->param(TITLE => 'Member Intel');
29
30 die "You don't have access" unless isHC();
31
32 my $showticks = 'AND i.tick > tick()';
33 if (defined param('show')){
34         if (param('show') eq 'all'){
35                 $showticks = '';
36         }elsif (param('show') =~ /^(\d+)$/){
37                 $showticks = "AND (i.tick - i.eta) > (tick() - $1)";
38         }
39 }
40
41
42 my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin, coords(t.x,t.y,t.z) AS target, t.nick',"t.alliance_id = 1 $showticks"));
43 $query->execute() or $error .= $DBH->errstr;
44 my @intellists;
45 my @incomings;
46 my $i = 0;
47 while (my $intel = $query->fetchrow_hashref){
48         if ($intel->{ingal}){
49                 $intel->{missionclass} = 'ingal';
50         }else{
51                 $intel->{missionclass} = $intel->{mission};
52         }
53         $i++;
54         $intel->{ODD} = $i % 2;
55         push @incomings,$intel;
56 }
57 push @intellists,{Message => 'Incoming fleets', Intel => \@incomings, Origin => 1};
58
59 $query = $DBH->prepare(intelquery('o.nick,coords(o.x,o.y,o.z) AS origin,t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',"o.alliance_id = 1 $showticks"));
60 $query->execute() or $error .= $DBH->errstr;
61 my @outgoings;
62 $i = 0;
63 while (my $intel = $query->fetchrow_hashref){
64         if ($intel->{ingal}){
65                 $intel->{missionclass} = 'ingal';
66         }else{
67                 $intel->{missionclass} = $intel->{mission};
68         }
69         $i++;
70         $intel->{ODD} = $i % 2;
71         push @outgoings,$intel;
72 }
73 push @intellists,{Message => 'Outgoing Fleets', Intel => \@outgoings, Target => 1};
74
75 $BODY->param(IntelLIsts => \@intellists);
76
77 $BODY->param(Error => $error);
78 1;