]> ruin.nu Git - ndwebbie.git/commitdiff
hostile alliances
authorMichael Andreen <harv@ruin.nu>
Mon, 19 Feb 2007 11:30:47 +0000 (11:30 +0000)
committerMichael Andreen <harv@ruin.nu>
Mon, 19 Feb 2007 11:30:47 +0000 (11:30 +0000)
ND/Web/Pages/HostileAlliances.pm [new file with mode: 0644]
startup.pl
templates/hostileAlliances.tmpl [new file with mode: 0644]
templates/skel.tmpl

diff --git a/ND/Web/Pages/HostileAlliances.pm b/ND/Web/Pages/HostileAlliances.pm
new file mode 100644 (file)
index 0000000..c9c0916
--- /dev/null
@@ -0,0 +1,71 @@
+#**************************************************************************
+#   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 ND::Web::Pages::HostileAlliances;
+use strict;
+use warnings FATAL => 'all';
+use ND::Include;
+use CGI qw/:standard/;
+use ND::Web::Include;
+
+use base qw/ND::Web::XMLPage/;
+
+$ND::Web::Page::PAGES{hostileAlliances} = __PACKAGE__;
+
+sub render_body {
+       my $self = shift;
+       my ($BODY) = @_;
+       $self->{TITLE} = 'Hostile Alliances';
+       my $DBH = $self->{DBH};
+
+       return $self->noAccess unless $self->isHC;
+
+       my $begintick = 0;
+       my $endtick = $self->{TICK};
+       if (param('ticks')){
+               $begintick = $endtick - param('ticks');
+       }elsif(defined param('begintick') && defined param('endtick')){
+               $begintick = param('begintick');
+               $endtick = param('endtick');
+
+       }
+       my $query = $DBH->prepare(q{
+               SELECT s.alliance_id AS id,s.alliance AS name,count(*) AS hostilecount
+FROM calls c 
+       JOIN incomings i ON i.call = c.id
+       JOIN current_planet_stats s ON i.sender = s.id
+WHERE c.landing_tick - i.eta > $1 and c.landing_tick - i.eta < $2
+GROUP BY s.alliance_id,s.alliance
+ORDER BY hostilecount DESC
+               })or $ND::ERROR .= $DBH->errstr;
+       $query->execute($begintick,$endtick) or $ND::ERROR .= $DBH->errstr;
+       my @alliances;
+       my $i = 0;
+       my $tick = $self->{TICK};
+       while (my $alliance = $query->fetchrow_hashref){
+               $i++;
+               $alliance->{ODD} = $i % 2;
+               push @alliances, $alliance;
+       }
+       $BODY->param(Alliances => \@alliances);
+       $BODY->param(Ticks => $endtick - $begintick);
+       $BODY->param(BeginTick =>$begintick);
+       $BODY->param(EndTick =>$endtick);
+       return $BODY;
+}
+1;
index 113a1cca352d6c4756b7f8a69fb1af0cb63734e6..e8afdae04202dc1335017b9ddb5e43bf24995700 100644 (file)
@@ -51,6 +51,7 @@ use ND::Web::Pages::Forum;
 use ND::Web::Pages::Settings;
 use ND::Web::Pages::Graph;
 use ND::Web::Pages::Mail;
+use ND::Web::Pages::HostileAlliances;
 
 
 
diff --git a/templates/hostileAlliances.tmpl b/templates/hostileAlliances.tmpl
new file mode 100644 (file)
index 0000000..8a3fe3c
--- /dev/null
@@ -0,0 +1,24 @@
+<form action="/<TMPL_VAR NAME=PAGE>" method="post"><p>
+       Show last <input style="width: 4em" type="text" name="ticks" value="<TMPL_VAR NAME=Ticks>"/> ticks
+       <input type="submit" value="Submit"/>
+       <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
+       </p>
+</form>
+<form action="/<TMPL_VAR NAME=PAGE>" method="post"><p>
+       Show hostile counts between <input style="width: 4em" type="text" name="begintick" value="<TMPL_VAR NAME=BeginTick>"/> and <input style="width: 4em" type="text" name="endtick" value="<TMPL_VAR NAME=EndTick>"/>
+       <input type="submit" value="Submit"/>
+       <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
+       </p>
+</form>
+<table class="stats">
+       <tr>
+               <th>Alliance</th>
+               <th>Hostile Counts</th>
+       </tr>
+<TMPL_LOOP Alliances>
+       <tr class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+               <td><a href="/alliances?alliance=<TMPL_VAR NAME=Id>"><TMPL_VAR NAME=Name></a></td>
+               <td><TMPL_VAR NAME=HostileCount></td>
+       </tr>
+</TMPL_LOOP>
+</table>
index f706b24f20ac6640536d8832624f37c9a43ff98f..37f8cdf96f324ebd2126a9226ed4b8cb0a71673a 100644 (file)
@@ -64,6 +64,7 @@
                <li><a href="/users">List users</a></li>
                <li><a href="/intel">Intel</a></li>
                <li><a href="/alliances">Alliances</a></li>
+               <li><a href="/hostileAlliances">Hostile Alliances</a></li>
                <li><a href="/memberIntel">Member Intel</a></li>
                <li><a href="/resources">Alliance resources</a></li>
                <li><a href="/planetNaps">Planet Naps</a></li>