@@ -349,222 +359,10 @@ $NUM1++;
-getVilWref($_POST['y'], $_POST['x']);
- $type = $database->getVillageType2($Wref);
- $oasistype = $type['oasistype'];
- $vdata = $database->getVillage($Wref);
- }
- if(!$_POST['x'] && !$_POST['y']){
- $errormsg .= "Enter coordinates.";
- }elseif(!$_POST['x'] || !$_POST['y']){
- $errormsg .= "Enter the correct coordinates.";
- }elseif($oasistype == 0 && $vdata == 0){
- $errormsg .= "In this village there are no coordinates.";
- }elseif($troops == 0){
- $errormsg .= "No troops has been selected.";
- }else{
-
- $Wref = $database->getVilWref($_POST['y'], $_POST['x']);
- $coor = $database->getCoor($village->wid);
-
- function getDistance($coorx1, $coory1, $coorx2, $coory2) {
- $max = 2 * WORLD_MAX + 1;
- $x1 = intval($coorx1);
- $y1 = intval($coory1);
- $x2 = intval($coorx2);
- $y2 = intval($coory2);
- $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1)));
- $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1)));
- $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2));
- return round($dist, 1);
- }
-
- $distance = getDistance($coor['x'], $coor['y'], $_POST['y'], $_POST['x']);
-
- $database->addSlotFarm($_POST['lid'], $Wref, $_POST['x'], $_POST['y'], $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
-
- header("Location: build.php?id=39&t=99");
-}
-}
-?>
-
-
1){ ?>
-
-
\ No newline at end of file
+}else if($create == 2){
+include("Templates/goldClub/farmlist_addraid.tpl");
+}else if($create == 3){
+include("Templates/goldClub/farmlist_editraid.tpl");
+}
\ No newline at end of file
diff --git a/Templates/goldClub/farmlist_addraid.tpl b/Templates/goldClub/farmlist_addraid.tpl
index 67f2d961..28515ea4 100644
--- a/Templates/goldClub/farmlist_addraid.tpl
+++ b/Templates/goldClub/farmlist_addraid.tpl
@@ -1,18 +1,29 @@
getFLData($_GET['lid']);
+if($FLData['owner'] == $session->uid){
if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
$troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+".$_POST['t5']."+".$_POST['t6']."+".$_POST['t7']."+".$_POST['t8']."+".$_POST['t9']."+".$_POST['t10']."";
- if($_POST['x'] && $_POST['y']){
- $Wref = $database->getVilWref($_POST['y'], $_POST['x']);
- $type = $database->getVillageType2($Wref);
- $oasistype = $type['oasistype'];
- $vdata = $database->getVillage($Wref);
- }
- if(!$_POST['x'] && !$_POST['y']){
+if($_POST['target_id'] != ""){
+$Wref = $_POST['target_id'];
+$WrefCoor = $database->getCoor($Wref);
+$WrefX = $WrefCoor['x'];
+$WrefY = $WrefCoor['y'];
+$type = $database->getVillageType2($Wref);
+$oasistype = $type['oasistype'];
+$vdata = $database->getVillage($Wref);
+}elseif($_POST['x'] && $_POST['y']){
+$Wref = $database->getVilWref($_POST['x'], $_POST['y']);
+$WrefX = $_POST['x'];
+$WrefY = $_POST['y'];
+$type = $database->getVillageType2($Wref);
+$oasistype = $type['oasistype'];
+$vdata = $database->getVillage($Wref);
+}
+ if(!$_POST['x'] && !$_POST['y'] && $_POST['target_id'] == ""){
$errormsg .= "Enter coordinates.";
- }elseif(!$_POST['x'] || !$_POST['y']){
+ }elseif((!$_POST['x'] || !$_POST['y']) && $_POST['target_id'] == ""){
$errormsg .= "Enter the correct coordinates.";
}elseif($oasistype == 0 && $vdata == 0){
$errormsg .= "There is no village on those coordinates.";
@@ -20,7 +31,16 @@ $troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+"
$errormsg .= "No troops has been selected.";
}else{
- $Wref = $database->getVilWref($_POST['y'], $_POST['x']);
+ if($_POST['target_id'] != ""){
+ $Wref = $_POST['target_id'];
+ $WrefCoor = $database->getCoor($Wref);
+ $WrefX = $WrefCoor['x'];
+ $WrefY = $WrefCoor['y'];
+ }else{
+ $Wref = $database->getVilWref($_POST['x'], $_POST['y']);
+ $WrefX = $_POST['x'];
+ $WrefY = $_POST['y'];
+ }
$coor = $database->getCoor($village->wid);
function getDistance($coorx1, $coory1, $coorx2, $coory2) {
@@ -35,119 +55,32 @@ $troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+"
return round($dist, 1);
}
- $distance = getDistance($coor['x'], $coor['y'], $_POST['y'], $_POST['x']);
+ $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
- $database->addSlotFarm($_POST['lid'], $Wref, $_POST['x'], $_POST['y'], $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
+ $database->addSlotFarm($_POST['lid'], $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
header("Location: build.php?id=39&t=99");
}
}
?>
-
-