<table>
<tr>
<td><img src="../graphic/big_buildings/statue1.png" title="Estatua" alt="" /></td>
<td>
<h2>Statue ({$village.statue|stage})
</h2>
Locuitorii satului aduc la statuie omagii Paladinului. Daca Paladinul cade in lupta, aici ai posibilitatea sa numesti un soldat ca nou Paladin.
</td>
</tr>
</table><br />
{php}
include("include/configs/unit_knight_config.php");
// nivel statuie
$statue = $this->_tpl_vars['village']['statue'];
if($statue != '0'){
$time = $time * 60 - 1;
$time_s = time() + $time;
// aflam resursele din sat
$village_wood = $this->_tpl_vars['village']['r_wood'];
$village_stone = $this->_tpl_vars['village']['r_stone'];
$village_iron = $this->_tpl_vars['village']['r_iron'];
// aflam id-ul userului
$userid = $this->_tpl_vars['user']['id'];
// codul de securitate
$hkey = $this->_tpl_vars['hkey'];
// pe ce sat este folosind metoda GET
$vill = $_GET['village'];
// selectam date user
$user = mysql_fetch_array(mysql_query("SELECT `knight`,`knight_name`,`knight_village_recruit`,`knight_village` FROM `users` WHERE `id` = '".$userid."'"));
if($user['knight_village'] > 0){
$numar_paladini = mysql_fetch_assoc(mysql_query("SELECT `all_unit_knight` FROM `villages` WHERE `id` = '".$user['knight_village']."'"));
}
// verificam daca se recruteaza vreun paladin
$recruit = mysql_num_rows(mysql_query("SELECT * FROM `recruit` WHERE `villageid` = '".$user['knight_village_recruit']."' AND `unit` = 'unit_knight'"));
if(!$recruit){
mysql_query("UPDATE `users` SET `knight` = '".$numar_paladini['all_unit_knight']."' WHERE `id` = '".$userid."'");
}
$user = mysql_fetch_array(mysql_query("SELECT `knight`,`knight_name`,`knight_village_recruit`,`knight_village` FROM `users` WHERE `id` = '".$userid."'"));
// anulam comanda
if($_GET['do'] == 'drep' && $_GET['hkey'] == $hkey){
mysql_query("UPDATE `users` SET `knight` = '0' WHERE `id` = '".$userid."'");
mysql_query("DELETE FROM `events` WHERE `event_id` = '".$_GET['id']."'");
$recruit_f1 = mysql_fetch_array(mysql_query("SELECT `villageid` FROM `recruit` WHERE `id` = '".$_GET['id']."'"));
mysql_query("UPDATE `villages` SET `r_bh` = `r_bh` - '".$farms."' WHERE `id` = '".$recruit_f1['villageid']."'") or die (mysql_error());
mysql_query("DELETE FROM recruit WHERE id = '".$_GET['id']."'");
header("Location: game.php?village=$vill&screen=statue");
}
// daca recrutam paladinul
if($_GET['recruit'] == 'paladin'){
if($user['knight'] >= '1'){
$error = 'Voê já possui um paladino.';
}else{
mysql_query("UPDATE `villages` SET `r_wood` = `r_wood` - '".$wood."' WHERE `id` = '".$_GET['village']."'") or die (mysql_error());
mysql_query("UPDATE `villages` SET `r_stone` = `r_stone` - '".$stone."' WHERE `id` = '".$_GET['village']."'");
mysql_query("UPDATE `villages` SET `r_iron` = `r_iron` - '".$iron."' WHERE id = '".$_GET['village']."'");
mysql_query("UPDATE `villages` SET `r_bh` = `r_bh` + '".$farms."' WHERE id = '".$_GET['village']."'");
mysql_query("INSERT INTO `recruit` (`unit`,`num_unit`,`num_finished`,`time_finished`,`time_start`,`time_per_unit`,`building`,`villageid`) VALUES ('".$unit."','1','0','".$time_s."','".time()."','".$time."','statue','".$_GET['village']."')") or die (mysql_error());
$select = mysql_query("SELECT * FROM `recruit` WHERE `unit` = 'unit_knight' AND `villageid` = '".$_GET['village']."' ORDER BY id DESC") or die (mysql_error());
$num = mysql_num_rows($select);
if($num > 0){
$array = mysql_fetch_array($select);
mysql_query("INSERT INTO events (`event_time`,`event_type`,`event_id`,`user_id`,`villageid`) VALUES ('".time()."','recruit','".$array['id']."','".$userid."','".$_GET['village']."')") or die (mysql_error());
}
mysql_query("UPDATE `users` SET `knight` = '1' WHERE `id` = '".$userid."'");
mysql_query("UPDATE `users` SET `knight_village_recruit` = '".$_GET['village']."' WHERE `id` = '".$userid."'");
mysql_query("UPDATE `users` SET `knight_village` = '".$_GET['village']."' WHERE `id` = '".$userid."'");
$vill = $_GET['village'];
header("Location: game.php?village=$vill&screen=statue");
}
}
$num = mysql_num_rows(mysql_query("SELECT * FROM `recruit` WHERE `villageid` = '".$vill."' AND building = 'statue'"));
if($num > 0){
{/php}
<table class="vis">
<tr>
<th width="150">Comando</th>
<th width="120">Duração</th>
<th width="150">Termino</th>
<th width="100">Cancelar *</th>
</tr>
{php}
$vil = $_GET['village'];
$o1 = mysql_query("SELECT id FROM villages WHERE userid = '".$userid."'") or die (mysql_error());
while ($array02 = mysql_fetch_array($o1)){
$query03 = mysql_fetch_array(mysql_query("SELECT * FROM recruit WHERE villageid = '".$vill."' AND building = 'statue'"));
if($array02['id'] == $query03['villageid']){
echo '<tr class="lit"><td><img src="../graphic/unit/unit_knight.png" />'.stripslashes(urldecode($user['knight_name'])).'</td><td align="center"><span class="timer">'.format_time($query03['time_finished']-time()+1).'</span></td><td align="center">'.date("d.m.y H:i", $query03['time_finished']).'</td><td><a href="game.php?village='.$vil.'&screen=statue&do=drep&id='.$query03['id'].'&hkey='.$hkey.'">cancelar</a></td></tr>';
}
}
{/php}
</table><br />
{php}
}
if(!empty($error)){
{/php}
<div class="error">{php} echo $error; {/php}</div>
{php}
}
{/php}
<table class="vis" width="100%">
<tr><th width="130">Unidade</th> <th width="40"><center><img src="../graphic/holz.png"></center></th>
<th width="40"><center><img src="../graphic/lehm.png"></center></th>
<th width="40"><center><img src="../graphic/eisen.png"></center></th>
<th width="40"><center><img src="../graphic/face.png"></center></th><th>Duração</th><th>Recrutar</th><th width="240">Localidade</th></tr>
<tr>
<td width="250"><a href="javascript:popup('popup_unit.php?unit={php} echo $unit; {/php}', 520, 520)"> <img src="../graphic/unit/{php} echo $unit; {/php}.png" alt="" />{php} echo stripslashes(urldecode($user['knight_name'])); {/php}</a></td>
<td align="center">{php}echo $wood;{/php}</td>
<td align="center">{php}echo $stone;{/php}</td>
<td align="center">{php}echo $iron;{/php}</td>
<td align="center">{php}echo $farms;{/php}</td>
<td align="center">{php}echo format_time($time+1);{/php}</td>
{php}
include("include/config.php");
include("include/configs/farm_limits.php");
$wood_re = $this->_tpl_vars['village']['r_wood'];
$stone_re = $this->_tpl_vars['village']['r_stone'];
$iron_re = $this->_tpl_vars['village']['r_iron'];
$farms_re = $this->_tpl_vars['village']['r_bh'];
$farms_lvl = $this->_tpl_vars['village']['farm'];
if($wood_re < $wood || $stone_re < $stone || $iron_re < $iron){
$error = '<td class="inactive" align="center">Recursos insuficientes.</td>';
}
if($user['knight'] >= '1'){
$error = '<td class="inactive" align="center">Só é permitido 1 paladino por jogador.</td>';
}
if($farms_re + $farms >= $arr_farm[$farms_lvl]){
$error = '<td class="inactive" align="center">A fazenda não pode prover mais unidades.</td>';
}
if(!empty($error)){
echo $error;
}else{
{/php}
<td align="center"><a href="game.php?village={$village.id}&screen=statue&recruit=paladin">Nomear paladino</a></td>
{php}
}
{/php}
<td align="center">
{php}
$knight_loc = mysql_fetch_assoc(mysql_query("SELECT * FROM `villages` WHERE `id` = '".$user['knight_village']."'"));
if ($knight_loc['all_unit_knight'] > 0) { echo '<a href="game.php?village='.$knight_loc[id].'&screen=overview">'.stripslashes(urldecode($knight_loc['name'])).' ('.$knight_loc['x'].'|'.$knight_loc['y'].') K'.$knight_loc['continent'].'</a>'; } else { echo '<center><b>---</b></center>'; } {/php}</td>
</tr>
</table>
{php}
if ($_GET['do'] == 'change'){
if (strlen(trim($_POST['knight_name'])) < 3 || strlen(trim($_POST['knight_name'])) > 32 ) { $error_1 = 'O nome do paladino deve ter entre 3 e 32 caracteres!'; } else
{
mysql_query("UPDATE users SET knight_name = '".urlencode($_POST['knight_name'])."' WHERE id = '".$userid."'");
header("Location: game.php?village=$vill&screen=statue");
exit;
}
}
{/php}{php} if ($error_1){ {/php}
<span class="error">{php} echo $error_1; {/php}</span>
{php} } {/php}
<br />
<form action="game.php?village={$village.id}&screen=statue&do=change" method="POST">
<table class="vis">
<tr><th>Nome</th><td><input type="text" name="knight_name" value="{php} echo stripslashes(urldecode($user['knight_name'])); {/php}" /><input type="submit" value="Ok" /></td></tr>
</table>
</form>
{php}}{/php}