battles/logs.php

125 lines
5.8 KiB
PHP
Raw Permalink Normal View History

<?php
$_GET['page'] = $_GET['page'] ?? 0;
$_REQUEST['log'] = $_REQUEST['log'] ?? 0;
require_once "functions.php";
$data = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id` = '" . $_REQUEST['log'] . "'"));
$log = file("backup/logs/battle" . $_REQUEST['log'] . ".txt");
\Battles\Template::header('Лог поединка');
2018-01-28 16:40:49 +00:00
?>
<H3>Лог поединка</H3>
<FORM>
<INPUT TYPE=hidden name=page value="<?= $_GET['page'] ?>">
<INPUT TYPE=hidden name=log value="<?= $_REQUEST['log'] ?>">
<?php
if ($_GET['stat'] != '1') {
echo "<form><input type=hidden name='log' value='" . (int)$_GET['log'] . "'><input type=hidden name='stat' value='1'><input type=submit value='Статистика боя'></form>";
2018-01-28 16:40:49 +00:00
if ($data['type'] == 10) {
$rr = "<IMG SRC=\"i/fighttype6.gif\" WIDTH=20 HEIGHT=20 ALT=\"Кровавый поединок\"> (поединок в башне смерти)";
} elseif ($data['blood'] && ($data['type'] == 5 || $data['type'] == 4)) {
$rr = "<IMG SRC=\"i/fighttype5.gif\" WIDTH=20 HEIGHT=20 ALT=\"кулачный бой\"><IMG SRC=\"i/fighttype6.gif\" WIDTH=20 HEIGHT=20 ALT=\"Кровавый поединок\"> (кровавый кулачный поединок)";
} elseif ($data['blood'] && ($data['type'] == 2 || $data['type'] == 3 || $data['type'] == 6)) {
$rr = "<IMG SRC=\"i/fighttype6.gif\" WIDTH=20 HEIGHT=20 ALT=\"Кровавый поединок\"> (кровавый поединок)";
} elseif ($data['type'] == 5 || $data['type'] == 4) {
$rr = "<IMG SRC=\"i/fighttype4.gif\" WIDTH=20 HEIGHT=20 ALT=\"кулачный бой\"> (кулачный поединок)";
} elseif ($data['type'] == 3 || $data['type'] == 2) {
$rr = "<IMG SRC=\"i/fighttype3.gif\" WIDTH=20 HEIGHT=20 ALT=\"групповой бой\"> (групповой поединок)";
} elseif ($data['type'] == 1) {
$rr = "<IMG SRC=\"i/fighttype1.gif\" WIDTH=20 HEIGHT=20 ALT=\"физический бой\"> (физический поединок)";
}
2018-01-28 16:40:49 +00:00
$t1 = explode(";", $data['t1']);
$t2 = explode(";", $data['t2']);
2018-01-28 16:40:49 +00:00
if ($data['win'] == 3) {
$battle = unserialize($data['teams']);
2018-01-28 16:40:49 +00:00
foreach ($t1 as $k => $v) {
if (in_array($v, array_keys($battle))) {
++$i;
if ($i > 1) {
$cc = ', ';
} else {
$cc = '';
}
$ffs .= $cc . Nick::id($v)->battleShort('B1');
}
}
2018-01-28 16:40:49 +00:00
$i = 0;
2018-01-28 16:40:49 +00:00
$ffs .= ' <i>против</i> ';
foreach ($t2 as $k => $v) {
if (in_array($v, array_keys($battle))) {
++$i;
if ($i > 1) {
$cc = ', ';
} else {
$cc = '';
}
$ffs .= $cc . Nick::id($v)->battleShort('B1');
}
}
$i = 0;
}
2018-01-28 16:40:49 +00:00
$countall = count($t1) + count($t2);
if ($countall > 70) {
echo "<h3>Эпическая битва!</h3>";
} elseif ($countall > 50) {
echo "<h3>Эпохальная битва!</h3>";
} elseif ($countall > 30) {
echo "<h3>Великая битва!</h3>";
}
2018-01-28 16:40:49 +00:00
echo "<form method=\"GET\" action=\"logs.php\"><input type=\"hidden\" name=\"page\" value=\"" . $_GET['page'] . "\" /><input type=\"hidden\" name=\"log\" value=\"" . $_REQUEST['log'] . "\" /><input type=\"submit\" name=\"analiz2\" value=\"Обновить\" /> </form>Тип боя: ";
echo $rr;
echo 'Страницы:';
2018-01-28 16:40:49 +00:00
$log = explode("<BR>", $log[0]);
$all = count($log) - 1;
$pgs = $all / 50;
for ($i = 0; $i <= $pgs; ++$i) {
if ($_GET['page'] == $i) {
echo ' <a href="?log=', $_GET['log'], '&page=', $i, '"><font color=#8f0000>', ($i + 1), '</font></a> ';
} else {
echo ' <a href="?log=', $_GET['log'], '&page=', $i, '">', ($i + 1), '</a> ';
}
}
echo '<hr>';
2018-01-28 16:40:49 +00:00
$start = 50 * $_GET['page'];
if (50 * $_GET['page'] + 50 <= $all) {
$stop = 50 * $_GET['page'] + 50;
} else {
$stop = 50 * $_GET['page'] + ($all - 50 * $_GET['page']) - 1;
}
for ($i = $start; $i <= $stop; $i++) {
echo $log[$i] . "<BR>";
}
echo '<hr>';
echo "<center>" . $ffs . "</center><HR>";
?>
<FORM>
<INPUT TYPE=hidden name=page value="<?= $_GET['page'] ?>"/>
<INPUT TYPE=hidden name=log value="<?= $_REQUEST['log'] ?>"/>
<INPUT TYPE=submit name=analiz2 value="Обновить">
</form>
&nbsp;
Страницы:
<?php
for ($i = 0; $i <= $pgs; ++$i) {
if ($_GET['page'] == $i) {
echo ' <a href="?log=', $_GET['log'], '&page=', $i, '"><font color=#8f0000>', ($i + 1), '</font></a> ';
} else {
echo ' <a href="?log=', $_GET['log'], '&page=', $i, '">', ($i + 1), '</a> ';
}
}
echo "<br><br><form method=get><input type=hidden name='log' value='" . (int)$_GET['log'] . "'><input type=hidden name='stat' value='1'><input type=submit value='Статистика боя'></form>";
} else {
echo "<form method=get><input type=hidden name='log' value='" . (int)$_GET['log'] . "'><input type=submit value='Лог боя'></form>";
echo "Статистика временно недоступна ...<br />";
echo "<br><form method=get><input type=hidden name='log' value='" . (int)$_GET['log'] . "'><input type=submit value='Лог боя'></form>";
}
?>
</FORM>