]> ruin.nu Git - ndwebbie.git/commitdiff
initial commit of calls
authorMichael Andreen <harv@ruin.nu>
Thu, 14 Dec 2006 13:24:31 +0000 (13:24 +0000)
committerMichael Andreen <harv@ruin.nu>
Thu, 14 Dec 2006 13:24:31 +0000 (13:24 +0000)
calls.pl [new file with mode: 0644]
index.pl
templates/calls.tmpl [new file with mode: 0644]
templates/skel.tmpl

diff --git a/calls.pl b/calls.pl
new file mode 100644 (file)
index 0000000..11c4ed7
--- /dev/null
+++ b/calls.pl
@@ -0,0 +1,73 @@
+#**************************************************************************
+#   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;
+use POSIX;
+our $BODY;
+our $DBH;
+our $LOG;
+
+$ND::TEMPLATE->param(TITLE => 'Defense Calls');
+
+die "You don't have access" unless isBC();
+
+
+my $call;
+if (param('call') =~ /^(\d+)$/){
+       my $query = $DBH->prepare(q{});
+       $call = $DBH->selectrow_hashref($query,undef,$1);
+}
+
+if ($call){
+}else{
+       my $where = 'open AND c.landing_tick-6 > tick()';
+       if (param('show') eq 'covered'){
+               $where = 'covered';
+       }elsif (param('show') eq 'all'){
+               $where = 'true';
+       }elsif (param('show') eq 'uncovered'){
+               $where = 'not covered';
+       }
+       my $query = $DBH->prepare(qq{
+SELECT c.id, coords(p.x,p.y,p.z), u.defense_points, c.landing_tick, 
+       TRIM('/' FROM concat(p2.race||'/')) AS race, TRIM('/' FROM concat(i.amount||'/')) AS amount,
+       TRIM('/' FROM concat(i.eta||'/')) AS eta, TRIM('/' FROM concat(i.shiptype||'/')) AS shiptype,
+       TRIM('/' FROM concat(c.landing_tick - tick() ||'/')) AS curreta,
+       TRIM('/' FROM concat(p2.alliance ||'/')) AS alliance,
+       TRIM('/' FROM concat(coords(p2.x,p2.y,p2.z) ||'/')) AS attackers
+FROM calls c 
+       JOIN incomings i ON i.call = c.id
+       JOIN users u ON c.member = u.uid
+       JOIN current_planet_stats p ON u.planet = p.id
+       JOIN current_planet_stats p2 ON i.sender = p2.id
+WHERE $where
+GROUP BY c.id, p.x,p.y,p.z, u.username, c.landing_tick, c.info,u.defense_points
+ORDER BY c.landing_tick DESC
+               })or print $DBH->errstr;
+       $query->execute or print $DBH->errstr;
+       my @calls;
+       my $i = 0;
+       while (my $call = $query->fetchrow_hashref){
+               $call->{ODD} = $i % 2;
+               push @calls, $call;
+               $i++;
+       }
+       $BODY->param(Calls => \@calls);
+}
+1;
index e0da7c0d710cf4441bdb67608108b29c5741a52f..3937831a738e81695fbfe29e681184ee0d442956 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -63,7 +63,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|covop|top100|launchConfirmation|addintel|defrequest|raids|editRaid)$/){
+if (param('page') =~ /^(main|check|motd|points|covop|top100|launchConfirmation|addintel|defrequest|raids|editRaid|calls)$/){
        $page = $1;
 }
 
diff --git a/templates/calls.tmpl b/templates/calls.tmpl
new file mode 100644 (file)
index 0000000..b08723d
--- /dev/null
@@ -0,0 +1,20 @@
+<TMPL_IF Call>
+<TMPL_ELSE>
+<table>
+       <tr><th>Call</th><th>Member (def points)</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>Current eta</th><th>Inital eta</th><th>Alliance</th><th>Attackers</th></tr>
+<TMPL_LOOP Calls>
+       <tr align="center" class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+               <td><a href="index.pl?page=calls&amp;call=<TMPL_VAR NAME=Id>"><TMPL_VAR NAME=Id></a></td>
+               <td><TMPL_VAR NAME=Coords> (<TMPL_VAR NAME=Defense_points>)</td>
+               <td><TMPL_VAR NAME=Landing_tick></td>
+               <td><TMPL_VAR NAME=Race></td>
+               <td><TMPL_VAR NAME=Amount></td>
+               <td><TMPL_VAR NAME=Shiptype></td>
+               <td><TMPL_VAR NAME=Curreta></td>
+               <td><TMPL_VAR NAME=Eta></td>
+               <td><TMPL_VAR NAME=Alliance></td>
+               <td><TMPL_VAR NAME=Attackers></td>
+       </tr>
+</TMPL_LOOP>
+</table>
+</TMPL_IF>
index 31c68601807e7b9c67e80777b1a5279ab4dd1fcc..babc5b16036067f5e6ff715f4341c779a3dfe7b1 100644 (file)
@@ -47,9 +47,9 @@
                <p>DC menu</p>
                <ul class="linkbar">
                        <li><a href="index.pl?page=calls">Defense calls</a></li>
-                       <li><a href="index.pl?page=calls?show=uncovered">Not covered calls</a></li>
-                       <li><a href="index.pl?page=calls?show=covered">Covered calls</a></li>
-                       <li><a href="index.pl?page=calls?show=all">All calls</a></li>
+                       <li><a href="index.pl?page=calls&amp;show=uncovered">Not covered calls</a></li>
+                       <li><a href="index.pl?page=calls&amp;show=covered">Covered calls</a></li>
+                       <li><a href="index.pl?page=calls&amp;show=all">All calls</a></li>
                </ul>
                </TMPL_IF>
                <TMPL_IF isHC>