Вход Регистрация
Файл: wenr.online/app/town/inv.php
Строк: 11
<?php

if (!$user->isAuth()) {
    
redirect('/');
    exit;
}

   
        
         if(isset(
$_GET['type'])){
         
$type Clean :: str($_GET['type']);
         
$kol Clean :: int($_GET['kol']);
         
         
$typeArray = ['warrior','catapult','ram'];
         
         
         
$kolArray = [1,10];
         
         if(!
in_array($type,$typeArray)){
             
redirect('/town');
             exit;
         }
         
         
          if(!
in_array($kol,$kolArray)){
             
redirect('/town');
             exit;
         }
         
         
         
         
$priceArray = ['warrior'=>20,'catapult'=>500,'ram'=>500];
         
         
$max 1000;
         
         if(
$type != 'warrior'$max 20;
         
         
         
$price $priceArray[$type]*$kol;
         
         
         if(
$user->get()->gold $price){
             
Notif :: error('Недостаточно золота','/town');
             exit;
         }
         
         
         if(
$user->get()->$type+$kol $max){
             
Notif :: error('Невозможно купить больше','/town');
             exit;
         }
         
         
         
$update $db->prepare('update `users` set `gold` = ?, `'.$type.'` = ? where `user_id` = ?');
         
$update -> execute([$user->get()->gold-$price,
                            
$user->get()->$type+$kol,
                            
$user->get()->user_id
                            
]);
                    
redirect('/town');        
         exit;
         }
Онлайн: 2
Реклама