From: Michael Andreen Date: Mon, 11 Dec 2006 17:40:11 +0000 (+0000) Subject: some more done X-Git-Url: https://ruin.nu/git/?a=commitdiff_plain;h=ebefd2fb237e23a0f0a189928d3059a54ebabbd5;p=ndwebbie.git some more done --- diff --git a/index.pl b/index.pl index e33d509..6827638 100755 --- a/index.pl +++ b/index.pl @@ -35,7 +35,7 @@ our $PLANET = undef; our $TEMPLATE = undef; our $TICK = undef; -$ND::TEMPLATE = HTML::Template->new(filename => 'skel.tmpl'); +$ND::TEMPLATE = HTML::Template->new(filename => 'templates/skel.tmpl'); for my $file ("db.pl"){ unless (my $return = do $file){ @@ -49,22 +49,39 @@ for my $file ("db.pl"){ ,undef,$ENV{'REMOTE_USER'}); ($TICK) = $DBH->selectrow_array('SELECT tick()',undef); -$TEMPLATE->param(TICK => $TICK); +my $query = $DBH->prepare('SELECT groupname,attack,gid from groupmembers NATURAL JOIN groups WHERE uid = ?'); +$query->execute($UID); -print header; +our $ATTACKER = 0; +our @GROUPS = (); +while (my ($name,$attack,$gid) = $query->fetchrow()){ + push @GROUPS,{name => $name, gid => $gid}; + $ATTACKER = 1 if $attack; +} + + +$TEMPLATE->param(Tick => $TICK); +$TEMPLATE->param(isMember => 1); +$TEMPLATE->param(isAttacker => $ATTACKER); -my $page = 'main.pl'; + + +my $page = 'main'; if (param('page') =~ /^(main)$/){ - $page = "$1.pl"; + $page = $1; } -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; +$ND::BODY = HTML::Template->new(filename => "templates/${page}.tmpl"); + +unless (my $return = do "${page}.pl"){ + print "couldn't parse $page: $@" if $@; + print "couldn't do $page: $!" unless defined $return; + print "couldn't run $page" unless $return; } +print header; +$ND::TEMPLATE->param(BODY => $ND::BODY->output); print $TEMPLATE->output; @@ -74,5 +91,7 @@ $UID = undef; $PLANET = undef; $TEMPLATE = undef; $TICK = undef; +@GROUPS = undef; +$ND::BODY = undef; exit; diff --git a/main.pl b/main.pl index ef9fda8..249fe43 100644 --- a/main.pl +++ b/main.pl @@ -21,4 +21,13 @@ use strict; $ND::TEMPLATE->param(TITLE => 'Main Page'); -$ND::TEMPLATE->param(BODY => 'FUN!'); +our $BODY; + +$BODY->param(Username => 'harv'); +$BODY->param(isMEMBER => 1); +$BODY->param(isHC => 1); +my @groups = map {name => $_->{name}}, @ND::GROUPS; +$BODY->param(Groups => \@groups); + + +1; diff --git a/templates/main.tmpl b/templates/main.tmpl index eeaa27f..b628d22 100644 --- a/templates/main.tmpl +++ b/templates/main.tmpl @@ -1,6 +1,6 @@ -

Hello .

-
Message from HC EDIT - +

Hello .

+
Message from HC EDIT +
Planet/account details
    @@ -11,7 +11,8 @@
  • Scan points:
  • Humor points:
  • Total points:
  • -
  • Member of the following groups:
  • + +
  • Member of the following groups: ,
  • Planet:
  • Size: