View file modules/arena/go_boy.asp

File size: 1.69Kb
<?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'])){
$id=abs(intval($_GET[id])); 

if(empty($id))
{
echo 'Ошибка...';
foot();     	exit;
}
$req = mysql_query("SELECT * FROM `arena` WHERE `id`='$id' and `status` = 'on'");
$avto = mysql_num_rows($req);
$arena = mysql_fetch_array($req);
if($avto <= 0)
{
echo 'Ошибка...';
foot();     	exit;
}
if($udata2['lvl'] < $arena['min_lvl'])
{
echo'Ваш уровень слишком мал.';
foot();     	exit;
}
if($udata2['lvl'] > $arena['max_lvl'])
{
echo'Ваш уровень слишком велик.';
foot();     	exit;
}
$req = mysql_query("SELECT * FROM `tmp_arena` WHERE `oponent`='".$udata2['nick']."'");
$avto = mysql_num_rows($req);
if($avto > 0)
{
echo 'Ошибка...';
foot();     	exit;
}
$time = time() + 600;
mysql_query("UPDATE `arena` SET `oponent` = '".$udata2['nick']."', `status` = 'off', `timer` = '$time' WHERE `id` = '$id' LIMIT 1");
mysql_query("UPDATE `tmp_arena` SET `oponent` = '".$udata2['nick']."' WHERE `usr` = '".$arena['lider']."' LIMIT 1");
mysql_query("INSERT INTO `tmp_arena` SET  `usr` = '".$udata2['nick']."', `oponent` = '".$arena['lider']."', `step` = 'not'");
header('Location: battle.asp?');


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