<?
require_once ('system/func.php');
auth(); // Только для авторизованных
$title = 'Колизей';
if($user['level'] < 10){
require_once ('system/header.php');
echo '<div class="block center">';
echo ''.ico('icons','coliseum.png').' '.$title.' доступен только с '.ico('icons','level.png').' 10 уровня'.$separ.'<a href="/arena" class="btn2">Перейти на Арену</a>';
echo '</div>';
require_once ('system/footer.php');
break;
}
$turnir_chereps = mysql_query("SELECT * FROM `turnir_chereps` ORDER BY `id` DESC LIMIT 1");
$batlle_user = mysql_query("SELECT * FROM `coliseum_users` WHERE `id_user` = '$myID' AND `end` = '0' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_query("SELECT * FROM `coliseum` WHERE `id` = '$batlle_user[id_batlle]' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
if(!$batlle){
$batlle = mysql_query("SELECT * FROM `coliseum` WHERE `start` < '2' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
}
if($count_users < 1)$count_users = 0;
if($batlle['start'] == 2 and $batlle['last'] < time()){
mysql_query("UPDATE `coliseum` SET `start` = '3' WHERE `id` = '$batlle[id]' LIMIT 1");
header('Location: ?');
exit();
}
if($batlle['start'] == 2 and $batlle_user['ubit'] == 1){
require_once ('system/header.php');
echo "<div class='block center'><img src='/images/things/coliseum.jpg' style='border-radius:8px;width:100%'></div>";
echo "<div class='block center'>";
echo "Вы были убиты во время боя<br><a href='?' class='btn2'>Обновить</a>";
echo "</div>";
echo "<div class='block'>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `coliseum_log` WHERE `id_batlle` = '$batlle[id]'"),0);
if($k_post == 0)echo "Логов не найдено...";
$q = mysql_query("SELECT * FROM `coliseum_log` WHERE `id_batlle` = '$batlle[id]' ORDER BY `id` DESC LIMIT 15");
while($post = mysql_fetch_assoc($q)){
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$post[id_user]'"));
$cel = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$post[cel]'"));
if($post['ubit'] == 1){
if($ank['id'] == $myID){
echo "Вы убили $cel[login]<br>";
}elseif($cel['id'] == $myID){
echo "<font color='red'>$ank[login] убил вас</font><br>";
}else{
echo "$ank[login] убил $cel[login]<br>";
}
}else{
if($cel['id'] == $myID and $post['uron'] > 0){
echo "<font color='red'>$ank[login] атаковал Вас на <b>$post[uron]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."</font><br>";
}elseif($ank['id'] == $myID){
if($post['uron'] > 0)echo "Вы атаковали $cel[login] на <b>$post[uron]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."<br>";
else echo "<span class='grey'>Промах</span><br>";
}elseif($post['uron'] > 0){
echo "$ank[login] атаковал $cel[login] на <b>$post[uron]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."<br>";
}
}
}
echo "</div>";
require_once ('system/footer.php');
}elseif($batlle['start'] == 3 or $batlle['start'] == 4 and $batlle_user['end'] == 0){
require_once ('system/header.php');
echo "<div class='block center'><img src='/images/things/coliseum.jpg' style='border-radius:8px;width:100%'></div>";
echo "<div class='block center'>";
echo "<span class='info'><b>Бой окончен!</b></span><br>";
$q = mysql_query("SELECT * FROM `coliseum_users` WHERE `id_batlle` = '$batlle[id]' ORDER BY `time_ubit` DESC, `ubito` DESC, `urons` DESC LIMIT 5");
while($post = mysql_fetch_assoc($q)) {
$a++;
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));
switch($a){
case 1:
$exp = rand(400,500);
break;
case 2:
$exp = rand(200,300);
break;
case 3:
$exp = rand(150,250);
break;
case 4:
$exp = rand(100,200);
break;
case 5:
$exp = rand(50,80);
break;
}
if($post['id_user'] == $myID){
echo "Награда за $a место ".ico('icons','exp.png')." $exp опыта!";
mysql_query("update `users` set `exp` = '".($ank['exp']+$exp)."' where (`id` = '".$ank['id']."')");
if($ank['id_clan'] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($ank['clan_exp']+clan_exp_koll($exp))."', `clan_exp_24` = '".($ank['clan_exp_24']+clan_exp_koll($exp))."' WHERE `id` = '".$ank['id']."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".clan_exp_koll($exp)."' WHERE `id` = '".$ank['id_clan']."' LIMIT 1");
}
}
}
echo '</div>';
echo "<div class='block center'>";
$q = mysql_query("SELECT * FROM `coliseum_users` WHERE `id_batlle` = '$batlle[id]' ORDER BY `time_ubit` DESC, `ubito` DESC, `urons` DESC LIMIT 5");
while($post = mysql_fetch_assoc($q)) {
$i++;
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));
switch($i){
case 1:
$rating = "4";
$win = '+';
break;
case 2:
$rating = "2";
$win = '+';
break;
case 3:
$rating = "0";
$win = '+';
break;
case 4:
$rating = "2";
$win = '-';
break;
case 5:
$rating = "4";
$win = '+';
break;
}
echo $i.". ".icons_user($ank['id'])." <a>$ank[login]</a> ".$win."$rating<br>";
if($post['id_user'] == $myID)mysql_query("UPDATE `users` SET `coliseum_rating` = `coliseum_rating`".$win."'".$rating."' WHERE `id` = '$ank[id]' LIMIT 1");
}
echo $separ."<a href='?vstat' class='btn2'>Встать в очередь</a>";
echo "</div>";
if($batlle['start'] == 3)mysql_query("UPDATE `coliseum` SET `start` = '4' WHERE `id` = '$batlle[id]' LIMIT 1");
mysql_query("UPDATE `coliseum_users` SET `end` = '1' WHERE `id` = '$batlle_user[id]' LIMIT 1");
$quest = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '11'"));
$q = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest[id]' AND `id_user` = '$myID'"));
if($q['last'] < time())mysql_query("update `quest_user` set `koll` = '".($q['koll']+1)."' where (`id` = '".$q['id']."')");
require_once ('system/footer.php');
}elseif($batlle['start'] == 2){
if(isset($_GET['exit'])){
mysql_query("UPDATE `coliseum_users` SET `ubit` = '1', `time_ubit` = '".time()."' WHERE `id` = '$batlle_user[id]' LIMIT 1");
header("Location: ?");
exit();
}
if(isset($_GET['list'])){
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `coliseum_users` WHERE `id_user` != '$myID' AND `id` != '$batlle_user[cel]' AND `ubit` = '0' AND `id_batlle` = '$batlle[id]' ORDER BY RAND() DESC LIMIT 1"));
if($opponent)mysql_query("UPDATE `coliseum_users` SET `cel` = '$opponent[id]' WHERE `id` = '$batlle_user[id]' LIMIT 1");
header('Location: ?attack');
exit();
}
if(isset($_GET['nastroika']) and $batlle_user['nastroika'] < time()){
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `coliseum_users` WHERE `cel` = '$batlle_user[id]'"));
mysql_query("UPDATE `coliseum_users` SET `health` = `max_health`, `nastroika` = '".(time()+90)."' WHERE `id` = '".$batlle_user['id']."' LIMIT 1");
header("Location: ?attack");
exit();
}
if(isset($_GET['uvorot']) and $batlle_user['uvorot'] < time()){
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `coliseum_users` WHERE `cel` = '$batlle_user[id]'"));
mysql_query("UPDATE `coliseum_users` SET `cel` = '0' WHERE `id` = '".$opponent['id']."' LIMIT 1");
mysql_query("UPDATE `coliseum_users` SET `uvorot` = '".(time()+30)."' WHERE `id` = '".$batlle_user['id']."' LIMIT 1");
header("Location: ?attack");
exit();
}
if(isset($_GET['kamen']) and $user['kamen'] >= 1 and $batlle_user['kamen'] < time()){
mysql_query("UPDATE `users` SET `kamen` = `kamen` - '1' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `coliseum_users` SET `kamen` = '".(time()+30)."' WHERE `id` = '".$batlle_user['id']."' LIMIT 1");
header('Location: ?attack');
exit();
}
if(isset($_GET['trava']) and $user['trava'] >= 1 and $batlle_user['trava'] < time()){
mysql_query("UPDATE `users` SET `trava` = `trava` - '1' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `coliseum_users` SET `trava` = '".(time()+30)."' WHERE `id` = '".$batlle_user['id']."' LIMIT 1");
header('Location: ?attack');
exit();
}
if(isset($_GET['attack'])){
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `coliseum_users` WHERE `id` = '$batlle_user[cel]' AND `ubit` = '0'"));
if(!$opponent or $opponet['ubit'] == 1 or $opponent['health'] < 0){
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `coliseum_users` WHERE `id_user` != '$myID' AND `ubit` = '0' AND `id_batlle` = '$batlle[id]' ORDER BY RAND() DESC LIMIT 1"));
mysql_query("UPDATE `coliseum_users` SET `cel` = '$opponent[id]' WHERE `id` = '$batlle_user[id]' LIMIT 1");
}
if(!$opponent){
mysql_query("UPDATE `coliseum` SET `start` = '3' WHERE `id` = '$batlle[id]' LIMIT 1");
header("Location: ?$random");
exit();
}
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$opponent[id_user]'"));
if($batlle_user['udar_last'] > time()){
$time = ($batlle_user['udar_last']-time());
switch($time){
case 1:
$_str = ceil($_str*80/100);
break;
case 2:
$_str = ceil($_str*60/100);
break;
case 3:
$_str = ceil($_str*40/100);
break;
case 4:
$_str = ceil($_str*10/100);
break;
}
}
if(mt_rand(0,100) < $user['krit']){
$krit = true;
}
if($krit)$_str *= 2;
$_str_opp = rand(round($ank['str']/6), round($ank['str']/4));
$_def_opp = rand(round($ank['def']/12), round($ank['def']/7));
if($batlle_user['kamen'] > time())$_str += ceil($_str*35/100);
if($opponent['trava'] > time())$_def_opp += ceil($_def_opp*35/100);
$_str = $_str - $_def_opp;
if($_str < 0)$_str = 0;
mysql_query("UPDATE `coliseum_users` SET `health` = `health`-'$_str' WHERE `id` = '$opponent[id]'");
mysql_query("UPDATE `coliseum_users` SET `udar_last` = '".(time()+4)."', `urons` = '".($batlle_user['urons']+$_str)."' WHERE `id` = '$batlle_user[id]' LIMIT 1");
mysql_query("INSERT INTO `coliseum_log` SET `uron` = '$_str', `id_user` = '$myID', `cel` = '$ank[id]', `krit` = '".($krit == true ? 1 : 0)."', `id_batlle` = '$batlle[id]'");

//Бот, атака
if($ank['bot'] == 1){
$_str_opp = rand(round($ank['str']/6), round($ank['str']/4));
if(mt_rand(0,100) < $ank['krit']){
$krit_opp = true;
}
if($krit_opp)$_str_opp *= 2;
if($batlle_user['trava'] > time())$_str_opp -= ceil($_str_opp*35/100);
$_str_opp = $_str_opp - $_def;
if($_str_opp < 0)$_str_opp = 0;
mysql_query("UPDATE `coliseum_users` SET `health` = `health`-'$_str_opp' WHERE `id` = '$batlle_user[id]'");
mysql_query("UPDATE `coliseum_users` SET `udar_last` = '".(time()+4)."', `urons` = '".($opponent['urons']+$_str_opp)."' WHERE `id` = '$opponent[id]' LIMIT 1");
mysql_query("INSERT INTO `coliseum_log` SET `uron` = '$_str_opp', `id_user` = '$ank[id]', `cel` = '$myID', `krit` = '".($krit_opp == true ? 1 : 0)."', `id_batlle` = '$batlle[id]'");
if($_str_opp > $batlle_user['health']){
mysql_query("UPDATE `coliseum_users` SET `ubit` = '1', `time_ubit` = '".time()."' WHERE `id` = '$batlle_user[id]' LIMIT 1");
mysql_query("UPDATE `coliseum_users` SET `cel` = '0', `ubito` = `ubito`+'1' WHERE `id` = '$opponent[id]' LIMIT 1");
mysql_query("INSERT INTO `coliseum_log` SET `ubit` = '1', `id_user` = '$ank[id]', `cel` = '$myID', `id_batlle` = '$batlle[id]'");
header("Location: ?$random");
exit();
}
}

if($_str > $opponent['health']){
if(mt_rand(0,100) < 60 and $turnir_chereps['start'] == 1){
$cherep = true;
}
if($cherep)mysql_query("UPDATE `users` SET `chereps` = '".($user['chereps']+1)."' WHERE `id` = '$myID' LIMIT 1");
mysql_query("UPDATE `coliseum_users` SET `ubit` = '1', `time_ubit` = '".time()."' WHERE `id` = '$opponent[id]' LIMIT 1");
mysql_query("UPDATE `coliseum_users` SET `cel` = '0', `ubito` = `ubito`+'1' WHERE `id` = '$batlle_user[id]' LIMIT 1");
mysql_query("INSERT INTO `coliseum_log` SET `ubit` = '1', `id_user` = '$myID', `cel` = '$ank[id]', `id_batlle` = '$batlle[id]'");
if($cherep){
$_SESSION['msg'] = 'За убийство противника вы получили '.ico('icons','cherep.png').' +1 череп';
}
}
header("Location: ?$random");
exit();
}
require_once ('system/head.php');
echo "<div class='linetop'></div><div class='title center'>".img('icons','health.png')." ".n_f($batlle_user['health'],1)."</div><div class='line'></div>";
$progress = round($batlle_user['health']/$batlle_user['max_health']*100,1);
if($progress > 100)$progress = 100;
echo '<div class="exp"><div class="exp_in" style="width: '.$progress.'% "><br></div></div>';
if(isset($_SESSION['msg'])){
echo msg($_SESSION['msg']);
unset($_SESSION['msg']);
}
echo "<div class='block center'>";
if($batlle_user['cel'] > 0){
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `coliseum_users` WHERE `id` = '$batlle_user[cel]'"));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$opponent[id_user]'"));
echo icons_user($ank['id'])." $ank[login] ".ico('icons','health.png')." $opponent[health]";
echo "<div class='stat_bar'><div class='progress' style='width: ".round($opponent['health']/$opponent['max_health']*100,1)."%;'></div></div>";
}
echo "<a href='?attack' class='btn2'>Атаковать</a><div class='md5'></div><a href='?list' class='btn2'>Сменить цель</a>$separ";
echo "<a href='?uvorot' class='btn2'>Уворот ".($batlle_user['uvorot'] > time() ? "<span id='time_".($batlle_user['uvorot']-time())."000'>".tl($batlle_user['uvorot']-time())."</span>" : "")."</a> ";
echo "<a href='?nastroika' class='btn2'>Настройка ".($batlle_user['nastroika'] > time() ? "<span id='time_".($batlle_user['nastroika']-time())."000'>".tl($batlle_user['nastroika']-time())."</span>" : "")."</a>$separ";
echo "<table cellpadding='5' cellspacing='0' align='center'><tr>";
echo "<td class='center' style='border-right: 1px solid #8D673A;'>";
if($user['kamen'] > 0)echo "<a href='?kamen' class='btn2'>".ico('icons','kamen.png')." Камень</a><br>";
else echo "<a href='?kamen' class='btn2'>".ico('icons','kamen.png')." <span class='grey'>Камень</span></a><br>";
if($batlle_user['kamen'] > time()){
echo "<span class='info'><span id='time_".($batlle_user['kamen']-time())."000'>".tl($batlle_user['kamen']-time())."</span></span>";
}else{
echo "<span class='white'>+35% урон</span>";
}
echo "</td>";
echo "<td class='center'>";
if($user['trava'] > 0)echo "<a href='?trava' class='btn2'>".ico('icons','trava.png')." Трава</a><br>";
else echo "<a href='?trava' class='btn2'>".ico('icons','trava.png')." <span class='grey'>Трава</span></a><br>";
if($batlle_user['trava'] > time()){
echo "<span class='info'><span id='time_".($batlle_user['trava']-time())."000'>".tl($batlle_user['trava']-time())."</span></span>";
}else{
echo "<span class='white'>-35% урон</span>";
}
echo "</td>";
echo "</tr></table>";
echo "До конца боя осталось: <span id='time_".($batlle['last']-time())."000'>".tl($batlle['last']-time())."</span>";
echo "</div>";
echo "<div class='block'>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `coliseum_log` WHERE `id_batlle` = '$batlle[id]'"),0);
if($k_post == 0)echo "Логов не найдено...";
$q = mysql_query("SELECT * FROM `coliseum_log` WHERE `id_batlle` = '$batlle[id]' ORDER BY `id` DESC LIMIT 15");
while($post = mysql_fetch_assoc($q)){
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$post[id_user]'"));
$cel = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$post[cel]'"));
if($post['ubit'] == 1){
if($ank['id'] == $myID){
echo "Вы убили $cel[login]<br>";
}elseif($ank['cel'] == $myID){
echo "<font color='red'>$ank[login] убил вас</font><br>";
}else{
echo "$ank[login] убил $cel[login]<br>";
}
}else{
if($cel['id'] == $myID and $post['uron'] > 0){
echo "<font color='red'>$ank[login] атаковал Вас на <b>$post[uron]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."</font><br>";
}elseif($ank['id'] == $myID){
if($post['uron'] > 0)echo "Вы атаковали $cel[login] на <b>$post[uron]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."<br>";
else echo "<span class='grey'>Промах</span><br>";
}elseif($post['uron'] > 0){
echo "$ank[login] атаковал $cel[login] на <b>$post[uron]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."<br>";
}
}
}
echo "</div>";
echo "<a href='?exit' class='link center'>".ico('icons','arrow.png')." Покинуть бой</a>";
?>
<script type="text/javascript">
        var secS = 'с.';
        var secM = 'с.';
        var minS = 'м.';
        var minM = 'м.';
        var hourS = 'ч.';
        var hourM = 'ч.';
        var dayS = 'д.';
        var dayM = 'д.';
        var detailOut = false;
        var readyLink = '0'+(detailOut?secS:' ' + secM);
</script>
<script src="/ajax/t.js" type="text/javascript"></script>
<?
echo "</body></html>";
}elseif($batlle['start'] == 1){
$batlle = mysql_query("SELECT * FROM `coliseum` WHERE `start` = '1' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
$count_users = mysql_result(mysql_query("SELECT COUNT(*) FROM `coliseum_users` WHERE `id_batlle` = '$batlle[id]'"),0);
if($count_users < 3){
mysql_query("UPDATE `coliseum` SET `start` = '0' WHERE `id` = '$batlle[id]' LIMIT 1");
header('Location: ?');
exit();
}
if($batlle['last'] < time()){
mysql_query("UPDATE `coliseum` SET `start` = '2', `last` = '".(time()+60*5)."' WHERE `id` = '$batlle[id]' LIMIT 1");
header('Location: ?');
exit();
}
require_once ('system/header.php');
echo "<div class='block center'><img src='/images/things/coliseum.jpg' style='border-radius:8px;width:100%'></div>";
echo "<div class='block center'>";
echo "В очереди: $count_users из 5 воинов<br>Бой начнется через: <span id='time_".($batlle['last']-time())."000'>".tl($batlle['last']-time())."</span>".$separ."";
if(!$batlle_user){
if(isset($_GET['vstat'])){
$batlle = mysql_query("SELECT * FROM `coliseum` WHERE `start` < '2' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
$count_users = mysql_result(mysql_query("SELECT COUNT(*) FROM `coliseum_users` WHERE `id_batlle` = '$batlle[id]'"),0);
if(!$batlle){
mysql_query("INSERT INTO `coliseum` SET `start` = '0'");
$id = mysql_insert_id();
mysql_query("INSERT INTO `coliseum_users` SET `id_user` = '$myID', `id_batlle` = '$id', `max_health` = '".num($user['max_health']*2)."', `health` = '".num($user['max_health']*2)."'");
header("Location: ?$random");
exit();
}else{
mysql_query("INSERT INTO `coliseum_users` SET `id_user` = '$myID', `id_batlle` = '$batlle[id]', `max_health` = '".num($user['max_health']*2)."', `health` = '".num($user['max_health']*2)."'");
if($count_users+1 == 5){
mysql_query("UPDATE `coliseum` SET `start` = '2', `last` = '".(time()+60*5)."' WHERE `id` = '$batlle[id]' LIMIT 1");
}
header("Location: ?$random");
exit();
}
}
echo "<a href='?vstat' class='btn2'>Встать в очередь</a>";
}else{
if(isset($_GET['exit'])){
mysql_query("DELETE FROM `coliseum_users` WHERE `id` = '$batlle_user[id]' LIMIT 1");
header("Location: ?$random");
exit();
}
echo "<a href='?$random' class='btn2'>Обновить</a><br>";
echo "<a href='?exit' class='btn2'>Покинуть очередь</a>";
}
echo "<div class='md5'></div>";
echo "<hr>";
echo "<table cellpadding='5' cellspacing='0' align='center'><tr>";
echo "<td class='center' style='border-right: 1px solid #8D673A;'>";
echo ico('icons','kamen.png')." <span class='white'>Камень</span><br>";
echo "<span class='white'>$user[kamen] штук</span>";
echo "</td>";
echo "<td class='center'>";
echo ico('icons','trava.png')." <span class='white'>Трава</span><br>";
echo "<span class='white'>$user[trava] штук</span>";
echo "</td>";
echo "</tr></table>";
if($turnir_chereps['start'] == 1){
echo "<hr>У вас: ".ico('icons','cherep.png')." $user[chereps] черепов!<br><span class='small'>Турнир по черепам проходит каждую неделю с понедельника по субботу!</span>";
echo "$separ<a href='/common/turnir_chereps/' class='btn2'>Подробнее об турнире</a>";
}
echo "</div>";
echo "<a href='/coliseum/rating/' class='link center'>".ico('icons','arrow.png')." Рейтинг колизея</a>";
require_once ('system/footer.php');
}elseif($batlle['start'] == 0){
$batlle = mysql_query("SELECT * FROM `coliseum` WHERE `start` < '2' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
if($count_users >= 3){
mysql_query("UPDATE `coliseum` SET `start` = '1', `last` = '".(time()+24)."' WHERE `id` = '$batlle[id]' LIMIT 1");
header('Location: ?');
exit();
}
if($count_users >= 1 and $count_users <= 2 and $batlle['last'] < time()){
$bot = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `bot` = '1' ORDER BY RAND() LIMIT 1"));
$bot_batlle = mysql_fetch_array(mysql_query("SELECT * FROM `batlle_users` WHERE `id_user` = '$bot[id]' ORDER BY `id` LIMIT 1"));
if($bot_batlle){
$bot = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `bot` = '1' AND `id` != '$bot[id]' ORDER BY RAND() LIMIT 1"));
}
mysql_query("INSERT INTO `coliseum_users` SET `id_user` = '$bot[id]', `id_batlle` = '$batlle[id]', `max_health` = '".num($bot['max_health']*2)."', `health` = '".num($bot['max_health']*2)."'");
if($count_users+1 < 3)mysql_query("UPDATE `coliseum` SET `last` = '".(time()+60)."' WHERE `id` = '$batlle[id]' LIMIT 1");
header('Location: ?');
exit();
}
require_once ('system/header.php');
echo "<div class='block center'><img src='/images/things/coliseum.jpg' style='border-radius:8px;width:100%'></div>";
echo "<div class='block center'>";
echo "В очереди: $count_users из 5 воинов".$separ."";
if(!$batlle_user){
if(isset($_GET['vstat'])){
$batlle = mysql_query("SELECT * FROM `coliseum` WHERE `start` <= '1' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
$count_users = mysql_result(mysql_query("SELECT COUNT(*) FROM `coliseum_users` WHERE `id_batlle` = '$batlle[id]'"),0);
if(!$batlle){
mysql_query("INSERT INTO `coliseum` SET `start` = '0', `last` = '".(time()+60)."'");
$id = mysql_insert_id();
mysql_query("INSERT INTO `coliseum_users` SET `id_user` = '$myID', `id_batlle` = '$id', `max_health` = '".num($user['max_health']*2)."', `health` = '".num($user['max_health']*2)."'");
header("Location: ?$random");
exit();
}else{
mysql_query("INSERT INTO `coliseum_users` SET `id_user` = '$myID', `id_batlle` = '$batlle[id]', `max_health` = '".num($user['max_health']*2)."', `health` = '".num($user['max_health']*2)."'");
if($count_users+1 == 5){
mysql_query("UPDATE `coliseum` SET `start` = '2', `last` = '".(time()+60*5)."' WHERE `id` = '$batlle[id]' LIMIT 1");
}
header("Location: ?$random");
exit();
}
}
echo "<a href='?vstat' class='btn2'>Встать в очередь</a>";
}else{
if(isset($_GET['exit'])){
mysql_query("DELETE FROM `coliseum_users` WHERE `id` = '$batlle_user[id]' LIMIT 1");
header("Location: ?$random");
exit();
}
echo "<a href='?$random' class='btn2'>Обновить</a><br>";
echo "<a href='?exit' class='btn2'>Покинуть очередь</a>";
}
echo "<div class='md5'></div>";
echo "<hr>";
echo "<table cellpadding='5' cellspacing='0' align='center'><tr>";
echo "<td class='center' style='border-right: 1px solid #8D673A;'>";
echo ico('icons','kamen.png')." <span class='white'>Камень</span><br>";
echo "<span class='white'>$user[kamen] штук</span>";
echo "</td>";
echo "<td class='center'>";
echo ico('icons','trava.png')." <span class='white'>Трава</span><br>";
echo "<span class='white'>$user[trava] штук</span>";
echo "</td>";
echo "</tr></table>";
if($turnir_chereps['start'] == 1){
echo "<hr>У вас: ".ico('icons','cherep.png')." $user[chereps] черепов!<br><span class='small'>Турнир по черепам проходит каждую неделю с понедельника по субботу!</span>";
echo "$separ<a href='/common/turnir_chereps/' class='btn2'>Подробнее об турнире</a>";
}
echo "</div>";
echo "<a href='/coliseum/rating/' class='link center'>".ico('icons','arrow.png')." Рейтинг колизея</a>";
require_once ('system/footer.php');
}
?>