<?php
const GAME = true;
include('_incl_data/__config.php');
include('_incl_data/class/__db_connect.php');
$u = User::start();
?>

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="windows-1251">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
    <meta http-equiv=Cache-Control Content=no-cache>
    <meta http-equiv=PRAGMA content=NO-CACHE>
    <link href="https://img.new-combats.com/css/main.css" rel="stylesheet" type="text/css">
    <title>Ìîíèòîð ïîåäèíêîâ</title>
</head>
<body style="padding-top:0px; margin-top:7px; height:100%; background-color:#dedede;">
<script type="text/javascript" src="js/jquery.js"></script>
<center><strong>Ïðîñìàòðèâàåò ïåðñîíàæ: </strong><?= $u->microLogin($u->info['id'], 1) ?></center>
<hr>
<INPUT style="float:right" class="btn btn-success" TYPE=button value="Îáíîâèòü" style='width: 100px'
       onClick="location.href='monitoring'"></div>
<h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Çàÿâêè
    íà õàîòè÷åñêèå ïîåäèíêè</h3>
<?php
$html = '';
$i = 0;
$sp = mysql_query('SELECT * FROM `zayvki` WHERE `razdel` = 5 AND `cancel` = 0 AND `btl_id` = 0 ORDER BY `id` ASC');
while ($pl = mysql_fetch_array($sp)) {
    $i++;
    //
    $users = '';
    //
    $spu = mysql_query('SELECT `id` FROM `stats` WHERE `zv` = "' . $pl['id'] . '"');
    while ($plu = mysql_fetch_array($spu)) {
        $users .= $u->microLogin($plu['id'], 1) . ',';
    }
    //
    if ($users == '') {
        $users = '<i><font color=grey><small>Ïîëå áîÿ æäåò ñâîèõ ãåðîåâ!</small></font></i>';
    } else {
        $users = rtrim($users, ',');
    }
    //
    $html .= $i . '. <span class="date">' . date('H:i', $pl['time']) . '</span> ';
    $html .= ' <img title="' . $u->city_name[$pl['city']] . '" src="https://img.new-combats.com/i/city_ico/' . $pl['city'] . '.gif">';
    $html .= ' (' . $users . ') (' . $pl['min_lvl_1'] . '-' . $pl['max_lvl_1'] . ') Òèï áîÿ: <img src="https://img.new-combats.com/i/fighttype' . $pl['type'] . '.gif"> ';
    if ($pl['noinc'] > 0) {
        $html .= '<img src="https://img.new-combats.com/closefight.gif" title="Â ïîåäèíîê íåëüçÿ âìåøàòüñÿ">';
    }
    if ($pl['fastfight'] > 0) {
        $html .= '<img src="https://img.new-combats.com/fastfight.gif" title="Äëÿ ñòàðòà ïîåäèíêà òðåáóåòñÿ ìèíèìóì äâîå ó÷àñòíèêîâ">';
    }
    if ($pl['arand'] > 0) {
        $html .= '<img src="https://img.new-combats.com/arand.gif" title="Êîìàíäû äåëÿòñÿ íà äâå ðàâíûå êîìàíäû (ðàâíûå ïî êîëè÷åñòâó, íî íå ïî ìîùíîñòè)">';
    }
    $html .= '<font color="grey">Áîé íà÷íåòñÿ ÷åðåç <b>' . $u->timeOut(
            $pl['time'] + $pl['time_start'] - time()
        ) . '</b>, òàéìàóò ' . $u->timeOut($pl['timeout']) . '</font>';
    if ($pl['priz'] > 0) {
        $html .= '<a href="https://new-combats.com/n/567/" target="_blank"><span style="color:#e65700;" title="Ó÷àñòíèêè ïîëó÷àò ïî 5-òü Ðåëèêâèé Àíãåëà,âíåçàâèñèìîñòè îò ïîáåäû èëè ïîðàæåíèÿ,à òàê æå ïîáåäèòåëè èìåþò 5% øàíñ íà ïîëó÷åíèå Æåòîíà Óñïåõà "><b>(Ãåðîè÷åñêîå Ñðàæåíèå)</b></span></a></font></i>';
    }
    $html .= '<br>';
}
if ($html == '') {
    $html = '<center>(Ðàçäåë ïóñò)</center>';
}
echo $html;
$html = '';
?>
<h3>Òåêóùèå áîè</h3>
<?php
$i = 0;
$sp = mysql_query('SELECT * FROM `battle` WHERE `team_win` = -1');
while ($pl = mysql_fetch_array($sp)) {
    //
    $users = '';
    $usersa = [];
    $userst = [];
    //
    $spu = mysql_query(
        'SELECT `a`.`id`,`b`.`team` FROM `users` AS `a` LEFT JOIN `stats` AS `b` ON `a`.`id` = `b`.`id` WHERE `a`.`battle` = "' . $pl['id'] . '"'
    );
    while ($plu = mysql_fetch_array($spu)) {
        if (!isset($usersa[$plu['team']])) {
            $userst[] = $plu['team'];
        }
        $usersa[$plu['team']] .= $u->microLogin($plu['id'], 1) . ',';
    }
    //
    if (count($usersa) > 0) {
        $j = 0;
        while ($j < count($userst)) {
            if ($users != '') {
                $users .= ' &nbsp;<b><font color=red><small>ïðîòèâ</small></font></b>&nbsp; ';
            }
            $users .= $usersa[$userst[$j]];
            $users = rtrim($users, ',');
            $j++;
        }
        //
        $i++;
        //

        $html .= $i . '. <span class="date">' . date('d.m.Y H:i', $pl['time_start']) . '</span> ';
        $html .= ' <img title="' . $u->city_name[$pl['city']] . '" src="https://img.new-combats.com/i/city_ico/' . $pl['city'] . '.gif">';
        $html .= ' (' . $users . ') Òèï áîÿ: <img src="https://img.new-combats.com/i/fighttype' . $pl['type'] . '.gif"> ';
        if ($pl['noinc'] > 0) {
            $html .= '<img src="https://img.new-combats.com/closefight.gif" title="Â ïîåäèíîê íåëüçÿ âìåøàòüñÿ">';
        }
        if ($pl['fastfight'] > 0) {
            $html .= '<img src="https://img.new-combats.com/fastfight.gif" title="Äëÿ ñòàðòà ïîåäèíêà òðåáóåòñÿ ìèíèìóì äâîå ó÷àñòíèêîâ">';
        }
        if ($pl['arand'] > 0) {
            $html .= '<img src="https://img.new-combats.com/arand.gif" title="Êîìàíäû äåëÿòñÿ íà äâå ðàâíûå êîìàíäû (ðàâíûå ïî êîëè÷åñòâó, íî íå ïî ìîùíîñòè)">';
        }
        $html .= '<font color="grey">, òàéìàóò ' . $u->timeOut($pl['timeout']) . '</font>';
        if ($pl['priz'] > 0) {
            $html .= '<a href="https://new-combats.com/n/567/" target="_blank"><span style="color:#e65700;" title="Ó÷àñòíèêè ïîëó÷àþò ïî 5-òü Ðåëèêâèé Àíãåëà, à òàê æå, òà ñòîðîíà êîòîðàÿ ïîáåäèëà ïîëó÷èò 5% øàíñ íà ïîëó÷åíèå äîïîëíèòåëüíî Æåòîíà Óñïåõà "><b>(Ãåðîè÷åñêîå Ñðàæåíèå)</b></span></a></font></i>';
        }
        $html .= ' <a href="/logs.php?log=' . $pl['id'] . '" target="_blank">&raquo;&raquo;</a> ';
        $html .= '<br>';
    }
    //
}
if ($html == '') {
    $html = '<center>(Ðàçäåë ïóñò)</center>';
}
echo $html;
$html = '';
?>
<h3>Áàøíÿ ñìåðòè</h3>
<?php
$sp = mysql_query('SELECT * FROM `bs_turnirs`');
$i = 0;
while ($pl = mysql_fetch_array($sp)) {
    $i++;
    //
    $html .= $i . '. <img title="' . $u->city_name[$pl['city']] . '" src="https://img.new-combats.com/i/city_ico/' . $pl['city'] . '.gif">';
    //
    $html .= ' [' . $pl['level'] . ']';
    if ($pl['status'] == 0) {
        //Îæèäàåì íà÷àëà íîâîãî òóðíèðà
        $html .= ' Íà÷àëî òóðíèðà â "Áàøíå Ñìåðòè" : <span class="date">' . date(
                'd.m.Y H:i', $pl['time_start']
            ) . '</span> (<small> <font color=grey>Íà÷íåòñÿ ÷åðåç <b>' . $u->timeOut(
                $pl['time_start'] - time()
            ) . '</b></font></small>) Ïðèçîâîé ôîíä íà òåêóùèé ìîìåíò: <b>' . round(
                ($pl['money'] / 100 * 85), 2
            ) . '</b> êð. Âñåãî ïîäàíî çàÿâîê: <b>' . $pl['users'] . '</b>';
    } else {
        //Óæå èäåò òóðíèð
        $users = '';
        $spu = mysql_query('SELECT `id` FROM `users` WHERE `inTurnir` = "' . $pl['id'] . '"');
        while ($plu = mysql_fetch_array($spu)) {
            $users .= $u->microLogin($plu['id'], 1) . ',';
        }
        $users = rtrim($users, ',');
        $html .= ' <span title="[' . $pl['status'] . ']">Òóðíèð Áàøíè Ñìåðòè óæå èäåò.</span>';
        $html .= ' Ó÷àñòíèêè: ' . $users . ', Ëîã òóðíèðà: <a href="/towerlog.php?towerid=' . $pl['id'] . '&id=' . $pl['count'] . '" target="_blank">&raquo;&raquo;</a>';
    }
    //
    $html .= '<br>';
    //
}
if ($html == '') {
    $html = '<center>(Ðàçäåë ïóñò)</center>';
}
echo $html;
$html = '';
?>

<h3>Âîéíû êëàíîâ</h3>
<?php
if ($html == '') {
    $html = '<center>(Ðàçäåë ïóñò)</center>';
}
echo $html;
$html = '';
?>

<h3>Èñòîðèÿ Âåëèêèõ ñðàæåíèé</h3>
<?php
if ($html == '') {
    $html = '<center>(Ðàçäåë ïóñò)</center>';
}
echo $html;
$html = '';
?>

<div align="right"><font style="color:#999;" size="1" face="verdana" color="black">
        <hr style="border-color:#CCC;">
        Áîéöîâñêèé Êëóá v2.1 &copy; <?= date('Y') ?>, «www.new-combats.com»™ &nbsp; &nbsp; </font></div>
<br/><br/>

</body>
</html>