]> ruin.nu Git - ndwebbie.git/commitdiff
covop targets
authorMichael Andreen <harv@ruin.nu>
Tue, 12 Dec 2006 11:26:11 +0000 (11:26 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 12 Dec 2006 11:26:11 +0000 (11:26 +0000)
covop.pl [new file with mode: 0644]
index.pl
points.pl
templates/covop.tmpl [new file with mode: 0644]
templates/skel.tmpl

diff --git a/covop.pl b/covop.pl
new file mode 100644 (file)
index 0000000..180a0a4
--- /dev/null
+++ b/covop.pl
@@ -0,0 +1,67 @@
+#**************************************************************************
+#   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.         *
+#**************************************************************************/
+
+use strict;
+
+$ND::TEMPLATE->param(TITLE => 'CovOp Targets');
+
+our $BODY;
+our $DBH;
+our $LOG;
+
+die "You don't have access" unless isMember();
+
+my $show = q{AND ((planet_status IS NULL OR NOT planet_status IN ('Friendly','NAP')) AND  (relationship IS NULL OR NOT relationship IN ('Friendly','NAP')))};
+$show = '' if param('show') eq 'all';
+if (param('covop') =~ /^(\d+)$/){
+       my $update = $DBH->prepare('UPDATE covop_targets SET covop_by = ?, last_covop = tick() WHERE planet = ? ');
+       $update->execute($ND::UID,$1);
+}
+
+my $list = '';
+my $where = '';
+if (param('list') eq 'distwhores'){
+       $list = '&amp;list=distwhores';
+       $where = qq{WHERE dists > 0 $show
+ORDER BY dists DESC,COALESCE(sec_centres::float/structures*100,0)ASC}
+}else{
+       $where = qq{WHERE MaxResHack > 130000 
+               $show
+ORDER BY COALESCE(sec_centres::float/structures*100,0) ASC,MaxResHack DESC,metal+crystal+eonium DESC};
+}
+
+my $query = $DBH->prepare(qq{SELECT id, coords, metal, crystal, eonium, sec_centres::float/structures*100 AS secs, dists, last_covop, username, MaxResHack
+FROM (SELECT p.id,coords(x,y,z), metal,crystal,eonium,
+       sec_centres,NULLIF(structures,0) AS structures,dists,last_covop,
+       u.username,max_bank_hack(metal,crystal,eonium,p.value,(SELECT value FROM
+       current_planet_stats WHERE id = ?)) AS MaxResHack, planet_status, relationship
+FROM covop_targets c JOIN current_planet_stats p ON p.id = c.planet
+       LEFT OUTER JOIN users u ON u.uid = c.covop_by) AS foo
+       $where});
+$query->execute($ND::PLANET);
+
+my @targets;
+while (my ($id,$coords,$metal,$crystal,$eonium,$seccents,$dists,$lastcovop,$user,$max) = $query->fetchrow){
+       push @targets,{Username => $user, Target => $id, Coords => $coords
+               , Metal => $metal, Crystal => $crystal, Eonium => $eonium, SecCents => $seccents
+               , Dists => $dists, MaxResHack => $max, LastCovOp => $lastcovop, List => $list};
+}
+$BODY->param(Targets => \@targets);
+
+1;
index 03f62f1b9779a956b2abb739c2b12a230e882743..ddc0da7c659cd8d66005397c96a566c43b328312 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -66,7 +66,7 @@ while (my ($name,$attack,$gid) = $query->fetchrow()){
 our $LOG = $DBH->prepare('INSERT INTO log (uid,text) VALUES(?,?)');
 
 my $page = 'main';
-if (param('page') =~ /^(main|check|motd|points)$/){
+if (param('page') =~ /^(main|check|motd|points|covop)$/){
        $page = $1;
 }
 
index 18f38c34f9a177873517e5442d6ea5b8776d9d1c..c75130c361fbab5390f54d065d3b17c67045ac33 100644 (file)
--- a/points.pl
+++ b/points.pl
@@ -19,7 +19,7 @@
 
 use strict;
 
-$ND::TEMPLATE->param(TITLE => 'Edit MOTD');
+$ND::TEMPLATE->param(TITLE => 'Top Members');
 
 our $BODY;
 our $DBH;
diff --git a/templates/covop.tmpl b/templates/covop.tmpl
new file mode 100644 (file)
index 0000000..29d36b1
--- /dev/null
@@ -0,0 +1,18 @@
+<table border="1">
+       <tr>
+       <th>Coords</th><th>Metal</th><th>Crystal</th><th>Eonium</th><th>% Sec Centres</th><th>Dists</th><th>Max (15 agents)</th><th>Last covop (tick)</th>
+       </tr>
+       <TMPL_LOOP Targets>
+       <tr align="center">
+       <td><a href="index.pl?page=check&amp;coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords></a></td>
+       <td><TMPL_VAR NAME=Metal></td>
+       <td><TMPL_VAR NAME=Crystal></td>
+       <td><TMPL_VAR NAME=Eonium></td>
+       <td><TMPL_VAR NAME=SecCents></td>
+       <td><TMPL_VAR NAME=Dists></td>
+       <td><TMPL_VAR NAME=MaxResHack></td>
+       <td><TMPL_VAR NAME=Username> (<TMPL_VAR NAME=LastCovOp>)</td>
+       <td><a href="index.pl?page=covop<TMPL_VAR NAME=List>&amp;covop=<TMPL_VAR NAME=Target>">Did CovOp this tick</a>
+       </tr>
+       </TMPL_LOOP>
+</table>
index f7ab88177f2f23020262ec91f8c604c775dc5d91..f3c99461c9e2ee653a19bdf0ff4714360c781f06 100644 (file)
@@ -19,8 +19,8 @@
                        <li><a href="index.pl?page=points">Top members</a></li>
                        <li><a href="index.pl?page=addintel.php">Add intel/scans</a></li>
                        <li><a href="index.pl?page=launchConfirmation.php">Launch confirmation</a></li>
-                       <li><a href="index.pl?page=covop.php">CovOp targets</a></li>
-                       <li><a href="index.pl?page=covop.php?list=distwhores">Distwhores</a></li>
+                       <li><a href="index.pl?page=covop">CovOp targets</a></li>
+                       <li><a href="index.pl?page=covop&amp;list=distwhores">Distwhores</a></li>
                        <li><a href="index.pl?page=top100.php">Top100 planets</a></li>
                        <li><a href="index.pl?page=defrequest.php">Request defense</a></li>
                </ul>