X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND%2FWeb%2FPages%2FMemberIntel.pm;fp=ND%2FWeb%2FPages%2FMemberIntel.pm;h=c70b52bea687ecb33c4bafa38c0e08c6c71f6ad7;hb=9ce5a8529e75cb109ed9ba3fc788c94ef47b1080;hp=0000000000000000000000000000000000000000;hpb=03830799201db0b0f28e9c494fdd1b5b5143749c;p=ndwebbie.git diff --git a/ND/Web/Pages/MemberIntel.pm b/ND/Web/Pages/MemberIntel.pm new file mode 100644 index 0000000..c70b52b --- /dev/null +++ b/ND/Web/Pages/MemberIntel.pm @@ -0,0 +1,97 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package ND::Web::Pages::MemberIntel; +use strict; +use warnings FATAL => 'all'; +use CGI qw/:standard/; +use ND::Web::Include; + +$ND::PAGES{memberIntel} = {parse => \&parse, process => \&process, render=> \&render}; + +sub parse { + my ($uri) = @_; + if ($uri =~ m{^/.*/(\w+)$}){ + param('list',$1); + } +} + +sub process { + +} + +sub render { + my ($DBH,$BODY) = @_; + my $error; + + $ND::TEMPLATE->param(TITLE => 'Member Intel'); + + return $ND::NOACCESS unless isHC(); + + my $showticks = 'AND i.tick > tick()'; + if (defined param('show')){ + if (param('show') eq 'all'){ + $showticks = ''; + }elsif (param('show') =~ /^(\d+)$/){ + $showticks = "AND (i.tick - i.eta) > (tick() - $1)"; + } + } + + + 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")); + $query->execute() or $error .= $DBH->errstr; + my @intellists; + my @incomings; + my $i = 0; + while (my $intel = $query->fetchrow_hashref){ + if ($intel->{ingal}){ + $intel->{missionclass} = 'ingal'; + }else{ + $intel->{missionclass} = $intel->{mission}; + } + $intel->{oalliance} = ' ' unless $intel->{oalliance}; + $i++; + $intel->{ODD} = $i % 2; + push @incomings,$intel; + } + push @intellists,{Message => 'Incoming fleets', Intel => \@incomings, Origin => 1}; + + $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")); + $query->execute() or $error .= $DBH->errstr; + my @outgoings; + $i = 0; + while (my $intel = $query->fetchrow_hashref){ + if ($intel->{ingal}){ + $intel->{missionclass} = 'ingal'; + }else{ + $intel->{missionclass} = $intel->{mission}; + } + $intel->{talliance} = ' ' unless $intel->{talliance}; + $i++; + $intel->{ODD} = $i % 2; + push @outgoings,$intel; + } + push @intellists,{Message => 'Outgoing Fleets', Intel => \@outgoings, Target => 1}; + + $BODY->param(IntelLIsts => \@intellists); + + $BODY->param(Error => $error); + return $BODY; +} +1;