our $LOG = $DBH->prepare('INSERT INTO log (uid,text) VALUES(?,?)');
my $page = 'main';
-if (param('page') =~ /^(main|check|motd|points|covop|top100|launchConfirmation)$/){
+if (param('page') =~ /^(main|check|motd|points|covop|top100|launchConfirmation|addintel|defrequest|raids)$/){
$page = $1;
}
-print header;
-$ND::BODY = HTML::Template->new(filename => "templates/${page}.tmpl");
+our $XML = 0;
+$XML = 1 if param('xml') and $page =~ /^(raids)$/;
+
+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");
+}
+
unless (my $return = do "${page}.pl"){
print "<p><b>couldn't parse $page: $@</b></p>" if $@;
print "<p><b>couldn't run $page</b></p>" unless $return;
}
-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(isAttacker => $ATTACKER && (!isMember() || ((($TICK - $fleetupdate < 24) || isScanner()) && $PLANET)));
+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(isAttacker => $ATTACKER && (!isMember() || ((($TICK - $fleetupdate < 24) || isScanner()) && $PLANET)));
+ if ($ATTACKER && (!isMember() || ((($TICK - $fleetupdate < 24) || isScanner()) && $PLANET))){
+ $ND::TEMPLATE->param(Targets => listTargets());
+ }
+}
$ND::TEMPLATE->param(BODY => $ND::BODY->output);
-print $TEMPLATE->output;
+my $output = $TEMPLATE->output;
+print header(-type=> $type, -charset => 'utf-8', -Content_Length => length $output);
+print $output;
$DBH->disconnect;