From f9988de5abba670c799cb616d55897a2ff723e54 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Thu, 14 Dec 2006 13:24:31 +0000 Subject: [PATCH] initial commit of calls --- calls.pl | 73 ++++++++++++++++++++++++++++++++++++++++++++ index.pl | 2 +- templates/calls.tmpl | 20 ++++++++++++ templates/skel.tmpl | 6 ++-- 4 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 calls.pl create mode 100644 templates/calls.tmpl diff --git a/calls.pl b/calls.pl new file mode 100644 index 0000000..11c4ed7 --- /dev/null +++ b/calls.pl @@ -0,0 +1,73 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# 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; diff --git a/index.pl b/index.pl index e0da7c0..3937831 100755 --- 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 index 0000000..b08723d --- /dev/null +++ b/templates/calls.tmpl @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + +
CallMember (def points)Landing tickRacesAmountShiptypesCurrent etaInital etaAllianceAttackers
()
+
diff --git a/templates/skel.tmpl b/templates/skel.tmpl index 31c6860..babc5b1 100644 --- a/templates/skel.tmpl +++ b/templates/skel.tmpl @@ -47,9 +47,9 @@

DC menu

-- 2.39.2