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

index ddc0da7c659cd8d66005397c96a566c43b328312..62e81c0eae5326b4333fbb9c8c4eab4484d3014c 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|covop)$/){
+if (param('page') =~ /^(main|check|motd|points|covop|top100)$/){
        $page = $1;
 }
 
index 4e6f42366b8bbb1c2772a26b30020f492d743992..3aa7f04245d3bb3f75fe50affee538b6340fd186 100644 (file)
@@ -1,12 +1,12 @@
 <table border="1">
        <tr>
        <th>User</th>
-       <th><a href="points.php?type=total">Total</a></th>
-       <th><a href="points.php?type=defense">Defenses</a></th>
-       <th><a href="points.php?type=attack">Attacks</a></th>
-       <th><a href="points.php?type=scan">Scans</a></th>
-       <th><a href="points.php?type=humor">Humor</a></th>
-       <th><a href="points.php?type=rank">ND Rank</a></th>
+       <th><a href="index.pl?page=points&amp;type=total">Total</a></th>
+       <th><a href="index.pl?page=points&amp;type=defense">Defenses</a></th>
+       <th><a href="index.pl?page=points&amp;type=attack">Attacks</a></th>
+       <th><a href="index.pl?page=points&amp;type=scan">Scans</a></th>
+       <th><a href="index.pl?page=points&amp;type=humor">Humor</a></th>
+       <th><a href="index.pl?page=points&amp;type=rank">ND Rank</a></th>
        </tr>
        <TMPL_LOOP Members>
        <tr>
index f3c99461c9e2ee653a19bdf0ff4714360c781f06..94cece834f3b6a265a6f697fba254b13d14fa972 100644 (file)
@@ -21,8 +21,8 @@
                        <li><a href="index.pl?page=launchConfirmation.php">Launch confirmation</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>
+                       <li><a href="index.pl?page=top100">Top100 planets</a></li>
+                       <li><a href="index.pl?page=defrequest">Request defense</a></li>
                </ul>
                </TMPL_IF>
                <TMPL_IF isATTACKER>
                                <input class="coord" type="text" name="coords" value="1:1:1"/>
                                <input class="coord" type="submit" value="Check"/>
                                </p></form></li>
-                       <li><a href="index.pl?page=raids.php">Web raids</a></li>
-                       <li><a href="oldraids.php">Old raid page (Raid page for Internet Explorer users)</a></li>
+                       <li><a href="index.pl?page=raids">Web raids</a></li>
                </ul><div id="targets"></div>
                </TMPL_IF>
                <TMPL_IF isBC>
                <p>BC menu</p>
                <ul class="linkbar">
-                       <li><a href="index.pl?page=editRaid.php">Create raid</a></li>
+                       <li><a href="index.pl?page=editRaid">Create raid</a></li>
                </ul>
                </TMPL_IF>
                <TMPL_IF isDC>
                <p>DC menu</p>
                <ul class="linkbar">
-                       <li><a href="index.pl?page=calls.php">Defense calls</a></li>
-                       <li><a href="index.pl?page=calls.php?show=uncovered">Not covered calls</a></li>
-                       <li><a href="index.pl?page=calls.php?show=covered">Covered calls</a></li>
-                       <li><a href="index.pl?page=calls.php?show=all">All calls</a></li>
+                       <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>
                </ul>
                </TMPL_IF>
                <TMPL_IF isHC>
                <p>HC menu</p>
                <ul class="linkbar">
-                       <li><a href="index.pl?page=users.php">List users</a></li>
-                       <li><a href="index.pl?page=intel.php">Intel</a></li>
-                       <li><a href="index.pl?page=alliances.php">Alliances</a></li>
-                       <li><a href="index.pl?page=allianceStatus.php">Alliance status</a></li>
-                       <li><a href="index.pl?page=allianceRes.php">Alliance resources</a></li>
+                       <li><a href="index.pl?page=users">List users</a></li>
+                       <li><a href="index.pl?page=intel">Intel</a></li>
+                       <li><a href="index.pl?page=alliances">Alliances</a></li>
+                       <li><a href="index.pl?page=allianceStatus">Alliance status</a></li>
+                       <li><a href="index.pl?page=allianceRes">Alliance resources</a></li>
                </ul>
                </TMPL_IF>
        <TMPL_VAR NAME=LEFTBAR>
diff --git a/templates/top100.tmpl b/templates/top100.tmpl
new file mode 100644 (file)
index 0000000..9376977
--- /dev/null
@@ -0,0 +1,34 @@
+<p><a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=PrevOffset>&amp;order=<TMPL_VAR NAME=Order>">Previous 100</a>
+       <a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=NextOffset>&amp;order=<TMPL_VAR NAME=Order>">Next 100</a></p>
+<table border="1">
+       <tr>
+       <tr><th>Coords</th><th>Planet</th><th>Race</th>
+       <th><a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=Offset>&amp;order=sizerank">Size (rank)</a></th>
+       <th><a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=Offset>&amp;order=scorerank">Score (rank)</a></th>
+       <th><a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=Offset>&amp;order=valuerank">Value (rank)</a></th>
+       <th><a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=Offset>&amp;order=xprank">XP (rank)</a></th>
+       <TMPL_IF isHC>
+       <th>Nick</th>
+       <th><a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=Offset>&amp;order=hit_us">Hit us</a></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>
+       <TMPL_IF isHC>
+       <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>
+<p><a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=PrevOffset>&amp;order=<TMPL_VAR NAME=Order>">Previous 100</a>
+       <a href="index.pl?page=top100&amp;offset=<TMPL_VAR NAME=NextOffset>&amp;order=<TMPL_VAR NAME=Order>">Next 100</a></p>
diff --git a/top100.pl b/top100.pl
new file mode 100644 (file)
index 0000000..27219e0
--- /dev/null
+++ b/top100.pl
@@ -0,0 +1,74 @@
+#**************************************************************************
+#   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 => '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;