]> ruin.nu Git - ndwebbie.git/commitdiff
removed in favor of ND::Include::log_message
authorMichael Andreen <harv@ruin.nu>
Fri, 5 Jan 2007 09:09:41 +0000 (09:09 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 5 Jan 2007 09:09:41 +0000 (09:09 +0000)
21 files changed:
ND.pm
ND/Web/AuthHandler.pm
addintel.pl
alliances.pl
calls.pl
check.pl
covop.pl
defrequest.pl
editRaid.pl
intel.pl
launchConfirmation.pl
main.pl
memberIntel.pl
motd.pl
planetNaps.pl
points.pl
raids.pl
resources.pl
startup.pl
top100.pl
users.pl

diff --git a/ND.pm b/ND.pm
index 7d9c8c08b2677cbc27e4ae5e64fe47e6cc3ab849..8539d1e5256df0199a78331d009fd86ea5051514 100755 (executable)
--- a/ND.pm
+++ b/ND.pm
@@ -81,9 +81,6 @@ sub page {
                $ATTACKER = 1 if $attack;
        }
 
-
-       our $LOG = $DBH->prepare('INSERT INTO log (uid,text) VALUES(?,?)');
-
        tie my @pages, 'Tie::File', "/var/www/ndawn/code/pages", mode => O_RDONLY, memory => 0 or die $!;
        $ND::PAGE = 'main' unless grep { /^$ND::PAGE$/ } @pages;
 
index 60204b0e8171e7a4e56826607469787480dbe65a..45428d8f676f1548e8f039053a46985c99930105 100644 (file)
@@ -24,6 +24,7 @@ use warnings FATAL => 'all';
 
 use ND::DB;
 use Apache2::Access ();
+use again;
 
 sub handler {
        my $r = shift;
@@ -35,6 +36,7 @@ sub handler {
                lower(username) = lower(?) AND password = MD5(?)},undef,$r->user,$sent_pw);
        $dbh->disconnect;
        if ($count == 1){
+               do 'reload.pl';
                return Apache2::Const::OK;
        }
        $r->note_basic_auth_failure();
index 5e65ad76b565bc2a34db2270c42fcf5757e8020c..405bece7b90361acb46b5ac65b4c5c7138e4eb67 100644 (file)
@@ -24,7 +24,6 @@ $ND::TEMPLATE->param(TITLE => 'Add Intel and Scans');
 
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 die "You don't have access" unless isMember();
index 8b5830836b8db4d63d9ef2aa5c2943879acda37a..b78d5ffb6f91b6e6732bfcf152557e138b7e384a 100644 (file)
@@ -19,9 +19,9 @@
 
 use strict;
 use warnings FATAL => 'all';
+use ND::Include;
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Alliances');
@@ -40,7 +40,7 @@ if ($alliance && defined param('cmd') && param ('cmd') eq 'change'){
                if ($DBH->do(q{UPDATE alliances SET relationship = ? WHERE id =?}
                                ,undef,$value,$alliance->{id})){
                        $alliance->{relationship} = $value;
-                       $LOG->execute($ND::UID,"HC set alliance: $alliance->{id} relationship: $value");
+                       log_message $ND::UID,"HC set alliance: $alliance->{id} relationship: $value";
                }else{
                        $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                }
@@ -55,7 +55,7 @@ WHERE id = (SELECT id FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?)
                        my $nick = '';
                        $nick = '(nick $4)' if defined $4;
                        $error .= "<p> Added planet $1:$2:$3 $nick to this alliance</p>";
-                       $LOG->execute($ND::UID,"HC Added planet $1:$2:$3 $nick to alliance: $alliance->{id}");
+                       log_message $ND::UID,"HC Added planet $1:$2:$3 $nick to alliance: $alliance->{id}";
                }else{
                        $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                }
index c09b6067acdacf6b87bda1b9514f2d975ddb561e..1f779d6244bf8d1cb3ad3538c1a5dc039018360f 100644 (file)
--- a/calls.pl
+++ b/calls.pl
@@ -21,7 +21,6 @@ use strict;
 use warnings FATAL => 'all';
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Defense Calls');
@@ -46,7 +45,7 @@ if ($call && defined param('cmd')){
                        if ($DBH->do(q{UPDATE calls SET landing_tick = ? WHERE id = ?}
                                        ,undef,param('tick'),$call->{id})){
                                $call->{landing_tick} = param('tick');
-                               $LOG->execute($ND::UID,"DC updated landing tick for call $call->{id}");
+                               log_message $ND::UID,"DC updated landing tick for call $call->{id}";
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                        }
@@ -55,7 +54,7 @@ if ($call && defined param('cmd')){
                        if ($DBH->do(q{UPDATE calls SET info = ? WHERE id = ?}
                                        ,undef,param('info'),$call->{id})){
                                $call->{info} = param('info');
-                               $LOG->execute($ND::UID,"DC updated info for call $call->{id}");
+                               log_message $ND::UID,"DC updated info for call $call->{id}";
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                        }
@@ -87,7 +86,7 @@ if ($call && defined param('cmd')){
                for my $param (param()){
                        if ($param =~ /^change:(\d+)$/){
                                if($query->execute($1,$call->{id})){
-                                       $LOG->execute($ND::UID,"DC deleted fleet: $1, call $call->{id}");
+                                       log_message $ND::UID,"DC deleted fleet: $1, call $call->{id}";
                                }else{
                                        $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                                }
@@ -101,7 +100,7 @@ if ($call && defined param('cmd')){
                        if ($param =~ /^change:(\d+)$/){
                                my $shiptype = escapeHTML(param("shiptype:$1"));
                                if($query->execute($shiptype,$1,$call->{id})){
-                                       $LOG->execute($ND::UID,"DC set fleet: $1, call $call->{id} to: $shiptype");
+                                       log_message $ND::UID,"DC set fleet: $1, call $call->{id} to: $shiptype";
                                }else{
                                        $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                                }
index 9acf9bf0d89d957189b3028a9c2dc7ba19db089b..04f49d3f4c89cda80677417b1c0baee47a4e67bd 100644 (file)
--- a/check.pl
+++ b/check.pl
 use strict;
 use warnings FATAL => 'all';
 no warnings qw(uninitialized);
+use ND::Include;
 
 $ND::TEMPLATE->param(TITLE => 'Check planets and galaxies');
 
 our $BODY;
 our $DBH;
-our $LOG;
 
 $BODY->param(isBC => isMember() && (isOfficer() || isBC));
 
@@ -51,7 +51,7 @@ if (isMember() && param('cmd') eq 'arbiter'){
        }else{
                $BODY->param(Arbiter => '<b>KILL THESE BASTARDS</b>');
        }
-       $LOG->execute($ND::UID,"Arbiter check on $x:$y");
+       log_message $ND::UID,"Arbiter check on $x:$y";
 }
 
 my $where = '';
@@ -71,7 +71,7 @@ if (defined $z){
 }else{
        $query->execute($x,$y);
        if (isMember() && (isBC() || isOfficer()) && !isHC()){
-               $LOG->execute($ND::UID,"BC browsing $x:$y");
+               log_message $ND::UID,"BC browsing $x:$y";
        }
 }
 my @planets;
@@ -91,7 +91,7 @@ while (my ($id,$coords,$planet,$race,$size,$score,$value,$xp,$sizerank,$scoreran
                $planet{Relationship} = $relationship;
                $planet{isBC} = 1;
                if ($z && $alliance eq 'NewDawn'){
-                       $LOG->execute($ND::UID,"BC browsing ND planet $coords tick $ND::TICK");
+                       log_message $ND::UID,"BC browsing ND planet $coords tick $ND::TICK";
                }
        }
        $i++;
index daf782458281a2e46a1257e236415e101f66c2fe..a07c47f39fa095f66cd6b1c42e34044ecf4380d0 100644 (file)
--- a/covop.pl
+++ b/covop.pl
@@ -24,7 +24,6 @@ $ND::TEMPLATE->param(TITLE => 'CovOp Targets');
 
 our $BODY;
 our $DBH;
-our $LOG;
 
 die "You don't have access" unless isMember();
 
index a80f62caf83beab24307d802fc97cf547c69bba6..c53f372efe587c8326b466605fff612c2a6acf39 100644 (file)
@@ -24,7 +24,6 @@ $ND::TEMPLATE->param(TITLE => 'Request Defense');
 
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 die "You don't have access" unless isMember();
index 1d5e1375c6b39971221c7204996a341bb466c735..94ed68da85685c964d3ef05d55b15759c0bd5e07 100644 (file)
@@ -19,9 +19,9 @@
 
 use strict;
 use warnings FATAL => 'all';
+use ND::Include;
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Create/Edit Raids');
@@ -32,7 +32,7 @@ my @alliances = alliances();
 $BODY->param(Alliances => \@alliances);
 
 my $raid;
-if (param('raid') =~ /^(\d+)$/){
+if (defined param 'raid' and param('raid') =~ /^(\d+)$/){
        my $query = $DBH->prepare(q{SELECT id,tick,waves,message,released_coords,open FROM raids WHERE id = ?});
        $raid = $DBH->selectrow_hashref($query,undef,$1);
 }
@@ -99,7 +99,7 @@ if ($raid && defined param('cmd')){
                        }
                }
                if (param('alliance') =~ /^(\d+)$/ && $1 != 1){
-                       $LOG->execute($ND::UID,"BC adding alliance $1 to raid");
+                       log_message $ND::UID,"BC adding alliance $1 to raid";
                        my $addtarget = $DBH->prepare(qq{INSERT INTO raid_targets(raid,planet) (
        SELECT ?,id FROM current_planet_stats p WHERE alliance_id = ? $sizelimit)});
                        unless ($addtarget->execute($raid->{id},$1)){
@@ -112,6 +112,7 @@ if ($raid && defined param('cmd')){
                $groups->execute();
                while (my $group = $groups->fetchrow_hashref){
                        my $query;
+                       next unless defined param $group->{gid};
                        if (param($group->{gid}) eq 'remove'){
                                $query = $delgroup;
                        }elsif(param($group->{gid}) eq 'add'){
index 7f1ec4a71ded074fc31410ff4e686cbb44b43da6..9ab58647886fe7045962dea1933b8f029cdd3b46 100644 (file)
--- a/intel.pl
+++ b/intel.pl
@@ -23,7 +23,6 @@ use ND::Web::Forum;
 
 our $BODY;
 our $DBH;
-our $LOG;
 our $ERROR;
 my $error;
 
index 39a0ff022fffff7a2d72c609a16caae3463d2e6d..ffe6b11b6c1bb39f524e56437006084d82529315 100644 (file)
 
 use strict;
 use warnings FATAL => 'all';
+use ND::Include;
 
 $ND::TEMPLATE->param(TITLE => 'Launch Confirmation');
 
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 
@@ -56,7 +56,8 @@ if (defined param('cmd') && param('cmd') eq 'submit'){
        while ($missions =~ m/\S+\s+(\d+):(\d+):(\d+)\s+(\d+):(\d+):(\d+)\s+\((?:(\d+)\+)?(\d+)\).*?(?:\d+hrs\s+)?\d+mins\s+(Attack|Defend|Return|Fake Attack|Fake Defend)(.*?)(?:Launching in tick (\d+), arrival in tick (\d+)|ETA: \d+, Return ETA: (\d+))/sg){
                my %mission;
 
-               my $tick = $ND::TICK+$7+$8;
+               my $tick = $ND::TICK+$8;
+               $tick += $7 if defined $7;
                my $eta = $8;
                my $mission = $9;
                my $x = $4;
@@ -92,7 +93,7 @@ if (defined param('cmd') && param('cmd') eq 'submit'){
                                $addattackpoint->execute($ND::UID);
                                $launchedtarget->execute($ND::UID,$claim->{target},$claim->{wave});
                                $mission{Warning} = "OK:$claim->{target},$claim->{wave},$claim->{launched}";
-                               $LOG->execute($ND::UID,"Gave attack point for confirmation on $mission mission to $x:$y:$z, landing tick $tick");
+                               log_message $ND::UID,"Gave attack point for confirmation on $mission mission to $x:$y:$z, landing tick $tick";
                        }
                }
 
@@ -107,7 +108,7 @@ if (defined param('cmd') && param('cmd') eq 'submit'){
                        push @ships,{Ship => $1, Amount => $2};
                }
                $mission{Ships} = \@ships;
-               $LOG->execute($ND::UID,"Pasted confirmation for $mission mission to $x:$y:$z, landing tick $tick");
+               log_message $ND::UID,"Pasted confirmation for $mission mission to $x:$y:$z, landing tick $tick";
                push @missions,\%mission;
        }
        $DBH->commit or $error .= '<p>'.$DBH->errstr.'</p>';
diff --git a/main.pl b/main.pl
index 345b1bea4dd112d8791ca13a3d55dcf889d56b4b..91c347ec9d6049123481cbd881d0deaa08142dda 100644 (file)
--- a/main.pl
+++ b/main.pl
@@ -19,6 +19,7 @@
 
 use strict;
 use warnings FATAL => 'all';
+use ND::Include;
 
 $ND::TEMPLATE->param(TITLE => 'Main Page');
 
@@ -54,7 +55,7 @@ if (defined param('cmd')){
                for my $param (param()){
                        if ($param =~ /^change:(\d+)$/){
                                if($updatefleets->execute($ND::UID,$1)){
-                                       $ND::LOG->execute($ND::UID,"Member recalled fleet $1");
+                                       log_message $ND::UID,"Member recalled fleet $1";
                                }else{
                                        $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                                }
@@ -67,7 +68,7 @@ if (defined param('cmd')){
                for my $param (param()){
                        if ($param =~ /^change:(\d+)$/){
                                if($updatefleets->execute(param("back:$1"),$ND::UID,$1)){
-                                       $ND::LOG->execute($ND::UID,"Member set fleet $1 to be back tick: ".param("back:$1"));
+                                       log_message $ND::UID,"Member set fleet $1 to be back tick: ".param("back:$1");
                                }else{
                                        $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                                }
index 61423242f660bc466f849c3f5ebe0cdeea8463f6..66e0dcd7b70f00be6e2f8cde8b8a345dfb3be91e 100644 (file)
@@ -21,7 +21,6 @@ use strict;
 use warnings FATAL => 'all';
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Member Intel');
diff --git a/motd.pl b/motd.pl
index f69a54a4f1da894581db34285a839f6717d2d7c8..b324cc013c3592ed966f8cd4b29fee61930c099c 100644 (file)
--- a/motd.pl
+++ b/motd.pl
 #**************************************************************************/
 
 use strict;
+use warnings FATAL => 'all';
+use ND::Include;
 
 $ND::TEMPLATE->param(TITLE => 'Edit MOTD');
 
 our $BODY;
 our $DBH;
-our $LOG;
 
 die "You don't have access" unless isHC();
 
-if (param('cmd') eq 'change'){
+if (defined param 'cmd' and param('cmd') eq 'change'){
        $DBH->begin_work;
        my $query = $DBH->prepare(q{UPDATE misc SET value= ? WHERE id='MOTD'});
        my $motd = escapeHTML(param('motd'));
        $query->execute($motd);
-       $LOG->execute($ND::UID,"Updated MOTD");
+       log_message $ND::UID,"Updated MOTD";
        $DBH->commit;
        $BODY->param(MOTD => $motd);
 }else{
index a18e2ac56ee6f6da0e980a0b9303e6a153d7c330..ff5a8370939f73871642256370be5acb01b10312 100644 (file)
@@ -24,7 +24,6 @@ $ND::TEMPLATE->param(TITLE => 'List planet naps');
 
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 die "You don't have access" unless isHC();
index 213fad9d84069e0e3f41d9dd26b229b37fe17e9a..e1a18863d1ed65ff4527f05254c1142083209a67 100644 (file)
--- a/points.pl
+++ b/points.pl
@@ -24,7 +24,6 @@ $ND::TEMPLATE->param(TITLE => 'Top Members');
 
 our $BODY;
 our $DBH;
-our $LOG;
 
 die "You don't have access" unless isMember();
 
index 1ebaad61fb0098ff6b29d3c551cc2ea4ef1c2805..a3cb3cc59170588c523a5d0c69960acaa7810c31 100644 (file)
--- a/raids.pl
+++ b/raids.pl
 
 use strict;
 use warnings FATAL => 'all';
+use ND::Include;
 use POSIX;
 our $BODY;
 our $DBH;
-our $LOG;
 our $XML;
 
 my $raid;
@@ -48,7 +48,7 @@ if (defined param('cmd') && defined param('target') && defined param('wave') &&
                if ($claims->rows == 0){
                        my $query = $DBH->prepare(q{INSERT INTO raid_claims (target,uid,wave) VALUES(?,?,?)});
                        if($query->execute($target,$ND::UID,$wave)){
-                               $LOG->execute($ND::UID,"Claimed target $target wave $wave.");
+                               log_message $ND::UID,"Claimed target $target wave $wave.";
                        }
                }
        }
@@ -60,7 +60,7 @@ if (defined param('cmd') && defined param('target') && defined param('wave') &&
                if ($claims->rows != 0){
                        my $query = $DBH->prepare(q{INSERT INTO raid_claims (target,uid,wave,joinable) VALUES(?,?,?,TRUE)});
                        if($query->execute($target,$ND::UID,$wave)){
-                               $LOG->execute($ND::UID,"Joined target $target wave $wave.");
+                               log_message $ND::UID,"Joined target $target wave $wave.";
                        }
                }
        }
@@ -74,7 +74,7 @@ if (defined param('cmd') && defined param('target') && defined param('wave') &&
        if (param('cmd') eq 'Unclaim'){
                my $query = $DBH->prepare(qq{DELETE FROM raid_claims WHERE target = ? AND uid = ? AND wave = ?});
                if ($query->execute($target,$ND::UID,$wave)){
-                       $LOG->execute($ND::UID,"Unclaimed target $target wave $wave.");
+                       log_message $ND::UID,"Unclaimed target $target wave $wave.";
                }
        }
        $DBH->commit;
index 12955667b3f172e21fdfb80038c161806cd04a42..fa64c3238a3eb4b9505e295738deb22bb145d6e7 100644 (file)
@@ -21,7 +21,6 @@ use strict;
 use warnings FATAL => 'all';
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Alliance Resources');
index 0597587049e5eea8a5eadd096dcdcab008c129b2..30d3163875ba8d282f38bf22ac0cb3d7e9d5161e 100644 (file)
@@ -11,6 +11,7 @@ use DBI;
 use DBD::Pg qw(:pg_types);
 
 use ND::DB;
+use ND::Include;
 use ND::Web::Include;
 use ND::Web::Forum;
 
index ccd681be7080a2e006b3e5168c9c6252aef4de74..1e3b85c1338fba0d73b148a0c2b2b0c8ab779dd9 100644 (file)
--- a/top100.pl
+++ b/top100.pl
@@ -24,7 +24,6 @@ $ND::TEMPLATE->param(TITLE => 'Top100 ');
 
 our $BODY;
 our $DBH;
-our $LOG;
 my $error = '';
 
 $BODY->param(isHC => isHC());
index 5e489e5c4c9fcea56781086582924134bfd39a03..0a91becf314620e13cfcacd151b1be201f83dd79 100644 (file)
--- a/users.pl
+++ b/users.pl
@@ -19,9 +19,9 @@
 
 use strict;
 use warnings FATAL => 'all';
+use ND::Include;
 our $BODY;
 our $DBH;
-our $LOG;
 
 $ND::TEMPLATE->param(TITLE => 'Users');
 
@@ -57,7 +57,7 @@ if ($user && defined param('cmd') && param('cmd') eq 'change'){
                        if ($DBH->do(qq{UPDATE users SET $column = ? WHERE uid = ? }
                                        ,undef,$value,$user->{uid})){
                                $user->{$column} = param($column);
-                               $LOG->execute($ND::UID,"HC set $column to $value for user: $user->{uid}");
+                               log_message $ND::UID,"HC set $column to $value for user: $user->{uid}";
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                        }
@@ -77,7 +77,7 @@ if ($user && defined param('cmd') && param('cmd') eq 'change'){
                }
                if ($query){
                        if ($query->execute($user->{uid},$group->{gid})){
-                               $LOG->execute($ND::UID,"HC added user: $user->{uid} to group: $group->{gid}");
+                               log_message $ND::UID,"HC added user: $user->{uid} to group: $group->{gid}";
                        }else{
                                $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
                        }