X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Def.pm;h=d3786a25bcc4badefb679c935087242ce7e112c2;hb=f5ce817fa21bc211bb804595296bb1b2b0a3f60d;hp=a21a17d5963d41c8542de5aab19ff3bdb14c41c4;hpb=51374bc34007df2eddd99153063824d0ab7f19ad;p=NDIRC.git diff --git a/Def.pm b/Def.pm index a21a17d..d3786a2 100644 --- a/Def.pm +++ b/Def.pm @@ -23,11 +23,13 @@ use ND::DB; use ND::Include; use NDIRC::Access; use NDIRC::Misc; +use CGI qw/:standard/; require Exporter; our @ISA = qw/Exporter/; -our @EXPORT = qw/showCall setType takeCall covCall ignoreCall defcall anon setDefPrio/; +our @EXPORT = qw/showCall setType takeCall covCall ignoreCall + defcall anon setDefPrio setCalc getCalc/; sub showCall { my ($msg,$command) = @_; @@ -98,7 +100,7 @@ sub setType { }elsif (defined $x){ $fleet = $ND::DBH->prepare(qq{ $query - WHERE i.call = ? AND p.id = planetid(?,?,?,0) + WHERE i.call = ? AND p.id = planetid(?,?,?,tick()) }); $fleet->execute($id,$x,$y,$z); }else{ @@ -108,9 +110,10 @@ sub setType { }); $fleet->execute($id); } + $type = escapeHTML($type); while (my ($id,$call,$oldtype,$coords,$tick) = $fleet->fetchrow()){ if($ND::DBH->do(q{UPDATE incomings SET shiptype = ? WHERE id = ?},undef,$type,$id) == 1){ - log_message $user->{uid}, "DC set fleet: $id to: $type"; + def_log $user->{uid}, $call , "Set fleet: [B] $id [/B] to: [B] $type [/B]"; $ND::server->command("msg $ND::target Set fleet from $coords on call $call to $type (previously $oldtype)"); if ($tick < 0 && not (defined $x && $x eq 'call')){ $ND::server->command("msg $ND::target This call is old, did you use the call id, instead of inc id by accident? You can use .settypeall callid to set the type on all incs in a call."); @@ -128,10 +131,11 @@ sub takeCall { $ND::server->command("notice $ND::nick Usage: $command callid"); return; } - if (dc()){ + if (my $user = dc()){ if ($ND::DBH->do(q{UPDATE calls SET dc = (SELECT uid FROM users WHERE hostmask ILIKE ?) WHERE id = ?} ,undef,$ND::address,$id) == 1){ $ND::server->command("msg $ND::target Updated the DC for call $id"); + def_log $user->{uid}, $id , "Used: [B] $command [/B]"; } } } @@ -145,10 +149,11 @@ sub covCall { $ND::server->command("notice $ND::nick Usage: $command callid"); return; } - if (dc()){ + if (my $user = dc()){ if($ND::DBH->do(q{UPDATE calls SET dc = (SELECT uid FROM users WHERE hostmask ILIKE ?), covered = TRUE, open = FALSE WHERE id = ?} ,undef,$ND::address,$id) == 1){ $ND::server->command("msg $ND::target Marked call $id as covered"); + def_log $user->{uid}, $id , "Used: [B] $command [/B]"; } } } @@ -162,10 +167,11 @@ sub ignoreCall { $ND::server->command("notice $ND::nick Usage: $command callid"); return; } - if (dc()){ + if (my $user = dc()){ if($ND::DBH->do(q{UPDATE calls SET dc = (SELECT uid FROM users WHERE hostmask ILIKE ?), covered = FALSE, open = FALSE WHERE id = ?} ,undef,$ND::address,$id) == 1){ $ND::server->command("msg $ND::target Marked call $id as ignored"); + def_log $user->{uid}, $id , "Used: [B] $command [/B]"; } } } @@ -219,6 +225,42 @@ sub anon { } } +sub setCalc { + my ($msg,$command) = @_; + my ($id, $calc); + if (defined $msg && $msg =~ /^(\d+) (.+)$/){ + $id = $1; + $calc = escapeHTML($2); + }else{ + $ND::server->command("notice $ND::nick Usage: $command callid calc"); + return; + } + if (my $user = dc()){ + if ($ND::DBH->do(q{UPDATE calls SET calc = $2 WHERE id = $1} + ,undef,$id, $calc) == 1){ + $ND::server->command("notice $ND::nick Updated calc call $ND::B$id$ND::O"); + def_log $user->{uid}, $id , 'Updated calc to: [URL]' + .$calc.'[/URL]'; + } + } +} + +sub getCalc { + my ($msg,$command) = @_; + my ($id); + if (defined $msg && $msg =~ /^(\d+)$/){ + $id = $1; + }else{ + $ND::server->command("notice $ND::nick Usage: $command callid"); + return; + } + if (my $user = dc()){ + my $calc = $ND::DBH->selectrow_array(q{SELECT calc + FROM calls WHERE id = $1} + ,undef,$id); + $ND::server->command("notice $ND::nick calc for call $ND::B$id$ND::O: $calc"); + } +} sub setDefPrio { my ($msg,$command) = @_;