From afc3b476209555d1769aaca6f4f376f57dcefc33 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 15 Dec 2006 12:01:46 +0000 Subject: [PATCH] done --- alliances.pl | 27 +++++++++++++++++++++++---- templates/alliances.tmpl | 20 +++++++++----------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/alliances.pl b/alliances.pl index 101f2db..62aae64 100644 --- a/alliances.pl +++ b/alliances.pl @@ -33,12 +33,31 @@ if (param('alliance') =~ /^(\d+)$/){ my $query = $DBH->prepare(q{SELECT id,name, relationship FROM alliances WHERE id = ?}); $alliance = $DBH->selectrow_hashref($query,undef,$1); } -if ($alliance && param ('cmd') eq 'coords'){ - $DBH->begin_work; - $DBH->commit or $error .= "

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

"; -} if ($alliance && param ('cmd') eq 'change'){ $DBH->begin_work; + if (param('crelationship')){ + my $value = escapeHTML(param('relationship')); + 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"); + }else{ + $error .= "

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

"; + } + } + my $coords = param('coords'); + my $addplanet = $DBH->prepare(q{ +UPDATE planets SET alliance_id = ?, nick = coalesce(?,nick) +WHERE id = (SELECT id FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?); + }); + while ($coords =~ m/(\d+):(\d+):(\d+)(?:\s+nick=\s*(\S+))?/g){ + if ($addplanet->execute($alliance->{id},$4,$1,$2,$3)){ + $error .= "

Added planet $1:$2:$3 (nick $4) to this alliance

"; + $LOG->execute($ND::UID,"HC Added planet $1:$2:$3 (nick $4) to alliance: $alliance->{id}"); + }else{ + $error .= "

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

"; + } + } $DBH->commit or $error .= "

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

"; } diff --git a/templates/alliances.tmpl b/templates/alliances.tmpl index 85f84ff..b090cf0 100644 --- a/templates/alliances.tmpl +++ b/templates/alliances.tmpl @@ -4,6 +4,7 @@ +

Alliance:

Relationship:

-

+
+ +
+

Paste a list of coords that you want to add to this alliance

+ +
+
 
+
@@ -42,16 +50,6 @@
-
Coords - - - -

Paste a list of coords that you want to add to this alliance

- -

-
-
-
-- 2.39.2
AllianceSender