General fixes

+Fixed a bug in the farm list that permitted to attack the same village
troops were sent
+Fixed a bug that permitted to delete others raid lists
+Fixed a bug that permitted to view broken reports
+Fixed a bug that permitted to insert 0 troops in the raid list
+Fixed the broken graphic of the raid/farm list
+Fixed a bug that didn't permit to send more than 2 raids at a time (in
the raid list)
+General improovements and bug fixing
+Some clean-up
This commit is contained in:
iopietro
2018-05-03 23:07:11 +02:00
parent e751a0c01f
commit 49bc3c5073
13 changed files with 280 additions and 373 deletions
+29 -79
View File
@@ -112,59 +112,10 @@ class Automation {
} }
} }
public function procResType($ref,$mode=0,$isoasis=0) { public function procResType($ref, $mode = 0) {
global $session; global $building;
switch($ref) { //Capital or only 1 village left = cannot be destroyed
case 1: $build = "Woodcutter"; break; return addslashes(empty($build = $building->procResType($ref)) && !$mode ? "Village can't be" : $build);
case 2: $build = "Clay Pit"; break;
case 3: $build = "Iron Mine"; break;
case 4: $build = "Cropland"; break;
case 5: $build = "Sawmill"; break;
case 6: $build = "Brickyard"; break;
case 7: $build = "Iron Foundry"; break;
case 8: $build = "Grain Mill"; break;
case 9: $build = "Bakery"; break;
case 10: $build = "Warehouse"; break;
case 11: $build = "Granary"; break;
case 12: $build = "Blacksmith"; break;
case 13: $build = "Armoury"; break;
case 14: $build = "Tournament Square"; break;
case 15: $build = "Main Building"; break;
case 16: $build = "Rally Point"; break;
case 17: $build = "Marketplace"; break;
case 18: $build = "Embassy"; break;
case 19: $build = "Barracks"; break;
case 20: $build = "Stable"; break;
case 21: $build = "Workshop"; break;
case 22: $build = "Academy"; break;
case 23: $build = "Cranny"; break;
case 24: $build = "Town Hall"; break;
case 25: $build = "Residence"; break;
case 26: $build = "Palace"; break;
case 27: $build = "Treasury"; break;
case 28: $build = "Trade Office"; break;
case 29: $build = "Great Barracks"; break;
case 30: $build = "Great Stable"; break;
case 31: $build = "City Wall"; break;
case 32: $build = "Earth Wall"; break;
case 33: $build = "Palisade"; break;
case 34: $build = "Stonemason's Lodge"; break;
case 35: $build = "Brewery"; break;
case 36: $build = "Trapper"; break;
case 37: $build = "Hero's Mansion"; break;
case 38: $build = "Great Warehouse"; break;
case 39: $build = "Great Granary"; break;
case 40: $build = "Wonder of the World"; break;
case 41: $build = "Horse Drinking Trough"; break;
case 42: $build = "Great Workshop"; break;
//default: $build = "Nothing had"; break;
}
if ($build=="" && !$mode) { //capital or only 1 village left.. not destroy
$build="Village can't be";
}
return addslashes($build);
} }
function recountPop($vid, $use_cache = true){ function recountPop($vid, $use_cache = true){
@@ -187,7 +138,6 @@ class Automation {
$this->procClimbers($owner); $this->procClimbers($owner);
return $popTot; return $popTot;
} }
function recountCP($vid){ function recountCP($vid){
@@ -208,7 +158,6 @@ class Automation {
mysqli_query($database->dblink,$q); mysqli_query($database->dblink,$q);
return $popTot; return $popTot;
} }
function buildingPOP($f,$lvl){ function buildingPOP($f,$lvl){
@@ -248,37 +197,38 @@ class Automation {
$ourFileHandle = fopen($autoprefix."GameEngine/Prevention/loyalty.txt", 'w'); $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/loyalty.txt", 'w');
fclose($ourFileHandle); fclose($ourFileHandle);
global $database; global $database;
$array = array();
$array = [];
$array = $database->getProfileVillages(0, 6); $array = $database->getProfileVillages(0, 6);
if(!empty($array)) { if(!empty($array)) {
foreach($array as $loyalty) { foreach($array as $loyalty) {
if (($t25_level = $this->getTypeLevel(25, $loyalty['wref'])) >= 1) { if (($t25_level = $this->getTypeLevel(25, $loyalty['wref'])) >= 1) {
$value = $t25_level; $value = $t25_level;
}elseif(($t26_level = $this->getTypeLevel(26,$loyalty['wref'])) >= 1){ }elseif(($t26_level = $this->getTypeLevel(26, $loyalty['wref'])) >= 1){
$value = $t26_level; $value = $t26_level;
} else {
$value = 0;
} }
$newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate2'])/(60*60)); else $value = 0;
$q = "UPDATE ".TB_PREFIX."vdata SET loyalty = $newloyalty, lastupdate2=".time()." WHERE wref = '".$loyalty['wref']."'";
$database->query($q); if($value > 0){
$newloyalty = min(100, $loyalty['loyalty'] + $value * (time() - $loyalty['lastupdate2']) / 3600);
$q = "UPDATE ".TB_PREFIX."vdata SET loyalty = $newloyalty, lastupdate2=".time()." WHERE wref = '".$loyalty['wref']."'";
$database->query($q);
}
} }
} }
$array = array();
$array = [];
$q = "SELECT conqured, loyalty, lastupdated, wref FROM ".TB_PREFIX."odata WHERE loyalty < 100"; $q = "SELECT conqured, loyalty, lastupdated, wref FROM ".TB_PREFIX."odata WHERE loyalty < 100";
$array = $database->query_return($q); $array = $database->query_return($q);
if(!empty($array)) { if(!empty($array)) {
foreach($array as $loyalty) { foreach($array as $loyalty) {
if(($t25_level = $this->getTypeLevel(25,$loyalty['conqured'])) >= 1){ $value = $this->getTypeLevel(37, $loyalty['conqured']);
$value = $t25_level;
}elseif(($t26_level = $this->getTypeLevel(26,$loyalty['conqured'])) >= 1){ if($value > 0){
$value = $t26_level; $newloyalty = min(100, $loyalty['loyalty'] + $value * (time() - $loyalty['lastupdated']) / 3600);
} else { $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'";
$value = 0; $database->query($q);
} }
$newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdated'])/(60*60));
$q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'";
$database->query($q);
} }
} }
} }
@@ -991,7 +941,7 @@ class Automation {
if ($isSecondRow) { if ($isSecondRow) {
if ($tbid > 0) { if ($tbid > 0) {
$info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\"> $info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\">
<img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid, $can_destroy, $isoasis)." <b>destroyed</b>."; <img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid, $can_destroy)." <b>destroyed</b>.";
} }
// embassy level was changed // embassy level was changed
@@ -1001,7 +951,7 @@ class Automation {
$info_cat .= "</td></tr></tbody>"; $info_cat .= "</td></tr></tbody>";
} else { } else {
$info_cat = "".$catp_pic.", ".$this->procResType($tbgid, $can_destroy, $isoasis)." <b>destroyed</b>."; $info_cat = "".$catp_pic.", ".$this->procResType($tbgid, $can_destroy)." <b>destroyed</b>.";
// embassy level was changed // embassy level was changed
if ($tbgid==18){ if ($tbgid==18){
@@ -1015,10 +965,10 @@ class Automation {
if ($isSecondRow) { if ($isSecondRow) {
if ($tbid > 0) { if ($tbid > 0) {
$info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\"> $info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\">
<img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid, $can_destroy, $isoasis)." was not damaged.</td></tr></tbody>"; <img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid, $can_destroy)." was not damaged.</td></tr></tbody>";
} }
} else { } else {
$info_cat = "".$catp_pic.",".$this->procResType($tbgid, $can_destroy, $isoasis)." was not damaged."; $info_cat = "".$catp_pic.",".$this->procResType($tbgid, $can_destroy)." was not damaged.";
} }
} }
else else
@@ -1057,7 +1007,7 @@ class Automation {
if ($isSecondRow) { if ($isSecondRow) {
$info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\"> $info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\">
<img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid, $can_destroy, $isoasis).$info_cata; <img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid, $can_destroy).$info_cata;
// embassy level was changed // embassy level was changed
if ($tbgid == 18) { if ($tbgid == 18) {
@@ -1066,7 +1016,7 @@ class Automation {
$info_cat .= "</td></tr></tbody>"; $info_cat .= "</td></tr></tbody>";
} else { } else {
$info_cat = "" . $catp_pic . "," . $this->procResType($tbgid, $can_destroy,$isoasis).$info_cata; $info_cat = "" . $catp_pic . "," . $this->procResType($tbgid, $can_destroy).$info_cata;
// embassy level was changed // embassy level was changed
if ($tbgid == 18) { if ($tbgid == 18) {
+4 -4
View File
@@ -7411,10 +7411,10 @@ References: User ID/Message ID, Mode
return mysqli_query($this->dblink,$q); return mysqli_query($this->dblink,$q);
} }
function delSlotFarm($id) { function delSlotFarm($id, $owner, $lid) {
list($id) = $this->escape_input((int) $id); list($id, $owner, $lid) = $this->escape_input((int) $id, (int) $owner, (int) $lid);
$q = "DELETE FROM " . TB_PREFIX . "raidlist where id = $id"; $q = "DELETE FROM " . TB_PREFIX . "raidlist WHERE id = $id AND lid = $lid AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $lid AND owner = $owner)";
return mysqli_query($this->dblink,$q); return mysqli_query($this->dblink,$q);
} }
+2 -1
View File
@@ -15,7 +15,7 @@ class Message {
public $note; public $note;
public $inbox, $inbox1, $sent, $sent1, $reading, $reply, $archived, $archived1, $noticearray, $notice, $readingNotice = array(); public $inbox, $inbox1, $sent, $sent1, $reading, $reply, $archived, $archived1, $noticearray, $notice, $readingNotice = array();
private $totalMessage, $totalNotice; private $totalMessage, $totalNotice;
private $allNotice = array(); private $allNotice = [];
function __construct() { function __construct() {
$req_file = basename($_SERVER['PHP_SELF']); $req_file = basename($_SERVER['PHP_SELF']);
@@ -118,6 +118,7 @@ class Message {
$this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type); $this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type);
$this->notice = $this->filter_by_value($database->getNotice3($session->uid, $session->alliance), "ntype", $type); $this->notice = $this->filter_by_value($database->getNotice3($session->uid, $session->alliance), "ntype", $type);
} }
if(isset($get['id'])) { if(isset($get['id'])) {
$this->readingNotice = $this->getReadNotice($get['id']); $this->readingNotice = $this->getReadNotice($get['id']);
} }
+1 -7
View File
@@ -8,14 +8,8 @@
<h1><?php echo RALLYPOINT;?> <span class="level"><?php echo LEVEL;?> <?php echo $village->resarray['f'.$id]; ?></span></h1> <h1><?php echo RALLYPOINT;?> <span class="level"><?php echo LEVEL;?> <?php echo $village->resarray['f'.$id]; ?></span></h1>
<p class="build_desc"><?php echo RALLYPOINT_DESC;?></p> <p class="build_desc"><?php echo RALLYPOINT_DESC;?></p>
<div id="textmenu">
<a href="build.php?id=<?php echo $id; ?>"><?php echo OVERVIEW;?></a> |
<a href="a2b.php"><?php echo SEND_TROOPS;?></a> |
<a href="warsim.php"><?php echo Q20_RESP1;?></a> <?php if($session->goldclub==1){ ?>|
<a href="build.php?id=<?php echo $id; ?>&amp;t=99">Gold Club</a>
<?php } ?>
</div>
<?php <?php
include_once("16_menu.tpl");
$units_type = $database->getMovement("34",$village->wid,1); $units_type = $database->getMovement("34",$village->wid,1);
$settlers = $database->getMovement("7",$village->wid,1); $settlers = $database->getMovement("7",$village->wid,1);
$oasis_incoming = 0; $oasis_incoming = 0;
+23 -41
View File
@@ -1,78 +1,60 @@
<?php <?php
if(!$session->goldclub) { if(!$session->goldclub) include("Templates/Build/16.tpl");
include "Templates/Build/16.tpl"; else
}else{ {
?> ?>
<div id="build" class="gid16"><a href="#" onClick="return Popup(16,4);" class="build_logo"> <div id="build" class="gid16"><a href="#" onClick="return Popup(16,4);" class="build_logo">
<img class="g16" src="img/x.gif" alt="Rally point" title="<?php echo RALLYPOINT;?>" /> <img class="g16" src="img/x.gif" alt="Rally point" title="<?php echo RALLYPOINT;?>" />
</a> </a>
<h1><?php echo RALLYPOINT;?> <span class="level"><?php echo LEVEL;?> <?php echo $village->resarray['f'.$id]; ?></span></h1> <h1><?php echo RALLYPOINT;?> <span class="level"><?php echo LEVEL;?> <?php echo $village->resarray['f'.$id]; ?></span></h1>
<p class="build_desc"><?php echo RALLYPOINT_DESC;?></p> <p class="build_desc"><?php echo RALLYPOINT_DESC;?></p>
<?php include("16_menu.tpl")?>
<div id="textmenu"> <div id="raidList">
<a href="build.php?id=<?php echo $id; ?>"><?php echo OVERVIEW;?></a> | <?php include("Templates/goldClub/farmlist.tpl"); ?>
<a href="a2b.php"><?php echo SEND_TROOPS;?></a> | </div>
<a href="warsim.php"><?php echo Q20_RESP1;?></a> <?php if($session->goldclub==1){ ?>|
<a href="build.php?id=<?php echo $id; ?>&amp;t=99">Gold Club</a>
<?php } ?>
</div>
<div id="raidList">
<?php include "Templates/goldClub/farmlist.tpl"; ?>
</div>
<br /> <br />
<?php if($hideevasion == 0){ ?> <?php if($hideevasion == 0){ ?>
<table cellpadding="1" cellspacing="1"> <table id="raidList" cellpadding="1" cellspacing="1">
<thead> <thead>
<tr> <tr>
<th colspan="4"><?php echo EVASION_SETTINGS;?></th> <th colspan="4"><?php echo EVASION_SETTINGS;?></th>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td><?php echo VILLAGE; ?></td>
<td><?php echo MULTI_V_HEADER; ?></td>
<td><?php echo OWN_TROOPS; ?></td> <td><?php echo OWN_TROOPS; ?></td>
<td><?php echo REINFORCEMENT;?></td> <td><?php echo REINFORCEMENT;?></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
for($i=0;$i<=count($session->villages)-1;$i++) { for($i = 0; $i <= count($session->villages) - 1; $i++) {
$wref = $session->villages[$i]; $wref = $session->villages[$i];
$vname = $database->getVillageField($wref,"name"); $vname = $database->getVillageField($wref, "name");
$vchecked = $database->getVillageField($wref,"evasion"); $vchecked = $database->getVillageField($wref, "evasion");
$reinf = $database->getEnforceVillage($wref,0); $reinf = $database->getEnforceVillage($wref, 0);
if($vchecked == 1){ $checked = 'checked'; }else{ $checked = ''; }
if($vchecked == 1) $checked = 'checked';
else $checked = '';
?> ?>
<tr> <tr>
<td><input type="checkbox" class="check" name="hideShow" onclick="window.location.href = '?gid=16&t=99&evasion=<?php echo $wref;?>';" <?php echo $checked; ?>></td> <td><input type="checkbox" class="check" name="hideShow" onclick="window.location.href = '?gid=16&t=99&evasion=<?php echo $wref;?>';" <?php echo $checked; ?>></td>
<td><?php echo $vname; ?></td> <td><?php echo $vname; ?></td>
<td><div style="text-align: center"><?php echo $database->getUnitsNumber($wref); ?></div></td>
<td><?php echo $database->getUnitsNumber($wref); ?></td> <td><div style="text-align: center"><?php echo count($reinf); ?></div></td>
<td><?php echo count($reinf); ?></td>
</tr> </tr>
<?php <?php
} }
$user = $database->getUserArray($session->uid, 1); $user = $database->getUserArray($session->uid, 1);
?> ?>
</tbody> </tbody>
</table> </table>
<form action="build.php?id=39&t=99" method="POST"> <form action="build.php?id=39&t=99" method="POST">
<br /> <br />
<tr> <?php echo SEND_TROOPS_AWAY_MAX;?> <input class="text" type="text" name="maxevasion" value="<?php echo $user['maxevasion']; ?>" maxlength="3" style="width:50px;"> <?php echo TIMES;?>
<?php echo SEND_TROOPS_AWAY_MAX;?> <input class="text" type="text" name="maxevasion" value="<?php echo $user['maxevasion']; ?>" maxlength="3" style="width:50px;"> <?php echo TIMES;?> <span class="none">(<?php echo COSTS;?>: <img src="<?php echo GP_LOCATE; ?>img/a/gold_g.gif" alt="Gold" title="<?php echo GOLD;?>"/><b>2</b> <?php echo PER_EVASION;?>)</span>
<span class="none">(<?php echo COSTS;?>: <img src="<?php echo GP_LOCATE; ?>img/a/gold_g.gif" alt="Gold" title="<?php echo GOLD;?>"/><b>2</b> <?php echo PER_EVASION;?>)</span> <div class="clear"></div><p><button value="ok" name="s1" id="btn_ok" class="trav_buttons" tabindex="8">OK</button></p></form>
</tr>
<tr>
<div class="clear"></div><p><input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" tabindex="8" alt="OK"/></p></form>
</tr>
</form>
<?php } ?> <?php } ?>
</div> </div>
<?php } ?> <?php } ?>
+8
View File
@@ -0,0 +1,8 @@
<div id="textmenu">
<a href="build.php?id=<?php echo $id; ?>" <?php if(!isset($_GET['t']) || (isset($_GET['t']) && $_GET['t'] == 99 && !$session->goldclub)) echo "class=\"selected\""; ?> ><?php echo OVERVIEW;?></a> |
<a href="a2b.php"><?php echo SEND_TROOPS;?></a> |
<a href="warsim.php"><?php echo Q20_RESP1;?></a>
<?php if($session->goldclub == 1){ ?>|
<a href="build.php?id=<?php echo $id; ?>&amp;t=99" <?php if(isset($_GET['t']) && $_GET['t'] == 99) echo "class=\"selected\""; ?> >Gold Club</a>
<?php } ?>
</div>
+4 -4
View File
@@ -1,7 +1,7 @@
<div id="textmenu"> <div id="textmenu">
<a href="build.php?id=<?php echo $id; ?>" <?php if(!isset($_GET['s'])) { echo "class=\"selected\""; } ?>><?php echo TRAIN; ?></a> <a href="build.php?id=<?php echo $id; ?>" <?php if(!isset($_GET['s']))echo "class=\"selected\""; ?>><?php echo TRAIN; ?></a>
| <a href="build.php?id=<?php echo $id; ?>&amp;s=2" <?php if(isset($_GET['s']) && $_GET['s'] == 2) { echo "class=\"selected\""; } ?>><?php echo CULTURE_POINTS; ?></a> | <a href="build.php?id=<?php echo $id; ?>&amp;s=2" <?php if(isset($_GET['s']) && $_GET['s'] == 2) echo "class=\"selected\""; ?>><?php echo CULTURE_POINTS; ?></a>
| <a href="build.php?id=<?php echo $id; ?>&amp;s=3" <?php if(isset($_GET['s']) && $_GET['s'] == 3) { echo "class=\"selected\""; } ?>><?php echo LOYALTY; ?></a> | <a href="build.php?id=<?php echo $id; ?>&amp;s=3" <?php if(isset($_GET['s']) && $_GET['s'] == 3) echo "class=\"selected\""; ?>><?php echo LOYALTY; ?></a>
| <a href="build.php?id=<?php echo $id; ?>&amp;s=4" <?php if(isset($_GET['s']) && $_GET['s'] == 4) { echo "class=\"selected\""; } ?>><?php echo EXPANSION; ?></a> | <a href="build.php?id=<?php echo $id; ?>&amp;s=4" <?php if(isset($_GET['s']) && $_GET['s'] == 4) echo "class=\"selected\""; ?>><?php echo EXPANSION; ?></a>
</div> </div>
+6 -7
View File
@@ -10,8 +10,7 @@
$sql1 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."units WHERE vref = ".(int) $getFLData['wref'])); $sql1 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."units WHERE vref = ".(int) $getFLData['wref']));
$sid = $row['id']; $sid = $row['id'];
$wref = $row['towref']; $wref = $row['towref'];
$t1 = $row['t1'];$t2 = $row['t2'];$t3 = $row['t3'];$t4 = $row['t4'];$t5 = $row['t5']; for($i = 1; $i <= 10; $i++) ${'t'.$i} = $row['t'.$i];
$t6 = $row['t6'];$t7 = $row['t7'];$t8 = $row['t8'];$t9 = $row['t9'];$t10 = $row['t10'];
$t11 = 0; $t11 = 0;
$villageOwner = $database->getVillageField($wref,'owner'); $villageOwner = $database->getVillageField($wref,'owner');
$userAccess = $database->getUserField($villageOwner,'access',0); $userAccess = $database->getUserField($villageOwner,'access',0);
@@ -60,7 +59,7 @@
$id = $database->addA2b( $ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, 4 ); $id = $database->addA2b( $ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, 4 );
$data = $database->getA2b( $ckey, $time_now ); $data = $database->getA2b( $ckey, $time_now );
$troopsTime = $units->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u'); $troopsTime = $units->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u');
$time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime); $time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime);
@@ -69,7 +68,7 @@
$reference = $database->addAttack( ( $getFLData['wref'] ), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $ctar1, $ctar2, 0, $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8'] ); $reference = $database->addAttack( ( $getFLData['wref'] ), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $ctar1, $ctar2, 0, $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8'] );
$totalunits = $data['u1'] + $data['u2'] + $data['u3'] + $data['u4'] + $data['u5'] + $data['u6'] + $data['u7'] + $data['u8'] + $data['u9'] + $data['u10'] + $data['u11']; $totalunits = $data['u1'] + $data['u2'] + $data['u3'] + $data['u4'] + $data['u5'] + $data['u6'] + $data['u7'] + $data['u8'] + $data['u9'] + $data['u10'] + $data['u11'];
$units = []; $troops = [];
$amounts = []; $amounts = [];
$modes = []; $modes = [];
@@ -80,16 +79,16 @@
$unitKey = $uname2 . ($u < 10 ? $u : 0); $unitKey = $uname2 . ($u < 10 ? $u : 0);
} }
$units[] = $unitKey; $troops[] = $unitKey;
$amounts[] = $data[ 'u' . $u]; $amounts[] = $data[ 'u' . $u];
$modes[] = 0; $modes[] = 0;
} }
$units[] = 'hero'; $troops[] = 'hero';
$amounts[] = $data['u11']; $amounts[] = $data['u11'];
$modes[] = 0; $modes[] = 0;
$database->modifyUnit($getFLData['wref'], $units, $amounts, $modes); $database->modifyUnit($getFLData['wref'], $troops, $amounts, $modes);
$database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time())); $database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time()));
// prevent re-use of the same attack via re-POSTing the same data // prevent re-use of the same attack via re-POSTing the same data
+14 -14
View File
@@ -1,10 +1,10 @@
<?php <?php
if(isset($_GET['t'])==99 && isset($_GET['action'])==0) { if(isset($_GET['t']) == 99 && isset($_GET['action']) == 0) {
if(isset($_GET['t'])==99 && isset($_POST['action'])=='addList' && $_POST['did']!="" && $_POST['name']!=""){ if(isset($_GET['t']) == 99 && isset($_POST['action']) == 'addList' && !empty($_POST['did']) && !empty($_POST['name'])){
$database->createFarmList($_POST['did'], $session->uid, $_POST['name']); $database->createFarmList($_POST['did'], $session->uid, $_POST['name']);
}else if(isset($_GET['t'])==99 && isset($_POST['action'])=='addList'){ }else if(isset($_GET['t']) == 99 && isset($_POST['action']) == 'addList'){
header("Location: build.php?gid=16&t=99&action=addList"); header("Location: build.php?gid=16&t=99&action=addList");
exit; exit;
} }
@@ -31,12 +31,12 @@ while($row = mysqli_fetch_array($sql)){
<?php echo $lvname; ?> - <?php echo $lname; ?> <?php echo $lvname; ?> - <?php echo $lname; ?>
<img alt="Loading..." class="loading hide" src="img/x.gif" align="absmiddle"> <img alt="Loading..." class="loading hide" src="img/x.gif" align="absmiddle">
</div> </div>
<div class="openedClosedSwitch switchOpened"> </div> <div class="openedClosedSwitch switchOpened"></div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div class="listContent "> <div class="listContent ">
<div class="detail"> <div class="detail">
<table class="list" cellpadding="1" cellspacing="1"> <table id="raidList" cellpadding="1" cellspacing="1">
<thead> <thead>
<tr> <tr>
<td class="checkbox edit"></td> <td class="checkbox edit"></td>
@@ -44,7 +44,7 @@ while($row = mysqli_fetch_array($sql)){
<td class="ew sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'ew');">Pop</td> <td class="ew sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'ew');">Pop</td>
<td class="distance sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'distance');">Distance</td> <td class="distance sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'distance');">Distance</td>
<td class="troops sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'troops');">Troops</td> <td class="troops sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'troops');">Troops</td>
<td class="lastRaid sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'lastRaid');">LastRaid</td> <td class="lastRaid sortable" onclick="Travian.Game.RaidList.sort(<?php echo $lid; ?>, 'lastRaid');">Last raid</td>
<td class="action"></td> <td class="action"></td>
</tr> </tr>
</thead> </thead>
@@ -54,7 +54,7 @@ while($row = mysqli_fetch_array($sql)){
$sql2 = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = ".(int) $lid." ORDER BY distance ASC"); $sql2 = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = ".(int) $lid." ORDER BY distance ASC");
$query2 = mysqli_num_rows($sql2); $query2 = mysqli_num_rows($sql2);
if($query2 == 0) { if($query2 == 0) {
echo '<td class="noData" colspan="7">There is not any raid list.</td>'; echo '<td class="noData" colspan="7">There are no village.</td>';
}else{ }else{
while($row = mysqli_fetch_array($sql2)){ while($row = mysqli_fetch_array($sql2)){
$id= $row['id'];$lid = $row['lid'];$towref = $row['towref'];$x = $row['x'];$y = $row['y']; $id= $row['id'];$lid = $row['lid'];$towref = $row['towref'];$x = $row['x'];$y = $row['y'];
@@ -240,11 +240,12 @@ while($row2 = mysqli_fetch_array($getnotice)){
<label for="raidListMarkAll<?php echo $lid; ?>">Select All</label> <label for="raidListMarkAll<?php echo $lid; ?>">Select All</label>
</div> </div>
<div class="addSlot"> <div class="addSlot"><br />
<a href="build.php?id=39&t=99&action=addraid&lid=<?php echo $lid; ?>">Add Raid</a> <button type="button" class="trav_buttons" onclick="window.location.href = '?gid=16&t=99&action=addraid&lid=<?php echo $lid; ?>';">Add Raid</button>
<button type="submit" class="trav_buttons" value="Start Raid">Start Raid</button>
</div> </div>
<div class="clear"></div>
<div class="clear"></div><br /><br />
<div class="troopSelection"> <div class="troopSelection">
<?php <?php
/* /*
@@ -261,8 +262,7 @@ for($i=$start;$i<=$end;$i++){
?> ?>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div>
<button type="submit" value="Start Raid"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Start Raid</div></div></button> </div>
</form> </form>
+71 -73
View File
@@ -2,63 +2,62 @@
$FLData = $database->getFLData($_GET['lid']); $FLData = $database->getFLData($_GET['lid']);
if($FLData['owner'] == $session->uid){ if($FLData['owner'] == $session->uid){
if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) { if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
$troops = 0;
for($i = 1; $i <= 10; $i++) $troops += $_POST['t'.$i];
if(!empty($_POST['target_id'])){
$Wref = $_POST['target_id'];
$WrefCoor = $database->getCoor($Wref);
$WrefX = $WrefCoor['x'];
$WrefY = $WrefCoor['y'];
$type = $database->getVillageType2($Wref);
$oasistype = $type;
$vdata = $database->getVillage($Wref);
}elseif(!empty($_POST['x']) && !empty($_POST['y']) && is_numeric($_POST['x']) && is_numeric($_POST['y']) && $_POST['x'] <= WORLD_MAX && $_POST['y'] <= WORLD_MAX){
$Wref = $database->getVilWref($_POST['x'], $_POST['y']);
$WrefX = $_POST['x'];
$WrefY = $_POST['y'];
$type = $database->getVillageType2($Wref);
$oasistype = $type;
$vdata = $database->getVillage($Wref);
}
$troops = "".$_POST['t1']."+".$_POST['t2']."+".$_POST['t3']."+".$_POST['t4']."+".$_POST['t5']."+".$_POST['t6']."+".$_POST['t7']."+".$_POST['t8']."+".$_POST['t9']."+".$_POST['t10'].""; if(empty($_POST['x']) && empty($_POST['y']) && empty($_POST['target_id'])) $errormsg = "Enter coordinates.";
elseif((empty($_POST['x']) || empty($_POST['y'])) && empty($_POST['target_id'])) $errormsg = "Enter the correct coordinates.";
elseif($oasistype == 0 && $vdata == 0) $errormsg = "There is no village on those coordinates.";
elseif($troops == 0) $errormsg = "No troops has been selected.";
elseif($database->hasBeginnerProtection($Wref) == 1) $errormsg = "Player under protection.";
elseif($_POST['target_id'] == $village->wid || $vdata['wref'] == $village->wid) $errormsg = "You can't attack the same village you send troops from.";
else
{
if($_POST['target_id'] != ""){ if(!empty($_POST['target_id'])){
$Wref = $_POST['target_id']; $Wref = $_POST['target_id'];
$WrefCoor = $database->getCoor($Wref); $WrefCoor = $database->getCoor($Wref);
$WrefX = $WrefCoor['x']; $WrefX = $WrefCoor['x'];
$WrefY = $WrefCoor['y']; $WrefY = $WrefCoor['y'];
$type = $database->getVillageType2($Wref);
$oasistype = $type['oasistype'];
$vdata = $database->getVillage($Wref);
}elseif($_POST['x']!="" && $_POST['y']!="" && is_numeric($_POST['x']) && is_numeric($_POST['y']) && $_POST['x']<= WORLD_MAX && $_POST['y']<= WORLD_MAX){
$Wref = $database->getVilWref($_POST['x'], $_POST['y']);
$WrefX = $_POST['x'];
$WrefY = $_POST['y'];
$type = $database->getVillageType2($Wref);
$oasistype = $type;
$vdata = $database->getVillage($Wref);
}
if($_POST['x']=="" && $_POST['y']=="" && $_POST['target_id'] == ""){
$errormsg .= "Enter coordinates.";
}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.";
}elseif($troops == "0"){
$errormsg .= "No troops has been selected.";
}elseif($database->hasBeginnerProtection($Wref)==1){
$errormsg .= "Player under protection.";
}else{
if($_POST['target_id'] != ""){
$Wref = $_POST['target_id'];
$WrefCoor = $database->getCoor($Wref);
$WrefX = $WrefCoor['x'];
$WrefY = $WrefCoor['y'];
}else{ }else{
$Wref = $database->getVilWref($_POST['x'], $_POST['y']); $Wref = $database->getVilWref($_POST['x'], $_POST['y']);
$WrefX = $_POST['x']; $WrefX = $_POST['x'];
$WrefY = $_POST['y']; $WrefY = $_POST['y'];
} }
$coor = $database->getCoor($village->wid); $coor = $database->getCoor($village->wid);
function getDistance($coorx1, $coory1, $coorx2, $coory2) { function getDistance($coorx1, $coory1, $coorx2, $coory2) {
$max = 2 * WORLD_MAX + 1; $max = 2 * WORLD_MAX + 1;
$x1 = intval($coorx1); $x1 = intval($coorx1);
$y1 = intval($coory1); $y1 = intval($coory1);
$x2 = intval($coorx2); $x2 = intval($coorx2);
$y2 = intval($coory2); $y2 = intval($coory2);
$distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1)));
$distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1)));
$dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2));
return round($dist, 1); return round($dist, 1);
} }
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
$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']); $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"); header("Location: build.php?id=39&t=99");
@@ -79,9 +78,9 @@ $vdata = $database->getVillage($Wref);
<input type="hidden" name="action" value="addSlot"> <input type="hidden" name="action" value="addSlot">
<table cellpadding="1" cellspacing="1" class="transparent"> <table cellpadding="1" cellspacing="1" class="transparent" id="raidList">
<tbody><tr> <tbody><tr>
<th>Farm Name:</th> <th>List name:</th>
<td> <td>
<select name="lid"> <select name="lid">
<?php <?php
@@ -103,7 +102,7 @@ $lvname = $database->getVillageField($row["wref"], 'name');
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Select target:</th> <th>Target village:</th>
<td class="target"> <td class="target">
<div class="coordinatesInput"> <div class="coordinatesInput">
@@ -111,35 +110,35 @@ $lvname = $database->getVillageField($row["wref"], 'name');
<label for="xCoordInput">X:</label> <label for="xCoordInput">X:</label>
<input value="<?php echo $_POST['x']; ?>" name="x" id="xCoordInput" class="text coordinates x "> <input value="<?php echo $_POST['x']; ?>" name="x" id="xCoordInput" class="text coordinates x ">
</div> </div>
<br />
<div class="yCoord"> <div class="yCoord">
<label for="yCoordInput">Y:</label> <label for="yCoordInput">Y:</label>
<input value="<?php echo $_POST['y']; ?>" name="y" id="yCoordInput" class="text coordinates y "> <input value="<?php echo $_POST['y']; ?>" name="y" id="yCoordInput" class="text coordinates y ">
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<br />
<div class="targetSelect"> <div class="targetSelect">
<label class="lastTargets">Last targets:</label> <label class="lastTargets">Last targets:</label>
<select name="target_id"> <select name="target_id">
<?php <?php
$getwref = "SELECT towref FROM ".TB_PREFIX."raidlist WHERE lid = ".$database->escape((int) $_GET['lid']).""; $getwref = "SELECT towref FROM ".TB_PREFIX."raidlist WHERE lid = ".$database->escape((int) $_GET['lid'])."";
$arraywref = $database->query_return($getwref); $arraywref = $database->query_return($getwref);
echo '<option value="">Select village</option>'; echo '<option value="">Select village</option>';
if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){ if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){
foreach($arraywref as $row){ foreach($arraywref as $row){
$towref = $row["towref"]; $towref = $row["towref"];
$tocoor = $database->getCoor($towref); $tocoor = $database->getCoor($towref);
$totype = $database->getVillageType2($towref); $totype = $database->getVillageType2($towref);
$tooasistype = $type['oasistype']; $tooasistype = $type['oasistype'];
if($tooasistype == 0){ if($tooasistype == 0) $tovname = $database->getVillageField($towref, 'name');
$tovname = $database->getVillageField($towref, 'name'); else $tovname = $database->getOasisField($towref, 'name');
}else{
$tovname = $database->getOasisField($towref, 'name'); if($vill[$towref] == 0){
} echo '<option value="'.$towref.'">'.$tovname.'('.$tocoor['x'].'|'.$tocoor['y'].')</option>';
if($vill[$towref] == 0){ }
echo '<option value="'.$towref.'">'.$tovname.'('.$tocoor['x'].'|'.$tocoor['y'].')</option>'; $vill[$towref] = 1;
} }
$vill[$towref] = 1;
}
} }
?> ?>
</select> </select>
@@ -150,10 +149,9 @@ $vill[$towref] = 1;
</tbody></table> </tbody></table>
</div> </div>
</div> </div>
<?php include "Templates/goldClub/trooplist2.tpl"; ?> <?php include("Templates/goldClub/trooplist2.tpl"); ?>
<br />
<button type="submit" value="save" name="save" id="save" class="trav_buttons">Save</button>
<button type="submit" value="save" name="save" id="save"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">save</div></div></button>
</form> </form>
</div> </div>
+59 -56
View File
@@ -1,65 +1,67 @@
<?php <?php
if(isset($_GET['action']) == 'editSlot' && $_GET['eid']) { if(isset($_GET['action']) == 'editSlot' && $_GET['eid']) {
$eiddata = $database->getRaidList($_GET['eid']); $eiddata = $database->getRaidList($_GET['eid']);
$x = $eiddata['x']; $x = $eiddata['x'];
$y = $eiddata['y']; $y = $eiddata['y'];
$t1 = $eiddata['t1'];$t2 = $eiddata['t2'];$t3 = $eiddata['t3'];$t4 = $eiddata['t4'];$t5 = $eiddata['t5'];$t6 = $eiddata['t6'];$t7 = $eiddata['t7'];$t8 = $eiddata['t8'];$t9 = $eiddata['t9'];$t10 = $eiddata['t10']; for($i = 1; $i <= 10; $i++) ${'t'.$i} = $eiddata['t'.$i];
$FLData = $database->getFLData($eiddata['lid']); $FLData = $database->getFLData($eiddata['lid']);
} }
if(isset($_POST['action']) == 'editSlot' && $_POST['eid']) { if(isset($_POST['action']) == 'editSlot' && $_POST['eid']) {
if($_POST['target_id'] != ""){ if(!empty($_POST['target_id'])){
$Wref = $_POST['target_id']; $Wref = $_POST['target_id'];
$WrefCoor = $database->getCoor($Wref); $WrefCoor = $database->getCoor($Wref);
$WrefX = $WrefCoor['x']; $WrefX = $WrefCoor['x'];
$WrefY = $WrefCoor['y']; $WrefY = $WrefCoor['y'];
$type = $database->getVillageType2($Wref); $type = $database->getVillageType2($Wref);
$oasistype = $type['oasistype']; $oasistype = $type;
$vdata = $database->getVillage($Wref); $vdata = $database->getVillage($Wref);
}elseif($_POST['x']!="" && $_POST['y']!="" && is_numeric($_POST['x']) && is_numeric($_POST['y'])){ }elseif(!empty($_POST['x']) && !empty($_POST['y']) && is_numeric($_POST['x']) && is_numeric($_POST['y'])){
$Wref = $database->getVilWref($_POST['x'], $_POST['y']); $Wref = $database->getVilWref($_POST['x'], $_POST['y']);
$WrefX = $_POST['x']; $WrefX = $_POST['x'];
$WrefY = $_POST['y']; $WrefY = $_POST['y'];
$type = $database->getVillageType2($Wref); $type = $database->getVillageType2($Wref);
$oasistype = $type['oasistype']; $oasistype = $type;
$vdata = $database->getVillage($Wref); $vdata = $database->getVillage($Wref);
} }
$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']=="" && $_POST['target_id'] == ""){ $troops = 0;
$errormsg .= "Enter coordinates."; for($i = 1; $i <= 10; $i++) $troops += $_POST['t'.$i];
}elseif(($_POST['x']=="" || $_POST['y']=="") && $_POST['target_id'] == ""){
$errormsg .= "Enter the correct coordinates."; if(empty($_POST['x']) && empty($_POST['y']) && empty($_POST['target_id'])) $errormsg = "Enter coordinates.";
}elseif($oasistype == 0 && $vdata == 0){ elseif((empty($_POST['x']) || empty($_POST['y'])) && empty($_POST['target_id'])) $errormsg = "Enter the correct coordinates.";
$errormsg .= "There is no village on those coordinates."; elseif($oasistype == 0 && $vdata == 0) $errormsg = "There is no village on those coordinates.";
}elseif($troops == "0"){ elseif($troops == 0) $errormsg = "No troops has been selected.";
$errormsg .= "No troops has been selected."; elseif($database->hasBeginnerProtection($Wref) == 1) $errormsg = "Player under protection.";
}else{ elseif($_POST['target_id'] == $village->wid || $vdata['wref'] == $village->wid) $errormsg = "You can't attack the same village you send troops from.";
else
{
if($_POST['target_id'] != ""){ if(!empty($_POST['target_id'])){
$Wref = $_POST['target_id']; $Wref = $_POST['target_id'];
$WrefCoor = $database->getCoor($Wref); $WrefCoor = $database->getCoor($Wref);
$WrefX = $WrefCoor['x']; $WrefX = $WrefCoor['x'];
$WrefY = $WrefCoor['y']; $WrefY = $WrefCoor['y'];
}else{ }else{
$Wref = $database->getVilWref($_POST['x'], $_POST['y']); $Wref = $database->getVilWref($_POST['x'], $_POST['y']);
$WrefX = $_POST['x']; $WrefX = $_POST['x'];
$WrefY = $_POST['y']; $WrefY = $_POST['y'];
} }
$coor = $database->getCoor($village->wid); $coor = $database->getCoor($village->wid);
function getDistance($coorx1, $coory1, $coorx2, $coory2) { function getDistance($coorx1, $coory1, $coorx2, $coory2) {
$max = 2 * WORLD_MAX + 1; $max = 2 * WORLD_MAX + 1;
$x1 = intval($coorx1); $x1 = intval($coorx1);
$y1 = intval($coory1); $y1 = intval($coory1);
$x2 = intval($coorx2); $x2 = intval($coorx2);
$y2 = intval($coory2); $y2 = intval($coory2);
$distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1)));
$distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1)));
$dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2));
return round($dist, 1); return round($dist, 1);
} }
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
$database->editSlotFarm($_GET['eid'], $_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']); $database->editSlotFarm($_GET['eid'], $_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']);
@@ -87,7 +89,7 @@ $lid2 = $getlid['lid'];
<input type="hidden" name="eid" value="<?php echo $_GET['eid']; ?>"> <input type="hidden" name="eid" value="<?php echo $_GET['eid']; ?>">
<input type="hidden" name="lid" value="<?php echo $lid2; ?>"> <input type="hidden" name="lid" value="<?php echo $lid2; ?>">
<table cellpadding="1" cellspacing="1" class="transparent"> <table cellpadding="1" cellspacing="1" class="transparent" id="raidList">
<tbody><tr> <tbody><tr>
<th>Farm Name:</th><?php echo $_GET["lid"]; ?> <th>Farm Name:</th><?php echo $_GET["lid"]; ?>
<td> <td>
@@ -117,13 +119,14 @@ $lvname = $database->getVillageField($row["wref"], 'name');
<label for="xCoordInput">X:</label> <label for="xCoordInput">X:</label>
<input value="<?php echo $x; ?>" name="x" id="xCoordInput" class="text coordinates x "> <input value="<?php echo $x; ?>" name="x" id="xCoordInput" class="text coordinates x ">
</div> </div>
<br />
<div class="yCoord"> <div class="yCoord">
<label for="yCoordInput">Y:</label> <label for="yCoordInput">Y:</label>
<input value="<?php echo $y; ?>" name="y" id="yCoordInput" class="text coordinates y "> <input value="<?php echo $y; ?>" name="y" id="yCoordInput" class="text coordinates y ">
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<div class="targetSelect"> <div class="targetSelect"><br />
<label class="lastTargets">Last targets:</label> <label class="lastTargets">Last targets:</label>
<select name="target_id"> <select name="target_id">
<?php <?php
@@ -159,9 +162,9 @@ $vill[$towref] = 1;
</div> </div>
<?php include "Templates/goldClub/trooplist.tpl"; ?> <?php include "Templates/goldClub/trooplist.tpl"; ?>
<br />
<button type="submit" value="save" name="save" id="save"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Save</div></div></button>&nbsp; <button type="submit" value="save" name="save" id="save" class="trav_buttons">Save</button>&nbsp;
<button type="button" value="delete" name="delete" id="delete" onclick="window.location.href = '?gid=16&t=99&action=deleteSlot&eid=<?php echo $_GET["eid"]; ?>';"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Delete</div></div></button> <button type="button" value="delete" name="delete" id="delete" class="trav_buttons" onclick="window.location.href = '?gid=16&t=99&action=deleteSlot&eid=<?php echo $_GET["eid"]; ?>&lid=<?php echo $eiddata['lid']; ?>';">Delete</button>
</form> </form>
</div> </div>
<?php <?php
+1 -1
View File
@@ -95,7 +95,7 @@ if(isset($_GET['newdid'])) {
<?php <?php
if (isset($_GET['id'])) if (isset($_GET['id']))
{ {
if (isset($_GET['aid']) && $_GET['aid'] > 0 && $_GET['aid'] == $session->alliance) if (isset($_GET['aid']) && $_GET['aid'] > 0 && $_GET['aid'] == $session->alliance && $database->getNotice2($_GET['id'], 'ally') == $session->alliance)
{ {
$type = $database->getNotice2($_GET['id'], 'ntype'); $type = $database->getNotice2($_GET['id'], 'ntype');
if ($type >= 10 && $type <= 17) unset($type); if ($type >= 10 && $type <= 17) unset($type);
+58 -86
View File
@@ -17,12 +17,12 @@ include_once( "GameEngine/Village.php" );
include_once( "GameEngine/Units.php" ); include_once( "GameEngine/Units.php" );
AccessLogger::logRequest(); AccessLogger::logRequest();
if ( isset( $_GET['newdid'] ) ) { if(isset($_GET['newdid'])){
$_SESSION['wid'] = $_GET['newdid']; $_SESSION['wid'] = $_GET['newdid'];
header( "Location: " . $_SERVER['PHP_SELF'] . ( isset( $_GET['id'] ) ? '?id=' . $_GET['id'] : ( isset( $_GET['gid'] ) ? '?gid=' . $_GET['gid'] : '' ) ) ); header("Location: " . $_SERVER['PHP_SELF'].(isset($_GET['id']) ? '?id='.$_GET['id'] : (isset($_GET['gid']) ? '?gid='.$_GET['gid'] : '')));
exit; exit;
} }
if (isset($_GET['id']) && ($_GET['id'] < 1 || $_GET['id'] > 40 && ($_GET['id'] == 99 && $village->natar == 0 || $_GET['id'] != 99))) { if(isset($_GET['id']) && ($_GET['id'] < 1 || $_GET['id'] > 40 && ($_GET['id'] == 99 && $village->natar == 0 || $_GET['id'] != 99))){
header("Location: dorf2.php"); header("Location: dorf2.php");
exit; exit;
} }
@@ -47,7 +47,7 @@ if ( isset( $_GET['id'] ) ) {
$_GET['id'] = "1"; $_GET['id'] = "1";
} }
$checkBuildings = array( 0, 16, 17, 25, 26, 27 ); $checkBuildings = [0, 16, 17, 25, 26, 27];
if ( $_GET['id'] < 19 || ( isset( $_GET['gid'] ) && ! in_array( $_GET['gid'], $checkBuildings ) ) ) { if ( $_GET['id'] < 19 || ( isset( $_GET['gid'] ) && ! in_array( $_GET['gid'], $checkBuildings ) ) ) {
$_GET['t'] = ""; $_GET['t'] = "";
@@ -188,75 +188,65 @@ if ($session->goldclub == 1 && count($session->villages) > 1) {
} }
} }
if ( $session->goldclub == 1 ) { if ($session->goldclub == 1) {
if ( isset( $_GET['t'] ) == 99 ) { if (isset($_GET['t']) == 99) {
if(isset($_GET['action'])){
if($_GET['action'] == 'addList') $create = 1;
elseif($_GET['action'] == 'addraid') $create = 2;
elseif($_GET['action'] == 'showSlot' && $_GET['eid']) $create = 3;
}
else $create = 0;
if ( isset( $_GET['action'] ) && $_GET['action'] == 'addList' ) { if(isset($_GET['slid']) && $_GET['slid']){
$create = 1; $FLData = $database->getFLData($_GET['slid']);
} else if ( isset( $_GET['action'] ) && $_GET['action'] == 'addraid' ) { if ($FLData['owner'] == $session->uid) $checked[$_GET['slid']] = 1;
$create = 2;
} else if ( isset( $_GET['action'] ) && $_GET['action'] == 'showSlot' && $_GET['eid'] ) {
$create = 3;
} else {
$create = 0;
} }
if ( isset( $_GET['slid'] ) && $_GET['slid'] ) { if(isset($_GET['action']) && $_GET['action'] == 'deleteList') {
$FLData = $database->getFLData( $_GET['slid'] ); $database->delFarmList($_GET['lid'], $session->uid);
if ( $FLData['owner'] == $session->uid ) { header("Location: build.php?id=39&t=99");
$checked[ $_GET['slid'] ] = 1;
}
}
if ( isset( $_GET['action'] ) && $_GET['action'] == 'deleteList' ) {
$database->delFarmList( $_GET['lid'], $session->uid );
header( "Location: build.php?id=39&t=99" );
exit; exit;
} elseif ( isset( $_GET['action'] ) && $_GET['action'] == 'deleteSlot' ) { } elseif(isset($_GET['action']) && $_GET['action'] == 'deleteSlot') {
$database->delSlotFarm( $_GET['eid'] ); $database->delSlotFarm($_GET['eid'], $session->uid, $_GET['lid']);
header( "Location: build.php?id=39&t=99" ); header("Location: build.php?id=39&t=99");
exit; exit;
} }
if ( isset( $_POST['action'] ) && $_POST['action'] == 'startRaid' ) { if(isset($_POST['action'] ) && $_POST['action'] == 'startRaid') {
if ( $session->access != BANNED ) { if($session->access != BANNED) include("Templates/a2b/startRaid.tpl");
include( "Templates/a2b/startRaid.tpl" ); else
} else { {
header( "Location: banned.php" ); header( "Location: banned.php");
exit; exit;
} }
} }
if ( isset( $_GET['slid'] ) && is_numeric( $_GET['slid'] ) ) { if(isset($_GET['slid']) && is_numeric($_GET['slid'])) {
$FLData = $database->getFLData( $_GET['slid'] ); $FLData = $database->getFLData($_GET['slid']);
if ( $FLData['owner'] == $session->uid ) { if ($FLData['owner'] == $session->uid) $checked[$_GET['slid']] = 1;
$checked[ $_GET['slid'] ] = 1;
}
} }
if ( isset( $_GET['evasion'] ) && is_numeric( $_GET['evasion'] ) ) { if(isset($_GET['evasion']) && is_numeric($_GET['evasion'])) {
$evasionvillage = $database->getVillage( $_GET['evasion'] ); $evasionvillage = $database->getVillage($_GET['evasion']);
if ( $evasionvillage['owner'] == $session->uid ) { if($evasionvillage['owner'] == $session->uid) $database->setVillageEvasion($_GET['evasion']);
$database->setVillageEvasion( $_GET['evasion'] );
} header("Location: build.php?id=39&t=99");
header( "Location: build.php?id=39&t=99" );
exit; exit;
} }
if ( isset( $_POST['maxevasion'] ) && is_numeric( $_POST['maxevasion'] ) ) { if (isset($_POST['maxevasion']) && is_numeric($_POST['maxevasion'])) {
$database->updateUserField( $session->uid, "maxevasion", $_POST['maxevasion'], 1 ); $database->updateUserField($session->uid, "maxevasion", $_POST['maxevasion'], 1);
header( "Location: build.php?id=39&t=99" ); header("Location: build.php?id=39&t=99" );
exit; exit;
} }
} }
} else {
$create = 0;
} }
else $create = 0;
if ( isset( $_POST['a'] ) == 533374 && isset( $_POST['id'] ) == 39 ) { if(isset($_POST['a']) == 533374 && isset($_POST['id']) == 39) {
if ( $session->access != BANNED ) { if($session->access != BANNED) $units->Settlers($_POST);
$units->Settlers( $_POST ); else
} else { {
header( "Location: banned.php" ); header( "Location: banned.php" );
exit; exit;
} }
@@ -296,9 +286,7 @@ if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'troops' && isset( $_GET['cancel
exit; exit;
} }
} }
if ( isset( $_GET['id'] ) ) { if(isset($_GET['id'])) $automation->isWinner();
$automation->isWinner();
}
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html> <html>
@@ -345,47 +333,32 @@ if ( isset( $_GET['id'] ) ) {
<div id="content" class="build"> <div id="content" class="build">
<?php <?php
if(isset($_GET['id']) || isset($_GET['gid']) || $route == 1 || isset($_POST['routeid']) || isset($_GET['buildingFinish'])) { if(isset($_GET['id']) || isset($_GET['gid']) || $route == 1 || isset($_POST['routeid']) || isset($_GET['buildingFinish'])) {
if(isset($_GET['s']))
{ if(isset($_GET['s']) && !ctype_digit($_GET['s'])) $_GET['s'] = null;
if (!ctype_digit($_GET['s'])) { if(isset($_GET['t']) && !ctype_digit($_GET['t'])) $_GET['t'] = null;
$_GET['s'] = null; if (!ctype_digit($_GET['id'])) $_GET['id'] = 1;
}
}
if(isset($_GET['t']))
{
if (!ctype_digit($_GET['t'])) {
$_GET['t'] = null;
}
}
if (!ctype_digit($_GET['id'])) {
$_GET['id'] = "1";
}
$id = $_GET['id']; $id = $_GET['id'];
if($id=='99' AND $village->resarray['f99t'] == 40){ if($_GET['id'] == 99 && $village->resarray['f99t'] == 40){
include("Templates/Build/ww.tpl"); include("Templates/Build/ww.tpl");
} else } elseif($village->resarray['f'.$_GET['id'].'t'] == 0 && $_GET['id'] >= 19) {
if($village->resarray['f'.$_GET['id'].'t'] == 0 && $_GET['id'] >= 19) {
include("Templates/Build/avaliable.tpl"); include("Templates/Build/avaliable.tpl");
} }
else { else {
if(isset($_GET['t'])) { if(isset($_GET['t'])) {
if($_GET['t'] == 1) { if($_GET['t'] == 1) $_SESSION['loadMarket'] = 1;
$_SESSION['loadMarket'] = 1;
}
include("Templates/Build/".$village->resarray['f'.$_GET['id'].'t']."_".$_GET['t'].".tpl"); include("Templates/Build/".$village->resarray['f'.$_GET['id'].'t']."_".$_GET['t'].".tpl");
} else } elseif(isset($_GET['s'])) {
if(isset($_GET['s'])) {
include("Templates/Build/".$village->resarray['f'.$_GET['id'].'t']."_".$_GET['s'].".tpl"); include("Templates/Build/".$village->resarray['f'.$_GET['id'].'t']."_".$_GET['s'].".tpl");
} }
else { else include("Templates/Build/".$village->resarray['f'.$_GET['id'].'t'].".tpl");
include("Templates/Build/".$village->resarray['f'.$_GET['id'].'t'].".tpl");
}
if((isset($_GET['buildingFinish'])) && $_GET['buildingFinish'] == 1) { if((isset($_GET['buildingFinish'])) && $_GET['buildingFinish'] == 1) {
if($session->gold >= 2) { if($session->gold >= 2) {
$building->finishAll("build.php?gid=".$_GET['id']."&ty=".$_GET['ty']); $building->finishAll("build.php?gid=".$_GET['id']."&ty=".$_GET['ty']);
exit; exit;
} }
} }
} }
}else{ }else{
header("Location: ".$_SERVER['PHP_SELF']."?id=39"); header("Location: ".$_SERVER['PHP_SELF']."?id=39");
@@ -428,9 +401,8 @@ echo round(($generator->pageLoadTimeEnd()-$pagestart)*1000);
// update TITLE to include building name, as it's not very possible to do in PHP in current codebase // update TITLE to include building name, as it's not very possible to do in PHP in current codebase
if (document.getElementsByTagName('h1').length) { if (document.getElementsByTagName('h1').length) {
document.title = document.title + ' » » ' + document.getElementsByTagName('h1')[0].innerHTML.replace(/(<([^>]+)>)/ig,""); document.title = document.title + ' » » ' + document.getElementsByTagName('h1')[0].innerHTML.replace(/(<([^>]+)>)/ig,"");
} else { }
document.title + ' » » New Building' else document.title + ' » » New Building'
}
</script> </script>
</body> </body>
</html> </html>