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 #**************************************************************************/
22 use warnings FATAL => 'all';
25 our @ISA = qw/Exporter/;
27 our @EXPORT = qw/isMember isHC isDC isBC isOfficer isScanner isIntel parseMarkup min max listTargets
28 alliances intelquery/;
31 return exists $ND::GROUPS{Members};
35 return exists $ND::GROUPS{HC};
39 return exists $ND::GROUPS{DC};
43 return exists $ND::GROUPS{BC};
47 return exists $ND::GROUPS{Officers};
51 return exists $ND::GROUPS{Scanners};
55 return exists $ND::GROUPS{Intel};
61 $text =~ s{\n}{\n<br/>}g;
62 $text =~ s{\[B\](.*?)\[/B\]}{<b>$1</b>};
68 return ($x > $y ? $y : $x);
73 return ($x < $y ? $y : $x);
77 my $query = $ND::DBH->prepare(qq{SELECT t.id, r.id AS raid, r.tick+c.wave-1 AS landingtick, released_coords, coords(x,y,z),c.launched,c.wave,c.joinable
79 JOIN raid_targets t ON c.target = t.id
80 JOIN raids r ON t.raid = r.id
81 JOIN current_planet_stats p ON t.planet = p.id
82 WHERE c.uid = ? AND r.tick+c.wave > ? AND r.open AND not r.removed
83 ORDER BY r.tick+c.wave,x,y,z});
84 $query->execute($ND::UID,$ND::TICK);
86 while (my $target = $query->fetchrow_hashref){
87 my $coords = "Target $target->{id}";
88 $coords = $target->{coords} if $target->{released_coords};
89 push @targets,{Coords => $coords, Launched => $target->{launched}, Raid => $target->{raid}
90 , Target => $target->{id}, Tick => $target->{landingtick}, Wave => $target->{wave}
91 , AJAX => $ND::AJAX, JoinName => $target->{joinable} ? 'N' : 'J'
92 , Joinable => $target->{joinable} ? 'FALSE' : 'TRUE'};
94 my $template = HTML::Template->new(filename => "templates/targetlist.tmpl", cache => 1);
95 $template->param(Targets => \@targets);
96 return $template->output;
102 push @alliances,{Id => -1, Name => ' ', Selected => not $alliance};
103 my $query = $ND::DBH->prepare(q{SELECT id,name FROM alliances ORDER BY name});
105 while (my $ally = $query->fetchrow_hashref){
106 push @alliances,{Id => $ally->{id}, Name => $ally->{name}, Selected => $alliance == $ally->{id}};
112 my ($columns,$where) = @_;
114 SELECT $columns, i.mission, i.tick AS landingtick,MIN(i.eta) AS eta, i.amount, i.ingal, u.username
115 FROM (intel i NATURAL JOIN users u)
116 JOIN current_planet_stats t ON i.target = t.id
117 JOIN current_planet_stats o ON i.sender = o.id
119 GROUP BY i.tick,i.mission,t.x,t.y,t.z,o.x,o.y,o.z,i.amount,i.ingal,u.username,t.alliance,o.alliance,t.nick,o.nick
120 ORDER BY i.tick DESC, i.mission};