mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-29 14:47:14 +00:00
Refactor + BugFix
1. Fix a bug in Admin Panel that you can edit by yourself your rank, now you cannot edit your rank anymore. 2. Now Alliance Leader can edit his own Position 3. Fix negative value on Demolition Building, now in database at lvl is appear new level not -1 4. Refactor Ajax map, now all is alligned (Ajax folder and Map folder) 5. Fix bug from Palace (when change capital now Automation recount population automaticaly on old capital and new capital)
This commit is contained in:
+41
-31
@@ -1,38 +1,58 @@
|
||||
<?php
|
||||
// PALACE - gid 26 - refactorizat
|
||||
if(time() - (!empty($_SESSION['time_p']) ? $_SESSION['time_p'] : 0) > 5){
|
||||
$_SESSION['time_p'] = '';
|
||||
$_SESSION['error_p'] = '';
|
||||
}
|
||||
|
||||
if($_POST and $_GET['action'] == 'change_capital' && !$village->capital){
|
||||
$pass = mysqli_escape_string($database->dblink, $_POST['pass']);
|
||||
// --- LOGICA SCHIMBARE CAPITALA ---
|
||||
if($_POST && $_GET['action'] == 'change_capital' && !$village->capital){
|
||||
$pass = $_POST['pass'];
|
||||
$query = mysqli_query($database->dblink, 'SELECT password FROM `'.TB_PREFIX.'users` WHERE `id` = '.(int)$session->uid);
|
||||
$data = mysqli_fetch_assoc($query);
|
||||
// 1. Verifică parola
|
||||
if(password_verify($pass, $data['password'])){
|
||||
$query1 = mysqli_query($database->dblink, 'SELECT wref FROM `'.TB_PREFIX.'vdata` WHERE `owner` = '.(int)$session->uid.' AND `capital` = 1');
|
||||
$data1 = mysqli_fetch_assoc($query1);
|
||||
$query2 = mysqli_query($database->dblink, 'SELECT * FROM `'.TB_PREFIX.'fdata` WHERE `vref` = '.(int)$data1['wref']);
|
||||
$data2 = mysqli_fetch_assoc($query2);
|
||||
if($data2['vref'] != $village->wid){
|
||||
$oldWid = (int)$data1['wref'];
|
||||
$newWid = (int)$village->wid;
|
||||
|
||||
if($oldWid != $newWid){
|
||||
// ia datele ambelor sate
|
||||
$query2 = mysqli_query($database->dblink, 'SELECT * FROM `'.TB_PREFIX.'fdata` WHERE `vref` = '.$oldWid);
|
||||
$data2 = mysqli_fetch_assoc($query2);
|
||||
$query3 = mysqli_query($database->dblink, 'SELECT * FROM `'.TB_PREFIX.'fdata` WHERE `vref` = '.$newWid);
|
||||
$data3 = mysqli_fetch_assoc($query3);
|
||||
|
||||
// 1. taie resursele vechii capitale la nivel 10
|
||||
for($i = 1; $i <= 18; ++$i){
|
||||
if($data2['f'.$i] > 10){
|
||||
$query2 = mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'` = 10 WHERE `vref` = '.(int)$data2['vref']);
|
||||
mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'` = 10 WHERE `vref` = '.$oldWid);
|
||||
}
|
||||
}
|
||||
// 2. șterge Zidarul din vechea capitală
|
||||
for($i = 19; $i <= 40; ++$i){
|
||||
if($data2['f'.$i.'t'] == 34){
|
||||
$query3 = mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.(int)$data2['vref']);
|
||||
mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.$oldWid);
|
||||
}
|
||||
}
|
||||
// 3. FIX: șterge clădirile specifice capitalei din NOUA capitală
|
||||
$capitalOnly = [29,30,38,39,42];
|
||||
for($i = 19; $i <= 40; ++$i){
|
||||
if(in_array((int)$data3['f'.$i.'t'], $capitalOnly)){
|
||||
mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.$newWid);
|
||||
}
|
||||
}
|
||||
|
||||
for($i = 19; $i <= 40; ++$i){
|
||||
if($data2['f'.$i.'t'] == 29 || $data2['f'.$i.'t'] == 30 || $data2['f'.$i.'t'] == 38 || $data2['f'.$i.'t'] == 39 || $data2['f'.$i.'t'] == 42){
|
||||
$query3 = mysqli_query($database->dblink, 'UPDATE `'.TB_PREFIX.'fdata` SET `f'.$i.'t` = 0, `f'.$i.'` = 0 WHERE `vref` = '.(int)$village->wid);
|
||||
}
|
||||
}
|
||||
|
||||
$database->changeCapital((int)$data1['wref'], 0);
|
||||
$database->changeCapital($village->wid);
|
||||
$database->changeCapital($oldWid, 0);
|
||||
$database->changeCapital($newWid);
|
||||
|
||||
// 4. FIX BUG-UL TĂU: recount populație instant
|
||||
if(!isset($automation)){
|
||||
include_once("GameEngine/Automation.php");
|
||||
}
|
||||
$automation->recountPop($oldWid, false);
|
||||
$automation->recountPop($newWid, false);
|
||||
|
||||
header("location: build.php?gid=26");
|
||||
exit;
|
||||
}
|
||||
@@ -40,37 +60,29 @@ if($_POST and $_GET['action'] == 'change_capital' && !$village->capital){
|
||||
$error = '<br /><font color="red">'.LOGIN_PW_ERROR.'</font><br />';
|
||||
$_SESSION['error_p'] = $error;
|
||||
$_SESSION['time_p'] = time();
|
||||
echo '<script language="javascript">location.href="build.php?id='.$building->getTypeField(26).'&confirm=yes";</script>';
|
||||
echo '<script>location.href="build.php?id='.$building->getTypeField(26).'&confirm=yes";</script>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div id="build" class="gid26"><h1><?php echo PALACE; ?> <span class="level"><?php echo LEVEL; ?> <?php echo $village->resarray['f'.$id]; ?></span></h1>
|
||||
<p class="build_desc">
|
||||
<a href="#" onClick="return Popup(26,4, 'gid');"
|
||||
class="build_logo"> <img
|
||||
class="building g26"
|
||||
src="img/x.gif" alt="Palace"
|
||||
title="<?php echo PALACE; ?>" /> </a>
|
||||
<a href="#" onClick="return Popup(26,4, 'gid');" class="build_logo"> <img class="building g26" src="img/x.gif" alt="Palace" title="<?php echo PALACE; ?>" /> </a>
|
||||
<?php echo PALACE_DESC; ?></p>
|
||||
|
||||
<?php
|
||||
if ($building->getTypeLevel(26) > 0) {
|
||||
|
||||
include("26_menu.tpl");
|
||||
|
||||
if($village->resarray['f'.$id] >= 10) include ("26_train.tpl");
|
||||
else echo '<div class="c">'.PALACE_TRAIN_DESC.'</div>';
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
if($village->capital == 1) {
|
||||
?>
|
||||
<p class="none"><?php echo CAPITAL; ?></p>
|
||||
<?php
|
||||
} else {
|
||||
if(empty($_GET['confirm'])) {
|
||||
print '<p><a href="?id='.$building->getTypeField(26).'&confirm=yes">» '.CHANGE_CAPITAL.'</a></p>';
|
||||
print '<p><a href="?id='.$building->getTypeField(26).'&confirm=yes">» '.CHANGE_CAPITAL.'</a></p>';
|
||||
} else {
|
||||
print '<p>Are you sure, that you want to change your capital?<br /><b>You can\'t undo this!</b><br />For security you must enter your password to confirm:<br />
|
||||
<form method="post" action="build.php?id='.$building->getTypeField(26).'&action=change_capital">
|
||||
@@ -81,9 +93,7 @@ if($village->capital == 1) {
|
||||
</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else echo "<b><?php echo PALACE_CONSTRUCTION; ?></b>";
|
||||
|
||||
} else echo "<b>".PALACE_CONSTRUCTION."</b>";
|
||||
include("upgrade.tpl");
|
||||
?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user