X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND%2FWeb%2FXMLPage.pm;h=d1804f1a02ea2c40d8a7d417209868f460258b81;hb=f82393d21ef37a97155f4603c538a1ad1e0e5844;hp=8381a1fc7035de628816b9770b352b9f11a49f4c;hpb=5e8e40894860b7bab39783a43c32d98d080801c9;p=ndwebbie.git diff --git a/ND/Web/XMLPage.pm b/ND/Web/XMLPage.pm index 8381a1f..d1804f1 100644 --- a/ND/Web/XMLPage.pm +++ b/ND/Web/XMLPage.pm @@ -27,7 +27,7 @@ use ND::Include; use ND::Web::Page; use ND::Web::Include; -our @ISA = qw/ND::Web::Page/; +use base qw/ND::Web::Page/; sub noAccess () { HTML::Template->new(filename => 'templates/NoAccess.tmpl', global_vars => 1, cache => 1); @@ -36,6 +36,32 @@ sub noAccess () { sub process : method { } +sub listTargets () : method { + my $self = shift; + my $DBH = $self->{DBH}; + my $query = $DBH->prepare(qq{SELECT t.id, r.id AS raid, r.tick+c.wave-1 AS landingtick, released_coords, coords(x,y,z),c.launched,c.wave,c.joinable +FROM raid_claims c + JOIN raid_targets t ON c.target = t.id + JOIN raids r ON t.raid = r.id + JOIN current_planet_stats p ON t.planet = p.id +WHERE c.uid = ? AND r.tick+c.wave > ? AND r.open AND not r.removed +ORDER BY r.tick+c.wave,x,y,z}); + $query->execute($ND::UID,$self->{TICK}); + my @targets; + while (my $target = $query->fetchrow_hashref){ + my $coords = "Target $target->{id}"; + $coords = $target->{coords} if $target->{released_coords}; + push @targets,{Coords => $coords, Launched => $target->{launched}, Raid => $target->{raid} + , Target => $target->{id}, Tick => $target->{landingtick}, Wave => $target->{wave} + , AJAX => $self->{AJAX}, JoinName => $target->{joinable} ? 'N' : 'J' + , Joinable => $target->{joinable} ? 'FALSE' : 'TRUE', JoinableTitle => $target->{joinable} ? 'Disable join' : 'Make target joinable'}; + } + my $template = HTML::Template->new(filename => "templates/targetlist.tmpl", cache => 1); + $template->param(Targets => \@targets); + return $template->output; +} + + sub render : method { my $self = shift; my $DBH = $self->{DBH}; @@ -54,6 +80,9 @@ sub render : method { $self->process; my $type = 'text/html'; + if ($self->{HTTP_ACCEPT} =~ m{application/xhtml\+xml}){ + $type = 'application/xhtml+xml' + } my $body; if ($self->{XML}){ $type = 'text/xml'; @@ -66,6 +95,10 @@ sub render : method { $body = $self->render_body($body); + unless ($body){ + return; + } + unless ($self->{XML}){ my $fleetupdate = $DBH->selectrow_array('SELECT landing_tick FROM fleets WHERE uid = ? AND fleet = 0',undef,$self->{UID}); @@ -83,27 +116,22 @@ sub render : method { $template->param(isHC => $self->isHC); $template->param(isDC => $self->isDC()); $template->param(isBC => $self->isBC()); - $template->param(isIntel => $self->isBC()); + $template->param(isIntel => $self->isIntel()); $template->param(isAttacker => $ATTACKER && (!$self->isMember() || ((($TICK - $fleetupdate < 24) || $self->isScanner()) && $self->{PLANET}))); if ($ATTACKER && (!$self->isMember() || ((($TICK - $fleetupdate < 24) || $self->isScanner()) && $self->{PLANET}))){ - $template->param(Targets => listTargets()); + $template->param(Targets => $self->listTargets); } $template->param(Coords => param('coords') ? param('coords') : '1:1:1'); my ($css) = $DBH->selectrow_array(q{SELECT css FROM users WHERE uid = $1},undef,$ND::UID); $template->param(CSS => $css); $template->param(TITLE => $self->{TITLE}); - } $template->param(Error => $ND::ERROR); $template->param(BODY => $body->output); my $output = $template->output; + $output =~ s/[^\x{9}\x{A}\x{D}\x{20}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]//g; print header(-type=> $type, -charset => 'utf-8', -Content_Length => length $output); print $output; - - - $DBH->rollback unless $DBH->{AutoCommit}; - $DBH->disconnect; - }; 1;