]> ruin.nu Git - ndwebbie.git/commitdiff
target list, and bcc
authorMichael Andreen <harv@ruin.nu>
Mon, 12 Mar 2007 08:38:50 +0000 (08:38 +0000)
committerMichael Andreen <harv@ruin.nu>
Mon, 12 Mar 2007 08:38:50 +0000 (08:38 +0000)
ND/Web/Pages/Mail.pm
ND/Web/Pages/TargetList.pm [new file with mode: 0644]
startup.pl
templates/targetList.tmpl [new file with mode: 0644]

index 98f5c2e62d01716350bf2e3e8f0e035f57b0e818..858d0ded49585e663e33288b61f80f5a32e70ea4 100644 (file)
@@ -59,7 +59,7 @@ sub render_body {
 
                my %mail = (
                        smtp => 'ruin.nu',
-                       To      => (join ',',@emails),
+                       BCC      => (join ',',@emails),
                        From    => 'NewDawn Command <nd@ruin.nu>',
                        'Content-type' => 'text/plain; charset="UTF-8"',
                        Subject => param('subject'),
diff --git a/ND/Web/Pages/TargetList.pm b/ND/Web/Pages/TargetList.pm
new file mode 100644 (file)
index 0000000..67c4653
--- /dev/null
@@ -0,0 +1,79 @@
+#**************************************************************************
+#   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::TargetList;
+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{targetList} = __PACKAGE__;
+
+sub render_body {
+       my $self = shift;
+       my ($BODY) = @_;
+       $self->{TITLE} = 'NF Value';
+       my $DBH = $self->{DBH};
+
+       return $self->noAccess unless $self->isHC;
+
+       my $order = 'nfvalue';
+       if (local $_ = param('order')){
+               if (/^(size|value|score|xp)$/){
+                       $order = "$1 DESC";
+               }elsif (/^(nfvalue|nfvalue2)$/){
+                       $order = "$1 ASC";
+               }
+       }
+
+       my $alliances = '15';
+       if (param('alliances') && param('alliances') =~ /^([\d,]+)$/){
+               $alliances = $1;
+       }
+       my $query = $DBH->prepare(qq{
+SELECT coords(p.x,p.y,p.z),p.alliance, p.score, p.value, p.size, p.xp,nfvalue, nfvalue - sum(pa.value) AS nfvalue2, p.race
+FROM current_planet_stats p
+       JOIN (SELECT g.x,g.y, sum(p.value) AS nfvalue
+       FROM galaxies g join current_planet_stats p on g.x = p.x AND g.y = p.y 
+       WHERE g.tick = (SELECT max(tick) from galaxies)
+               AND ((planet_status IS NULL OR NOT planet_status IN ('Friendly','NAP')) AND  (relationship IS NULL OR NOT relationship IN ('Friendly','NAP'))) 
+       GROUP BY g.x,g.y
+       ) g ON p.x = g.x AND p.y = g.y
+       JOIN current_planet_stats pa ON pa.x = g.x AND pa.y = g.y
+WHERE p.alliance_id IN ($alliances)
+       AND pa.alliance_id IN ($alliances)
+GROUP BY p.x,p.y,p.z,p.alliance, p.score, p.value, p.size, p.xp, nfvalue,p.race
+ORDER BY $order
+               });
+       $query->execute;
+       my @alliances;
+       my $i = 0;
+       while (my $alliance = $query->fetchrow_hashref){
+               $i++;
+               $alliance->{ODD} = $i % 2;
+               push @alliances,$alliance;
+       }
+       $BODY->param(Alliances => \@alliances);
+
+       return $BODY;
+}
+1;
index 996b3b7449969b26be964ab5b89a93fc7af752f7..663c62155bf7d74c6274f6c5124fc27e4170cbc9 100644 (file)
@@ -54,6 +54,7 @@ use ND::Web::Pages::Mail;
 use ND::Web::Pages::HostileAlliances;
 use ND::Web::Pages::AllianceRankings;
 use ND::Web::Pages::GalaxyRankings;
+use ND::Web::Pages::TargetList;
 
 
 
diff --git a/templates/targetList.tmpl b/templates/targetList.tmpl
new file mode 100644 (file)
index 0000000..f61701a
--- /dev/null
@@ -0,0 +1,27 @@
+<TMPL_VAR NAME=Error>
+<table class="stats">
+       <tr>
+               <th>Coords</th>
+               <th>Alliance</th>
+               <th>Race</th>
+               <th><a href="/<TMPL_VAR NAME=PAGE>?order=score">Score</a></th>
+               <th><a href="/<TMPL_VAR NAME=PAGE>?order=value">Value</a></th>
+               <th><a href="/<TMPL_VAR NAME=PAGE>?order=xp">XP</a></th>
+               <th><a href="/<TMPL_VAR NAME=PAGE>?order=size">Size</a></th>
+               <th><a href="/<TMPL_VAR NAME=PAGE>?order=nfvalue">NF Value</a></th>
+               <th><a href="/<TMPL_VAR NAME=PAGE>?order=nfvalue2">NF Value - Ally Value</a></th>
+       </tr>
+<TMPL_LOOP Alliances>
+       <tr class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+               <td><a href="/check?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords></a></td>
+               <td><TMPL_VAR NAME=Alliance></td>
+               <td><TMPL_VAR NAME=Race></td>
+               <td><TMPL_VAR NAME=score></td>
+               <td><TMPL_VAR NAME=Value></td>
+               <td><TMPL_VAR NAME=XP></td>
+               <td><TMPL_VAR NAME=size></td>
+               <td><TMPL_VAR NAME=nfvalue></td>
+               <td><TMPL_VAR NAME=nfvalue2></td>
+       </tr>
+</TMPL_LOOP>
+</table>