1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
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. *
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. *
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 #**************************************************************************/
20 package NDWeb::Pages::MemberIntel;
22 use warnings FATAL => 'all';
23 use CGI qw/:standard/;
26 use base qw/NDWeb::XMLPage/;
28 $NDWeb::Page::PAGES{memberIntel} = __PACKAGE__;
33 $self->{TITLE} = 'Member Intel';
34 my $DBH = $self->{DBH};
37 return $self->noAccess unless $self->isHC;
39 my $showticks = 'AND i.tick > tick()';
40 if (defined param('show')){
41 if (param('show') eq 'all'){
43 }elsif (param('show') =~ /^(\d+)$/){
44 $showticks = "AND (i.tick - i.eta) > (tick() - $1)";
49 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"));
50 $query->execute() or $error .= $DBH->errstr;
54 while (my $intel = $query->fetchrow_hashref){
56 $intel->{missionclass} = 'ingal';
58 $intel->{missionclass} = $intel->{mission};
60 $intel->{oalliance} = ' ' unless $intel->{oalliance};
62 $intel->{ODD} = $i % 2;
63 push @incomings,$intel;
65 push @intellists,{Message => 'Incoming fleets', Intel => \@incomings, Origin => 1};
67 $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"));
68 $query->execute() or $error .= $DBH->errstr;
71 while (my $intel = $query->fetchrow_hashref){
73 $intel->{missionclass} = 'ingal';
75 $intel->{missionclass} = $intel->{mission};
77 $intel->{talliance} = ' ' unless $intel->{talliance};
79 $intel->{ODD} = $i % 2;
80 push @outgoings,$intel;
82 push @intellists,{Message => 'Outgoing Fleets', Intel => \@outgoings, Target => 1};
84 $BODY->param(IntelLIsts => \@intellists);
86 $BODY->param(Error => $error);