$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;
use ND::DB;
use Apache2::Access ();
+use again;
sub handler {
my $r = shift;
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();
our $BODY;
our $DBH;
-our $LOG;
my $error;
die "You don't have access" unless isMember();
use strict;
use warnings FATAL => 'all';
+use ND::Include;
our $BODY;
our $DBH;
-our $LOG;
my $error;
$ND::TEMPLATE->param(TITLE => 'Alliances');
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>";
}
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>";
}
use warnings FATAL => 'all';
our $BODY;
our $DBH;
-our $LOG;
my $error;
$ND::TEMPLATE->param(TITLE => 'Defense Calls');
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>";
}
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>";
}
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>";
}
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>";
}
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));
}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 = '';
}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;
$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++;
our $BODY;
our $DBH;
-our $LOG;
die "You don't have access" unless isMember();
our $BODY;
our $DBH;
-our $LOG;
my $error;
die "You don't have access" unless isMember();
use strict;
use warnings FATAL => 'all';
+use ND::Include;
our $BODY;
our $DBH;
-our $LOG;
my $error;
$ND::TEMPLATE->param(TITLE => 'Create/Edit Raids');
$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);
}
}
}
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)){
$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'){
our $BODY;
our $DBH;
-our $LOG;
our $ERROR;
my $error;
use strict;
use warnings FATAL => 'all';
+use ND::Include;
$ND::TEMPLATE->param(TITLE => 'Launch Confirmation');
our $BODY;
our $DBH;
-our $LOG;
my $error;
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;
$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";
}
}
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>';
use strict;
use warnings FATAL => 'all';
+use ND::Include;
$ND::TEMPLATE->param(TITLE => 'Main Page');
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>";
}
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>";
}
use warnings FATAL => 'all';
our $BODY;
our $DBH;
-our $LOG;
my $error;
$ND::TEMPLATE->param(TITLE => 'Member Intel');
#**************************************************************************/
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{
our $BODY;
our $DBH;
-our $LOG;
my $error;
die "You don't have access" unless isHC();
our $BODY;
our $DBH;
-our $LOG;
die "You don't have access" unless isMember();
use strict;
use warnings FATAL => 'all';
+use ND::Include;
use POSIX;
our $BODY;
our $DBH;
-our $LOG;
our $XML;
my $raid;
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.";
}
}
}
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.";
}
}
}
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;
use warnings FATAL => 'all';
our $BODY;
our $DBH;
-our $LOG;
my $error;
$ND::TEMPLATE->param(TITLE => 'Alliance Resources');
use DBD::Pg qw(:pg_types);
use ND::DB;
+use ND::Include;
use ND::Web::Include;
use ND::Web::Forum;
our $BODY;
our $DBH;
-our $LOG;
my $error = '';
$BODY->param(isHC => isHC());
use strict;
use warnings FATAL => 'all';
+use ND::Include;
our $BODY;
our $DBH;
-our $LOG;
$ND::TEMPLATE->param(TITLE => 'Users');
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>";
}
}
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>";
}