<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Разборки';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
if($new_lvl=='yes'){header('Location: arena.php');exit;}
//******************************
$mag = mysql_fetch_array(mysql_query("SELECT * FROM `mag` WHERE `usr` = '$log'"));
                if ($mag['yarost'] > 0) {
                    switch ($mag['yarost']) {
                        case 5:
                            $a_1_bonus  = 45;
                            $a_1_chanse = 8;
                            break;
                        case 10:
                            $a_1_bonus  = 50;
                            $a_1_chanse = 8;
                            break;
                        case 15:
                            $a_1_bonus  = 55;
                            $a_1_chanse = 8;
                            break;
                        case 20:
                            $a_1_bonus  = 60;
                            $a_1_chanse = 8;
                            break;
                        case 25:
                            $a_1_bonus  = 65;
                            $a_1_chanse = 8;
                            break;
                        case 30:
                            $a_1_bonus  = 65;
                            $a_1_chanse = 11;
                            break;
                        case 35:
                            $a_1_bonus  = 70;
                            $a_1_chanse = 11;
                            break;
                        case 40:
                            $a_1_bonus  = 75;
                            $a_1_chanse = 11;
                            break;
                        case 45:
                            $a_1_bonus  = 80;
                            $a_1_chanse = 11;
                            break;
                        case 50:
                            $a_1_bonus  = 85;
                            $a_1_chanse = 11;
                            break;
                        case 55:
                            $a_1_bonus  = 85;
                            $a_1_chanse = 14;
                            break;
                        case 60:
                            $a_1_bonus  = 90;
                            $a_1_chanse = 14;
                            break;
                        case 65:
                            $a_1_bonus  = 95;
                            $a_1_chanse = 14;
                            break;
                        case 70:
                            $a_1_bonus  = 100;
                            $a_1_chanse = 14;
                            break;
                        case 75:
                            $a_1_bonus  = 105;
                            $a_1_chanse = 14;
                            break;
                        case 80:
                            $a_1_bonus  = 105;
                            $a_1_chanse = 17;
                            break;
                        case 85:
                            $a_1_bonus  = 145;
                            $a_1_chanse = 20;
                            break;
                        case 90:
                            $a_1_bonus  = 165;
                            $a_1_chanse = 23;
                            break;
                        case 95:
                            $a_1_bonus  = 165;
                            $a_1_chanse = 23;
                            break;
                        case 100:
                            $a_1_bonus  = 200;
                            $a_1_chanse = 25;
                            break;

                    }
                    if (isset($a_1_chanse) AND mt_rand(0, 100) <= $a_1_chanse) {
                        $a_1 = true;
                    }
                }
                if ($mag['bronya'] > 0) {
                    switch ($mag['bronya']) {
                        case 5:
                            $a_2_bonus  = 45;
                            $a_2_chanse = 8;
                            break;
                        case 10:
                            $a_2_bonus  = 50;
                            $a_2_chanse = 8;
                            break;
                        case 15:
                            $a_2_bonus  = 55;
                            $a_2_chanse = 8;
                            break;
                        case 20:
                            $a_2_bonus  = 60;
                            $a_2_chanse = 8;
                            break;
                        case 25:
                            $a_2_bonus  = 65;
                            $a_2_chanse = 8;
                            break;
                        case 30:
                            $a_2_bonus  = 65;
                            $a_2_chanse = 11;
                            break;
                        case 35:
                            $a_2_bonus  = 70;
                            $a_2_chanse = 11;
                            break;
                        case 40:
                            $a_2_bonus  = 75;
                            $a_2_chanse = 11;
                            break;
                        case 45:
                            $a_2_bonus  = 80;
                            $a_2_chanse = 11;
                            break;
                        case 50:
                            $a_2_bonus  = 85;
                            $a_2_chanse = 11;
                            break;
                        case 55:
                            $a_2_bonus  = 85;
                            $a_2_chanse = 14;
                            break;
                        case 60:
                            $a_2_bonus  = 90;
                            $a_2_chanse = 14;
                            break;
                        case 65:
                            $a_2_bonus  = 95;
                            $a_2_chanse = 14;
                            break;
                        case 70:
                            $a_2_bonus  = 100;
                            $a_2_chanse = 14;
                            break;
                        case 75:
                            $a_2_bonus  = 105;
                            $a_2_chanse = 14;
                            break;
                        case 80:
                            $a_2_bonus  = 105;
                            $a_2_chanse = 17;
                            break;
                        case 85:
                            $a_2_bonus  = 145;
                            $a_2_chanse = 20;
                            break;
                        case 90:
                            $a_2_bonus  = 165;
                            $a_2_chanse = 23;
                            break;
                        case 95:
                            $a_2_bonus  = 165;
                            $a_2_chanse = 23;
                            break;
                         case 100:
                            $a_2_bonus  = 200;
                            $a_2_chanse = 25;
                            break;
                    }
                    if (isset($a_2_chanse) AND mt_rand(0, 100) <= $a_2_chanse) {
                        $a_2 = true;
                    }
                }
                if ($mag['vihr'] > 0) {
                    switch ($mag['vihr']) {
                        case 5:
                            $a_3_bonus       = 5;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 5;
                            break;
                        case 10:
                            $a_3_bonus       = 10;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 5;
                            break;
                        case 15:
                            $a_3_bonus       = 15;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 5;
                            break;
                        case 20:
                            $a_3_bonus       = 20;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 10;
                            break;
                        case 25:
                            $a_3_bonus       = 25;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 10;
                            break;
                        case 30:
                            $a_3_bonus       = 30;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 15;
                            break;
                        case 35:
                            $a_3_bonus       = 35;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 15;
                            break;
                        case 40:
                            $a_3_bonus       = 40;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 20;
                            break;
                        case 45:
                            $a_3_bonus       = 45;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 20;
                            break;
                        case 50:
                            $a_3_bonus       = 50;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 25;
                            break;
                        case 55:
                            $a_3_bonus       = 55;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 25;
                            break;
                        case 60:
                            $a_3_bonus       = 60;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 30;
                            break;
                        case 65:
                            $a_3_bonus       = 65;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 30;
                            break;
                        case 70:
                            $a_3_bonus       = 70;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 35;
                            break;
                        case 75:
                            $a_3_bonus       = 75;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 35;
                            break;
                        case 80:
                            $a_3_bonus       = 80;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 40;
                            break;
                        case 85:
                            $a_3_bonus       = 85;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 40;
                            break;
                        case 90:
                            $a_3_bonus       = 90;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 45;
                            break;
                        case 95:
                            $a_3_bonus       = 95;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 45;
                            break;
                       case 100:
                            $a_3_bonus       = 100;
                            $a_3_crit_chanse = 20;
                            $a_3_chanse      = 50;
                            break;
                    }
                    if (isset($a_3_chanse) AND mt_rand(0, 100) <= $a_3_chanse) {
                        $a_3 = true;
                    }
                }
                if ($mag['stoika'] > 0) {
                    switch ($mag['stoika']) {
                        case 5:
                            $a_4_bonus  = 28;
                            $a_4_chanse = 10;
                            break;
                        case 10:
                            $a_4_bonus  = 30;
                            $a_4_chanse = 10;
                            break;
                        case 15:
                            $a_4_bonus  = 32;
                            $a_4_chanse = 10;
                            break;
                        case 20:
                            $a_4_bonus  = 34;
                            $a_4_chanse = 10;
                            break;
                        case 25:
                            $a_4_bonus  = 36;
                            $a_4_chanse = 10;
                            break;
                        case 30:
                            $a_4_bonus  = 36;
                            $a_4_chanse = 15;
                            break;
                        case 35:
                            $a_4_bonus  = 38;
                            $a_4_chanse = 15;
                            break;
                        case 40:
                            $a_4_bonus  = 40;
                            $a_4_chanse = 15;
                            break;
                        case 45:
                            $a_4_bonus  = 42;
                            $a_4_chanse = 15;
                            break;
                        case 50:
                            $a_4_bonus  = 44;
                            $a_4_chanse = 15;
                            break;
                        case 55:
                            $a_4_bonus  = 44;
                            $a_4_chanse = 20;
                            break;
                        case 60:
                            $a_4_bonus  = 46;
                            $a_4_chanse = 20;
                            break;
                        case 65:
                            $a_4_bonus  = 48;
                            $a_4_chanse = 20;
                            break;
                        case 70:
                            $a_4_bonus  = 50;
                            $a_4_chanse = 20;
                            break;
                        case 75:
                            $a_4_bonus  = 52;
                            $a_4_chanse = 20;
                            break;
                        case 80:
                            $a_4_bonus  = 52;
                            $a_4_chanse = 25;
                            break;
                        case 85:
                            $a_4_bonus  = 68;
                            $a_4_chanse = 30;
                            break;
                        case 90:
                            $a_4_bonus  = 76;
                            $a_4_chanse = 35;
                            break;
                        case 95:
                            $a_4_bonus  = 76;
                            $a_4_chanse = 35;
                            break;
                        case 100:
                            $a_4_bonus  = 80;
                            $a_4_chanse = 40;
                            break;
                    }
                    if (isset($a_4_chanse) AND mt_rand(0, 100) <= $a_4_chanse) {
                        $a_4 = true;
                    }
                }
//******************************
$time=time();
switch($_GET['mod']){
default:
$leg=mysql_query("SELECT * FROM `arenalog` WHERE `usr`='$log' LIMIT 1");
$logs=mysql_num_rows($leg);
if($logs==0){
mysql_query("INSERT INTO `arenalog` SET `usr` = '$log'");
}

echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">Если тюрьма не учит заключенного жить в обществе, она учит его жить в тюрьме</span></div><div class="mini-line"></div></div>';

if(isset($_SESSION['light'])){
echo'<div class="block_zero center">'.$_SESSION['light'].'';
$_SESSION['light']=NULL;
}

if(isset($_GET['log'])){
$leg=mysql_query("SELECT * FROM `arenalog` WHERE `usr`='$log' LIMIT 1");
$logs=mysql_fetch_array($leg);
if($_GET['log']=='hp'){
echo'<div class="main"><div class="block_zero center"><span style="color: #c66;">Ты истащен! <br>Для наезда надо минимум <img src="image/icon/health.png" alt="*"> 10% здоровья и <img src="image/icon/mana.png" alt="*"> 20 энергии</span></div><div class="separ"></div><div class="block_zero"><img class="float-left" src="image/nastojka/potion.png" width="40" height="40" style="margin-left:80px;margin-right:10px;" alt="аватар">Чифир<br> +100% энергии и здоровья<br><br><div class="block_zero center"><a class="btn" href="arena.php?mod=pokupka"><span class="end"><span class="label">Купить за <img src="image/icon/almaz.png" alt="*"> 15 рублей</span></span></a></div></div><div class="mini-line"></div></div>';
}

if($_GET['log']=='sliv'){

$hpg=round($udata['hp']/10);
$kount = mysql_result(mysql_query("SELECT COUNT(*)  FROM `users`"),0);
$health = rand(1,$udata['lvl']);
if($udata['lvl']>=0){$_exp=rand(3,7);$silver=rand(11,15);}
if($udata['lvl']>10){$_exp=rand(3,7);$silver=rand(21,25);}
if($udata['lvl']>15){$_exp=rand(13,17);$silver=rand(31,39);}
if($udata['lvl']>20){$_exp=rand(23,27);$silver=rand(41,51);}
if($udata['lvl']>25){$_exp=rand(33,37);$silver=rand(55,68);}
if($udata['lvl']>30){$_exp=rand(43,47);$silver=rand(70,88);}
if($udata['lvl']>40){$_exp=rand(63,67);$silver=rand(88,101);}

$fights=round(intval($udata['mp']/20));

if($udata['almaz']<1){
$_SESSION['err']="Не достаточно рублей";
header('Location: arena.php?');
}
elseif($fights<1 OR $udata['hp']<$hpg){
header('Location: arena.php?log=hp');
}
elseif($fights>0){
$f=20;
if($set['vip']=='on'){
$ds=intval(($silver*$fights)*1.6);
$de=intval(($_exp*$fights)*1.6);
}else{
$ds=$silver*$fights;
$de=$_exp*$fights;
}
mysql_query("UPDATE `users` SET `mp`='".($udata['mp']-$f*$fights)."' WHERE `id`='$udata[id]'");
mysql_query("UPDATE `users` SET `money`='".($udata['money']+($silver*$fights))."' WHERE `id`='$udata[id]'");
mysql_query("UPDATE `users` SET `exp`='".($udata['exp']+($_exp*$fights))."',`almaz`='".($udata['almaz']-1)."',`hp`='".(rand(0,$udata['hp']))."' WHERE `id`='$udata[id]'");

$req = mysql_query("SELECT * FROM `clan` where `lider`='$udata[clan]'");
$avto=mysql_num_rows($req);

if($avto==1){
$clexp=$de/10;
}
mysql_query("UPDATE `clan` SET `exp` = `exp`+'$clexp' WHERE `lider` = '$udata[clan]'");
mysql_query("UPDATE `users` SET `clanexp` = `clanexp`+'$clexp' WHERE `usr` = '$log'");

                        if ($mag['yarost'] >= 1) {
                            $pic = 1;
                        }
                        if ($mag['yarost'] >= 20) {
                            $pic = 2;
                        }
                        if ($mag['yarost'] >= 40) {
                            $pic = 3;
                        }
                        if ($mag['yarost'] >= 60) {
                            $pic = 4;
                        }
                        if ($mag['yarost'] >= 80) {
                            $pic = 5;
                        }
                        if ($mag['yarost'] == 100) {
                            $pic = 6;
                        }
                        if ($mag['bronya'] >= 1) {
                            $pic2 = 1;
                        }
                        if ($mag['bronya'] >= 20) {
                            $pic2 = 2;
                        }
                        if ($mag['bronya'] >= 40) {
                            $pic2 = 3;
                        }
                        if ($mag['bronya'] >= 60) {
                            $pic2 = 4;
                        }
                        if ($mag['bronya'] >= 80) {
                            $pic2 = 5;
                        }
                        if ($mag['bronya'] == 100) {
                            $pic2 = 6;
                        }
                        if ($mag['vihr'] >= 1) {
                            $pic3 = 1;
                        }
                        if ($mag['vihr'] >= 20) {
                            $pic3 = 2;
                        }
                        if ($mag['vihr'] >= 40) {
                            $pic3 = 3;
                        }
                        if ($mag['vihr'] >= 60) {
                            $pic3 = 4;
                        }
                        if ($mag['vihr'] >= 80) {
                            $pic3 = 5;
                        }
                        if ($mag['vihr'] == 100) {
                            $pic3 = 6;
                        }
                        if ($mag['stoika'] >= 1) {
                            $pic4 = 1;
                        }
                        if ($mag['stoika'] >= 20) {
                            $pic4 = 2;
                        }
                        if ($mag['stoika'] >= 40) {
                            $pic4 = 3;
                        }
                        if ($mag['stoika'] >= 60) {
                            $pic4 = 4;
                        }
                        if ($mag['stoika'] >= 80) {
                            $pic4 = 5;
                        }
                        if ($mag['stoika'] == 100) {
                            $pic4 = 6;
                        }
$loses=rand(0,$fights);
$pobed=$fights-$loses;
mysql_query("UPDATE `users` SET `arenawins`=`arenawins`+'$pobed' WHERE `id`='$udata[id]'");
if($mag['yarost'] == 0){
$pica1='';
}else{
$pica1="<img src='/image/umehi/1.$pic.png' width='25px' height='25px' alt='*'/>";
}
if($mag['bronya'] == 0){
$pica2='';
}else{
$pica2="<img src='/image/umehi/2.$pic2.png' width='25px' height='25px' alt='*'/>";
}
if($mag['vihr'] == 0){
$pica3='';
}else{
$pica3="<img src='/image/umehi/3.$pic3.png' width='25px' height='25px' alt='*'/>";
}
if($mag['stoika'] == 0){
$pica4='';
}else{
$pica4="<img src='/image/umehi/4.$pic4.png' width='25px' height='25px' alt='*'/>";
}
if($mag['yarost'] !== 0 OR $mag['bronya'] !== 0 OR  $mag['vihr'] !== 0  OR $mag['stoika'] !== 0){
$line="<div class='separ'></div>";
}else{
$line="";
}
$_SESSION['light']="<h3 class='dgreen' style='font-weight:bold;'><img src='/image/icon/2hit.png' alt=''/> Вся энергия использована! <img src='/image/icon/2hit.png' alt=''/></h3><div class='separ'></div>
<span style='color: #9c9;'> Побед: $pobed </span>| <span style='color: #c66;'> Поражений: $loses</span><div class='separ'></div>$pica1 $pica2 $pica3 $pica4$line<img src='/image/icon/money.png'/> $ds сигарет <img src='/image/icon/exp.png'/> $de авторитета<br><a href='arena.php?mod=pokupka'><span style='color: #999;'>Пополнить энергию и здоровье <img src='image/icon/almaz.png' alt='*'> 15 рублей</span></a></div><div class='mini-line'></div>";
header('Location: arena.php?');
}
}

if($_GET['log']=='win'){
echo'<div class="block_zero center"><span style="color: #9c9;"><img src="image/icon/2hit.png" alt="*"> Ништяк! Ты победил! <img src="image/icon/2hit.png" alt="*"></span>';
if ((isset($a_1) AND $a_1 == true) OR (isset($a_2) AND $a_2 == true) OR (isset($a_3) AND $a_3 == true) OR (isset($a_4) AND $a_4 == true)) {
echo'<div class="separ"></div>';
                    if (isset($a_1) AND $a_1 == true) {
                        if ($mag['yarost'] >= 1) {
                            $pic = 1;
                        }
                        if ($mag['yarost'] >= 20) {
                            $pic = 2;
                        }
                        if ($mag['yarost'] >= 40) {
                            $pic = 3;
                        }
                        if ($mag['yarost'] >= 60) {
                            $pic = 4;
                        }
                        if ($mag['yarost'] >= 80) {
                            $pic = 5;
                        }
                        if ($mag['yarost'] == 100) {
                            $pic = 6;
                        }
                        echo ' <img src=\'/image/umehi/1.' . $pic . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_2) AND $a_2 == true) {
                        if ($mag['bronya'] >= 1) {
                            $pic2 = 1;
                        }
                        if ($mag['bronya'] >= 20) {
                            $pic2 = 2;
                        }
                        if ($mag['bronya'] >= 40) {
                            $pic2 = 3;
                        }
                        if ($mag['bronya'] >= 60) {
                            $pic2 = 4;
                        }
                        if ($mag['bronya'] >= 80) {
                            $pic2 = 5;
                        }
                        if ($mag['bronya'] == 100) {
                            $pic2 = 6;
                        }
                        echo ' <img src=\'/image/umehi/2.' . $pic2 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_3) AND $a_3 == true) {
                        if ($mag['vihr'] >= 1) {
                            $pic3 = 1;
                        }
                        if ($mag['vihr'] >= 20) {
                            $pic3 = 2;
                        }
                        if ($mag['vihr'] >= 40) {
                            $pic3 = 3;
                        }
                        if ($mag['vihr'] >= 60) {
                            $pic3 = 4;
                        }
                        if ($mag['vihr'] >= 80) {
                            $pic3 = 5;
                        }
                        if ($mag['vihr'] == 100) {
                            $pic3 = 6;
                        }
                        echo ' <img src=\'/image/umehi/3.' . $pic3 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_4) AND $a_4 == true) {
                        if ($mag['stoika'] >= 1) {
                            $pic4 = 1;
                        }
                        if ($mag['stoika'] >= 20) {
                            $pic4 = 2;
                        }
                        if ($mag['stoika'] >= 40) {
                            $pic4 = 3;
                        }
                        if ($mag['stoika'] >= 60) {
                            $pic4 = 4;
                        }
                        if ($mag['stoika'] >= 80) {
                            $pic4 = 5;
                        }
                        if ($mag['stoika'] == 100) {
                            $pic4 = 6;
                        }
                        echo ' <img src=\'/image/umehi/4.' . $pic4 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
}
echo'<div class="separ"></div><img src="image/icon/money.png" alt="*"> '.$logs['money'].' сигарет <img src="image/icon/exp.png" alt="*"> '.$logs['exp'].' авторитета';

include($path.'relict.php');

echo "<br><br><a href='arena.php?log=sliv'>Использовать всю энергию <img src='image/icon/almaz.png'/>1</a></div><div class='mini-line'></div>";
}

if($_GET['log']=='los'){
echo'<div class="block_zero center"><span style="color: #c66;"><img src="image/icon/2hit.png" alt="*"> Фуу! Ты проиграл! <img src="image/icon/2hit.png" alt="*"></span>';
if ((isset($a_1) AND $a_1 == true) OR (isset($a_2) AND $a_2 == true) OR (isset($a_3) AND $a_3 == true) OR (isset($a_4) AND $a_4 == true)) {
echo'<div class="separ"></div>';
                    if (isset($a_1) AND $a_1 == true) {
                        if ($mag['yarost'] >= 1) {
                            $pic = 1;
                        }
                        if ($mag['yarost'] >= 20) {
                            $pic = 2;
                        }
                        if ($mag['yarost'] >= 40) {
                            $pic = 3;
                        }
                        if ($mag['yarost'] >= 60) {
                            $pic = 4;
                        }
                        if ($mag['yarost'] >= 80) {
                            $pic = 5;
                        }
                        if ($mag['yarost'] == 100) {
                            $pic = 6;
                        }
                        echo ' <img src=\'/image/umehi/1.' . $pic . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_2) AND $a_2 == true) {
                        if ($mag['bronya'] >= 1) {
                            $pic2 = 1;
                        }
                        if ($mag['bronya'] >= 20) {
                            $pic2 = 2;
                        }
                        if ($mag['bronya'] >= 40) {
                            $pic2 = 3;
                        }
                        if ($mag['bronya'] >= 60) {
                            $pic2 = 4;
                        }
                        if ($mag['bronya'] >= 80) {
                            $pic2 = 5;
                        }
                        if ($mag['bronya'] == 100) {
                            $pic2 = 6;
                        }
                        echo ' <img src=\'/image/umehi/2.' . $pic2 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_3) AND $a_3 == true) {
                        if ($mag['vihr'] >= 1) {
                            $pic3 = 1;
                        }
                        if ($mag['vihr'] >= 20) {
                            $pic3 = 2;
                        }
                        if ($mag['vihr'] >= 40) {
                            $pic3 = 3;
                        }
                        if ($mag['vihr'] >= 60) {
                            $pic3 = 4;
                        }
                        if ($mag['vihr'] >= 80) {
                            $pic3 = 5;
                        }
                        if ($mag['vihr'] == 100) {
                            $pic3 = 6;
                        }
                        echo ' <img src=\'/image/umehi/3.' . $pic3 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_4) AND $a_4 == true) {
                        if ($mag['stoika'] >= 1) {
                            $pic4 = 1;
                        }
                        if ($mag['stoika'] >= 20) {
                            $pic4 = 2;
                        }
                        if ($mag['stoika'] >= 40) {
                            $pic4 = 3;
                        }
                        if ($mag['stoika'] >= 60) {
                            $pic4 = 4;
                        }
                        if ($mag['stoika'] >= 80) {
                            $pic4 = 5;
                        }
                        if ($mag['stoika'] == 100) {
                            $pic4 = 6;
                        }
                        echo ' <img src=\'/image/umehi/4.' . $pic4 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
}
echo'<div class="separ"></div><img src="image/icon/money.png" alt="*"> '.$logs['money'].' сигарет <img src="image/icon/exp.png" alt="*"> '.$logs['exp'].' авторитета';
echo "<br><br><a href='arena.php?log=sliv'>Использовать всю энергию <img src='image/icon/almaz.png'/>1</a></div><div class='mini-line'></div>";
}
if($_GET['log']=='nogold'){
$nogold=5-$udata['almaz'];
echo'<div class="block_zero center">Не хватает <img src="image/icon/almaz.png" alt="*"> '.$nogold.' рублей<div class="separ"></div><a href="buy"><span class="btn"><span class="end"><input class="label" type="submit" value="Купить"></span></span></a></div>';
}
}
echo'<div class="main"><div class="block_zero">';
if(empty($boys1['usr'])){
$log1=rand($udata['lvl'],$udata['lvl']);
$boy1=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log1' ORDER BY RAND() LIMIT 1");
$boys1 = mysql_fetch_array($boy1);
$avto = mysql_num_rows($boy1);
if($avto==0){
$log1=rand($udata['lvl'],$udata['lvl']);
$boy1=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log1' ORDER BY RAND() LIMIT 1");
$boys1 = mysql_fetch_array($boy1);
}
}
//-----
if(empty($boys1['usr'])){
$stat1=false;
echo'<img class="float-left" src="image/avatar/not.png" width="110" height="110" style="margin-left:10px;margin-right:10px;" alt="аватар">';
echo'Нет подходящего игрока<br>';

}else{
$stat1=$boys1['sila']+$boys1['hp']+$boys1['lovk']+$boys1['prot'];
if($boys1['klas']=='wizard'){$kl='w';}else{$kl='f';}
if($boys1['lvl']<5){$st="a";}
if($boys1['storona']=="white"){$papka="scw";}else{$papka="scb";}
if($boys1['lvl']<5){$st="a";}
elseif($boys1['lvl']>=5 and $boys1['lvl']<10){$st="b";}
elseif($boys1['lvl']>=10 and $boys1['lvl']<15){$st="c";}
elseif($boys1['lvl']>=15 and $boys1['lvl']<20){$st="d";}
elseif($boys1['lvl']>=20 and $boys1['lvl']<25){$st="e";}
elseif($boys1['lvl']>=25 and $boys1['lvl']<35){$st="f";}
elseif($boys1['lvl']>=35 and $boys1['lvl']<45){$st="g";}
elseif($boys1['lvl']>=45 and $boys1['lvl']<55){$st="h";}
elseif($boys1['lvl']>=55){$st="i";}
$ban = mysql_num_rows(mysql_query("SELECT * FROM `ban` WHERE `usr` = '$boys1[usr]' LIMIT 1"));
$sett = mysql_query("SELECT * FROM `set` WHERE `usr` = '$boys1[usr]' LIMIT 1");
$sett = mysql_fetch_array($sett);
if($ban >0){
echo'<img class="float-left" src="image/avatar/ban.png" width="110" height="110" style="margin-left:10px;margin-right:20px;" alt="аватар">';
}
elseif(!empty($sett['avatar'])){
echo'<img class="float-left" src="image/avatar/upload/'.$sett['avatar'].'" width="110" height="110" style="margin-left:10px;margin-right:20px;" alt="аватар">';
}
elseif(!empty($boys1['avatar'])){
echo'<img class="float-left" src="image/avatar/not.png" width="110" height="110" style="margin-left:10px;margin-right:20px;" alt="аватар">';
}else{
echo'<img class="float-left" src="image/avatar/not.png" width="100" height="110" style="margin-left:10px;margin-right:20px;" alt="аватар">';
}
$ref = mysql_fetch_assoc(mysql_query("SELECT `storona` FROM `users` WHERE `usr` = '$boys1[usr]' LIMIT 1"));
if($ref['storona']=='white'){
$p=1;
}else{
$p=0;
}
$laikas = 300;
$dabar = time();
$timeout = $dabar - $laikas;
$asd = mysql_num_rows(mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeout' AND `usr` = '$boys1[usr]'"));
if($asd==0){
$gde='off';
}else{
$gde='';
}
if($udata['usr']==$boys1['usr']){
echo'<img src="image/icon/'.$p.''.$gde.'.png" alt="*"> Ваш клон<br>';
}else{
echo'<img src="image/icon/'.$p.''.$gde.'.png" alt="*"> '.$boys1['usr'].'<br>';
}
//echo'<img src="image/icon/'.$p.''.$gde.'.png" alt="*"> '.$boys1['usr'].'<br>';
echo'
<img src="image/icon/str.png" alt="*"> 
Сила: '.$boys1['sila'].'<br>
<img src="image/icon/health.png" alt="*"> 
Здоровье: '.$boys1['hp'].'<br>
<img src="image/icon/agi.png" alt="*"> 
Ловкость: '.$boys1['lovk'].'<br>
<img src="image/icon/def.png" alt="*"> 
Защита: '.$boys1['prot'].'<br>
';
echo'<form action="arena.php?mod=ataka&ataka&user1='.$boys1['usr'].'&stat='.$stat1.'" method="POST"><span class="btn"><span class="end"><input class="label" type="submit" value="Наехать"></span></span></form>';
}
echo'</div><div class="dot-line"></div><div class="block_zero">';

echo'</div><div class="mini-line"><div class="block_zero center"><a href="arena.php?"><span class="btn"><span class="end"><input class="label" type="submit" value="Сменить противника"></span></span></a></div><div class="mini-line"></div>';

if($udata['storona']=='white'){
$pers=1;
}else{
$pers=0;
}

if ($user_id==0){
$gde1='off';
}else{
$gde1='';
}

echo'
<div class="block_zero">
';

if(isset($_GET['log'])){
$ref = mysql_fetch_assoc(mysql_query("SELECT `storona` FROM `users` WHERE `usr` = '$logs[oponent]' LIMIT 1"));
if($ref['storona']=='white'){
$p=1;
}else{
$p=0;
}
$laikas = 300;
$dabar = time();
$timeout = $dabar - $laikas;
$asd = mysql_num_rows(mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeout' AND `usr` = '$logs[oponent]'"));
if($asd==0){
$gde='off';
}else{
$gde='';
}
/*if($_GET['log']=='win'){
echo'<img src="image/icon/'.$pers.''.$gde1.'.png" alt="*"> '.$log.'<br><img src="image/icon/hit.png" alt="*"><small> Нанесено урона: '.$logs['myudar'].'</small></div><div class="dot-line"></div><div class="block_zero"><img src="image/icon/'.$p.''.$gde.'.png" alt="*"> '.$logs['oponent'].'<br><img src="image/icon/hit.png" alt="*"><small> Получено урона: '.$logs['userudar'].'</small></div><div class="mini-line"></div>';
}
if($_GET['log']=='los'){
echo'<img src="image/icon/'.$pers.''.$gde1.'.png" alt="*"> '.$log.'<br><img src="image/icon/hit.png" alt="*"><small> Нанесено урона: '.$logs['myudar'].'</small></div><div class="dot-line"></div><div class="block_zero"><img src="image/icon/'.$p.''.$gde.'.png" alt="*"> '.$logs['oponent'].'<br><img src="image/icon/hit.png" alt="*"><small> Получено урона: '.$logs['userudar'].'</small></div><div class="mini-line"></div>';
}*/
}

echo'
<div class="block_zero">Твои параметры:<br>
<img src="image/icon/str.png" alt="*"> 
'.$udata['sila'].' 
<img src="image/icon/health.png" alt="*"> 
'.$udata['hp'].'
<img src="image/icon/agi.png" alt="*"> 
'.$udata['lovk'].' 
<img src="image/icon/def.png" alt="*"> 
'.$udata['prot'].'
</div></div><div class="mini-line"></div>
';

echo'<ul class="hint"><li> Если нет подходящих противников, то вы будите нападать на свою копию!(Шанс победы над своей копией 50%)</li></ul></div></div></div>';

include($path.'files/down.php');

case 'ataka':
if(isset($_GET['ataka'])){
$header=TRUE;
$log1=rand($udata['lvl']);
$boy1=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log1' ORDER BY RAND() LIMIT 1");
$boys1 = mysql_fetch_array($boy1);
$rand=rand(0,100);
$mprand=20;
$hprand=$udata['hpall']/10;
if($udata['hp']<$hprand OR $udata['mp']<20){
mysql_query("UPDATE `arenalog` SET `name` = 'hp' WHERE `usr` = '$log'");
header ("Location: arena.php?log=hp");exit;
}else{
if($udata['lvl']>=0 AND $udata['lvl']<=5){
$koef1=rand(2,4);
$koef2=rand(4,8);
$koef3=rand(6,10);
$bon1=rand(1,4)*1.5;
$bon2=rand(2,6)*1.5;
$bon3=rand(6,8)*1.5;
}
if($udata['lvl']>5 and $udata['lvl']<=10){
$koef1=rand(2,4);
$koef2=rand(4,8);
$koef3=rand(6,10);
$bon1=rand(1,4)*1.5;
$bon2=rand(5,15)*1.5;
$bon3=rand(10,20)*1.5;
}
if($udata['lvl']>10 and $udata['lvl']<=20){
$koef1=rand(8,16);
$koef2=rand(10,20);
$koef3=rand(20,30);
$bon1=rand(8,16)*1.6;
$bon2=rand(10,20)*1.6;
$bon3=rand(20,30)*1.6;
}
if($udata['lvl']>20 and $udata['lvl']<=30){
$koef1=rand(14,22);
$koef2=rand(15,25);
$koef3=rand(30,40);
$bon1=rand(14,22)*1.7;
$bon2=rand(15,25)*1.7;
$bon3=rand(30,40)*1.7;
}
if($udata['lvl']>30 and $udata['lvl']<=40){
$koef1=rand(20,28);
$koef2=rand(20,35);
$koef3=rand(40,50);
$bon1=rand(20,28)*1.8;
$bon2=rand(20,35)*1.8;
$bon3=rand(40,50)*1.8;
}
if($udata['lvl']>40 and $udata['lvl']<=50){
$koef1=rand(26,32);
$koef2=rand(30,45);
$koef3=rand(50,60);
$bon1=rand(26,32)*1.9;
$bon2=rand(30,45)*1.9;
$bon3=rand(50,60)*1.9;
}
if($udata['lvl']>50 and $udata['lvl']<=60){
$koef1=rand(30,36);
$koef2=rand(35,55);
$koef3=rand(50,65);
$bon1=rand(30,36)*2;
$bon2=rand(35,55)*2;
$bon3=rand(50,70)*2;
}
if(!empty($_GET['user1'])){
$shans=80;
$var=round($koef1+$set['razb']*1.5);$bon=round($bon1+$set['razb']*3);$user=$_GET['user1'];
}
if(!empty($_GET['user2'])){
$shans=66;
$var=round($koef2+$set['razb']*1.5);$bon=round($bon2+$set['razb']*3);$user=$_GET['user2'];
}
if(!empty($_GET['user3'])){
$shans=40;
$var=round($koef3+$set['razb']*2);
$bon=round($bon3+$set['razb']*3);$user=$_GET['user3'];
}
$stat=$_GET['stat'];
$my=$udata['sila']+$udata['hpall']+$udata['lovk']+$udata['prot'];
if(($my-$stat)>=10){
$shans=80;
}
if($shans>=$rand){
$inv=$set['arenainv']-1;
$win=$udata['arenawins']+1;
$los=$udata['arenaloses'];
$uron=3+rand(0,$udata['hp']/5);
$uron=round($uron);
$udar=round($uron+$uron/6);
if($set['vip']=='on'){
$var=$var*1.5;
$bon=$bon*1.5;
}

mysql_query("UPDATE `users` SET `money` = '$udata[money]'+'$var', `exp` = '$udata[exp]'+'$bon', `hp` =  '$udata[hp]'-'$uron'
, `mp` = '$udata[mp]'-'$mprand', `arenawins` = '$win',`arenaloses` = '$los' WHERE `usr` = '$log'");
mysql_query("UPDATE `arenalog` SET `name`='win',`oponent` = '".mysql_real_escape_string($user)."',`money` = '".mysql_real_escape_string($var)."',`exp` = '".mysql_real_escape_string($bon)."',
`myudar` = '$udar', `userudar` = '$uron' WHERE `usr` = '$log'");
$req = mysql_query("SELECT * FROM `clan` where `lider`='$udata[clan]'");
$avto=mysql_num_rows($req);

if($avto==1){
$clexp=$bon/10;
}
mysql_query("UPDATE `clan` SET `exp` = `exp`+'$clexp' WHERE `lider` = '$udata[clan]'");
mysql_query("UPDATE `users` SET `clanexp` = `clanexp`+'$clexp' WHERE `usr` = '$log'");
ob_start();
$header=TRUE;
header ("Location: arena.php?log=win");exit;
}else{
$inv=$set['arenainv']-1;
$win=$udata['arenawins'];
$los=$udata['arenaloses']+1;
if($set['vip']=='on'){
$var=$var*1.5;
$bon=$bon*1.5;
}else{
$var=1*round($var/4);
$bon=round($bon/2);
}
$uron=1+rand(0,$udata['hp']/5);
$uron=round($uron);
$udar=round($uron-$uron/6);

mysql_query("UPDATE `users` SET `money` = '$udata[money]'+'$var', `exp` = '$udata[exp]'+'$bon', `hp` = '$udata[hp]'-'$uron', `mp` = '$udata[mp]'-'$mprand', `arenawins` = '$win',`arenaloses` = '$los' WHERE `usr` = '$log'");
mysql_query("UPDATE `arenalog` SET `name` = 'los',`oponent` = '".mysql_real_escape_string($user)."',`money` = '".mysql_real_escape_string($var)."',`exp` = '".mysql_real_escape_string($bon)."',
`myudar` = '$udar', `userudar` = '$uron' WHERE `usr` = '$log'");
$req = mysql_query("SELECT * FROM `clan` where `lider`='$udata[clan]'");
$avto=mysql_num_rows($req);
$clan = mysql_fetch_array($req);
if($avto==1){
$clexp=$bon/10;
}
mysql_query("UPDATE `clan` SET `exp` = `exp`+'$clexp' WHERE `lider` = '$udata[clan]'");
mysql_query("UPDATE `users` SET `clanexp` = `clanexp`+'$clexp' WHERE `usr` = '$log'");
header ("Location: arena.php?log=los");exit;
}
}
}
break;
//-----
case 'pokupka':
if($udata['almaz']<15){
header ("Location: arena.php?log=nogold");exit;
}else{
mysql_query("UPDATE `users` SET `almaz` = '$udata[almaz]'-'15', `hp` = '$udata[hpall]', `mp` = '$udata[mpall]' WHERE `usr` = '$log'");
header ("Location: arena.php?");exit;
}
break;
//-----
break;
include($path.'files/down.php');
}
?>