our @ISA = qw/Exporter/;
-our @EXPORT = qw/min max log_message/;
+our @EXPORT = qw/min max log_message intel_log/;
sub min {
my ($x,$y) = @_;
my ($uid, $message) = @_;
my $log = $ND::DBH->prepare_cached(q{INSERT INTO forum_posts (ftid,uid,message) VALUES(
(SELECT ftid FROM forum_threads WHERE log_uid = $1),$1,$2)});
- $log->execute($uid,$message);
+ $log->execute($uid,$message) or $ND::ERROR .= p($ND::DBH->errstr);
+}
+
+sub intel_log {
+ my ($uid,$planet, $message) = @_;
+ my $log = $ND::DBH->prepare_cached(q{INSERT INTO forum_posts (ftid,uid,message) VALUES(
+ (SELECT ftid FROM forum_threads WHERE planet = $3),$1,$2)});
+ $log->execute($uid,$message,$planet) or $ND::ERROR .= p($ND::DBH->errstr);
}
1;
use ND::Include;
our $BODY;
our $DBH;
+our $ERROR;
my $error;
$ND::TEMPLATE->param(TITLE => 'Alliances');
}
}
my $coords = param('coords');
+ my $findplanet = $DBH->prepare(q{SELECT id FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?});
my $addplanet = $DBH->prepare(q{
-UPDATE planets SET alliance_id = ?, nick = coalesce(?,nick)
-WHERE id = (SELECT id FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?);
+UPDATE planets SET alliance_id = $2, nick = coalesce($3,nick)
+WHERE id = $1;
});
while ($coords =~ m/(\d+):(\d+):(\d+)(?:\s+nick=\s*(\S+))?/g){
- if ($addplanet->execute($alliance->{id},$4,$1,$2,$3)){
+ my ($id) = $DBH->selectrow_array($findplanet,undef,$1,$2,$3) or $ERROR .= p $DBH->errstr;
+ if ($addplanet->execute($id,$alliance->{id},$4)){
my $nick = '';
$nick = '(nick $4)' if defined $4;
$error .= "<p> Added planet $1:$2:$3 $nick to this alliance</p>";
- log_message $ND::UID,"HC Added planet $1:$2:$3 $nick to alliance: $alliance->{id}";
+ intel_log $ND::UID,$id,"HC Added planet $1:$2:$3 $nick to alliance: $alliance->{id} ($alliance->{name})";
}else{
$error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
}
use strict;
use warnings FATAL => 'all';
use ND::Web::Forum;
+use ND::Include;
our $BODY;
our $DBH;
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>";