From: Michael Andreen Date: Fri, 5 Jan 2007 09:09:41 +0000 (+0000) Subject: removed in favor of ND::Include::log_message X-Git-Url: https://ruin.nu/git/?a=commitdiff_plain;ds=sidebyside;h=3fbdd3816ab065ed3ac2b5f77e7617b2c09ea00c;p=ndwebbie.git removed in favor of ND::Include::log_message --- diff --git a/ND.pm b/ND.pm index 7d9c8c0..8539d1e 100755 --- 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; diff --git a/ND/Web/AuthHandler.pm b/ND/Web/AuthHandler.pm index 60204b0..45428d8 100644 --- a/ND/Web/AuthHandler.pm +++ b/ND/Web/AuthHandler.pm @@ -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(); diff --git a/addintel.pl b/addintel.pl index 5e65ad7..405bece 100644 --- a/addintel.pl +++ b/addintel.pl @@ -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(); diff --git a/alliances.pl b/alliances.pl index 8b58308..b78d5ff 100644 --- a/alliances.pl +++ b/alliances.pl @@ -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 .= "

Something went wrong: ".$DBH->errstr."

"; } @@ -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 .= "

Added planet $1:$2:$3 $nick to this alliance

"; - $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 .= "

Something went wrong: ".$DBH->errstr."

"; } diff --git a/calls.pl b/calls.pl index c09b606..1f779d6 100644 --- 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 .= "

Something went wrong: ".$DBH->errstr."

"; } @@ -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 .= "

Something went wrong: ".$DBH->errstr."

"; } @@ -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 .= "

Something went wrong: ".$DBH->errstr."

"; } @@ -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 .= "

Something went wrong: ".$DBH->errstr."

"; } diff --git a/check.pl b/check.pl index 9acf9bf..04f49d3 100644 --- a/check.pl +++ b/check.pl @@ -20,12 +20,12 @@ 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 => 'KILL THESE BASTARDS'); } - $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++; diff --git a/covop.pl b/covop.pl index daf7824..a07c47f 100644 --- 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(); diff --git a/defrequest.pl b/defrequest.pl index a80f62c..c53f372 100644 --- a/defrequest.pl +++ b/defrequest.pl @@ -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(); diff --git a/editRaid.pl b/editRaid.pl index 1d5e137..94ed68d 100644 --- a/editRaid.pl +++ b/editRaid.pl @@ -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'){ diff --git a/intel.pl b/intel.pl index 7f1ec4a..9ab5864 100644 --- a/intel.pl +++ b/intel.pl @@ -23,7 +23,6 @@ use ND::Web::Forum; our $BODY; our $DBH; -our $LOG; our $ERROR; my $error; diff --git a/launchConfirmation.pl b/launchConfirmation.pl index 39a0ff0..ffe6b11 100644 --- a/launchConfirmation.pl +++ b/launchConfirmation.pl @@ -19,12 +19,12 @@ 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 .= '

'.$DBH->errstr.'

'; diff --git a/main.pl b/main.pl index 345b1be..91c347e 100644 --- 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 .= "

Something went wrong: ".$DBH->errstr."

"; } @@ -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 .= "

Something went wrong: ".$DBH->errstr."

"; } diff --git a/memberIntel.pl b/memberIntel.pl index 6142324..66e0dcd 100644 --- a/memberIntel.pl +++ b/memberIntel.pl @@ -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 f69a54a..b324cc0 100644 --- a/motd.pl +++ b/motd.pl @@ -18,21 +18,22 @@ #**************************************************************************/ 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{ diff --git a/planetNaps.pl b/planetNaps.pl index a18e2ac..ff5a837 100644 --- a/planetNaps.pl +++ b/planetNaps.pl @@ -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(); diff --git a/points.pl b/points.pl index 213fad9..e1a1886 100644 --- 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(); diff --git a/raids.pl b/raids.pl index 1ebaad6..a3cb3cc 100644 --- a/raids.pl +++ b/raids.pl @@ -19,10 +19,10 @@ 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; diff --git a/resources.pl b/resources.pl index 1295566..fa64c32 100644 --- a/resources.pl +++ b/resources.pl @@ -21,7 +21,6 @@ use strict; use warnings FATAL => 'all'; our $BODY; our $DBH; -our $LOG; my $error; $ND::TEMPLATE->param(TITLE => 'Alliance Resources'); diff --git a/startup.pl b/startup.pl index 0597587..30d3163 100644 --- a/startup.pl +++ b/startup.pl @@ -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; diff --git a/top100.pl b/top100.pl index ccd681b..1e3b85c 100644 --- 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()); diff --git a/users.pl b/users.pl index 5e489e5..0a91bec 100644 --- 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 .= "

Something went wrong: ".$DBH->errstr."

"; } @@ -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 .= "

Something went wrong: ".$DBH->errstr."

"; }