+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
-# *
-# 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 NDWeb::Pages::Intel;
-use strict;
-use warnings FATAL => 'all';
-use NDWeb::Forum;
-use NDWeb::Include;
-use ND::Include;
-use CGI qw/:standard/;
-
-use base qw/NDWeb::XMLPage/;
-
-$NDWeb::Page::PAGES{intel} = __PACKAGE__;
-
-sub parse {
- my $self = shift;
- if ($self->{URI} =~ m{^/.*/((\d+)(?: |:)(\d+)(?: |:)(\d+))$}){
- param('coords',$1);
- }
-}
-
-sub render_body {
- my $self = shift;
- my ($BODY) = @_;
- $self->{TITLE} = 'Intel';
- my $DBH = $self->{DBH};
-
- return $self->noAccess unless $self->isIntel || $self->isHC;
-
- my $error;
-
- my $planet;
- if (defined param('coords') && param('coords') =~ /^(\d+)(?: |:)(\d+)(?: |:)(\d+)$/){
- my $query = $DBH->prepare(q{SELECT x,y,z,coords(x,y,z),id, nick, alliance,alliance_id, planet_status,channel,ftid,gov FROM current_planet_stats
- WHERE x = ? AND y = ? AND z = ?});
- $planet = $DBH->selectrow_hashref($query,undef,$1,$2,$3) or $ND::ERROR .= p $DBH->errstr;
- }
-
- my $showticks = 'AND (i.tick - i.eta) > (tick() - 48)';
- if (defined param('show')){
- if (param('show') eq 'all'){
- $showticks = '';
- }elsif (param('show') =~ /^(\d+)$/){
- $showticks = "AND (i.tick - i.eta) > (tick() - $1)";
- }
- }
-
- my $thread;
- if (defined $planet){
- $thread = $DBH->selectrow_hashref(q{SELECT ftid AS id, subject FROM forum_threads
- where ftid = $1},undef,$planet->{ftid}) or $ND::ERROR .= p($DBH->errstr);
- }
-
- if (defined param('cmd') && param('cmd') eq 'coords'){
- my $coords = param('coords');
- $DBH->do(q{CREATE TEMPORARY TABLE coordlist (
- x integer NOT NULL,
- y integer NOT NULL,
- z integer NOT NULL,
- PRIMARY KEY (x,y,z)
- )});
- my $insert = $DBH->prepare(q{INSERT INTO coordlist (x,y,z) VALUES(?,?,?)});
- while ($coords =~ m/(\d+):(\d+):(\d+)/g){
- $insert->execute($1,$2,$3);
- }
- my $planets = $DBH->prepare(q{SELECT (((p.x || ':') || p.y) || ':') || p.z AS coords, alliance FROM current_planet_stats p
- JOIN coordlist c ON p.x = c.x AND p.y = c.y AND p.z = c.z
- ORDER BY alliance, p.x, p.y, p.z});
- $planets->execute;
- my @planets;
- while (my $planet = $planets->fetchrow_hashref){
- push @planets,$planet;
- }
- $BODY->param(CoordList => \@planets);
- }
- if (defined $thread and defined param('cmd') and param('cmd') eq 'forumpost'){
- addForumPost($DBH,$thread,$ND::UID,param('message'));
- }
-
- if ($planet && defined param('cmd')){
- if (param('cmd') eq 'change'){
- $DBH->begin_work;
- if (param('cnick')){
- my $value = escapeHTML(param('nick'));
- if ($DBH->do(q{UPDATE planets SET nick = ? WHERE id =?}
- ,undef,$value,$planet->{id})){
- intel_log $ND::UID,$planet->{id},"Set nick to: $value";
- $planet->{nick} = $value;
- }else{
- $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
- }
- }
- if (param('cchannel')){
- my $value = escapeHTML(param('channel'));
- if ($DBH->do(q{UPDATE planets SET channel = ? WHERE id =?}
- ,undef,$value,$planet->{id})){
- intel_log $ND::UID,$planet->{id},"Set channel to: $value";
- $planet->{channel} = $value;
- }else{
- $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
- }
- }
- if (param('cstatus')){
- my $value = escapeHTML(param('status'));
- if ($DBH->do(q{UPDATE planets SET planet_status = ? WHERE id =?}
- ,undef,$value,$planet->{id})){
- intel_log $ND::UID,$planet->{id},"Set planet_status to: $value";
- $planet->{planet_status} = $value;
- }else{
- $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
- }
- }
- if (param('cgov')){
- my $value = escapeHTML(param('gov'));
- if ($DBH->do(q{UPDATE planets SET gov = ? WHERE id =?}
- ,undef,$value,$planet->{id})){
- intel_log $ND::UID,$planet->{id},"Set government to: $value";
- $planet->{gov} = $value;
- }else{
- $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
- }
- }
- if (param('calliance')){
- if ($DBH->do(q{UPDATE planets SET alliance_id = NULLIF(?,-1) WHERE id =?}
- ,undef,param('alliance'),$planet->{id})){
- intel_log $ND::UID,$planet->{id},"Set alliance_id to: ".param('alliance');
- $planet->{alliance_id} = param('alliance');
- }else{
- $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
- }
- }
- $DBH->commit or $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
- }
- }
-
- if (param('coords')){
- my $channel = param('coords');
- $channel = $planet->{channel} if ($planet);
- my $findchannel = $DBH->prepare('SELECT coords(x,y,z),alliance,nick,channel FROM current_planet_stats WHERE channel ILIKE ? ');
- $findchannel->execute($channel);
- my @channelusers;
- while (my $user = $findchannel->fetchrow_hashref){
- push @channelusers,$user;
- }
- $BODY->param(ChannelUsers => \@channelusers);
- }
-
- if ($planet){
- $BODY->param(Coords => $planet->{coords});
- $BODY->param(Planet => $planet->{id});
- $BODY->param(Nick => escapeHTML($planet->{nick}));
- $BODY->param(Channel => $planet->{channel});
- my @gov;
- for my $gov ("","Feu", "Dic", "Dem","Uni"){
- push @gov,{Gov => $gov, Selected => $gov eq $planet->{gov}}
- }
- $BODY->param(Gov => \@gov);
- my @status;
- for my $status ("","Friendly", "NAP", "Hostile"){
- push @status,{Status => $status, Selected => $status eq $planet->{planet_status}}
- }
- $BODY->param(PlanetStatus => \@status);
- my @alliances = alliances($planet->{alliance_id});
- $BODY->param(Alliances => \@alliances);
-
- $BODY->param(Thread => viewForumThread $thread);
-
- my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin',"t.id = ? $showticks"));
- $query->execute($planet->{id}) or $error .= $DBH->errstr;
- my @intellists;
- my @incomings;
- while (my $intel = $query->fetchrow_hashref){
- if ($intel->{ingal}){
- $intel->{missionclass} = 'ingal';
- }else{
- $intel->{missionclass} = $intel->{mission};
- }
- push @incomings,$intel;
- }
- push @intellists,{Message => 'Incoming fleets', Intel => \@incomings, Origin => 1};
-
- $query = $DBH->prepare(intelquery('t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',"o.id = ? $showticks"));
- $query->execute($planet->{id}) or $error .= $DBH->errstr;
- my @outgoings;
- while (my $intel = $query->fetchrow_hashref){
- if ($intel->{ingal}){
- $intel->{missionclass} = 'ingal';
- }else{
- $intel->{missionclass} = $intel->{mission};
- }
- push @outgoings,$intel;
- }
- push @intellists,{Message => 'Outgoing Fleets', Intel => \@outgoings, Target => 1};
-
- $BODY->param(IntelLIsts => \@intellists);
-
- }elsif(!param('coords')){
- my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin, t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',qq{not ingal
- AND ((( t.alliance_id != o.alliance_id OR t.alliance_id IS NULL OR o.alliance_id IS NULL) AND (i.mission = 'Defend' OR i.mission = 'AllyDef' ))
- OR ( t.alliance_id = o.alliance_id AND i.mission = 'Attack'))
- AND i.sender NOT IN (SELECT planet FROM users u NATURAL JOIN groupmembers gm WHERE gid = 8 AND planet IS NOT NULL)
- AND NOT (i.back IS NOT NULL AND i.back = i.tick + 4)
- $showticks
- }));
- $query->execute() or $error .= $DBH->errstr;
-
- my @intellists;
- my @intel;
- while (my $intel = $query->fetchrow_hashref){
- if ($intel->{ingal}){
- $intel->{missionclass} = 'ingal';
- }else{
- $intel->{missionclass} = $intel->{mission};
- }
- push @intel,$intel;
- }
- push @intellists,{Message => q{Intel where alliances doesn't match}, Intel => \@intel, Origin => 1, Target => 1};
- $BODY->param(IntelLIsts => \@intellists);
- }
- $BODY->param(Error => $error);
- return $BODY;
-}
-1;
INSERT INTO roles VALUES('stats_missions');
INSERT INTO roles VALUES('stats_scans');
INSERT INTO roles VALUES('stats_planetdata');
+INSERT INTO roles VALUES('intel');
INSERT INTO group_roles (gid,role) VALUES(2,'member_menu');
INSERT INTO group_roles (gid,role) VALUES(2,'attack_menu');
INSERT INTO group_roles (gid,role) VALUES(4,'raids_edit');
INSERT INTO group_roles (gid,role) VALUES(5,'intel_menu');
+INSERT INTO group_roles (gid,role) VALUES(5,'intel');
INSERT INTO group_roles (gid,role) VALUES(8,'no_fleet_update');
INSERT INTO group_roles (gid,role) VALUES(1,'calls_edit');
INSERT INTO group_roles (gid,role) VALUES(1,'raids_info');
INSERT INTO group_roles (gid,role) VALUES(1,'raids_edit');
+INSERT INTO group_roles (gid,role) VALUES(1,'intel');
INSERT INTO group_roles (gid,role) VALUES(3,'dc_menu');
INSERT INTO group_roles (gid,role) VALUES(3,'bc_menu');
INSERT INTO group_roles (gid,role) VALUES(3,'calls_edit');
INSERT INTO group_roles (gid,role) VALUES(3,'raids_info');
INSERT INTO group_roles (gid,role) VALUES(3,'raids_edit');
+INSERT INTO group_roles (gid,role) VALUES(3,'intel');
__PACKAGE__->allow_access_if('/raids/view',1);
__PACKAGE__->allow_access_if('/raids/findRaid',1);
__PACKAGE__->allow_access_if('/raids/log',1);
+__PACKAGE__->deny_access_unless('/intel',[qw/intel/]);
=head1 NAME
--- /dev/null
+package NDWeb::Controller::Intel;
+
+use strict;
+use warnings;
+use parent 'Catalyst::Controller';
+
+use NDWeb::Include;
+
+=head1 NAME
+
+NDWeb::Controller::Intel - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+=cut
+
+sub index :Path : Args(0) {
+ my ( $self, $c ) = @_;
+ my $dbh = $c->model;
+
+ my $ticks = $c->req->param('ticks') || 48;
+ $c->stash(showticks => $ticks);
+
+ my $query = $dbh->prepare(intelquery q{
+ o.alliance AS oalliance ,coords(o.x,o.y,o.z) AS ocoords, i.sender
+ ,t.alliance AS talliance,coords(t.x,t.y,t.z) AS tcoords, i.target
+ },q{not ingal
+ AND ((( t.alliance_id != o.alliance_id OR t.alliance_id IS NULL OR o.alliance_id IS NULL) AND (i.mission = 'Defend' OR i.mission = 'AllyDef' ))
+ OR ( t.alliance_id = o.alliance_id AND i.mission = 'Attack'))
+ AND i.sender NOT IN (SELECT planet FROM users u NATURAL JOIN groupmembers gm WHERE gid = 8 AND planet IS NOT NULL)
+ AND NOT (i.back IS NOT NULL AND i.back = i.tick + 4)
+ AND i.tick > (tick() - $1)
+ });
+ $query->execute($ticks);
+ $c->stash(intel => $query->fetchall_arrayref({}) );
+
+ if (defined $c->req->param('coords')){
+ my $coords = $c->req->param('coords');
+ my @coords;
+ while ($coords =~ m/(\d+:\d+:\d+)/g){
+ push @coords,$1;
+ }
+ my $planets = $dbh->prepare(q{SELECT id,coords(x,y,z), alliance
+ FROM current_planet_stats p
+ WHERE coords(x,y,z) = ANY($1)
+ ORDER BY alliance, p.x, p.y, p.z
+ });
+ $planets->execute(\@coords);
+ $c->stash(coordslist => $planets->fetchall_arrayref({}) );
+ }
+}
+
+sub planet : Local {
+ my ( $self, $c, $id ) = @_;
+ my $dbh = $c->model;
+
+ $c->forward('findPlanet');
+ my $p = $c->stash->{p};
+
+ $c->stash(checkcoords => "$p->{x}:$p->{y}:$p->{z}");
+ my $ticks = $c->req->param('ticks') || 48;
+ $c->stash(showticks => $ticks);
+
+ my $query = $dbh->prepare(q{SELECT id,coords(x,y,z),alliance,nick,channel
+ FROM current_planet_stats WHERE channel ILIKE ?
+ ORDER BY alliance,x,y,z
+ });
+ $query->execute($p->{channel});
+ $c->stash(channelusers => $query->fetchall_arrayref({}) );
+
+ $c->forward('/listAlliances');
+ $c->forward('/forum/findPosts',[$p->{ftid}]);
+
+ $c->stash(govs => ["","Feu", "Dic", "Dem","Uni"]);
+ $c->stash(planetstatus => ["","Friendly", "NAP", "Hostile"]);
+
+ $query = $dbh->prepare(intelquery q{i.sender
+ ,o.alliance AS oalliance,coords(o.x,o.y,o.z) AS ocoords
+ },q{i.target = $1 AND i.tick > (tick() - $2)});
+ $query->execute($id,$ticks);
+ $c->stash(incoming => $query->fetchall_arrayref({}) );
+
+ $query = $dbh->prepare(intelquery q{i.target
+ ,t.alliance AS talliance,coords(t.x,t.y,t.z) AS tcoords
+ },q{i.sender = $1 AND i.tick > (tick() - $2)});
+ $query->execute($id,$ticks);
+ $c->stash(outgoing => $query->fetchall_arrayref({}) );
+
+}
+
+sub postplanetcomment : Local {
+ my ($self, $c, $p) = @_;
+
+ $c->forward('findPlanet');
+ $p = $c->stash->{p};
+
+ $c->forward('/forum/insertPost',[$p->{ftid}]);
+ $c->res->redirect($c->uri_for('planet',$p->{id}));
+}
+
+sub postplanetupdate : Local {
+ my ($self, $c, $p) = @_;
+ my $dbh = $c->model;
+
+ $c->forward('findPlanet');
+ $p = $c->stash->{p};
+
+ $dbh->begin_work;
+ my $log = $dbh->prepare(q{INSERT INTO forum_posts (ftid,uid,message)
+ VALUES($2,$1,$3)
+ });
+ if ($c->req->param('cnick')){
+ my $value = html_escape $c->req->param('nick');
+ $dbh->do(q{UPDATE planets SET nick = ? WHERE id =?}
+ ,undef,$value,$p->{id});
+ $log->execute($c->user->id,$p->{ftid},"Set nick to: $value");
+ }
+ if ($c->req->param('cchannel')){
+ my $value = html_escape $c->req->param('channel');
+ $dbh->do(q{UPDATE planets SET channel = ? WHERE id =?}
+ ,undef,$value,$p->{id});
+ $log->execute($c->user->id,$p->{ftid},"Set channel to: $value");
+ }
+ if ($c->req->param('cstatus')){
+ my $value = $c->req->param('status');
+ $dbh->do(q{UPDATE planets SET planet_status = ? WHERE id =?}
+ ,undef,$value,$p->{id});
+ $log->execute($c->user->id,$p->{ftid},"Set planet_status to: $value");
+ }
+ if ($c->req->param('cgov')){
+ my $value = $c->req->param('gov');
+ $dbh->do(q{UPDATE planets SET gov = ? WHERE id =?}
+ ,undef,$value,$p->{id});
+ $log->execute($c->user->id,$p->{ftid},"Set gov to: $value");
+ }
+ if ($c->req->param('calliance')){
+ my $value = $c->req->param('alliance');
+ $dbh->do(q{UPDATE planets SET alliance_id = NULLIF(?,-1) WHERE id =?}
+ ,undef,$value,$p->{id});
+ $log->execute($c->user->id,$p->{ftid},"Set alliance_id to: $value");
+ }
+ $dbh->commit;
+
+ $c->res->redirect($c->uri_for('planet',$p->{id}));
+}
+
+
+sub find : Local {
+ my ( $self, $c, $find ) = @_;
+ my $dbh = $c->model;
+
+ local $_ = $find || $c->req->param('coords');
+
+ if (/(\d+)(?: |:)(\d+)(?: |:)(\d+)(?:(?: |:)(\d+))?/){
+ my $planet = $dbh->selectrow_array(q{SELECT planetid($1,$2,$3,$4)}
+ ,undef,$1,$2,$3,$4);
+ $c->res->redirect($c->uri_for('planet',$planet));
+ }
+}
+
+sub findPlanet : Private {
+ my ( $self, $c, $id ) = @_;
+ my $dbh = $c->model;
+
+ my $query = $dbh->prepare(q{SELECT x,y,z,id, nick, alliance,alliance_id
+ , planet_status,channel,ftid,gov
+ FROM current_planet_stats
+ WHERE id = $1
+ });
+ $query->execute($id);
+ $c->stash(p => $query->fetchrow_hashref);
+}
+
+
+=head1 AUTHOR
+
+Michael Andreen (harv@ruin.nu)
+
+=head1 LICENSE
+
+GPL 2.0, or later.
+
+=cut
+
+1;
JOIN current_planet_stats t ON i.target = t.id
JOIN current_planet_stats o ON i.sender = o.id
WHERE $where
-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
+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,i.sender,i.target
ORDER BY i.tick DESC, i.mission};
}
[% IF c.check_user_roles("intel_menu") %]
<p>Intel menu</p>
<ul class="linkbar">
- <li><a href="intel">Intel</a></li>
+ <li><a href="/intel">Intel</a></li>
+ <li><form action="/intel/find" method="post"><p>
+ <input class="coordsinput" type="text" name="coords" value="[% checkcoords %]">
+ <input class="coordsinput" type="submit" value="Check">
+ </p></form>
+ </li>
</ul>
[% END %]
[% IF c.check_user_roles("hc_menu") %]
--- /dev/null
+[% META title = 'Find' %]
+
+<p>Could not find: "[% c.req.param('coords') | html %]"</p>
+
+<p>The following syntaxes are possible:</p>
+<ul>
+ <li>X:Y:Z tick (i.e. "1:1:1 37") Finds the planet that had the coords at the specified tick</li>
+ <li>X:Y:Z (i.e. "1:1:1") Finds the planet that had the coords at the current tick</li>
+</ul>
--- /dev/null
+[% META title = 'Intel' %]
+
+[% IF coordslist %]
+<table class="stats">
+ <tr><th>Coords</th><th>Alliance</th></tr>
+ [% FOR p IN coordslist %]
+ <tr>
+ <td><a href="[% c.uri_for('planet',p.id) %]">[% p.coords %]</a></td>
+ <td>[% p.alliance %]</td>
+ </tr>
+ [% END %]
+</table>
+[% END %]
+
+
+<form action="[% c.uri_for('') %]" method="post">
+ <p>Show last <input type="text" name="ticks" value="[% showticks %]"> ticks <input type="submit" value="Show"></p>
+</form>
+
+<table class="stats">
+ <tr>
+ <th>Alliance</th><th>Sender</th>
+ <th>Mission</th><th>Landing tick</th><th>ETA</th><th>Amount</th>
+ <th>Target</th><th>Alliance</th>
+ <th>Reported by</th>
+ </tr>
+[% FOR i IN intel %]
+ <tr class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
+ <td>[% i.oalliance %]</td>
+ <td><a href="[% c.uri_for('planet',i.sender) %]">[% i.ocoords %]</a></td>
+ <td class="[% i.mission %]">[% i.mission %]</td>
+ <td align="center">[% i.landingtick %]</td>
+ <td align="center">[% i.eta %]</td>
+ <td>[% i.amount %]</td>
+ <td><a href="[% c.uri_for('planet',i.target) %]">[% i.tcoords %]</a></td>
+ <td>[% i.talliance %]</td>
+ <td>[% i.username %]</td>
+ </tr>
+[% END %]
+</table>
+
+<form action="[% c.uri_for('') %]" method="post"><fieldset> <legend>Coords</legend>
+ <p>Paste a list of coords that you want to check here</p>
+ <textarea rows="25" cols="80" name="coords"></textarea>
+ <br><input type="submit" value="Submit">
+</fieldset></form>
--- /dev/null
+[% META title = 'Intel' %]
+
+<div class="leftinfo">
+<form action="[% c.uri_for('planet',p.id) %]" method="post">
+ <p>Show last <input type="text" name="ticks" value="[% showticks %]"> ticks <input type="submit" value="Show"></p>
+</form>
+<form action="[% c.uri_for('postplanetupdate',p.id) %]" method="post">
+ <table>
+ <tr>
+ <th></th>
+ <th>Value</th>
+ <th>Change?</th>
+ </tr>
+ <tr><td>Nick</td>
+ <td><input type="text" name="nick" value="[% p.nick %]"></td>
+ <td><input type="checkbox" name="cnick"></td>
+ </tr>
+ <tr><td>Channel</td>
+ <td><input type="text" name="channel" value="[% p.channel %]"></td>
+ <td><input type="checkbox" name="cchannel"></td>
+ </tr>
+ <tr><td>Government</td>
+ <td><select name="gov">
+[% FOR gov IN govs %]
+ <option value="[% gov %]" [% IF gov == p.gov %]selected[% END %]> [% gov %]</option>
+[% END %]
+ </select></td>
+ <td><input type="checkbox" name="cgov"></td>
+ </tr>
+ <tr><td>Planet status</td>
+ <td><select name="status">
+[% FOR ps IN planetstatus %]
+ <option value="[% ps %]" [% IF ps == p.planet_status %]selected[% END %]> [% ps %]</option>
+[% END %]
+ </select></td>
+ <td><input type="checkbox" name="cstatus"></td>
+ </tr>
+ <tr><td>Alliance</td>
+ <td><select name="alliance">
+[% FOR a IN alliances %]
+ <option value="[% a.id %]" [% IF a.id == p.alliance_id %]selected[% END %]> [% a.name %]</option>
+[% END %]
+ </select></td>
+ <td><input type="checkbox" name="calliance"></td>
+ </tr>
+ </table>
+ <p><input type="submit" value="Change">
+ </p>
+</form>
+
+[% IF channelusers.size > 0 %]
+<table class="stats">
+ <tr>
+ <th>Coords</th><th>Alliance</th><th>Nick</th><th>Channel</th>
+ </tr>
+ [% FOR cu IN channelusers %]
+ <tr>
+ <td><a href="[% c.uri_for('planet',cu.id) %]">[% cu.coords %]</a></td>
+ <td>[% cu.alliance %]</td><td>[% cu.nick %]</td><td>[% cu.channel %]</td>
+ </tr>
+ [% END %]
+</table>
+[% END %]
+<table class="stats">
+ <tr>
+ <th>Alliance</th><th>Sender</th>
+ <th>Mission</th><th>Landing tick</th><th>ETA</th><th>Amount</th>
+ <th>Ingal</th><th>Reported by</th>
+ </tr>
+[% FOR i IN incoming %]
+ <tr class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
+ <td>[% i.oalliance %]</td>
+ <td><a href="[% c.uri_for('planet',i.sender) %]">[% i.ocoords %]</a></td>
+ <td class="[% i.ingal ? 'ingal' : i.mission %]">[% i.mission %]</td>
+ <td align="center">[% i.landingtick %]</td>
+ <td align="center">[% i.eta %]</td>
+ <td>[% i.amount %]</td>
+ <td>[% i.ingal %]</td>
+ <td>[% i.username %]</td>
+ </tr>
+[% END %]
+</table>
+
+<table class="stats">
+ <tr>
+ <th>Mission</th><th>Landing tick</th><th>ETA</th><th>Amount</th>
+ <th>Target</th><th>Alliance</th>
+ <th>Ingal</th><th>Reported by</th>
+ </tr>
+[% FOR i IN outgoing %]
+ <tr class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
+ <td class="[% i.ingal ? 'ingal' : i.mission %]">[% i.mission %]</td>
+ <td align="center">[% i.landingtick %]</td>
+ <td align="center">[% i.eta %]</td>
+ <td>[% i.amount %]</td>
+ <td><a href="[% c.uri_for('planet',i.target) %]">[% i.tcoords %]</a></td>
+ <td>[% i.talliance %]</td>
+ <td>[% i.ingal %]</td>
+ <td>[% i.username %]</td>
+ </tr>
+[% END %]
+</table>
+</div>
+
+<div class="leftinfo">
+[% FOR post IN posts %]
+<fieldset class="forum-post">
+<legend class="unread:[% post.unread %]"><b>[% post.username %]</b> : [% post.time %]</legend>
+ [% post.message %]
+</fieldset>
+[% END %]
+
+<form action="[% c.uri_for('postplanetcomment', p.id) %]" method="post"><fieldset class="forum-post"> <legend>New Reply</legend>
+ <textarea rows="10" cols="60" name="message"></textarea>
+ <input type="submit" value="Submit">
+</fieldset></form>
+</div>
--- /dev/null
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+BEGIN { use_ok 'Catalyst::Test', 'NDWeb' }
+BEGIN { use_ok 'NDWeb::Controller::Intel' }
+
+ok( request('/intel')->is_success, 'Request should succeed' );
+
+
+++ /dev/null
-<TMPL_VAR NAME=Error>
-<div class='leftinfo'>
-<form action="<TMPL_VAR NAME=PAGE>" method="post"><p>
- <input type="text" name="coords" value="<TMPL_VAR NAME=Coords>"/>
- <input type="submit" value="Check"/>
- <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
- </p>
-</form>
-<p><a href="/<TMPL_VAR NAME=PAGE>?<TMPL_IF Coords>&coords=<TMPL_VAR NAME=Coords></TMPL_IF>&show=all">Show all ticks</a></p>
-
-<TMPL_IF CoordList>
-<table class="stats">
- <tr><th>Coords</th><th>Alliance</th></tr>
- <TMPL_LOOP CoordList>
- <tr>
- <td><a href="/<TMPL_VAR NAME=PAGE>?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords></a></td>
- <td><TMPL_VAR NAME=Alliance></td>
- </tr>
- </TMPL_LOOP>
-</table>
-</TMPL_IF>
-
-<TMPL_IF Coords>
-<form action="<TMPL_VAR NAME=PAGE>" method="post">
- <input type="hidden" name="coords" value="<TMPL_VAR NAME=Coords>"/>
- <input type="hidden" name="planet" value="<TMPL_VAR NAME=Planet>"/>
- <input type="hidden" name="cmd" value="change"/>
- <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
- <table>
- <tr>
- <th></th>
- <th>Value</th>
- <th>Change?</th>
- </tr>
- <tr><td>Nick</td>
- <td><input type="text" name="nick" value="<TMPL_VAR NAME=Nick>"/></td>
- <td><input type="checkbox" name="cnick"/></td>
- </tr>
- <tr><td>Channel</td>
- <td><input type="text" name="channel" value="<TMPL_VAR NAME=Channel>"/></td>
- <td><input type="checkbox" name="cchannel"/></td>
- </tr>
- <tr><td>Government</td>
- <td><select name="gov">
- <TMPL_LOOP Gov>
- <option value="<TMPL_VAR NAME=Gov>" <TMPL_IF NAME=Selected>selected="selected"</TMPL_IF>><TMPL_VAR NAME=Gov></option>
- </TMPL_LOOP>
- </select></td>
- <td><input type="checkbox" name="cgov"/></td>
- </tr>
- <tr><td>Planet status</td>
- <td><select name="status">
- <TMPL_LOOP PlanetStatus>
- <option value="<TMPL_VAR NAME=Status>" <TMPL_IF NAME=Selected>selected="selected"</TMPL_IF>><TMPL_VAR NAME=Status></option>
- </TMPL_LOOP>
- </select></td>
- <td><input type="checkbox" name="cstatus"/></td>
- </tr>
- <tr><td>Alliance</td>
- <td><select name="alliance">
- <TMPL_LOOP Alliances>
- <option value="<TMPL_VAR NAME=Id>" <TMPL_IF NAME=Selected>selected="selected"</TMPL_IF>><TMPL_VAR NAME=Name></option>
- </TMPL_LOOP>
- </select></td>
- <td><input type="checkbox" name="calliance"/></td>
- </tr>
- </table>
- <p><input type="submit" value="Change"/>
- </p>
-</form>
-</TMPL_IF>
-<TMPL_IF ChannelUsers>
-<p>Planets sharing this channel</p>
-<table class="stats">
- <tr>
- <th>Coords</th><th>Alliance</th><th>Nick</th><th>Channel</th>
- </tr>
-<TMPL_LOOP ChannelUsers>
- <tr>
- <td><a href="/<TMPL_VAR NAME=PAGE>?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords></a></td>
- <td><TMPL_VAR NAME=Alliance></td><td><TMPL_VAR NAME=Nick></td><td><TMPL_VAR NAME=Channel></td>
- </tr>
-</TMPL_LOOP>
-</table>
-</TMPL_IF>
-</div>
-
-<TMPL_IF Thread>
-<div>
-<TMPL_VAR ESCAPE=NONE NAME=Thread>
-<form action="<TMPL_VAR NAME=PAGE>#NewPosts" method="post"><fieldset class="forum-post"> <legend>New Reply</legend>
- <textarea rows="10" cols="60" name="message"></textarea>
- <input type="hidden" name="cmd" value="forumpost"/>
- <input type="hidden" name="t" value="<TMPL_VAR NAME=Id>"/>
- <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
- <input type="hidden" name="coords" value="<TMPL_VAR NAME=Coords>"/>
- <br/>
- <input type="submit" value="Submit"/>
-</fieldset></form>
-</div>
-</TMPL_IF>
-
-<TMPL_LOOP IntelLists>
-<TMPL_IF Message><p><TMPL_VAR NAME=Message></p></TMPL_IF>
-<table class="stats">
- <tr>
- <TMPL_IF Origin><th>Alliance</th><th>Sender</th></TMPL_IF>
- <th>Mission</th><th>Landing tick</th><th>ETA</th><th>Amount</th>
- <TMPL_IF Target><th>Target</th><th>Alliance</th></TMPL_IF>
- <th>Ingal</th><th>Reported by</th>
- </tr>
- <TMPL_LOOP Intel>
- <tr class="<TMPL_IF __odd__>odd<TMPL_ELSE>even</TMPL_IF>">
- <TMPL_IF Origin>
- <td><TMPL_VAR NAME=OAlliance></td>
- <td><a href="/<TMPL_VAR NAME=PAGE>?coords=<TMPL_VAR NAME=Origin>"><TMPL_VAR NAME=Origin></a></td>
- </TMPL_IF>
- <td class="<TMPL_VAR NAME=MissionClass>"><TMPL_VAR NAME=Mission></td>
- <td align="center"><TMPL_VAR NAME=landingtick></td>
- <td align="center"><TMPL_VAR NAME=ETA></td>
- <td><TMPL_VAR NAME=Amount></td>
- <TMPL_IF Target>
- <td><a href="/<TMPL_VAR NAME=PAGE>?coords=<TMPL_VAR NAME=Target>"><TMPL_VAR NAME=Target></a></td>
- <td><TMPL_VAR NAME=TAlliance></td>
- </TMPL_IF>
- <td><TMPL_VAR NAME=Ingal></td>
- <td><TMPL_VAR NAME=Username></td>
- </tr>
- </TMPL_LOOP>
-</table>
-</TMPL_LOOP>
-
- <form action="<TMPL_VAR NAME=PAGE>" method="post"><fieldset> <legend>Coords</legend>
- <p>Paste a list of coords that you want to check here</p>
- <textarea rows="25" cols="80" name="coords"></textarea>
- <input type="hidden" name="cmd" value="coords"/>
- <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
- <br/><input type="submit" value="Submit"/>
-</fieldset></form>