]> ruin.nu Git - ndwebbie.git/blobdiff - index.pl
empty row each 24 ticks
[ndwebbie.git] / index.pl
index e557be179b6bc51e6c3e03f71008c86e4dacf9ac..abedcdfc83464c5e4247414554705069be8e50e9 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -w -T
 #**************************************************************************
 #   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
 #                                                                         *
@@ -25,16 +25,16 @@ use DBI;
 use DBD::Pg qw(:pg_types);
 use strict;
 
-
 my $cgi = new CGI;
-
-chdir $ENV{'DOCUMENT_ROOT'};
-
 our $DBH = undef;
 our $USER = $ENV{'REMOTE_USER'};
 my $error;
 
-our $TEMPLATE = HTML::Template->new(filename => 'templates/skel.tmpl');
+if ($ENV{'DOCUMENT_ROOT'} =~ m{((\w|/)+)}){
+       chdir $1;
+}
+
+our $TEMPLATE = HTML::Template->new(filename => 'templates/skel.tmpl', global_vars => 1);
 
 for my $file ("db.pl","include.pl"){
        unless (my $return = do $file){
@@ -64,20 +64,23 @@ 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|top100|launchConfirmation|addintel|defrequest|raids|editRaid|calls|intel|users|alliances)$/){
+if (param('page') =~ /^(main|check|motd|points|covop|top100|launchConfirmation|addintel|defrequest|raids|editRaid|calls|intel|users|alliances|memberIntel|resources)$/){
        $page = $1;
 }
 
 our $XML = 0;
 $XML = 1 if param('xml') and $page =~ /^(raids)$/;
 
+our $AJAX = 1;
+
 my $type = 'text/html';
 if ($XML){
        $type = 'text/xml';
        $ND::TEMPLATE = HTML::Template->new(filename => "templates/xml.tmpl");
        $ND::BODY = HTML::Template->new(filename => "templates/${page}.xml.tmpl");
 }else{
-       $ND::BODY = HTML::Template->new(filename => "templates/${page}.tmpl");
+       $ND::BODY = HTML::Template->new(filename => "templates/${page}.tmpl", global_vars => 1);
+       $ND::BODY->param(PAGE => $page);
 }
 
 
@@ -96,6 +99,7 @@ unless ($XML){
        $TEMPLATE->param(isHC => isHC());
        $TEMPLATE->param(isDC => isDC());
        $TEMPLATE->param(isBC => isBC());
+       $TEMPLATE->param(isIntel => isBC());
        $TEMPLATE->param(isAttacker => $ATTACKER && (!isMember() || ((($TICK - $fleetupdate < 24) || isScanner()) && $PLANET)));
        if ($ATTACKER && (!isMember() || ((($TICK - $fleetupdate < 24) || isScanner()) && $PLANET))){
                $ND::TEMPLATE->param(Targets => listTargets());
@@ -117,7 +121,7 @@ $USER = undef;
 $PLANET = undef;
 $TEMPLATE = undef;
 $TICK = undef;
-%GROUPS = undef;
+undef %GROUPS;
 $ND::BODY = undef;
 
 exit;