getRaidList($eid); if (!$eiddata) { header("Location: build.php?id=39&t=99"); exit; } $x = $eiddata['x']; $y = $eiddata['y']; for ($i = 1; $i <= 6; $i++) { ${'t'.$i} = $eiddata['t'.$i]; } $FLData = $database->getFLData($eiddata['lid']); if ($FLData['owner'] != $session->uid) { header("Location: build.php?id=39&t=99"); exit; } } /* ===================================================== HANDLE EDIT SUBMIT ===================================================== */ $postAction = $_POST['action'] ?? null; if ( $postAction === 'editSlot' && $eid && !empty($_POST['lid']) ) { $FLData = $database->getFLData((int)$_POST['lid']); /* ====================== TARGET RESOLVE ====================== */ $Wref = null; $WrefX = null; $WrefY = null; $vdata = null; $oasistype = null; $targetId = $_POST['target_id'] ?? ''; $px = $_POST['x'] ?? ''; $py = $_POST['y'] ?? ''; if (!empty($targetId)) { $Wref = (int)$targetId; $coor = $database->getCoor($Wref); $WrefX = $coor['x']; $WrefY = $coor['y']; } elseif ($px !== '' && $py !== '' && is_numeric($px) && is_numeric($py)) { $Wref = $database->getVilWref($px, $py); $WrefX = (int)$px; $WrefY = (int)$py; } if ($Wref) { $oasistype = $database->getVillageType2($Wref); $vdata = $database->getVillage($Wref); } /* ====================== TROOP COUNT ====================== */ $troops = 0; for ($i = 1; $i <= 6; $i++) { $unitId = $i + ($session->tribe - 1) * 10; if (!in_array($unitId, [4, 14, 23, 44, 52, 64, 74, 82])) { $troops += (int)($_POST['t'.$i] ?? 0); } } /* ====================== VALIDATION ====================== */ if (empty($px) && empty($py) && empty($targetId)) { $errormsg = "Enter coordinates."; } elseif (($px === '' || $py === '') && empty($targetId)) { $errormsg = "Enter the correct coordinates."; } elseif ($oasistype == 0 && !$vdata) { $errormsg = "There is no village on those coordinates."; } elseif ($troops == 0) { $errormsg = "No troops has been selected."; } elseif ($database->hasBeginnerProtection($Wref)) { $errormsg = "Player under protection."; } elseif ( $Wref == $FLData['wref'] || ($vdata['wref'] ?? null) == $FLData['wref'] ) { $errormsg = "You can't attack the same village you're sending troops from."; } else { /* ====================== UPDATE SLOT ====================== */ $coor = $database->getCoor($village->wid); $distance = $database->getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); $oldLid = $database->getRaidList($eid)['lid']; $database->editSlotFarm( $eid, (int)$_POST['lid'], $oldLid, $session->uid, $Wref, $WrefX, $WrefY, $distance, (int)($_POST['t1'] ?? 0), (int)($_POST['t2'] ?? 0), (int)($_POST['t3'] ?? 0), (int)($_POST['t4'] ?? 0), (int)($_POST['t5'] ?? 0), (int)($_POST['t6'] ?? 0) ); header("Location: build.php?id=39&t=99"); exit; } } ?>