From: Michael Andreen Date: Tue, 12 Dec 2006 11:59:36 +0000 (+0000) Subject: top100 and minor fixes X-Git-Url: https://ruin.nu/git/?a=commitdiff_plain;h=64df4f268381089651b2067a1c09d22004c4f04b;p=ndwebbie.git top100 and minor fixes --- diff --git a/index.pl b/index.pl index ddc0da7..62e81c0 100755 --- 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|covop)$/){ +if (param('page') =~ /^(main|check|motd|points|covop|top100)$/){ $page = $1; } diff --git a/templates/points.tmpl b/templates/points.tmpl index 4e6f423..3aa7f04 100644 --- a/templates/points.tmpl +++ b/templates/points.tmpl @@ -1,12 +1,12 @@ - - - - - - + + + + + + diff --git a/templates/skel.tmpl b/templates/skel.tmpl index f3c9946..94cece8 100644 --- a/templates/skel.tmpl +++ b/templates/skel.tmpl @@ -21,8 +21,8 @@
  • Launch confirmation
  • CovOp targets
  • Distwhores
  • -
  • Top100 planets
  • -
  • Request defense
  • +
  • Top100 planets
  • +
  • Request defense
  • @@ -33,33 +33,32 @@

    -
  • Web raids
  • -
  • Old raid page (Raid page for Internet Explorer users)
  • +
  • Web raids
  • BC menu

    DC menu

    HC menu

    diff --git a/templates/top100.tmpl b/templates/top100.tmpl new file mode 100644 index 0000000..9376977 --- /dev/null +++ b/templates/top100.tmpl @@ -0,0 +1,34 @@ +

    Previous 100 + Next 100

    +
    UserTotalDefensesAttacksScansHumorND RankTotalDefensesAttacksScansHumorND Rank
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CoordsPlanetRaceSize (rank)Score (rank)Value (rank)XP (rank)NickHit usAlliance
    +

    Previous 100 + Next 100

    diff --git a/top100.pl b/top100.pl new file mode 100644 index 0000000..27219e0 --- /dev/null +++ b/top100.pl @@ -0,0 +1,74 @@ +#************************************************************************** +# 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; + +$ND::TEMPLATE->param(TITLE => 'Top100 '); + +our $BODY; +our $DBH; +our $LOG; + +$BODY->param(isHC => isHC()); + + +die "You don't have access" unless isMember(); + +my $offset = 0; +if (param('offset') =~ /^(\d+)$/){ + $offset = $1; +} +$BODY->param(Offset => $offset); +$BODY->param(PrevOffset => $offset - 100); +$BODY->param(NextOffset => $offset + 100); + +my $order = 'scorerank'; +if (param('order') =~ /^(scorerank|sizerank|valuerank|xprank|hit_us)$/){ + $order = $1; +} +$BODY->param(Order => $order); +$order .= ' DESC' if ($order eq 'hit_us'); + + +my $extra_columns = ''; +if (isHC()){ + $extra_columns = ",planet_status,hit_us, alliance,relationship,nick"; +} +my $query = $DBH->prepare(qq{SELECT id,coords(x,y,z), ruler, planet,race, + size, score, value, xp, sizerank, scorerank, valuerank, xprank + $extra_columns FROM current_planet_stats ORDER BY $order LIMIT 100 OFFSET $offset}); +$query->execute; +my @planets; +while (my ($id,$coords,$ruler,$planet,$race,$size,$score,$value,$xp,$sizerank,$scorerank,$valuerank,$xprank + ,$planet_status,$hit_us,$alliance,$relationship,$nick) = $query->fetchrow){ + my %planet = (Coords => $coords, Planet => "$ruler OF $planet", Race => $race, Size => "$size ($sizerank)" + , Score => "$score ($scorerank)", Value => "$value ($valuerank)", XP => "$xp ($xprank)"); + if (isHC){ + $planet{HitUs} = $hit_us; + $planet{Alliance} = "$alliance ($relationship)"; + $planet{Nick} = "$nick ($planet_status)"; + $planet{PlanetStatus} = $planet_status; + $planet{Relationship} = $relationship; + $planet{isHC} = 1; + } + push @planets,\%planet; +} +$BODY->param(Planets => \@planets); + +1;