defined('AntiBK') or die("Доступ запрещен!");
$do = getVar('do');
$fight = getVar('fight');
$battle_type = getVar('battle_type');
$timeout = getVar('timeout');
$log = getVar('log');
$ac = getVar('ac');
$accept = getVar('accept');
$accept2 = getVar('accept2');
$otkaz = getVar('otkaz');
$id = getVar('id');
$denie = getVar('denie');
/*
$dat = $adb->select("SELECT * FROM `zayavka`;");
$countrows = count ($dat);
for ($i = 0; $i < $countrows; $i++)
{
$cr = $dat[$i]['creator'];
$player = $adb->selectCell("SELECT `login` FROM `characters` WHERE `id` = '$cr';");
$search = $adb->selectCell("SELECT `login` FROM `online` WHERE `login` = '$player';");
$online = ($search) ?1 :0;
if ($online == 0)
{
$del = $adb->query("DELETE FROM `zayavka` WHERE `creator` = '$cr';");
$del1 = $adb->query("DELETE FROM `team1` WHERE `battle_id` = '$cr';");
$del2 = $adb->query("DELETE FROM `team2` WHERE `battle_id` = '$cr';");
}
if ($m == $dat[$i]['creator'] && $dat[$i]['status'] == 1)
$zayavka_status = "awaiting";
if ($m == $dat[$i]['creator'] && $dat[$i]['status'] == 2 && $t == 1)
$zayavka_status = "confirm_mine";
if ($m == $dat[$i]['creator'] && $dat[$i]['status'] == 2 && $t == 2)
$zayavka_status = "confirm_opp";
if ($m == $dat[$i]['creator'] && $dat[$i]['status'] == 3)
goBattle($login);
}
if (empty($zayavka_status))
$zayavka_status = "no";*/
$flags = $char->city->getRoom($room, $city, 'flags');
$hps = array('fiz', 'dgv', 'group', 'haos');
?>
switch ($fight)
{
case 'fiz':
if (!($flags & 1))
die("
В этой комнате невозможно подавать заявки");
echo "После подачи заявки, вам будет подобран случайный противник вашего уровня
";
echo "";
break;
case 'dgv':
die("
Выберите раздел...");
break;
case 'group':
if ($level < 2)
die("
В групповые бои только со второго уровня.");
else if (!($flags & 1))
die("
В этой комнате невозможно подавать заявки");
break;
case 'haos':
if ($level < 2)
die("
В хаотичные бои только со второго уровня.");
else if (!($flags & 1))
die("
В этой комнате невозможно подавать заявки");
break;
case 'tklogs':
break;
case 'logs':
break;
default:
die("
Выберите раздел");
break;
}
die();
/*=====status disc=========*/
/*1 - ожидает вызова */
/*2 - ожидает подтверждения*/
/*3 - принята */
/*=========================*/
switch ($act)
{
/*подать заявку*/
case 'podat':
if ($db['hp_all'] / 3 > $db['hp'])
{
echo "Вы слишком ослаблены для поединка! Восстановитесь!
";
echo "назад";
die ();
}
$st1 = $adb->selectCell("SELECT `player` FROM `team1` WHERE `player` = '$login';");
$st2 = $adb->selectCell("SELECT `player` FROM `team2` WHERE `player` = '$login';");
if ($st1 || $st2)
{
echo "Вы не можете принять эту заявку! Сначала отзовите свою!
";
echo "Назад";
die ();
}
if (empty($ip))
$ip = ($_SERVER['HTTP_X_FORWARDED_FOR']) ?$_SERVER['HTTP_X_FORWARDED_FOR'] :$_SERVER['REMOTE_ADDR'] ;
$date = date ("d.m.y H:i");
$time = date("H:i");
$mine_id = $db['id'];
$query = $adb->query(" INSERT INTO `zayavka` (status,type,date,timeout,creator)
VALUES ('1', '$battle_type', '$time', '$timeout', '$mine_id');");
$query = $adb->query(" INSERT INTO `team1` (player,ip,battle_id,hitted,over)
VALUES ('$login', '$ip', '$mine_id', '0', '0')");
$query = $adb->query(" UPDATE `characters`
SET `zayavka` = '1'
WHERE `login` = '$login';
");
$zayavka_c_m = 0;
session_register ('zayavka_c_m');
echo "";
break;
/*принять вызов*/
case 'a':
if($db['hp_all'] / 3 > $db['hp'])
{
echo "Вы слишком ослаблены для поединка! Восстановитесь!
";
echo "Назад";
die();
}
$st1 = $adb->selectCell("SELECT `player` FROM `team1` WHERE `player` = '$login';");
$st2 = $adb->selectCell("SELECT `player` FROM `team2` WHERE `player` = '$login';");
if ($st1 || $st2)
{
echo "Вы не можете принять этот вызов! Сначала отзовите свою!
";
echo "Вернуться";
die ();
}
$q = $adb->selectCell("SELECT `creator` FROM `zayavka` WHERE `creator` = '$id';");
if(empty($ip))
$ip = ($_SERVER['HTTP_X_FORWARDED_FOR']) ?$_SERVER['HTTP_X_FORWARDED_FOR'] :$_SERVER['REMOTE_ADDR'] ;
if($q)
{
$zayavka_c_o = 0;
session_register ('zayavka_c_o');
$d2 = $adb->selectCell("SELECT `player` FROM `team2` WHERE `battle_id` = '$id';");
$d = $adb->selectCell("SELECT `player` FROM `team1` WHERE `battle_id` = '$id';");
if ($d2 == '' || empty($d2))
{
$q = $adb->query(" INSERT INTO `team2` (player,ip,battle_id,hitted,over)
VALUES ('$login', '$ip', '$id', '0', '0');");
$s = $adb->query(" UPDATE `zayavka`
SET `status` = '2'
WHERE `creator` = '$id';
");
if ($q)
{
$s11 = $adb->query(" UPDATE `characters`
SET `zayavka` = '1'
WHERE `login` = '$d';
");
echo "";
}
}
}
break;
/*отозвать заявку*/
case 'recall':
$s = $adb->selectCell("SELECT `battle_id` FROM `team1` WHERE `player` = '$login';");
if ($s)
{
$dd = $adb->selectCell("SELECT `status` FROM `zayavka` WHERE `creator` = '$cr';");
if ($dd != 2)
{
$query = $adb->query("DELETE FROM `zayavka` WHERE `creator` = '$s';");
$s2 = $adb->query("DELETE FROM `team1` WHERE `battle_id` = '$s';");
if ($query)
{
$s11 = $adb->query(" UPDATE `characters`
SET `zayavka` = '0'
WHERE `login` = '$login';
");
echo "";
}
}
}
break;
/*отозвать свою заявку*/
case 'recallbattle':
$q = $adb->selectCell("SELECT `battle_id` FROM `team2` WHERE `player` = '$login';");
if ($q)
{
$cr = $q;
$dd = $adb->selectCell("SELECT `status` FROM `zayavka` WHERE `creator` = '$cr';");
if ($dd != 3)
{
$query = $adb->query(" UPDATE `zayavka`
SET `status` = '1'
WHERE `creator` = '$cr';
");
$ssd = $adb->query("DELETE FROM `team2` WHERE `battle_id` = '$cr';");
if ($query)
{
$p = $adb->selectCell("SELECT `player` FROM `team1` WHERE `battle_id` = '$cr';");
$s11 = $adb->query(" UPDATE `characters`
SET `zayavka` = '0'
WHERE `login` = '$p';
");
echo "";
}
}
}
break;
/*подтвердить заявку*/
case 'confirm':
if ($denie)
{
$s = $adb->selectCell("SELECT `battle_id` FROM `team1` WHERE `player` = '$login';");
if ($S)
{
$query = $adb->query(" UPDATE `zayavka`
SET `status` = '1'
WHERE `creator` = '$s';
");
$op = $adb->selectCell("SELECT `player` FROM `team2` WHERE `battle_id` = '$s';");
$s2 = $adb->query("DELETE FROM `team2` WHERE `battle_id` = '$s';");
if ($query)
{
$_SESSION['zayavka_c_m'] = 0;
$s11 = $adb->query(" UPDATE `characters`
SET `zayavka` = '0'
WHERE `login` = '$op';
");
echo "";
}
}
}
if ($accept)
{
$data = $adb->selectRow("SELECT * FROM `team1` WHERE `player` = '$login';");
if ($data)
{
$tt = $data['type'];
$cr = $data['battle_id'];
$zz = $adb->selectCell("SELECT `player` FROM `team2` WHERE `battle_id` = '$cr';");
if ($zz)
{
$q = $adb->query(" INSERT INTO `battles` (type,status,creator_id)
VALUES('$tt', 'during', '$cr');");
if ($q)
{
$op = $adb->selectCell("SELECT `player` FROM `team2` WHERE `battle_id` = '$cr';");
$sql_rm = $adb->query(" UPDATE `zayavka`
SET `status` = '3'
WHERE `creator` = '$cr';
");
$s1 = $adb->query(" UPDATE `characters`
SET `zayavka` = '2'
WHERE `login` = '$login';
");
$s11 = $adb->query(" UPDATE `characters`
SET `zayavka` = '2'
WHERE `login` = '$op';
");
goBattle($login);
}
}
}
}
break;
}
if ($zayavka_status == "no")
{
?>
}
else if ($zayavka_status == "awaiting")
{
?>
}
else if ($zayavka_status == "confirm_mine")
{
$op_level = $adb->selectCell("SELECT `level` FROM `characters` WHERE `login` = '$opponent';");
?>
}
else if ($zayavka_status == "confirm_opp")
{
$op_level = $adb->selectCell("SELECT `level` FROM `characters` WHERE `login` = '$opponent';");
?>
}
echo "";
?>