From: Michael Andreen Date: Mon, 11 Dec 2006 16:35:24 +0000 (+0000) Subject: initial commit of the new perl webbie X-Git-Url: https://ruin.nu/git/?a=commitdiff_plain;h=1a2401c5ecba4d15756cadf0229d203ec5d6de54;p=ndwebbie.git initial commit of the new perl webbie --- diff --git a/index.pl b/index.pl new file mode 100755 index 0000000..e33d509 --- /dev/null +++ b/index.pl @@ -0,0 +1,78 @@ +#!/usr/bin/perl -w +#************************************************************************** +# 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. * +#**************************************************************************/ + +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; diff --git a/main.pl b/main.pl new file mode 100644 index 0000000..ef9fda8 --- /dev/null +++ b/main.pl @@ -0,0 +1,24 @@ +#************************************************************************** +# 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 => 'Main Page'); + +$ND::TEMPLATE->param(BODY => 'FUN!'); diff --git a/templates/main.tmpl b/templates/main.tmpl new file mode 100644 index 0000000..eeaa27f --- /dev/null +++ b/templates/main.tmpl @@ -0,0 +1,62 @@ +

Hello .

+
Message from HC EDIT + +
+
Planet/account details +
    + +
  • ND rank (by score):
  • +
  • Defense points:
  • +
  • Attack points:
  • +
  • Scan points:
  • +
  • Humor points:
  • +
  • Total points:
  • +
  • Member of the following groups:
  • + +
  • Planet:
  • +
  • Size:
  • +
  • Score:
  • +
  • Value:
  • +
  • XP:
  • + + +
    +

    We need your planet's coordinates: + + +

    +
    +
    +
    +
+
+
Fleets + +
TargetMissionAmountLanding Tick
+
+
+
SMS +

Number: + + +

+
+
+
+
Fleet +

Paste your total fleet from ships section on overview here (do it daily to see the menus):

+ + +
+
+
+
+
Change password +

Old password: + + New password: + + +

+
+
diff --git a/templates/skel.tmpl b/templates/skel.tmpl new file mode 100644 index 0000000..e3fa761 --- /dev/null +++ b/templates/skel.tmpl @@ -0,0 +1,68 @@ + + + + + NewDawn: <TMPL_VAR NAME=TITLE> + + + + + + + + +