]> ruin.nu Git - ndwebbie.git/blobdiff - calls.pl
don't show posts for autogenerated boards, and ND::Include needed for calls
[ndwebbie.git] / calls.pl
index ce708fc0df83aa37c90a9c33988111e3bb2bd815..342f47d080e8bfc39299f2760faf24ce6491393a 100644 (file)
--- a/calls.pl
+++ b/calls.pl
 #**************************************************************************/
 
 use strict;
-use POSIX;
+use warnings FATAL => 'all';
+use ND::Include;
 our $BODY;
 our $DBH;
-our $LOG;
 my $error;
 
 $ND::TEMPLATE->param(TITLE => 'Defense Calls');
@@ -29,7 +29,7 @@ $ND::TEMPLATE->param(TITLE => 'Defense Calls');
 die "You don't have access" unless isDC();
 
 my $call;
-if (param('call') =~ /^(\d+)$/){
+if (defined param('call') && param('call') =~ /^(\d+)$/){
        my $query = $DBH->prepare(q{
 SELECT c.id, coords(p.x,p.y,p.z), c.landing_tick, c.info, covered, open, dc.username AS dc, u.defense_points,c.member
 FROM calls c 
@@ -39,14 +39,14 @@ FROM calls c
 WHERE c.id = ?});
        $call = $DBH->selectrow_hashref($query,undef,$1);
 }
-if ($call){
+if ($call && defined param('cmd')){
        if (param('cmd') eq 'Submit'){
                $DBH->begin_work;
                if (param('ctick')){
                        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 +55,7 @@ if ($call){
                        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 +87,7 @@ if ($call){
                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 +101,7 @@ if ($call){
                        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>";
                                }
@@ -160,7 +160,7 @@ WHERE i.call = ?
 ORDER BY p.x,p.y,p.z});
        $attackers->execute($call->{id});
        my @attackers;
-       my $i = 0;
+       $i = 0;
        while(my $attacker = $attackers->fetchrow_hashref){
                $i++;
                $attacker->{ODD} = $i % 2;
@@ -169,12 +169,14 @@ ORDER BY p.x,p.y,p.z});
        $BODY->param(Attackers => \@attackers);
 }else{
        my $where = 'open AND c.landing_tick-6 > tick()';
-       if (param('show') eq 'covered'){
-               $where = 'covered';
-       }elsif (param('show') eq 'all'){
-               $where = 'true';
-       }elsif (param('show') eq 'uncovered'){
-               $where = 'not covered';
+       if (defined param('show')){
+               if (param('show') eq 'covered'){
+                       $where = 'covered';
+               }elsif (param('show') eq 'all'){
+                       $where = 'true';
+               }elsif (param('show') eq 'uncovered'){
+                       $where = 'not covered';
+               }
        }
        my $pointlimits = $DBH->prepare(q{SELECT value :: int FROM misc WHERE id = ?});
        my ($minpoints) = $DBH->selectrow_array($pointlimits,undef,'DEFMIN');