--- /dev/null
+#!/usr/bin/perl -w
+#**************************************************************************
+# 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. *
+#**************************************************************************/
+
+package ND;
+use CGI qw/:standard/;
+use HTML::Template;
+use DBI;
+use DBD::Pg qw(:pg_types);
+use strict;
+
+my $cgi = new CGI;
+
+chdir $ENV{'DOCUMENT_ROOT'};
+
+our $DBH = undef;
+our $UID = undef;
+our $PLANET = undef;
+our $TEMPLATE = undef;
+our $TICK = undef;
+
+$ND::TEMPLATE = HTML::Template->new(filename => 'skel.tmpl');
+
+for my $file ("db.pl"){
+ unless (my $return = do $file){
+ warn "couldn't parse $file: $@" if $@;
+ warn "couldn't do $file: $!" unless defined $return;
+ warn "couldn't run $file" unless $return;
+ }
+}
+
+($UID,$PLANET) = $DBH->selectrow_array('SELECT uid,planet FROM users WHERE username = ?'
+ ,undef,$ENV{'REMOTE_USER'});
+
+($TICK) = $DBH->selectrow_array('SELECT tick()',undef);
+$TEMPLATE->param(TICK => $TICK);
+
+
+print header;
+
+my $page = 'main.pl';
+if (param('page') =~ /^(main)$/){
+ $page = "$1.pl";
+}
+
+unless (my $return = do $page){
+ warn "couldn't parse $page: $@" if $@;
+ warn "couldn't do $page: $!" unless defined $return;
+ warn "couldn't run $page" unless $return;
+}
+
+print $TEMPLATE->output;
+
+
+$DBH->disconnect;
+$DBH = undef;
+$UID = undef;
+$PLANET = undef;
+$TEMPLATE = undef;
+$TICK = undef;
+
+exit;
--- /dev/null
+#**************************************************************************
+# 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 => 'Main Page');
+
+$ND::TEMPLATE->param(BODY => 'FUN!');
--- /dev/null
+<p>Hello <TMPL_VAR=Username>.</p>
+<fieldset> <legend>Message from HC<TMPL_IF isHC> <a href="index.pl?page=motd">EDIT</TMPL_IF></a></legend>
+ <TMPL_VAR=MOTD>
+</fieldset>
+<fieldset> <legend>Planet/account details</legend>
+ <ul>
+ <TMPL_IF isMEMBER>
+ <li> ND rank (by score): <TMPL_VAR NAME=NDRank> </li>
+ <li> Defense points: <TMPL_VAR NAME=DefensePoints> </li>
+ <li> Attack points: <TMPL_VAR NAME=AttackPoints> </li>
+ <li> Scan points: <TMPL_VAR NAME=ScanPoints> </li>
+ <li> Humor points: <TMPL_VAR NAME=HumorPoints> </li>
+ <li> Total points: <TMPL_VAR NAME=TotalPoints> </li>
+ <li> Member of the following groups: <TMPL_VAR NAME=Groups></li>
+ <TMPL_IF hasPLANET>
+ <li>Planet: <TMPL_VAR NAME=PlanetName></li>
+ <li>Size: <TMPL_VAR NAME=PlanetSize></li>
+ <li>Score: <TMPL_VAR NAME=PlanetScore></li>
+ <li>Value: <TMPL_VAR NAME=PlanetValue></li>
+ <li>XP: <TMPL_VAR NAME=PlanetXP></li>
+ <TMPL_ELSE>
+ <TMPL_IF isMEMBER>
+ <form action="index.pl?page=main" method="post">
+ <p>We need your planet's coordinates:
+ <input type="text" name="planet" value=""/>
+ <input type="submit" value="Submit"/>
+ </p>
+ </form>
+ </TMPL_IF>
+ </TMPL_IF>
+ </ul>
+</fieldset>
+<fieldset> <legend>Fleets</legend>
+ <table>
+ <tr><th>Target</th><th>Mission</th><th>Amount</th><th>Landing Tick</th></tr></table>
+</fieldset>
+<form action="/index.pl" method="post">
+<fieldset> <legend>SMS</legend>
+ <p>Number:
+ <input type="text" name="sms" value="+46730506275"/>
+ <input type="submit" value="Submit"/>
+ </p>
+</fieldset>
+</form>
+<form action="/index.php" method="post">
+<fieldset> <legend>Fleet</legend>
+ <p>Paste your total fleet from ships section on overview here (do it daily to see the menus):</p>
+ <textarea rows="15" cols="50" name="fleet"></textarea>
+ <input type="hidden" name="cmd" value="fleet"/>
+ <br/><input type="submit" value="Submit"/>
+</fieldset>
+</form>
+<form action="/index.php" method="post">
+<fieldset> <legend>Change password</legend>
+ <p>Old password:
+ <input type="password" name="oldpass" value=""/>
+ New password:
+ <input type="password" name="pass" value=""/>
+ <input type="submit" value="Submit"/>
+ </p>
+</fieldset>
+</form>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>NewDawn: <TMPL_VAR NAME=TITLE></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
+ <link rel="stylesheet" type="text/css" href="nd.css"/>
+ <TMPL_VAR NAME=HEADER>
+</head>
+<body>
+<div id="leftbar">
+ <ul class="linkbar">
+ <li><a href="index.pl?page=main">Main page</a></li>
+ </ul> <p>Tick: <TMPL_VAR NAME=TICK></p>
+ <TMPL_IF isMEMBER>
+ <p>Member menu</p>
+ <ul class="linkbar">
+ <li><a href="index.pl?page=points.php">Top members</a></li>
+ <li><a href="index.pl?page=addintel.php">Add intel/scans</a></li>
+ <li><a href="index.pl?page=launchConfirmation.php">Launch confirmation</a></li>
+ <li><a href="index.pl?page=covop.php">CovOp targets</a></li>
+ <li><a href="index.pl?page=covop.php?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>
+ </ul>
+ </TMPL_IF>
+ <TMPL_IF isATTACKER>
+ <p>Attack menu</p>
+ <ul class="linkbar">
+ <li><form action="index.pl?page=check.php" method="post"><p>
+ <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>
+ </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>
+ </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>
+ </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>
+ </ul>
+ </TMPL_IF>
+ <TMPL_VAR NAME=LEFTBAR>
+</div>
+<TMPL_VAR NAME=BODY>
+</body>
+</html>