]> ruin.nu Git - ndwebbie.git/commitdiff
intel_log
authorMichael Andreen <harv@ruin.nu>
Fri, 5 Jan 2007 09:57:37 +0000 (09:57 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 5 Jan 2007 09:57:37 +0000 (09:57 +0000)
ND/Include.pm
alliances.pl
intel.pl

index 8aa2bd4e76143680f1c8f24216b620cc2f695dc1..889c97d08d50343c3fc91a68fef18ad7874f4a06 100644 (file)
@@ -25,7 +25,7 @@ require Exporter;
 
 our @ISA = qw/Exporter/;
 
 
 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) = @_;
 
 sub min {
     my ($x,$y) = @_;
@@ -41,7 +41,14 @@ sub log_message {
        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)});
        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;
 }
 
 1;
index b78d5ffb6f91b6e6732bfcf152557e138b7e384a..4f89a48f264131c3e28794f7f11d0d67a400cb27 100644 (file)
@@ -22,6 +22,7 @@ use warnings FATAL => 'all';
 use ND::Include;
 our $BODY;
 our $DBH;
 use ND::Include;
 our $BODY;
 our $DBH;
+our $ERROR;
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Alliances');
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Alliances');
@@ -46,16 +47,18 @@ if ($alliance && defined param('cmd') && param ('cmd') eq 'change'){
                }
        }
        my $coords = param('coords');
                }
        }
        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{
        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){
                });
        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>";
                        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>";
                }
                }else{
                        $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                }
index 9ab58647886fe7045962dea1933b8f029cdd3b46..e538411cf8796856fe395e221e13a65fe0d18757 100644 (file)
--- a/intel.pl
+++ b/intel.pl
@@ -20,6 +20,7 @@
 use strict;
 use warnings FATAL => 'all';
 use ND::Web::Forum;
 use strict;
 use warnings FATAL => 'all';
 use ND::Web::Forum;
+use ND::Include;
 
 our $BODY;
 our $DBH;
 
 our $BODY;
 our $DBH;
@@ -85,6 +86,7 @@ if ($planet && defined param('cmd')){
                        my $value = escapeHTML(param('nick'));
                        if ($DBH->do(q{UPDATE planets SET nick = ? WHERE id =?}
                                        ,undef,$value,$planet->{id})){
                        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>";
                                $planet->{nick} = $value;
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
@@ -94,6 +96,7 @@ if ($planet && defined param('cmd')){
                        my $value = escapeHTML(param('channel'));
                        if ($DBH->do(q{UPDATE planets SET channel = ? WHERE id =?}
                                        ,undef,$value,$planet->{id})){
                        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>";
                                $planet->{channel} = $value;
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
@@ -103,6 +106,7 @@ if ($planet && defined param('cmd')){
                        my $value = escapeHTML(param('status'));
                        if ($DBH->do(q{UPDATE planets SET planet_status = ? WHERE id =?}
                                        ,undef,$value,$planet->{id})){
                        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>";
                                $planet->{planet_status} = $value;
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
@@ -111,6 +115,7 @@ if ($planet && defined param('cmd')){
                if (param('calliance')){
                        if ($DBH->do(q{UPDATE planets SET alliance_id = NULLIF(?,-1) WHERE id =?}
                                        ,undef,param('alliance'),$planet->{id})){
                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>";
                                $planet->{alliance_id} = param('alliance');
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";