Файл: wenr.online/app/clan/control.php
Строк: 31
<?php
if (!$user->isAuth() or $user->get()->clan == 0) {
redirect('/');
exit;
}
$clan = $db->prepare('select * from clan where id = ?');
$clan -> execute([$user->get()->clan]);
$clan = $clan -> fetch(PDO :: FETCH_OBJ);
if(isset($_GET['type']) and $user->get()->user_id == $clan->user){
$type = Clean :: str($_GET['type']);
$typeArray = ['def','attack','lucky'];
if(!in_array($type,$typeArray)){
redirect('/clan/control?ww');
exit;
}
$price = 5000;
$max = 100;
if($clan->gold < $price){
Notif :: error('Недостаточно золота в казне клана','/clan/control');
exit;
}
if($town->$type+$kol > $max){
Notif :: error('Невозможно улучшить больше','/clan/control');
exit;
}
$update = $db->prepare('update clan set gold = ?, '.$type.' = ? where id = ?');
$update -> execute([$clan->gold-$price,
$clan->$type+1,
$clan->id
]);
redirect('/clan/control');
exit;
}
echo $template->render('clan.control', ['clan'=>$clan]);