]> ruin.nu Git - ndwebbie.git/blobdiff - index.pl
fix some links that were bad
[ndwebbie.git] / index.pl
index e0da7c0d710cf4441bdb67608108b29c5741a52f..f9a534539ba86c8d1272a8feb00be22db666af47 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -32,8 +32,9 @@ chdir $ENV{'DOCUMENT_ROOT'};
 
 our $DBH = undef;
 our $USER = $ENV{'REMOTE_USER'};
+my $error;
 
-our $TEMPLATE = HTML::Template->new(filename => 'templates/skel.tmpl');
+our $TEMPLATE = HTML::Template->new(filename => 'templates/skel.tmpl', global_vars => 1);
 
 for my $file ("db.pl","include.pl"){
        unless (my $return = do $file){
@@ -63,41 +64,48 @@ 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)$/){
+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);
 }
 
 
 unless (my $return = do "${page}.pl"){
-       print "<p><b>couldn't parse $page: $@</b></p>" if $@;
-       print "<p><b>couldn't do $page: $!</b></p>"    unless defined $return;
-       print "<p><b>couldn't run $page</b></p>"       unless $return;
+       $error .= "<p><b>couldn't parse $page: $@</b></p>" if $@;
+       $error .= "<p><b>couldn't do $page: $!</b></p>"    unless defined $return;
+       $error .= "<p><b>couldn't run $page</b></p>"       unless $return;
 }
 
 unless ($XML){
        my $fleetupdate = $DBH->selectrow_array('SELECT landing_tick FROM fleets WHERE uid = ? AND fleet = 0',undef,$UID);
 
+
        $TEMPLATE->param(Tick => $TICK);
        $TEMPLATE->param(isMember => (($TICK - $fleetupdate < 24) || isScanner()) && $PLANET && isMember());
        $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());
        }
+       $TEMPLATE->param(Coords => param('coords') ? param('coords') : '1:1:1');
+       $TEMPLATE->param(Error => $error);
 
 }
 $ND::TEMPLATE->param(BODY => $ND::BODY->output);
@@ -113,7 +121,7 @@ $USER = undef;
 $PLANET = undef;
 $TEMPLATE = undef;
 $TICK = undef;
-%GROUPS = undef;
+undef %GROUPS;
 $ND::BODY = undef;
 
 exit;