refactor, remove mysql_query, errors
This commit is contained in:
parent
e2daf51a5f
commit
4e9d2deed4
@ -19,6 +19,7 @@ if ($_GET['r'] == 3 || $_GET['r'] == 8 || !isset($_GET['r'])) {
|
||||
$_GET['r'] = 2;
|
||||
}
|
||||
|
||||
/** @var User $u */
|
||||
if ($u->info['inTurnir'] > 0 && $u->info['inUser'] == 0 && $u->info['room'] == 318) {
|
||||
die('<script>location="main.php";</script>');
|
||||
}
|
||||
@ -30,6 +31,9 @@ $js_5356 = sprintf(
|
||||
0 + $u->stats['mpNow'], 0 + $u->stats['mpAll'], time() - $u->info['regHP'], time() - $u->info['regMP'],
|
||||
0 + $u->rgd[0], 0 + $u->rgd[1]
|
||||
);
|
||||
|
||||
$code ??= PassGen::intCode();
|
||||
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery.js"></script>
|
||||
<script>
|
||||
@ -77,18 +81,19 @@ $js_5356 = sprintf(
|
||||
<tr>
|
||||
<td class="firsttd m"> <b>Бои:</b> </td>
|
||||
<?php if ($u->info['level'] == 0): ?>
|
||||
<td class="<?= $_GET['r'] == 1 ? 's' : 'm' ?>"><a href="main.php?zayvka=1&r=1&rnd=<?= $code ?>">Новички</a>
|
||||
<td class="<?= $_GET['r'] == 1 ? 's' : 'm' ?>"><a href="/main.php?zayvka=1&r=1&rnd=<?= $code ?>">Новички</a>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td class="<?= $_GET['r'] == 2 ? 's' : 'm' ?>"><a href="main.php?zayvka=1&r=2&rnd=<?= $code ?>">Турниры</a>
|
||||
<td class="<?= $_GET['r'] == 2 ? 's' : 'm' ?>"><a href="/main.php?zayvka=1&r=2&rnd=<?= $code ?>">Турниры</a>
|
||||
</td>
|
||||
<td class="<?= $_GET['r'] == 4 ? 's' : 'm' ?>"><a
|
||||
href="main.php?zayvka=1&r=4&rnd=<?= $code ?>">Групповые</a></td>
|
||||
href="main.php?zayvka=1&r=4&rnd=<?= $code ?>">Групповые</a></td>
|
||||
<td class="<?= $_GET['r'] == 5 ? 's' : 'm' ?>"><a
|
||||
href="main.php?zayvka=1&r=5&rnd=<?= $code ?>">Хаотичные</a></td>
|
||||
href="main.php?zayvka=1&r=5&rnd=<?= $code ?>">Хаотичные</a></td>
|
||||
<?php endif; ?>
|
||||
<td class="<?= $_GET['r'] == 6 ? 's' : 'm' ?>"><a href="main.php?zayvka=1&r=6&rnd=<?= $code ?>">Текущие</a></td>
|
||||
<td class="<?= $_GET['r'] == 7 ? 's' : 'm' ?>"><a href="main.php?zayvka=1&r=7&rnd=<?= $code ?>">Завершенные</a>
|
||||
<td class="<?= $_GET['r'] == 6 ? 's' : 'm' ?>"><a href="/main.php?zayvka=1&r=6&rnd=<?= $code ?>">Текущие</a>
|
||||
</td>
|
||||
<td class="<?= $_GET['r'] == 7 ? 's' : 'm' ?>"><a href="/main.php?zayvka=1&r=7&rnd=<?= $code ?>">Завершенные</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -123,38 +128,28 @@ $js_5356 = sprintf(
|
||||
}
|
||||
|
||||
if ($u->info['zv'] != 0) {
|
||||
$zi = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT * FROM `zayvki` WHERE `id`=' . $u->info['zv'] . ' AND `start` = 0 AND `cancel` = 0 AND
|
||||
(`time` > unix_timestamp() - 60 * 60 * 2 OR `razdel` > 3)'
|
||||
)
|
||||
);
|
||||
$zi = Db::getRow('select id, razdel from zayvki where id = ? and start = 0 and cancel = 0 and time > unix_timestamp() - 60 * 60 * 2 or razdel > 3', [$u->info['zv']]);
|
||||
if (!isset($zi['id'])) {
|
||||
$zi = false;
|
||||
$u->info['zv'] = 0;
|
||||
mysql_query('UPDATE `stats` SET `zv` = 0 WHERE `id` = ' . $u->info['id']);
|
||||
Db::sql('update stats set zv = 0 where id = ?', [$u->info['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($u->info['battle'] == 0) {
|
||||
if (isset($_POST['groupClick']) && !isset($zi['id'])) {
|
||||
$zg = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT * FROM `zayvki` WHERE `id` = ' . (int)$_POST['groupClick'] . ' AND `cancel` = 0 AND
|
||||
`btl_id` = 0 AND `razdel` = 4 AND `start` = 0 AND `time` > unix_timestamp() - 60 * 60 * 2')
|
||||
);
|
||||
$zg = Db::getRow('select * from zayvki where id = ? and start = 0 and cancel = 0 and time > unix_timestamp() - 60 * 60 * 2 and btl_id = 0 and razdel = 4', [(int)$_POST['groupClick']]);
|
||||
if (!isset($zg['id'])) {
|
||||
echo '<center><br /><br />Заявка на групповой бой не найдена.</center>';
|
||||
echo '<div style="text-align: center;"><br><br>Заявка на групповой бой не найдена.</div>';
|
||||
} else {
|
||||
$tm_start = floor(($zg['time'] + $zg['time_start'] - time()) / 6) / 10;
|
||||
$tm_start = $zv->rzv($tm_start);
|
||||
$tm1 = '';
|
||||
$tm2 = '';
|
||||
$users = mysql_query(
|
||||
'SELECT `u`.`id`, `u`.`login`, `u`.`level`, `u`.`align`, `u`.`clan`, `u`.`admin`, `st`.`team` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `u`.`id` = `st`.`id` WHERE `st`.`zv` = "' . $zg['id'] . '"'
|
||||
);
|
||||
while ($s = mysql_fetch_array($users)) {
|
||||
${'tm' . $s['team']} .= '<b>' . $s['login'] . '</b> [' . $s['level'] . ']<a href="info/' . $s['id'] . '" target="_blank"><img src="//img.new-combats.tech/i/inf_capitalcity.gif" title="Инф. о ' . $s['login'] . '" /></a><br />';
|
||||
$tm3 = '';
|
||||
$users = Db::getRow('select users.id, login, level, align, clan, admin, team from users left join stats on users.id = stats.id where zv = ?', [$zg['id']]);
|
||||
foreach ($users as $user) {
|
||||
${'tm' . $user['team']} .= '<b>' . $user['login'] . '</b> [' . $user['level'] . ']<a href="info/' . $user['id'] . '" target="_blank"><img src="//' . Config::get('img') . '/i/inf_capitalcity.gif" title="Инф. о ' . $user['login'] . '" alt="inf"></a><br>';
|
||||
}
|
||||
if (empty($tm1)) {
|
||||
$tm1 = 'группа пока не набрана';
|
||||
@ -186,7 +181,8 @@ $js_5356 = sprintf(
|
||||
$sv3 = $zg['tm2max'] - $sv3;
|
||||
}
|
||||
|
||||
?></div>
|
||||
?>
|
||||
</div>
|
||||
<table style="margin-top:2px;" width="100%">
|
||||
<tr>
|
||||
<td> Бой начнется через <?= $tm_start; ?> мин.</td>
|
||||
@ -262,7 +258,7 @@ $js_5356 = sprintf(
|
||||
}
|
||||
} elseif (isset($_GET['cancelzv']) && !isset($_POST['add_new_zv'])) {
|
||||
$zv->cancelzv();
|
||||
} elseif (isset($_GET['startBattle']) && isset($zi['id']) && ($zi['razdel'] >= 1 || $zi['razdel'] <= 3)) {
|
||||
} elseif (isset($_GET['startBattle']) && isset($zi['id']) && ($zi['razdel'] >= 1 && $zi['razdel'] <= 3)) {
|
||||
$zv->startBattle($zi['id']);
|
||||
}
|
||||
}
|
||||
@ -273,12 +269,12 @@ if (isset($_POST['btl_go'])) {
|
||||
$zv->go($_GET['btl_go']);
|
||||
}
|
||||
|
||||
if ($zv->error != '') {
|
||||
echo '<b style="color: red">' . $zv->error . '</b><br />';
|
||||
if ($zv->error) {
|
||||
echo '<b style="color: red">' . $zv->error . '</b><br>';
|
||||
}
|
||||
|
||||
if ($zv->test_s != '') {
|
||||
echo '<b style="color: red">' . $zv->test_s . '</b><br />';
|
||||
if ($zv->test_s) {
|
||||
echo '<b style="color: red">' . $zv->test_s . '</b><br>';
|
||||
}
|
||||
?>
|
||||
<table style="padding:2px;" width="100%" border="0" cellspacing="0" cellpadding="2">
|
||||
|
Loading…
Reference in New Issue
Block a user