]> ruin.nu Git - ndwebbie.git/commitdiff
inital commit of the check page
authorMichael Andreen <harv@ruin.nu>
Mon, 11 Dec 2006 21:31:58 +0000 (21:31 +0000)
committerMichael Andreen <harv@ruin.nu>
Mon, 11 Dec 2006 21:31:58 +0000 (21:31 +0000)
check.pl [new file with mode: 0644]
include.pl
index.pl
templates/check.tmpl [new file with mode: 0644]
templates/skel.tmpl

diff --git a/check.pl b/check.pl
new file mode 100644 (file)
index 0000000..ec73c68
--- /dev/null
+++ b/check.pl
@@ -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.         *
+#**************************************************************************/
+
+use strict;
+
+$ND::TEMPLATE->param(TITLE => 'Check planets and galaxies');
+
+our $BODY;
+our $DBH;
+
+$BODY->param(isBC => isMember() && (isOfficer() || isBC));
+
+
+die "You don't have access" unless $ND::ATTACKER;
+
+my ($x,$y,$z);
+if (param('coords') =~ /(\d+)(?: |:)(\d+)(?:(?: |:)(\d+))?(?: |:(\d+))?/){
+       $x = $1;
+       $y = $2;
+       $z = $3;
+}else{
+       die "Bad coords";
+}
+
+if (param('cmd') eq 'arbiter'){
+}
+
+my $where = '';
+my $extra_columns = '';
+
+$where = 'AND z = ?' if defined $z;
+if (isMember() && isOfficer()){
+       $extra_columns = ",planet_status,hit_us, alliance,relationship,nick";
+}elsif (isMember() && isBC()){
+       $extra_columns = ", planet_status,hit_us, alliance,relationship";
+}
+
+my $query = $DBH->prepare(qq{Select id,coords(x,y,z), ((ruler || ' OF ') || p.planet) as planet,race, size, score, value, xp, sizerank, scorerank, valuerank, xprank, p.value - p.size*200 - coalesce(c.metal+c.crystal+c.eonium,0)/150 - coalesce(c.structures,(SELECT avg(structures) FROM covop_targets)::int)*1500 AS fleetvalue,(c.metal+c.crystal+c.eonium)/100 AS resvalue  $extra_columns from current_planet_stats p LEFT OUTER JOIN covop_targets c ON p.id = c.planet where x = ? AND y = ? $where order by x,y,z asc});
+
+if (defined $z){
+       $query->execute($x,$y,$z);
+}else{
+       $query->execute($x,$y);
+}
+my @planets;
+while (my ($id,$coords,$planet,$race,$size,$score,$value,$xp,$sizerank,$scorerank,$valuerank,$xprank
+               ,$fleetvalue,$resvalue,$planet_status,$hit_us,$alliance,$relationship,$nick) = $query->fetchrow){
+       my %planet = (Coords => $coords, Planet => $planet, Race => $race, Size => "$size ($sizerank)"
+               , Score => "$score ($scorerank)", Value => "$value ($valuerank)", XP => "$xp ($xprank)"
+               , FleetValue => "$fleetvalue ($resvalue)");
+       if (isMember() && (isOfficer() || isBC())){
+               $planet{HitUs} = $hit_us;
+               $planet{Alliance} = "$alliance ($relationship)";
+               $planet{Nick} = "$nick ($planet_status)";
+               $planet{PlanetStatus} = $planet_status;
+               $planet{Relationship} = $relationship;
+               $planet{isBC} = 1;
+       }
+       push @planets,\%planet;
+}
+$BODY->param(Planets => \@planets);
+
+1;
index eab857ee916101c6c0fff8631c96d099577c4eda..cb27693ad98045eb1a947189119942749a44bf70 100644 (file)
@@ -36,6 +36,10 @@ sub isBC {
        return exists $ND::GROUPS{BC};
 }
 
+sub isOfficer {
+       return exists $ND::GROUPS{Officers};
+}
+
 sub parseMarkup {
        my ($text) = @_;
 
index bfb7a738813a39aec091cf9e114954606d86e70c..1b55a133f8c3b74b9ccc1d4a21208ebe9e0958fc 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -68,13 +68,14 @@ $TEMPLATE->param(isDC => isDC());
 $TEMPLATE->param(isBC => isBC());
 $TEMPLATE->param(isAttacker => $ATTACKER);
 
-
+our $LOG = $DBH->prepare('INSERT INTO log (uid,text) VALUES(?,?)');
 
 my $page = 'main';
-if (param('page') =~ /^(main)$/){
+if (param('page') =~ /^(main|check)$/){
        $page = $1;
 }
 
+print header;
 $ND::BODY = HTML::Template->new(filename => "templates/${page}.tmpl");
 
 unless (my $return = do "${page}.pl"){
@@ -83,7 +84,6 @@ unless (my $return = do "${page}.pl"){
        print "<p><b>couldn't run $page</b></p>"       unless $return;
 }
 
-print header;
 $ND::TEMPLATE->param(BODY => $ND::BODY->output);
 print $TEMPLATE->output;
 
diff --git a/templates/check.tmpl b/templates/check.tmpl
new file mode 100644 (file)
index 0000000..bdfd593
--- /dev/null
@@ -0,0 +1,15 @@
+<p><a href="index.pl?page=check&amp;cmd=arbiter&amp;coords=<TMPL_VAR NAME=Coords>">Do arbiter check on gal</a></p>
+<table border="1">
+       <tr><th>Coords</th><th>Planet</th><th>Race</th><th>Size (rank)</th><th>Score (rank)</th><th>Value (rank)</th>
+               <th>XP (rank)</th><th>Fleet (Resouce) value</th><TMPL_IF isBC><th>Nick</th><th>Hit us</th><th>Alliance</th></TMPL_IF>
+       </tr>
+       <TMPL_LOOP Planets>
+       <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=Planet></td><td><TMPL_VAR NAME=Race></td><td><TMPL_VAR NAME=Size></td>
+               <td><TMPL_VAR NAME=Score></td><td><TMPL_VAR NAME=Value></td><td><TMPL_VAR NAME=XP></td>
+               <td><TMPL_VAR NAME=FleetValue></td><TMPL_IF isBC><td class="<TMPL_VAR NAME=PlanetStatus>"><TMPL_VAR NAME=Nick></td><td><TMPL_VAR NAME=HitUs></td>
+               <td class="<TMPL_VAR NAME=Relationship>"><TMPL_VAR NAME=Alliance></td></TMPL_IF>
+       </tr>
+</TMPL_LOOP>
+</table>
index e3fa761cd4ae8b92678603666ee62e076a54dc41..03bae8ec41b5117299874751ee59e10640c3c287 100644 (file)
@@ -28,7 +28,8 @@
                <TMPL_IF isATTACKER>
                <p>Attack menu</p>
                <ul class="linkbar">
-                       <li><form action="index.pl?page=check.php" method="post"><p>
+                       <li><form action="index.pl" method="post"><p>
+                               <input type="hidden" name="page" value="check">
                                <input class="coord" type="text" name="coords" value="1:1:1"/>
                                <input class="coord" type="submit" value="Check"/>
                                </p></form></li>