Вход Регистрация
Файл: public_html/js/func.php
Строк: 103
<?php
$connect 
= array('localhost''cd90484_lasthero''112233''cd90484_lasthero');
    
    
$base $db = new mysqli($connect['0'], $connect['1'], $connect['2'], $connect['3']);
    
             
$base -> query("SET NAMES 'UTF8'"); 
                 
                 if(
$base -> connect_errno) die('ERROR -> '.$base -> connect_error);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
function vvod($vvod){GLOBAL $base; return trim(mysqli_real_escape_string($base,$vvod));}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
function vivod($vivod){return trim(htmlspecialchars(stripslashes($vivod)));}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
function num($chislo){return abs(intval($chislo));}
function 
getSkillBonus2($skill)
{
    global 
$u,$user_okr;
    if(
$skill == 'heal')
    {
        
$heal_percent ceil($user_okr['hp_max']*0.1);
        
$hh_percent ceil($user_okr['hp_max']*0.01);
        
$skill_bonus $heal_percent+($hh_percent*(($u['heal_skill'] == 1) ? : ($u['heal_skill']-1)));
    }
    else
    {
        
$arrow_percent ceil($user_okr['att_user']*0.03);
        
$skill_bonus = ($user_okr['att_user']*2)+($arrow_percent*(($u['arrow_skill'] == 1) ? : ($u['arrow_skill']-1)));
    }
    return 
$skill_bonus;
}

function 
getDamage($userDamage$opponentDefense$out=0)
{
    if(
$userDamage $opponentDefense)
    {
        
$min_damage round($userDamage/2);
        
$max_damage round($userDamage/1.5);
    }
    elseif(
$userDamage == $opponentDefense)
    {
        
$min_damage round($userDamage/4);
        
$max_damage round($userDamage/3);
    }
    else
    {
        
$min_damage round($userDamage/6);
        
$max_damage round($userDamage/5);
    }
    if(
$out == 1) return ['min_damage' => $min_damage'max_damage' => $max_damage];
    else return 
rand($min_damage$max_damage);
}

$time=time();$topswap['error']=1;
header('Content-type: application/json');

if(isset(
$_COOKIE['login'])  && isset($_COOKIE['password'])) {
    
$u $base -> query("SELECT * FROM `users` WHERE `login` = '".vvod($_COOKIE['login'])."' && `password` = '".vvod($_COOKIE['password'])."' LIMIT 1") -> fetch_assoc();
if(
$u['id']>0){

if (isset(
$_GET['m'])) {$mod=vvod($_GET['m']);} else {$mod="";}

switch(
$mod
{


case 
'camp':

$user_okrmysqli_fetch_assoc(mysqli_query($base,"select * from `camp` WHERE `id_user`='".num($u['id'])."' and `status`!=0 and `hp`>0 limit 1"));
if(
$user_okr['id']==or $user_okr['hp']==0){
$topswap['error']=1;
}else{
$topswap['hp_user']=$user_okr['hp'];$topswap['hp_vrag']=$user_okr['hp_vrag'];
$topswap['time_serv']=$time;
if(
$user_okr['time_att']<$time){
$topswap['time_att']=$time+1;

$topswap['att_user']=getDamage($user_okr['att_user'],$user_okr['deff']);

$tt='`status`=1';
if(
$user_okr['time_att_vrag']<$time){
$topswap['att_vrag']=getDamage($user_okr['att'],$user_okr['deff_user']);
if(
$topswap['att_vrag']>=$user_okr['hp']){$tt='`hp`=0, `time_att_vrag`='.($time+3).'';}else{$tt='`hp`=`hp`-'.$topswap['att_vrag'].', `time_att_vrag`='.($time+3).'';}
}




if(
$topswap['att_user']>=$user_okr['hp_vrag']){
mysqli_query($base,"UPDATE `camp` SET $tt,`hp_vrag`='0', `time_att`='".num($time+1)."'  WHERE `id`='".num($user_okr['id'])."'");}
else{
mysqli_query($base,"UPDATE `camp` SET $tt,`hp_vrag`=`hp_vrag`-'".num($topswap['att_user'])."', `time_att`='".num($time+1)."'  WHERE `id`='".num($user_okr['id'])."'");}

}else{
$topswap['att_user']=0;$topswap['att_vrag']=0;$topswap['time_att']=$user_okr['time_att'];}
$topswap['error']=0;

}



break;
//////////////
//////////
case 'isc_camp':
$user_okrmysqli_fetch_assoc(mysqli_query($base,"select * from `camp` WHERE `id_user`='".num($u['id'])."' and `status`!=0 and `hp`>0 limit 1"));
if(
$user_okr['id']==or $user_okr['hp']==0){
$topswap['error']=1;
}else{
if(
$user_okr['navik_pr1']>$time){$topswap['error']=0;$topswap['hp_add']=0;$topswap['hp']=$user_okr['hp'];$topswap['time_add']=0;}else{

$topswap['error']=0;$topswap['time_add']=$time+30;$iscgetSkillBonus2('heal');

if(
$user_okr['hp']+$isc>$user_okr['hp_max']){$topswap['hp_add']=$user_okr['hp_max']-$user_okr['hp'];if($topswap['hp_add']<0){$topswap['hp_add']=0;}}else{$topswap['hp_add']=$isc;}

$topswap['hp']=$topswap['hp_add']+$user_okr['hp'];

$tt='`status`=1';
if(
$user_okr['time_att_vrag']<$time){
$topswap['att_vrag']=getDamage($user_okr['att'],$user_okr['deff_user']);
if(
$topswap['att_vrag']>=$user_okr['hp']){$tt='`hp`=0, `time_att_vrag`='.($time+3).'';$topswap['hp']=0;}else{$tt='`hp`=`hp`-'.$topswap['att_vrag'].', `time_att_vrag`='.($time+3).'';$topswap['hp']=$topswap['hp']-$topswap['att_vrag'];}
}
mysqli_query($base,"UPDATE `camp` SET $tt,`hp`='".$topswap['hp']."',`navik_pr1`='".$topswap['time_add']."'  WHERE `id`='".num($user_okr['id'])."'");
}
}
break;
//////////
case 'moln_camp':
$topswap['error']=1;
$user_okrmysqli_fetch_assoc(mysqli_query($base,"select * from `camp` WHERE `id_user`='".num($u['id'])."' and `status`!=0 and `hp`>0 limit 1"));
if(
$user_okr['id']==or $user_okr['hp']==or $user_okr['hp_vrag']==0){
$topswap['error']=1;
}else{
$topswap['hp_user']=$user_okr['hp'];$topswap['hp_vrag']=$user_okr['hp_vrag'];

if(
$user_okr['navik_pr2']<$time){
$topswap['time_add']=$time+40;
$topswap['att_user']=getDamage(getSkillBonus2('arrow'),$user_okr['deff']);


$tt='`status`=1';
if(
$user_okr['time_att_vrag']<$time){
$topswap['att_vrag']=getDamage($user_okr['att'],$user_okr['deff_user']);
if(
$topswap['att_vrag']>=$user_okr['hp']){$tt='`hp`=0,`time_att_vrag`='.($time+3).'';}else{$tt='`hp`=`hp`-'.$topswap['att_vrag'].', `time_att_vrag`='.($time+3).'';}
}


if(
$topswap['att_user']>=$user_okr['hp_vrag']){
mysqli_query($base,"UPDATE `camp` SET $tt,`hp_vrag`='0',`navik_pr2`='".$topswap['time_add']."'  WHERE `id`='".num($user_okr['id'])."'");}
else{
mysqli_query($base,"UPDATE `camp` SET $tt,`hp_vrag`=`hp_vrag`-'".num($topswap['att_user'])."',`navik_pr2`='".$topswap['time_add']."'  WHERE `id`='".num($user_okr['id'])."'");}


}else{
$topswap['att_user']=0;$topswap['att_vrag']=0;}
$topswap['error']=0;
}

break;


}

}
}

echo 
json_encode($topswap);
?>
Онлайн: 1
Реклама