Code clean. Твою ж мать, проще переписать чем ковыряться...

This commit is contained in:
Igor Barkov (iwork) 2020-09-28 18:59:12 +03:00
parent 716dd93a91
commit 7fef811dbf

View File

@ -1,13 +1,14 @@
<?php
session_start();
if (!isset($_SESSION['uid'])) {
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include("config.php");
include("functions.php");
if ($user['battle'] != 0) {
$user = $user ?? [];
if ($user->battle != 0) {
header('Location: fbattle.php');
die();
exit;
}
db::c()->query('LOCK TABLES `bots` WRITE, `battle` WRITE, `logs` WRITE, `users` WRITE, `inventory` WRITE, `zayavka` WRITE, `effects` WRITE, `online` WRITE, `clans` WRITE');
@ -16,7 +17,7 @@ if ($do == "clear" && $user->admin == 1) {
db::c()->query('UPDATE `zayavka` SET `coment` = "?s" WHERE `id` = ?i', '<em>Вырезано цензурой!</em>', $_GET['zid']);
}
if (!empty($_GET['del']) && $user['admin'] == 1) { //удаление заявки на бой.
if (!empty($_GET['del']) && $user->admin == 1) { //удаление заявки на бой.
$zayavka = db::c()->query('SELECT `id` FROM `zayavka` WHERE `id` = ?i', $_GET['zid'])->fetch_assoc();
if (isset($zayavka['id'])) {
db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = ?i', $zayavka['id']);
@ -26,16 +27,20 @@ if (!empty($_GET['del']) && $user['admin'] == 1) { //удаление заявк
}
}
$_SESSION['view'] = false;
if (isset($_REQUEST['view'])) $_SESSION['view'] = $_REQUEST['view'];
if (isset($_REQUEST['view'])) {
$_SESSION['view'] = $_REQUEST['view'];
}
class zayavka
class Zayavka
{
var $mysql;
/**
* @var string
*/
private $errorMessage;
function __construct()
function __construct($user_id)
{
global $mysql;
$this->mysql = $mysql;
}
function fteam($team)
@ -53,7 +58,7 @@ class zayavka
* @return mixed
* @throws \Krugozor\Database\Mysql\Exception
*/
function getlist($razdel = 4, $level = null, $id = null)
public function getlist($razdel = 4, $level = null, $id = null)
{
$sql = db::c()->prepare('SELECT * FROM `zayavka` WHERE `level` = ?i', $razdel);
if (!is_null($level)) {
@ -86,65 +91,71 @@ class zayavka
return $zay;
}
function addteam($team, $r)
public function addteam($team, $r)
{
global $user;
$id = $_SESSION['uid'];
$zay = $_REQUEST['gocombat'];
$error = null;
$owntravma = db::c()->query('SELECT `id`, `type` FROM `effects` WHERE (`type` = 12 OR `type` = 13) AND `owner` = ?i', $id)->fetch_assoc();
$z = $this->getlist($r, null, $zay);
if ($owntravma) {
switch ($owntravma['type']) {
case ($owntravma['type'] == 12 && ($z[$zay]['type'] != 4 && $z[$zay]['type'] != 5)):
return "У Вас средняя травма, поединки с оружием слишком тяжелы для Вас...";
break;
case 13:
return "У Вас тяжелая травма, Вы не сможете драться...";
break;
if ($owntravma['type'] == 12 && ($z[$zay]['type'] != 4 && $z[$zay]['type'] != 5)) {
$this->errorMessage = "У Вас средняя травма, поединки с оружием слишком тяжелы для Вас...";
} elseif ($owntravma['type'] == 13) {
$this->errorMessage = "У Вас тяжелая травма, Вы не сможете драться...";
}
if (!empty($user['zayavka'])) {
$this->errorMessage = "Вы находитесь в заявке";
}
if ($user['hp'] < $user['maxhp'] * 0.33) {
$this->errorMessage = "Вы слишком ослаблены для боя, восстановитесь.";
}
if (!$z || !empty($this->user_status($id))) {
$this->errorMessage = "Эта заявка не может быть принята Вами.";
}
if ($z[$zay]['type'] != 3 || $z[$zay]['type'] != 5) {
if ($team == 1) {
$teamz = 2;
} else {
$teamz = 1;
}
if (!empty($user['zayavka'])) return "Вы находитесь в заявке";
if ($user['hp'] < $user['maxhp'] * 0.33) return "Вы слишком ослаблены для боя, восстановитесь.";
if (!$z) return "Эта заявка не может быть принята Вами.";
if ($this->user_status($id) != 0) return "Эта заявка не может быть принята Вами.";
if ($z[$zay]['type'] != 3 OR $z[$zay]['type'] != 5) {
if ($team == 1) $teamz = 2;
else $teamz = 1;
foreach ($z[$zay]['team' . $teamz] as $v) {
$enemy = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $v)->fetch_assoc();
if ($user['klan'] == $enemy['klan']) return "Нельзя драться против сокланов!";
if ($user['klan'] == $enemy['klan']) {
$this->errorMessage = "Нельзя драться против сокланов!";
}
}
}
if ($z[$zay]['t' . $team . 'min'] == 99) {
$toper = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $z[$zay]['team' . $team][0])->fetch_assoc();
if ($user['klan'] != $toper['klan']) return "Эта заявка не может быть принята Вами.";
if ($user['klan'] != $toper['klan']) {
$this->errorMessage = "Эта заявка не может быть принята Вами.";
}
} else {
if ($user['level'] > 0 && !($z[$zay]['t' . $team . 'min'] <= $user['level'] && $z[$zay]['t' . $team . 'max'] >= $user['level'])) {
return "Эта заявка не может быть принята Вами. - " . $z[$zay]['t' . $team . 'min'];
$this->errorMessage = "Эта заявка не может быть принята Вами. - " . $z[$zay]['t' . $team . 'min'];
}
}
if (count($z[$zay]['team' . $team]) >= $z[$zay]['t' . $team . 'c']) {
return "Группа уже набрана.";
$this->errorMessage = "Группа уже набрана.";
}
$z[$zay]['team' . $team][] = '';
if (mysql_query("UPDATE `users`, `zayavka` SET `users`.`zayavka` = {$zay}, `zayavka`.`team{$team}` = '" . implode(";", $z[$zay]['team' . $team]) . "" . $id . ";' WHERE `users`.`id` = {$id} AND `users`.`zayavka` = 0 AND `zayavka`.`id` = {$zay}")) {
if ($this->errorMessage) {
return $this->errorMessage;
} else {
mysql_query("UPDATE `users`, `zayavka` SET `users`.`zayavka` = {$zay}, `zayavka`.`team{$team}` = '" . implode(";", $z[$zay]['team' . $team]) . "" . $id . ";' WHERE `users`.`id` = {$id} AND `users`.`zayavka` = 0 AND `zayavka`.`id` = {$zay}");
return "Вы приняли заявку на бой.";
} else return 'addteam(): database error!';
}
}
function delteam($id, $zay, $r)
public function delteam($id, $zay, $r)
{
$z = $this->getlist($r, null, $zay);
if ($z[$zay]['level'] > 3 || $z[$zay]['level'] == null) {
return "Ай-ай-ай!";
$this->errorMessage = 'Неизвестная ошибка.';
}
foreach ($z[$zay]['team2'] as $v) {
@ -152,38 +163,52 @@ class zayavka
$teams[] = $v;
}
}
if (mysql_query("UPDATE `users`, `zayavka` SET `users`.`zayavka` = '0', `zayavka`.`team{$team}` = '{$teams}' WHERE `users`.`id` = {$id} AND `zayavka`.`id` = {$zay};")) {
if ($this->errorMessage) {
return $this->errorMessage;
} else {
mysql_query("UPDATE `users`, `zayavka` SET `users`.`zayavka` = '0', `zayavka`.`team{$team}` = '{$teams}' WHERE `users`.`id` = {$id} AND `zayavka`.`id` = {$zay};");
return "Вы отозвали запрос";
} else return 'delteam(): database error!';
}
}
function addzayavka($start, $timeout, $t1c, $t2c, $type, $t1min, $t2min, $t1max, $t2max, $coment, $level, $blood = 0)
public function addzayavka($start, $timeout, $t1c, $t2c, $type, $t1min, $t2min, $t1max, $t2max, $coment, $level, $blood = 0)
{
global $user;
if (!in_array($level, [2, 4, 5])) $level = 4; /*2-физ, 4-группа, 5-хаос*/
if ($level == 2 AND $type != 1 AND $type != 4 AND $type != 6) $type = 1;
if ($level == 4 AND $type != 2 AND $type != 4) $type = 2;
if ($level == 5 AND $type != 3 AND $type != 5) $type = 3;
if (!in_array($start, [1, 3, 5, 10, 15, 30, 60])) $start = 1;
if (!in_array($timeout, [1, 3, 5, 10])) $timeout = 1;
if ($this->user_status($user['id']) != 0) exit();
if (!in_array($level, [2, 4, 5])) {
$level = 4;
} /*2-физ, 4-группа, 5-хаос*/
if ($level == 2 && $type != 1 && $type != 4 && $type != 6) {
$type = 1;
}
if ($level == 4 && $type != 2 && $type != 4) {
$type = 2;
}
if ($level == 5 && $type != 3 && $type != 5) {
$type = 3;
}
if (!in_array($start, [1, 3, 5, 10, 15, 30, 60])) {
$start = 1;
}
if (!in_array($timeout, [1, 3, 5, 10])) {
$timeout = 1;
}
if ($this->user_status($user['id']) != 0) {
exit();
}
if (!$user['klan'] && $t1min == 99) {
return "Вы не состоите в клане.";
$this->errorMessage = "Вы не состоите в клане.";
}
if ($user['hp'] < $user['maxhp'] * 0.33) {
return "Вы слишком ослаблены для боя, восстановитесь.";
$this->errorMessage = "Вы слишком ослаблены для боя, восстановитесь.";
}
if ($this->errorMessage) {
return $this->errorMessage;
} else {
if ($type == 3) {
AddChatSystem('Внимание! Подана заявка на хаотический поединок ({$t1min} - {$t1max}), который начнется через {$start} минут.');
}
$start = time() + $start * 60;
db::c()->query('INSERT INTO `zayavka`
@ -191,34 +216,32 @@ class zayavka
VALUES (?i,?i,?i,?i,?i,?i,"?s","?s",?d,?i,?i,?i,?i,"?s",?i)',
$start, $timeout, $t1c, $t2c, $type, $level, $coment, $user['id'], $t1min, $t2min, $t1max, $t2max, date('H:i'), $blood);
db::c()->query('UPDATE `users` SET `zayavka` = ?i WHERE `id` = ?i', db::c()->getLastInsertId(), $user['id']);
return null;
return 'Заявка подана!';
}
}
function delzayavka($id, $zay, $r, $f = 1)
public function delzayavka($id, $zay, $r, $f = 1)
{
$z = $this->getlist($r, null, $zay);
if ($f != 1) {
if ($z[$zay]['level'] > 3) {
return 'Ай-ай-ай!';
}
}
if (mysql_query("DELETE FROM `zayavka` WHERE `id` = {$zay} AND (`team1` LIKE '{$id};%' OR `team2` LIKE '{$id};%') LIMIT 1")) {
if ($f != 1 && $z[$zay]['level'] > 3) {
return 'Неизвестная ошибка.';
} else {
mysql_query("DELETE FROM `zayavka` WHERE `id` = {$zay} AND (`team1` LIKE '{$id};%' OR `team2` LIKE '{$id};%') LIMIT 1");
if (count($z[$zay]['team1']) > 0) {
foreach ($z[$zay]['team1'] as $k => $v)
foreach ($z[$zay]['team1'] as $k => $v) {
db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i', $v);
}
}
if (count($z[$zay]['team2']) > 0) {
foreach ($z[$zay]['team2'] as $k => $v)
foreach ($z[$zay]['team2'] as $k => $v) {
db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i', $v);
}
}
return 'Вы отозвали заявку.';
} else return 'delzayavka(): database error!';
}
}
function showfiz($row)
public function showfiz($row)
{
global $user;
$rr = "<input type=\"radio\" " . ((in_array($user['id'], $row['team1']) || in_array($user['id'], $row['team2']) || $row['team2']) ? "disabled " : "") . " name=\"gocombat\" value=\"{$row['id']}\" /><font class=date>{$row['podan']}</font> ";
@ -246,7 +269,7 @@ class zayavka
return $rr;
}
function showgroup($row)
public function showgroup($row)
{
if ($row['t1min'] == 99) {
$range1 = "<i>клан</i>";
@ -308,7 +331,7 @@ class zayavka
return $rr;
}
function showhaos($row)
public function showhaos($row)
{
global $user;
$rr = "<input type=\"radio\" " . ((in_array($user['id'], $row['team1']) || in_array($user['id'], $row['team2'])) ? "disabled " : "") . " name=\"gocombat\" value=\"{$row['id']}\" /><font class=\"date\">{$row['podan']}</font> (";
@ -367,7 +390,7 @@ class zayavka
return $rr;
}
function user_status($id)
public function user_status($id)
{
$r = db::c()->query('SELECT `team1`,`team2` FROM `zayavka`, `users` WHERE `users`.`id` = ?i AND `zayavka`.`id` = `users`.`zayavka`', $id)->fetch_assoc();
$t1 = $this->fteam($r['team1']);
@ -381,7 +404,7 @@ class zayavka
}
}
function battlestart($id, $zay, $r)
public function battlestart($id, $zay, $r)
{
global $user;
$z = $this->getlist($r, null, $zay);
@ -470,7 +493,7 @@ class zayavka
}
}
while (count($cost) > 0) {
while (!empty($cost)) {
if ($power1 <= $power2) {
$tmp = array_shift($cost);
$power1 += $tmp[1];
@ -509,7 +532,9 @@ class zayavka
die();
}
if (!in_array($z['timeout'], [3, 4, 5, 7, 10])) $z['timeout'] = 3;
if (!in_array($z['timeout'], [3, 4, 5, 7, 10])) {
$z['timeout'] = 3;
}
if (count($teams) > 1) {
if ($z['type'] == 1 || $z['type'] == 4) {
@ -576,7 +601,7 @@ VALUES ("?s","?s",?i,?i,?i,"?s","?s",?i,?i,?i,?i)',
}
}
$zay = new zayavka;
$zay = new Zayavka;
header("Cache-Control: no-cache");
if (!empty($_POST['open'])) {
$f = fopen("/tmp/zayavka/" . $user['id'] . ".txt", "w+");
@ -609,7 +634,9 @@ if (!empty($_POST['open'])) {
<TABLE width=100% cellspacing=1 cellpadding=1>
<TR>
<TD colspan=5>
<?php if (!empty($level)) {echo Nick::id($user)->battle();} ?>
<?php if (!empty($level)) {
echo Nick::id($user)->battle();
} ?>
</TD>
<TD colspan=4 align=right>
<INPUT TYPE=button value="Вернуться" onclick="location.href='main.php?top=<?= mt_rand() ?>';">
@ -629,8 +656,12 @@ if (!empty($_POST['open'])) {
<TD>
<?php
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
if ($user['room'] != 1 AND $get != 'current') die(err('В этой комнате невозможно подавать заявки!'));
if (!$get) echo '<p style="text-align: center; font-weight: bold; margin-top: 16px;">Выберите раздел</p>';
if ($user->room != 1 && $get != 'current') {
exit('В этой комнате невозможно подавать заявки!');
}
if (!$get) {
echo '<p style="text-align: center; font-weight: bold; margin-top: 16px;">Выберите раздел</p>';
}
if ($get == 'fiz') {
echo "<b style='color: #f80000;'>";
@ -657,7 +688,7 @@ if (!empty($_POST['open'])) {
echo $zay->delteam($z[$user['zayavka']]['team2'][0], $user['zayavka'], 2);
AddChatSystem('Внимание!' . Nick::id($user['id'])->short() . ' отказался от поединка.');
}
if (!empty($_POST['confirm2']) AND empty($user['zayavka'])) {
if (!empty($_POST['confirm2']) && empty($user['zayavka'])) {
$z = $zay->getlist(2, null, $_REQUEST['gocombat']);
$toper = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $z[$_REQUEST['gocombat']]['team1'][0])->fetch_assoc();
if ($user['klan'] != $toper['klan'] || $user['klan'] == '') {
@ -740,16 +771,16 @@ if (!empty($_POST['open'])) {
}
}
}
if ($zay->user_status($user['id']) == 2) {
if ($z[$user['zayavka']]['level'] == 2)
if ($zay->user_status($user['id']) == 2 && $z[$user['zayavka']]['level'] == 2) {
echo "Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'>";
}
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user['level'] . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '<tr><td><INPUT TYPE=hidden name=level value=fiz><INPUT TYPE=submit value="Принять вызов" NAME=confirm2><BR>';
if ($z = $zay->getlist(2, $_SESSION['view']))
if ($z = $zay->getlist(2, $_SESSION['view'])) {
foreach ($z as $k => $v) {
echo $zay->showfiz($v);
}
}
echo '<INPUT TYPE=submit value="Принять вызов" NAME=confirm2></TD></TR></TABLE>';
}
@ -782,7 +813,8 @@ if (!empty($_POST['open'])) {
<option value=10>10 мин.</option>
</select>
<BR><BR>
Ваша команда <INPUT TYPE=text NAME=nlogin1 size=3 maxlength=2 placeholder="Количество союзников"> бойцов<BR>
Ваша команда <INPUT TYPE=text NAME=nlogin1 size=3 maxlength=2
placeholder="Количество союзников"> бойцов<BR>
Уровни союзников &nbsp;&nbsp;<SELECT NAME=levellogin1>
<option value=0>любой
<option value=1>только моего и ниже
@ -829,7 +861,7 @@ if (!empty($_POST['open'])) {
<?php }
if (!empty($_POST['goconfirm']) AND empty($user['zayavka'])) {
if (!empty($_POST['goconfirm']) && empty($user['zayavka'])) {
echo '<TABLE width=100%><TR><TD>';
$z = $zay->getlist(4, null, $_POST['gocombat']);
echo "<B>Ожидаем начала группового боя...</B><BR>Бой начнется через: " . round(($z[$_POST['gocombat']]['start'] - time()) / 60, 1) . " мин.";
@ -843,19 +875,25 @@ if (!empty($_POST['goconfirm']) AND empty($user['zayavka'])) {
</TD></TR><TR>
<TD align=center>';
foreach ($z[$_POST['gocombat']]['team1'] as $k => $v) {
if ($k != 0) $rr .= "<BR>";
if ($k != 0) {
$rr .= "<BR>";
}
echo Nick::id($v)->full(1);
}
echo '</TD><TD align=center>';
foreach ($z[$_POST['gocombat']]['team2'] as $k => $v) {
if ($k != 0) $rr .= "<BR>";
if ($k != 0) {
$rr .= "<BR>";
}
echo Nick::id($v)->full(1);
}
echo '</TD></TR><TR>';
if ($z[$_POST['gocombat']]['team1'][0] != 1000 && $z[$_POST['gocombat']]['team1'][0] != 1001)
if ($z[$_POST['gocombat']]['team1'][0] != 1000 && $z[$_POST['gocombat']]['team1'][0] != 1001) {
echo '<TD align=center><INPUT TYPE=submit name=confirm1 value="Я за этих!"></TD>';
else echo '<TD align=center>Силы Хаоса</TD>';
} else {
echo '<TD align=center>Силы Хаоса</TD>';
}
echo '<TD align=center><INPUT TYPE=submit name=confirm2 value="Я за этих!"></TD></TR></TABLE><INPUT TYPE=hidden name=gocombat value="' . $_POST['gocombat'] . '"><INPUT TYPE=hidden name=level value=group>';
die();
@ -863,16 +901,16 @@ if (!empty($_POST['goconfirm']) AND empty($user['zayavka'])) {
echo "<b style='color: #f80000;'>";
if (!empty($_POST['confirm1']) AND !empty($_POST['gocombat']) AND empty($user['zayavka'])) {
if (!empty($_POST['confirm1']) && !empty($_POST['gocombat']) && empty($user['zayavka'])) {
echo $zay->addteam(1, 4);
}
if (!empty($_POST['confirm2']) AND $_POST['gocombat'] AND empty($user['zayavka'])) {
if (!empty($_POST['confirm2']) && $_POST['gocombat'] && empty($user['zayavka'])) {
echo $zay->addteam(2, 4);
}
if (!empty($_POST['open']) AND empty($user['zayavka'])) {
//print_r($_REQUEST);
if (!empty($_POST['open']) && empty($user['zayavka'])) {
switch ($_POST['levellogin1']) {
default:
case 0 : //любой
$min1 = 0;
$max1 = 21;
@ -907,6 +945,7 @@ if (!empty($_POST['open']) AND empty($user['zayavka'])) {
break;
}
switch ($_POST['levellogin2']) {
default:
case 0 : //любой
$min1 = 0;
$max1 = 21;
@ -940,8 +979,12 @@ if (!empty($_POST['open']) AND empty($user['zayavka'])) {
$max1 = 99;
break;
}
if ($min1 < 0) $min1 = 0;
if ($max1 < 0) $max1 = 0;
if ($min1 < 0) {
$min1 = 0;
}
if ($max1 < 0) {
$max1 = 0;
}
if ($_POST['k']) {
$_POST['k'] = 4;
} else {
@ -952,37 +995,33 @@ if (!empty($_POST['open']) AND empty($user['zayavka'])) {
} else {
$blood = 0;
}
if ($_POST['nlogin1'] == 1 && $_POST['nlogin2'] == 1) {
echo "Не надо превращать групповой бой в физический поединок";
} else {
echo $zay->addzayavka($_POST['startime'] / 60, $_POST['timeout'], $_POST['nlogin1'], $_POST['nlogin2'], $_POST['k'], $min1, $min2, $max1, $max2, $_POST['cmt'], 4, $blood);
}
}
/////////////////////////////////
echo "</b><INPUT TYPE=hidden name=level value=group>";
echo '</TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user['level'] . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '<tr><td width=85%>';
echo '<BR><INPUT TYPE=submit value="Принять участие" NAME=goconfirm><BR>';
if ($z = $zay->getlist(4, $_SESSION['view']))
if ($z = $zay->getlist(4, $_SESSION['view'])) {
foreach ($z as $k => $v) {
if ((($z[$k]['start'] - time()) < 0) || (($z[$k]['t1c'] == count($z[$k]['team1'])) && ($z[$k]['t2c'] == count($z[$k]['team2'])))) {
$zay->battlestart("CHAOS", $k, 4);
}
echo $zay->showgroup($v);
}
}
echo '<INPUT TYPE=submit value="Принять участие" NAME=goconfirm></td></tr></table>';
}
if ($get == 'haos') {
if ($user['level'] < 2) {
die("<BR><BR><BR><CENTER><B>Хаотичные бои доступны с 2 уровня.</b></CENTER>");
}
if (!empty($_POST['open']) AND empty($user['zayavka'])) {
if (!empty($_POST['open']) && empty($user['zayavka'])) {
switch ($_POST['levellogin1']) {
default:
case 0 :
$min1 = 1;
$max1 = 21;
@ -996,7 +1035,6 @@ if ($get == 'haos') {
$max1 = (int)$user['level'] + 1;
break;
}
//$_POST['k'] = 3;
$blood = 0;
if ($_POST['travma']) {
@ -1014,27 +1052,31 @@ if ($get == 'haos') {
}
if ($zay->user_status($user['id']) != 0) {
$z = $zay->getlist(5, null, $user['zayavka']);
if ($z[$user['zayavka']]['level'] == 5)
if ($z[$user['zayavka']]['level'] == 5) {
echo "<B>Ожидаем начала группового боя...</B><BR>Бой начнется через: " . round(($z[$user['zayavka']]['start'] - time()) / 60, 1) . " мин.";
}
}
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user['level'] . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '<tr><td width=85%><INPUT TYPE=hidden name=level value=haos><INPUT TYPE=submit value="Принять участие" NAME=confirm2><BR>';
if ($z = $zay->getlist(5, $_SESSION['view']))
if ($z = $zay->getlist(5, $_SESSION['view'])) {
foreach ($z as $k => $v) {
if (($z[$k]['start'] - time()) < 0) {
$zay->battlestart("CHAOS", $k, 5);
}
echo $zay->showhaos($v);
}
}
echo '<INPUT TYPE=submit value="Принять участие" NAME=confirm2></TD></TR></TABLE>';
//print_r($_POST);
}
if ($get == 'current') {
$t1 = floor(time() - 900);
$data = db::c()->query('SELECT * FROM `battle` WHERE `win` = 3 AND `to1` > ?i AND `to2` > ?i ORDER BY `id` ASC', $t1, $t1);
if (empty($data->getNumRows())) echo 'Надо же! Ни одного поединка!';
else while ($row = $data->fetch_assoc()) {
if (empty($data->getNumRows())) {
echo 'Надо же! Ни одного поединка!';
}
else {
while ($row = $data->fetch_assoc()) {
echo "<span class=date>{$row['date']}</span>";
$z = explode(";", $row['t1']);
foreach ($z as $k => $v) {
@ -1054,6 +1096,7 @@ if ($get == 'current') {
echo "<img src='i/fighttype{$row['type']}.gif'> <a href='logs.php?log={$row['id']}' target=_blank>»»</a><br />";
}
}
}
db::c()->query('UNLOCK TABLES');