Вход Регистрация
Файл: Gladiators v2.2/modules/arena/battle.asp
Строк: 199
<?php

/**
 * @author ByUNNAMED
 * @copyright 2012
 */

ob_start();
$title='Арена';//Титул
include('../../system/include/settings.inc');//Потключаемся к базе    
include('../../system/include/function.inc');//Выводим функции
head($title,$udata2);//Верх страницы
if(isset($udata['pass']) && isset($udata2['nick'])){
        
$req1 mysql_query("SELECT * FROM `arena` WHERE `lider` = '".$udata2['nick']."' or `oponent` = '".$udata2['nick']."' LIMIT 1");
        
$t mysql_fetch_array($req1);
        
$time time();
        if(
$time $t['timer'])
        {
        
mysql_query("DELETE FROM `tmp_arena` WHERE `usr` = '".$udata2['nick']."'");
        
mysql_query("DELETE FROM `tmp_arena` WHERE `oponent` = '".$udata2['nick']."'");
        
mysql_query("DELETE FROM `arena` WHERE `oponent` = '".$udata2['nick']."' or `lider` = '".$udata2['nick']."'");
        echo 
'Время на поединок закончилось, вы проиграли бой.<br />';
        echo 
'<a href="index.asp">Продолжить</a><br />';
        
foot();         exit;
        }

        
$req2 mysql_query("SELECT * FROM `tmp_arena` WHERE `oponent` = '".$udata2['nick']."' LIMIT 1");
        
$ar2 mysql_fetch_array($req2);
        
$req mysql_query("SELECT * FROM `tmp_arena` WHERE `usr` = '".$udata2['nick']."' LIMIT 1");
        
$ar mysql_fetch_array($req);
        
$chek mysql_num_rows($req);
        if(
$chek <= 0)
        {
        
header('Location: index.asp?');
        }
        if(
$ar['step'] == 'yes')
        {
                echo
'Вы уже сделали ход<br />ожидайте хода противника<br /><a href="battle.asp?'.rand(1000,9999).'">Обновить</a><br />';foot();         exit;
        }
switch(
$_GET['mod'])
{
    default:
                        if(
$udata2['hp'] <= 0)
                    {
                        
header('Location: battle.asp?mod=udar');
                        
                        
foot();         exit;
                    }
        
$req mysql_query("SELECT * FROM `arena` WHERE `lider` = '".$udata2['nick']."' LIMIT 1");
        
$chek mysql_fetch_array($req);
        if(
$chek['oponent'] == 'not')
        {
        echo
'Нет противника<br />';
        echo
'<a href="battle.asp?'.rand(1000,9999).'">Обновить</a> | <a href="battle.asp?mod=exit&go=lider">Отменить</a><br />';
        
foot();         exit;
        }
        
$req mysql_query("SELECT * FROM `chars` WHERE `nick` = '".$ar['oponent']."' LIMIT 1");
        
$op mysql_fetch_array($req);
        echo
'HP: '.$op[hp].'/'.$op['hpall'];
            echo 
'<form action="battle.asp?mod=udar" method="post">';
                echo 
"Ударить:<br/>
                <select name="
a_kuda">
                <option value="
golova">В голову</option>
                <option value="
body">В живот</option>
                <option value="
nogi">В ноги</option>
                </select><br/>"
;
                echo 
"Защита:<br/>
                <select name="
p_kuda">
                <option value="
golova">Головы</option>
                <option value="
body">Живота</option>
                <option value="
nogi">Ног</option>
                </select><br/>"
;
            echo 
'<input class="button" type="submit" value="Ударить" /></form>';
            echo 
'<a href="?mod=elixir">Использовать эликсир</a><br />';
            
$req mysql_query("SELECT * FROM `msg_arena` WHERE `oponent` = '".$udata2['nick']."' ORDER BY `id` DESC LIMIT 3");
            
$avto mysql_num_rows($req);
                
            while(
$msg mysql_fetch_array($req)){
                    if(
time() < $msg['time'])
                    {
                    echo 
$msg['msg'];
            echo 
'<br />';
                    }
            }
                
        break;
        case 
'elixir':
        
        
                
$req mysql_query("SELECT * FROM `implements` WHERE `usr`='".$udata2['nick']."' and `type` = 'elixir'");
                    
$avto mysql_num_rows($req);
                        if(
$avto 0)
                        {
            while(
$elixir mysql_fetch_array($req))
            {
                
                echo 
$elixir['name'].' [<a href="?mod=elixir_ok&amp;id='.$elixir['id'].'">Использовать</a>]<br/>';
                
                }
                    }else{
                        echo 
'Нет вещей!<br />';
                            }
                            echo 
'<a href="?">Назад</a>';
        
        break;
            case 
'elixir_ok':
                
$id=abs(intval($_GET['id'])); 
                
             
$req mysql_query("SELECT * FROM `implements` WHERE `id`='$id' and `usr` = '".$udata2['nick']."'");
             
             
$elixir mysql_fetch_array($req);
                if(
$udata2['lvl'] < $elixir['lvl'])
                {
                    echo 
'Вы не можете использовать эту вещь так как ваш уровень слишком мал!<br /><a href="?">Назад</a>';
                            
foot();    exit;
                    }
                    if(
$elixir['usr'] != $udata2['nick'])
                        {
                            echo 
'Вы не можете испльзовать чужую вещь!<br /><a href="?">Назад</a>';
                            
foot();    exit;
                            }
                        if(
$elixir['type'] != 'elixir')
                            {
                                echo 
'Это не елексир!<br /><a href="?">Назад</a>';
                                
foot();    exit;
                                }
                        
$avto mysql_num_rows($req);
                            if(
$avto <= 0)
                                {
                                    echo 
'Нет такого елексира!<br /><a href="?">Назад</a>';
                                    
foot();    exit;
                                    }
                                    
                    echo 
'<form action="?mod=elixir_ok&who=ok&amp;id='.$elixir['id'].'" method="post">';
                    
                    echo
'Количество элексиров<br/>
                    <input class="input" type="text" size="13" name="kol" maxlength="10"/><br/>'
;
                    
                    echo 
'<input class="button" type="submit" value="Продолжить" /></form><br>';
                    
                        if(
$_GET['who'] == 'ok')
                        
                            {
                                
$kol mysql_real_escape_string($_POST['kol']);
                                if(empty(
$_POST['kol']))
                                    {
                                        echo 
'Вы не указали количество элексиров!<br /><a href="?mod=elixir_ok&amp;id='.$elixir['id'].'">Назад</a>';;
                                        
foot(); exit;
                                    }
                                    if(
$elixir['number'] < $kol)
                                    {
                                        echo 
'У вас нет столько элексиров!<br /><a href="?mod=elixir_ok&amp;id='.$elixir['id'].'">Назад</a>';;
                                        
foot(); exit;
                                    }
                                
                                
$kol_hp $elixir['hp'] * $kol;
                                
$hp $kol_hp $udata2['hp'];
                                
                                if(
$udata2['hpall'] < $hp)
                                    {
                                        
$hp $udata2['hpall'];
                                    }
                                
$kol_el $elixir['number'] - $kol;
                            
                             if(
$elixir['number'] == $kol)
                                    {
                                       
mysql_query("DELETE FROM `implements` WHERE `id` = '".$elixir['id']."'");
                                    }else{
                                       
mysql_query("UPDATE `implements` SET `number` = '$kol_el' WHERE `id` = '".$elixir['id']."'");
                                    }
                            
             
             
$req mysql_query("UPDATE `chars` SET `hp` = '$hp' WHERE `nick` = '".$udata2['nick']."'");
             if(
$req == true)
        {
                echo 
'Вы успешно использовали '.$elixir['name'];
                echo 
'<br /><a href="?">Назад</a>';
        }else{
                    echo 
'Ошибка... Администратор извещен.';
                    echo 
'<br /><a href="?">Назад</a>';
                    
mysql_query("INSERT INTO `log_error` SET  `usr` = '".$udata2['nick']."', `text` = 'Ошибка при использовании еликсира ".$elixir['name'].".', `file` = 'modules/arena/battle.asp'");
        }
                        }
    case
'udar':
        
$req mysql_query("SELECT * FROM `arena` WHERE `lider` = '".$udata2['nick']."' LIMIT 1");
        
$chek mysql_fetch_array($req);
        if(
$chek['oponent'] == 'not')
        {
        echo
'Нет противника<br />';
        echo
'<a href="battle.asp?'.rand(1000,9999).'">Обновить</a> | <a href="battle.asp?mod=exit">Отменить</a><br />';
        
foot();         exit;
        }
        
$req mysql_query("SELECT * FROM `tmp_arena` WHERE `usr` = '".$udata2['nick']."'");
        
$chek mysql_num_rows($req);
        if(
$chek <= 0)
        {
        
header('Location: index.asp?');
        }
            
$req mysql_query("SELECT * FROM `chars` WHERE `nick` = '".$ar['oponent']."' LIMIT 1");
            
$op mysql_fetch_array($req);
                
$attack mysql_real_escape_string($_POST['a_kuda']);
                
$protect mysql_real_escape_string($_POST['p_kuda']);
                    if(
$_POST['a_kuda'] == 'golova')
                    {
                    
$uron $udata2['p_ataka'] - $op['p_golova'];
                    
$msg 'Игрок '.$udata2['nick'].' ударил вас в голову на '.$uron.' урона';
                    }
                    if(
$_POST['a_kuda'] == 'body')
                    {
                    
$uron $udata2['p_ataka'] - $op['p_body'];
                    
$msg 'Игрок '.$udata2['nick'].' ударил вас в живот на '.$uron.' урона';
                    }
                    if(
$_POST['a_kuda'] == 'nogi')
                    {
                    
$uron $udata2['p_ataka'] - $op['p_nogi'];
                    
$msg 'Игрок '.$udata2['nick'].' ударил вас в ноги на '.$uron.' урона';
                    }
                    
                    if(
$uron $op['hp'])
                    {
                        echo 
'Вы побeдили игрока '.$op['nick'];
                        echo 
'<br /><a href="index.asp">Продолжить</a><br />';
                        
$win $udata2['arena_win'] + 1;
                        
mysql_query("UPDATE `chars` SET `arena_win` = '$win', `hp` = '".$udata2['hpall']."' WHERE `nick` = '".$udata2['nick']."' LIMIT 1");
                        
mysql_query("DELETE FROM `tmp_arena` WHERE `usr` = '".$udata2['nick']."'");
                        
mysql_query("DELETE FROM `tmp_arena` WHERE `usr` = '".$op['nick']."'");
                        
mysql_query("DELETE FROM `arena` WHERE `oponent` = '".$udata2['nick']."' or `lider` = '".$udata2['nick']."'");
                        
                        
foot();         exit;
                    }
                    if(
$udata2['hp'] <= 0)
                    {
                        echo 
'Вы проиграли';
                        echo 
'<br /><a href="index.asp">Продолжить</a><br />';
                        
mysql_query("UPDATE `chars` SET `hp` = '".$udata2['hpall']."' WHERE `nick` = '".$udata2['nick']."' LIMIT 1");
                        
mysql_query("DELETE FROM `tmp_arena` WHERE `usr` = '".$udata2['nick']."'");
                        
mysql_query("DELETE FROM `tmp_arena` WHERE `usr` = '".$op['nick']."'");
                        
mysql_query("DELETE FROM `arena` WHERE `oponent` = '".$udata2['nick']."'");
                        
                        
foot();         exit;
                    }
                    
$uron $op['hp'] - $uron;
                    if(
$uron <= 0)
                    {
                    
$uron $op['hp'] - 0;
                    
$msg 'Игрок '.$udata2['nick'].' нанес вам 0 урона';
                    }
                    if(
$attack == $ar2['protect'])
                    {
                    
$uron $op['hp'] -0;
                    
$msg 'Вы заблокировали удар';
                    }
                    
$time time()+30;
                
mysql_query("INSERT INTO `msg_arena` SET  `usr` = '".$udata2['nick']."', `oponent` = '".$ar['oponent']."', `msg` = '$msg', `time` = '$time'");
                
mysql_query("UPDATE `tmp_arena` SET `step` = 'yes', `protect` = '$protect', `attack` = '$attack' WHERE `usr` = '".$udata2['nick']."' LIMIT 1");
                
$req mysql_query("UPDATE `tmp_arena` SET `step` = 'not' WHERE `oponent` = '".$udata2['nick']."' LIMIT 1");
                
mysql_query("UPDATE `chars` SET `hp` = '$uron' WHERE `nick` = '".$ar['oponent']."' LIMIT 1");
                        if(
$req true)
                            {
                        
                        
header('Location: battle.asp?');
                        
                        }else{
                echo 
'Ошибка... Администратор извещен.';
                
mysql_query("INSERT INTO `log_error` SET  `usr` = '".$udata2['nick']."', `text` = 'Ошибка при атаке на арене.', `file` = 'modules/arena/battle.asp'");
                        }
        break;
    case 
'exit':
        if(
$_GET['go'] == 'lider')
        {
            
mysql_query("DELETE FROM `tmp_arena` WHERE `usr` = '".$udata2['nick']."'");
            
mysql_query("DELETE FROM `tmp_arena` WHERE `oponent` = '".$udata2['nick']."'");
            
mysql_query("DELETE FROM `arena` WHERE `lider` = '".$udata2['nick']."'");
            
header('Location: index.asp?');
        }
    
    
        break;





}}else{echo
'Вы не ';
echo 
'<a href="../../index.asp">авторизированы</a> или не выбран персонаж';
}
ob_end_flush();
foot();     
?>
Онлайн: 0
Реклама