use strict;
use warnings FATAL => 'all';
use ND::Web::Forum;
+use ND::Include;
our $BODY;
our $DBH;
my $planet;
if (defined param('coords') && param('coords') =~ /^(\d+)(?: |:)(\d+)(?: |:)(\d+)$/){
- my $query = $DBH->prepare(q{SELECT x,y,z,coords(x,y,z),id, nick, alliance,alliance_id, planet_status,channel FROM current_planet_stats
+ my $query = $DBH->prepare(q{SELECT x,y,z,coords(x,y,z),id, nick, alliance,alliance_id, planet_status,channel,ftid FROM current_planet_stats
WHERE x = ? AND y = ? AND z = ?});
- $planet = $DBH->selectrow_hashref($query,undef,$1,$2,$3);
+ $planet = $DBH->selectrow_hashref($query,undef,$1,$2,$3) or $ND::ERROR .= p $DBH->errstr;
}
my $showticks = 'AND (i.tick - i.eta) > (tick() - 48)';
my $thread;
if (defined $planet){
$thread = $DBH->selectrow_hashref(q{SELECT ftid AS id, subject FROM forum_threads
- where planet = $1},undef,$planet->{id}) or $ERROR .= p($DBH->errstr);
+ where ftid = $1},undef,$planet->{ftid}) or $ERROR .= p($DBH->errstr);
}
if (defined param('cmd') && param('cmd') eq 'coords'){
my $value = escapeHTML(param('nick'));
if ($DBH->do(q{UPDATE planets SET nick = ? WHERE id =?}
,undef,$value,$planet->{id})){
+ intel_log $ND::UID,$planet->{id},"Set nick to: $value";
$planet->{nick} = $value;
}else{
$error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
my $value = escapeHTML(param('channel'));
if ($DBH->do(q{UPDATE planets SET channel = ? WHERE id =?}
,undef,$value,$planet->{id})){
+ intel_log $ND::UID,$planet->{id},"Set channel to: $value";
$planet->{channel} = $value;
}else{
$error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
my $value = escapeHTML(param('status'));
if ($DBH->do(q{UPDATE planets SET planet_status = ? WHERE id =?}
,undef,$value,$planet->{id})){
+ intel_log $ND::UID,$planet->{id},"Set planet_status to: $value";
$planet->{planet_status} = $value;
}else{
$error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
if (param('calliance')){
if ($DBH->do(q{UPDATE planets SET alliance_id = NULLIF(?,-1) WHERE id =?}
,undef,param('alliance'),$planet->{id})){
+ intel_log $ND::UID,$planet->{id},"Set alliance_id to: ".param('alliance');
$planet->{alliance_id} = param('alliance');
}else{
$error .= "<p> Something went wrong: ".$DBH->errstr."</p>";