]> ruin.nu Git - ndwebbie.git/blob - memberIntel.pl
member intel, shows all incoming and outgoing fleets for member planets
[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 POSIX;
22 our $BODY;
23 our $DBH;
24 our $LOG;
25 my $error;
26
27 $ND::TEMPLATE->param(TITLE => 'Member Intel');
28
29 die "You don't have access" unless isHC();
30
31 my $showticks = 'AND i.tick > tick()';
32 if (param('show') eq 'all'){
33         $showticks = '';
34 }elsif (param('show') =~ /^(\d+)$/){
35         $showticks = "AND (i.tick - i.eta) > (tick() - $1)";
36 }
37
38
39 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"));
40 $query->execute() or $error .= $DBH->errstr;
41 my @intellists;
42 my @intel;
43 my $i = 0;
44 while (my $intel = $query->fetchrow_hashref){
45         if ($intel->{ingal}){
46                 $intel->{missionclass} = 'ingal';
47         }else{
48                 $intel->{missionclass} = $intel->{mission};
49         }
50         $intel->{ODD} = $i % 2;
51         push @intel,$intel;
52         $i++;
53 }
54 push @intellists,{Message => 'Incoming fleets', Intel => \@intel, Origin => 1};
55
56 my $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"));
57 $query->execute() or $error .= $DBH->errstr;
58 my @intel;
59 my $i = 0;
60 while (my $intel = $query->fetchrow_hashref){
61         if ($intel->{ingal}){
62                 $intel->{missionclass} = 'ingal';
63         }else{
64                 $intel->{missionclass} = $intel->{mission};
65         }
66         $intel->{ODD} = $i % 2;
67         push @intel,$intel;
68         $i++;
69 }
70 push @intellists,{Message => 'Outgoing Fleets', Intel => \@intel, Target => 1};
71
72 $BODY->param(IntelLIsts => \@intellists);
73
74 $BODY->param(Error => $error);
75 1;