<?php

use Core\Config;
use Core\Database;

require_once __DIR__ . DIRECTORY_SEPARATOR . '_incl_data/autoload.php';

Config::init();
Database::init();
$u = User::start();

$url = explode('?', $_SERVER["REQUEST_URI"]);
$url = explode('/', $url[0]);

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="windows-1251"/>
    <title>Рейтинг персонажей браузерной онлайн игры Новый «Бойцовский клуб»</title>
    <meta name="description"
          content="ТОП-лист персонажей в игре БК ? на сегодняшний день. Сильнейшие маги, критоувороты, увороты, силовики, криты и танки на проекте новый «Бойцовский клуб». "/>
    <meta name="viewport" content="width=device-width, initial-scale=0.4, maximum-scale=1.0, user-scalable=yes"/>
    <link rel="stylesheet" type="text/css" href="https://new-combats.com/i/main.css">
    <link href="https://new-combats.com/i/move/design3.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        <!--
        @import url(https://fonts.googleapis.com/css?family=Philosopher&subset=latin,cyrillic);

        body, td {
            font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
            font-size: 12pt;
            color: #000000
        }

        A {
            font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
            font-size: 12pt;
            color: #decdb9;
        }

        a:link {
            color: #333;
            text-decoration: none
        }

        A:visited {
            color: #333;
            text-decoration: none
        }

        A:hover, A:active {
            color: red;
            text-decoration: none;
        }

        body {
            background-color: #000000;
            margin: 0;
            font-family: Tahoma, Arial, Helvetica, sans-serif;
            font-size: 12pt;
            color: #000000;
        }

        .nicname {
            color: #bfa178;
            font-size: 9pt;
            font-weight: bold;
        }

        td.text {
            background-position: right top;
            background-repeat: no-repeat;
        }

        .place {
            color: #cc8e43;
            font-size: 8pt;
            font-weight: bold;
        }

        .nomber {
            color: #7c3e00;
            font-size: 8pt;
            font-weight: bold;
        }

        .green {
            color: #526700;
            font-size: 8pt;
            font-weight: bold;
        }

        .about {
            font-size: 9pt;
        }

        .levels {
            color: #bfa178;
            font-family: Tahoma, Arial, Helvetica, sans-serif;
            font-size: 7pt;
        }

        TD.topbgl {
            background-image: url(https://new-combats.com/new/register/topbgl.jpg);
            background-position: right top
        }

        .style1 {
            color: #4b2500;
            font-weight: bold;
            font-size: 9pt;
        }

        a.lnkstyle1, a.lnkstyle1:link, a.lnkstyle1:visited, a.lnkstyle1:hover, a.lnkstyle1:active {
            color: #4b2500;
            font-weight: bold;
            font-size: 9pt;
        }

        a.lnkstyle2 {
            font-size: 9pt;
            font-weight: bold;
            color: #4b2500;
        }

        a.lnkstyle2:link {
            font-weight: bold;
            color: #4b2500;
            text-decoration: none
        }

        a.lnkstyle2:visited {
            font-weight: bold;
            color: #4b2500;
            text-decoration: none
        }

        a.lnkstyle2:hover, a.lnkstyle2:active {
            font-weight: bold;
            color: #84643e;
            text-decoration: none;
        }

        input {
            font-size: 12px;
        }

        -->
    </style>
    </script>
    <script type="text/javascript">
        function MM_preloadImages() { //v3.0
            var d = document;
            if (d.images) {
                if (!d.MM_p) d.MM_p = new Array();
                var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
                for (i = 0; i < a.length; i++)
                    if (a[i].indexOf("#") != 0) {
                        d.MM_p[j] = new Image;
                        d.MM_p[j++].src = a[i];
                    }
            }
        }

        function MM_swapImgRestore() { //v3.0
            var i, x, a = document.MM_sr;
            for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
        }

        function MM_findObj(n, d) { //v4.01
            var p, i, x;
            if (!d) d = document;
            if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
                d = parent.frames[n.substring(p + 1)].document;
                n = n.substring(0, p);
            }
            if (!(x = d[n]) && d.all) x = d.all[n];
            for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
            for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
            if (!x && d.getElementById) x = d.getElementById(n);
            return x;
        }

        function MM_swapImage() { //v3.0
            var i, j = 0, x, a = MM_swapImage.arguments;
            document.MM_sr = new Array;
            for (i = 0; i < (a.length - 2); i += 3)
                if ((x = MM_findObj(a[i])) != null) {
                    document.MM_sr[j++] = x;
                    if (!x.oSrc) x.oSrc = x.src;
                    x.src = a[i + 2];
                }
        }
    </script>

</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td width="39%" valign="top">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td height="513" class="topbgl">&nbsp;</td>
                </tr>
            </table>
        </td>
        <td width="1%" valign="top" background="https://new-combats.com/new/register/bgl.jpg">
            <div style="width: 67px; height: 108px;"><!-- Тут был флеш-ролик. --></div>
            <img src="https://new-combats.com/new/register/topl.jpg"/></td>
        <td width="20%" valign="top">
            <table width="850" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td><img src="https://new-combats.com/new/register/top.jpg" width="850" height="32"/></td>
                </tr>
                <tr>
                    <td height="1"><img src="https://new-combats.com/new/register/top1_nul.jpg" width="850"
                                        height="65"/></td>
                </tr>
                <tr>
                    <td height="593" align="left" valign="top">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="1" valign="top"
                                    background="https://new-combats.com/new/register/vesch_leftbg.jpg"><img
                                            src="https://new-combats.com/new/register/vesch_left.jpg" width="49"
                                            height="416"/></td>
                                <td height="577" align="center" valign="top" bgcolor="#edd7ae">
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td height="540" align="left" valign="top">

                                                <BODY aLink=#000000 bgColor=#666666 leftMargin=0 link=#000000
                                                      topMargin=0
                                                      vLink=#333333 marginheight="0" marginwidth="0" 0>
                                                <TABLE border=0 cellPadding=0 cellSpacing=0 height="100%" width="100%">
                                                    <TBODY>
                                                    <TR>
                                                        <TD vAlign=top width="15%">

                                                            <!-- Begin of text -->

                                                            <style type="text/css">

                                                                .rating, .rating tr, .rating tr td {
                                                                    font-family: Times New Roman;
                                                                    font-size: 14px;
                                                                    border: 1px solid black;
                                                                    border-collapse: collapse;
                                                                    text-align: center;
                                                                    vertical-align: top;
                                                                }

                                                                .rating {
                                                                    border: 3px solid black;
                                                                    border-collapse: collapse;
                                                                }

                                                                .rating .al {
                                                                    text-align: left;
                                                                }

                                                                .rating .vam {
                                                                    vertical-align: middle;
                                                                }

                                                                .rating .ac {
                                                                    text-align: center;
                                                                }

                                                                .rating .b {
                                                                    font-weight: bold;
                                                                }

                                                                .rating .p {
                                                                    padding: 0px 5px 0px 5px;
                                                                }

                                                                .rating .btop {
                                                                    border-top: 3px solid black;
                                                                    border-collapse: collapse;
                                                                }

                                                                .rating .bright {
                                                                    border-right: 3px solid black;
                                                                    border-collapse: collapse;
                                                                }

                                                                .rating .bleft {
                                                                    border-left: 3px solid black;
                                                                    border-collapse: collapse;
                                                                }

                                                                .rating .bbottom {
                                                                    border-bottom: 3px solid black;
                                                                    border-collapse: collapse;
                                                                }

                                                                .rating .light {
                                                                    background: #F4E7CC;
                                                                }

                                                                .rinfo p {
                                                                    text-align: justify;
                                                                    text-indent: 25px;
                                                                }

                                                                .rinfo p span {
                                                                    color: red;
                                                                    font-weight: bold;
                                                                }

                                                                h2 {
                                                                    text-align: center;
                                                                    font-family: Times New Roman;
                                                                    font-size: 18px;
                                                                    font-weight: bold;
                                                                    margin: 10px auto 5px;
                                                                }

                                                            </style>

                                                            <h2 style=" margin-top: 0;">Рейтинг Персонажей</h2>    <br/>

                                                            <center><a href="/rating_pers">РЕЙТИНГ</a>

                                                                <table width="100%" class="rating"
                                                                       style="margin-top: 5px;">

                                                                    <tr class="b bbottom">
                                                                        <td class="bright p" width=100>
                                                                            Место
                                                                        </td>
                                                                        <td class="bright p al"
                                                                            style='padding-left: 20px;'>
                                                                            Персонаж
                                                                        </td>
                                                                        <td class="bright p" width=100>
                                                                            Рейтинг
                                                                        </td>
                                                                        <td class="p" width=200>
                                                                            <?php if ($url[2] == 'wins') {
                                                                                echo 'Победы';
                                                                            } else {
                                                                                echo 'Опыт';
                                                                            } ?>
                                                                        </td>
                                                                    </tr>

                                                                    <?php
                                                                    $i = 0;
                                                                    $html = '';
                                                                    $bya = '`pos` ASC';
                                                                    if ($url[2] == 'exp') {
                                                                        $bya = '`exp_real` DESC';
                                                                    } elseif ($url[2] == 'wins') {
                                                                        $bya = '`win` DESC';
                                                                    }
                                                                    $sp = mysql_query(
                                                                        'SELECT * FROM `aaa_reting_list` WHERE `date` = ' . date(
                                                                            'dmY'
                                                                        ) . ' ORDER BY '.$bya.' LIMIT 10'
                                                                    );


                                                                    while ($pl = mysql_fetch_array($sp)) {
                                                                        var_dump($pl);
                                                                        //
                                                                        if ($url[2] != 'exp' && $url[2] != 'wins') {
                                                                            $last_post = mysql_fetch_array(
                                                                                mysql_query(
                                                                                    'SELECT `pos` FROM `aaa_reting_list` WHERE `uid` = ' . $pl['uid'] . ' AND `date` != ' . $pl['date'] . ' ORDER BY `id` DESC LIMIT 1'
                                                                                )
                                                                            );
                                                                        }
                                                                        //
                                                                        $i++;
                                                                        $vid = $i;
                                                                        if (isset($last_post['pos']) && $url[2] != 'exp' && $url[2] != 'wins') {
                                                                            $last_post = $last_post['pos'];
                                                                            if ($last_post < $pl['pos']) {
                                                                                $vid = '<img src="https://img.new-combats.com/down_red.png" height="16"> <b>' . $pl['pos'] . '</b> <sup style=\'color:red;\'>-' . ($pl['pos'] - $last_post) . '</sup>';
                                                                            } elseif ($last_post > $pl['pos']) {
                                                                                $vid = '<img src="https://img.new-combats.com/up_green.png" height="16"> <b>' . $pl['pos'] . '</b> <sup style=\'color:green;\'>+' . ($last_post - $pl['pos']) . '</sup>';
                                                                            }
                                                                        }
                                                                        //
                                                                        $usr = mysql_fetch_array(
                                                                            mysql_query(
                                                                                'SELECT `id`,`login`,`level`,`align`,`align2`,`clan` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
                                                                            )
                                                                        );
                                                                        $clrt = '';
                                                                        if ('id' . $usr['id'] == $url[2]) {
                                                                            $clrt = ' bgcolor="#c3a878"';
                                                                        }
                                                                        $html .= "<tr" . $clrt . "><td class='vam p' style='font-size: 14pt;'><b>" . $vid . "</b><a name='" . $usr['id'] . "' /></td>
                      <td class='vam al' style='padding-left: 20px;'><img src='https://img.new-combats.com/i/align/align" . $usr['align'] . ".gif' />";
                                                                        if ($usr['align2'] > 0) {
                                                                            $html .= '<img src="https://img.new-combats.com/i/align/align' . $usr['align2'] . '.gif" /> ';
                                                                        }
                                                                        if ($usr['clan'] > 0) {
                                                                            $html .= '<img src="https://img.new-combats.com/i/clan/' . $usr['clan'] . '.gif" /> ';
                                                                        }
                                                                        $html .= '<b>' . $usr['login'] . '</b> [' . $usr['level'] . '] <a href="/info/' . $usr['id'] . '" target="_blank"><img src="https://img.new-combats.com/i/inf_capitalcity.gif" /></a></td>
                      ';
                                                                        if ($url[2] != 'exp' && $url[2] != 'wins') {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'><b>' . round(
                                                                                    $pl['global'], 2
                                                                                ) . '</b></td>';
                                                                        } else {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'>' . round(
                                                                                    $pl['global'], 2
                                                                                ) . '</td>';
                                                                        }

                                                                        if ($url[2] == 'exp') {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'><b>' . number_format(
                                                                                    $pl['exp_real'], 0, ",", " "
                                                                                ) . '</b></td></tr>';
                                                                        } elseif ($url[2] == 'wins') {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'><b>' . number_format(
                                                                                    $pl['win'], 0, ",", " "
                                                                                ) . '</b></td></tr>';
                                                                        } else {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'>' . number_format(
                                                                                    $pl['exp_real'], 0, ",", " "
                                                                                ) . '</td></tr>';
                                                                        }
                                                                    }

                                                                    //----------------------------------------- личный рейтинг
                                                                    $spu = mysql_query(
                                                                        'SELECT * FROM `aaa_reting_list` WHERE `date` = "' . date(
                                                                            'dmY'
                                                                        ) . '" AND `uid` = "' . $u->info['id'] . '" ORDER BY ' . $bya . ' LIMIT 1'
                                                                    );

                                                                    while ($pl = mysql_fetch_array($spu)) {
                                                                        //
                                                                        if ($url[2] != 'exp' && $url[2] != 'wins') {
                                                                            $last_post = mysql_fetch_array(
                                                                                mysql_query(
                                                                                    'SELECT `pos` FROM `aaa_reting_list` WHERE `uid` = "' . $pl['uid'] . '" AND `date` != "' . $pl['date'] . '" ORDER BY `id` DESC LIMIT 1'
                                                                                )
                                                                            );
                                                                        }
                                                                        //
                                                                        $i++;
                                                                        $vid = $pl['pos'];
                                                                        if (isset($last_post['pos']) && $url[2] != 'exp' && $url[2] != 'wins') {
                                                                            $last_post = $last_post['pos'];
                                                                            if ($last_post < $pl['pos']) {
                                                                                $vid = '<img src="https://img.new-combats.com/down_red.png" height="16"> <b>' . $pl['pos'] . '</b> <sup style=\'color:red;\'>-' . ($pl['pos'] - $last_post) . '</sup>';
                                                                            } elseif ($last_post > $pl['pos']) {
                                                                                $vid = '<img src="https://img.new-combats.com/up_green.png" height="16"> <b>' . $pl['pos'] . '</b> <sup style=\'color:green;\'>+' . ($last_post - $pl['pos']) . '</sup>';
                                                                            }
                                                                        }
                                                                        //
                                                                        $html .= "<tr style='border-right: 0px; border-left: 0px;'><td style='border-right: 0px; border-left: 0px;'><b style='color:red;'><big>Ваш рейтинг:</big></b></td><td style='border-right: 0px; border-left: 0px;'></td><td style='border-right: 0px; border-left: 0px;'></td><td style='border-right: 0px; border-left: 0px;'></td></tr>";
                                                                        $usr = mysql_fetch_array(
                                                                            mysql_query(
                                                                                'SELECT `id`,`login`,`level`,`align`,`align2`,`clan` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
                                                                            )
                                                                        );
                                                                        $clrt = '';
                                                                        if ('id' . $usr['id'] == $url[2]) {
                                                                            $clrt = ' bgcolor="#c3a878"';
                                                                        }
                                                                        $html .= "<tr" . $clrt . "><td class='vam p' style='font-size: 14pt;'><b>" . $vid . "</b><a name='" . $usr['id'] . "' /></td>
                      <td class='vam al' style='padding-left: 20px;'><img src='https://img.new-combats.com/i/align/align" . $usr['align'] . ".gif' />";
                                                                        if ($usr['align2'] > 0) {
                                                                            $html .= '<img src="https://img.new-combats.com/i/align/align' . $usr['align2'] . '.gif" /> ';
                                                                        }
                                                                        if ($usr['clan'] > 0) {
                                                                            $html .= '<img src="https://img.new-combats.com/i/clan/' . $usr['clan'] . '.gif" /> ';
                                                                        }
                                                                        $html .= '<b>' . $usr['login'] . '</b> [' . $usr['level'] . '] <a href="/info/' . $usr['id'] . '" target="_blank"><img src="https://img.new-combats.com/i/inf_capitalcity.gif" /></a></td>
                      ';
                                                                        if ($url[2] != 'exp' && $url[2] != 'wins') {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'><b>' . round(
                                                                                    $pl['global'], 2
                                                                                ) . '</b></td>';
                                                                        } else {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'>' . round(
                                                                                    $pl['global'], 2
                                                                                ) . '</td>';
                                                                        }

                                                                        if ($url[2] == 'exp') {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'><b>' . number_format(
                                                                                    $pl['exp_real'], 0, ",", " "
                                                                                ) . '</b></td></tr>';
                                                                        } elseif ($url[2] == 'wins') {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'><b>' . number_format(
                                                                                    $pl['win'], 0, ",", " "
                                                                                ) . '</b></td></tr>';
                                                                        } else {
                                                                            $html .= '<td class=\'vam p\' style=\'font-size: 14pt;\'>' . number_format(
                                                                                    $pl['exp_real'], 0, ",", " "
                                                                                ) . '</td></tr>';
                                                                        }
                                                                    }


                                                                    echo $html;
                                                                    unset($html);
                                                                    ?>

                                                                </table>

                                                                <div class="rinfo">
                                                                    <p>
                                                                    <center style="font-size: 14px;">Рейтинг игроков
                                                                        обновляется 1 раз в сутки в 00:00 по
                                                                        серверу.<br>
                                                                        Полное обнуление рейтинга игроков осуществляется
                                                                        1 раз в месяц, 1-го числа каждого месяца.
                                                                    </center>
                                                                    </p>
                                                                    <p>
                                                                    <center style="font-size: 14px;"><b>Очки рейтинга
                                                                            начисляются в зависимости от выполнения
                                                                            Ежедневных Событий</b></center>
                                                                    </p>
                                                                </div>


                                                                <!-- End of text -->
                                                        </TD>
                                                        <!--td width=15% valign=top><img src="encicl/images/new_ico.gif" width=86 height=89 border=0></td-->
                                                    </TR>
                                                    </TBODY>
                                                </TABLE>
                                            </TD>
                                        </TR>
                                        </TBODY></TABLE>
                                <td width="1" valign="top" bgcolor="#edd7ae"><img
                                            src="https://new-combats.com/new/register/vesch_right.jpg" width="26"
                                            height="421"/></td>
                            </tr>
                            <tr>
                                <td colspan="3" valign="top"><img
                                            src="https://new-combats.com/new/register/vesch_bot2.jpg" width="850"
                                            height="56"/></td>
                            </tr>
                        </table>

                    </td>
                </tr>
            </table>
        </td>
        <td width="1%" valign="top" background="https://new-combats.com/new/register/bgr2.jpg"><img
                    src="https://new-combats.com/new/register/topr.jpg" width="83" height="593"/><br/>
            <img src="https://new-combats.com/new/register/right2.jpg" width="83" height="114"/></td>
        <td width="39%" valign="top">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td height="507" background="https://new-combats.com/new/register/topbgr.jpg">&nbsp;</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td valign="top">&nbsp;</td>
        <td colspan="3" valign="top"><img src="https://new-combats.com/new/register/bottom.jpg" width="1000"
                                          height="163"/></td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">&nbsp;</td>
        <td colspan="3" align="left" valign="top">
            <table width="970" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="225" align="left" valign="top">&nbsp;</td>
                    <td width="546" align="center" valign="top">
                        <style>
                            A.copi {
                                font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
                                font-size: 7pt;
                                color: #005348;
                                font-weight: bold;
                                text-decoration: none;
                            }

                            a.copi:link {
                                color: #005348;
                                font-weight: bold;
                                text-decoration: none;
                            }

                            A.copi:visited {
                                color: #005348;
                                font-weight: bold;
                                text-decoration: none;
                            }

                            A.copi:hover, A.copi:active {
                                color: #329700;
                                font-weight: bold;
                                text-decoration: none;
                            }
                        </style>
                        <br><span style="color:#EBD88B; font-family:'Philosopher', sans-serif;font-size: 18px;">Бойцовский Клуб © 2018</span>
                    </td>
                    <td width="199" align="right" valign="top"><img src="https://new-combats.com/new/register/pix.gif"
                                                                    width="10" height="30"/><br/>
                        &nbsp;
                    </td>
                </tr>
            </table>
        </td>
        <td valign="top">&nbsp;</td>
    </tr>
</table>
<div style="display:none;"></div>
</body>
</html>