<?php


define('_IN_JOHNCMS', 1);

$headmod = 'bookmaker';
$textl = 'Futbol bashorati';
require_once '../incfiles/core.php';
require_once '../incfiles/head.php';

if (!$user_id) {
    echo functions::display_error($lng['access_guest_forbidden']);
    require_once '../incfiles/end.php';
    exit;
}
else {
    switch ($act) {

        case 'list_matches':
            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;Bashorat uchun o\'yinlar</div>';

            $total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_matches` WHERE `status` = '0'"), 0);
            if ($total) {
                $req = mysql_query("SELECT * FROM `bookmaker_matches` WHERE `status` = '0' ORDER BY `time` ASC LIMIT $start, $kmess");
                $i = 0;
                while ($res = mysql_fetch_assoc($req)) {
                    $total_bets = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_bets` WHERE `match_id` = " . $res['id'] . ""), 0);
                    echo '<div class="list' . ($i % 2 ? 1 : 2) . '">'
                        . functions::image('football.png')
                        . '<a href="?act=bet&amp;id=' . $res['id'] . '">' . functions::checkout($res['team_1']) . ' - ' . functions::checkout($res['team_2']) . '</a>'
                        . '&nbsp;<span class="gray">(' . functions::display_date($res['time']) . ')</span>';
                    if (!empty($res['champ']))
                        echo '<div class="sub">' . functions::checkout($res['champ']) . '</div>';
                    echo '<div class="sub">Barcha stavkalar:&nbsp;<span style="color: #0000bb;"><b>' . $total_bets . '</b></span></div><div class="sub">';
                        if ($rights >= 7)
                            echo '<a href="admin.php?mod=edit&amp;id=' . $res['id'] . '">O\'zgartirish</a>&nbsp;'
                            . '|&nbsp;<a href="admin.php?mod=del&amp;id=' . $res['id'] . '">O\'chirish</a>&nbsp;'
                            . '|&nbsp;<a href="admin.php?mod=play&amp;id=' . $res['id'] . '">Tugatish</a>&nbsp;|&nbsp;';
                    echo '<a href="./?act=forec_add&amp;id=' . $res['id'] . '">Tahmin yozish</a>'
                            . '</div></div>';
                    $i++;
                }
            }
            else {
                echo '<div class="menu">Aktiv matchlar yo\'q</div>';
            }
            echo '<div class="phdr">Hammasi:&nbsp;' . $total . '</div>';
            if ($total > $kmess)
                echo '<div class="topmenu">' . functions::display_pagination('?act=list_matches&amp;', $start, $total, $kmess) . '</div>';

            echo '<div class="menu"><a href="./">Orqaga</a></div>';
            break;

        case 'forec_add':
            $res = mysql_fetch_assoc(mysql_query("SELECT * FROM `bookmaker_matches` WHERE `id` = '$id'"));

            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;Tahmin yozish</div>';
            if (mysql_num_rows(mysql_query("SELECT `id` FROM `bookmaker_forecasts` WHERE `match_id` = '$id' AND (`user_id` = '$user_id' OR `status` = '1')"))) {
                echo functions::display_error('Endi bu matchga tahmin yoza olmaysiz. Yoki siz bu tahminni matchga yozgansiz yoki bu tahmin mavjud.');
            }
            elseif ($res['time'] - 3600 < time()) {
                echo functions::display_error('Tahmin yozish vaqti o\'yin boshlanishiga 1 soat qolgancha davom etadi.');
            }
            else {
                if (isset($_POST['submit'])) {
                    $text = isset($_POST['text']) ? substr(functions::checkin($_POST['text']), 0, 1500) : null;
                    $forec = isset($_POST['forec']) ? substr(functions::checkin($_POST['forec']), 0, 15) : null;

                    $error = array();
                    if (empty($text))
                        $error[] = 'Tahmin matni bo\'sh';
                    if (empty($forec))
                        $error[] = 'Siz matchga tahminingizni tanlamadingiz';
                    if ($error) {
                        echo functions::display_error($error, '<a href="?act=forec_add&amp;id=' . $id . '">Takrorlash</a>');
                    }
                    else{
                        mysql_query("INSERT INTO `bookmaker_forecasts` SET
                          `match_id` = $id,
                          `user_id` = $user_id,
                          `text` = '" . mysql_real_escape_string($text) . "',
                          `forec` = '" . mysql_real_escape_string($forec) . "',
                          `time` = " . time() . "");
                        header('location: ./');
                    }
                }
                else {

                    echo '<div class="bmenu"><p>Barcha tahminlar moderatsiyadan o\'tkaziladi. Bir matchda faqat bir moderatsiyadan o\'tgan tahmin bo\'ladi</p></div>'
                        . '<div class="gmenu"><form action="?act=forec_add&amp;id=' . $id . '" method="post" name="form">'
                        . '<p>Match:&nbsp;<b>' . functions::checkout($res['team_1']) . ' - ' . functions::checkout($res['team_2']) . '</b></p>'
                        . '<p>O\'yin vaqti:&nbsp;' . functions::display_date($res['time']) . '</p>'
                        . '<p>Tahmin matni (max 1500):<br>'
                        . bbcode::auto_bb('form', 'text') . '</p>'
                        . '<textarea name="text"></textarea>'
                        . '<p>Sizning tahmin:</p>'
                        . '<select name="forec">'
                        . '<option value="П1">'.$res['team_1'].'</option>'
                        . '<option value="Х">Durrang</option>'
                        . '<option value="П2">'.$res['team_2'].'</option>'
                        . '</select>'
                        . '<p><input type="submit" name="submit" value="Qo\'shish"></p>'
                        . '</form></div>';
                }
            }
            echo '<div class="menu"><a href="./?act=list_matches">Orqaga</a></div>';
            break;

        case 'list_forecasts':
            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;Foydalanuvchialr tahmini</div>';

            $total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_forecasts` " . ($rights >= 7 ? '' : 'WHERE `status` = 1') . ""), 0);
            if ($total) {
                $req = mysql_query("SELECT * FROM `bookmaker_forecasts` " . ($rights >= 7 ? '' : 'WHERE `status` = 1') . " ORDER BY `time` ASC LIMIT $start, $kmess");
                $i = 0;
                while ($res = mysql_fetch_assoc($req)) {
                    $match = mysql_fetch_assoc(mysql_query("SELECT `team_1`, `team_2`, `time` FROM `bookmaker_matches` WHERE `id` = " . $res['match_id'] . ""));
                    $author = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `users` WHERE `id` = " . $res['user_id'] . ""));
                    echo '<div class="list' . ($i % 2 ? 1 : 2) . '">'
                        . functions::image('football.png')
                        . '<a href="?act=forec&amp;id=' . $res['id'] . '">' . functions::checkout($match['team_1']) . ' - ' . functions::checkout($match['team_2']) . '</a>'
                        . '&nbsp;<span class="gray">(' . functions::display_date($match['time']) . ')</span>';
                    if ($res['status'] == 0) echo '<span class="red">&nbsp;[moderatsiyada]</span>';
                    echo '<div class="sub"><a href="../users/profile.php?user=' . $res['user_id'] . '">' . functions::checkout($author['name']) . '</a> tahmini</div>'
                        . '</div>';
                    $i++;
                }
            }
            else {
                echo '<div class="menu">Tahminlar hali bildirilmagan</div>';
            }

            echo '<div class="phdr">Hammasi:&nbsp;' . $total . '</div>';
            if ($total > $kmess)
                echo '<div class="topmenu">' . functions::display_pagination('?act=list_forecasts&amp;', $start, $total, $kmess) . '</div>';

            echo '<div class="menu"><a href="./">Orqaga</a></div>';
            break;

        case 'forec':
            $res = mysql_fetch_assoc(mysql_query("SELECT * FROM `bookmaker_forecasts` WHERE `id` = '$id'"));
            $match = mysql_fetch_assoc(mysql_query("SELECT `team_1`, `team_2`, `champ`, `time` FROM `bookmaker_matches` WHERE `id` = " . $res['match_id'] . ""));
            $author = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `users` WHERE `id` = " . $res['user_id'] . ""));

            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;matchga tahmin <b>' . functions::checkout($match['team_1']) . ' - ' . functions::checkout($match['team_2']) . '</b></div>';
            if ($res['status'] == 0)
                echo '<div class="rmenu"><a href="admin.php?mod=moderation&amp;do=mod&amp;user=' . $res['user_id'] . '&amp;id=' . $res['id'] . '&amp;match=' . $res['match_id'] . '">Tasdiqlash</a>&nbsp;|&nbsp;<a href="admin.php?mod=moderation&amp;do=del&amp;id=' . $res['id'] . '">Bekor qilish</a></div>';

            echo '<div class="bmenu">Match:&nbsp;<b>' . functions::checkout($match['team_1']) . ' - ' . functions::checkout($match['team_2']) . '</b>'
                . '<p>Chempionat:&nbsp;' . (empty($match['champ']) ? 'Не указано' : functions::checkout($match['champ'])) . '</p>'
                . '<p>O\'yin vaqti:&nbsp;' . functions::display_date($match['time']) . '</p>'
                . '<p>Tahmin muallifi:<a href="../users/profile.php?user=' . $res['user_id'] . '">' . functions::checkout($author['name']) . '</a></p>'
                . '</div>';
            echo '<div class="gmenu">'
                . '<p>Tahmin:</p>'
                . functions::smileys(functions::checkout($res['text'], 1, 1), $user['rights'] >= 1 ? 1 : 0)
                . '<p>Mablag\':&nbsp;<b>' . functions::checkout($res['forec']) . '</b></p>'
                . '</div>';

            include_once '../incfiles/classes/likes.php';
            $arg = array(
                'likes_table'  => 'book_forecast_likes',
                'sub_id'       => $id,
                'url'          => '?act=forec&amp;id=' . $id
            );
            new Likes($arg);
			
            $total_comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `book_forecasts_comments` WHERE `sub_id` = '$id'"), 0);

            echo '<div class="phdr"><a href="?act=comments&amp;id=' . $id . '">Fikrlar&nbsp;(' . $total_comm. ')</a></div>'
                . '<div class="menu"><a href="./?act=list_forecasts">Orqaga</a></div>';
            break;

        case 'comments':
            $res = mysql_fetch_assoc(mysql_query("SELECT * FROM `bookmaker_matches` WHERE `id` = '$id'"));
            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;Foydalanuvchilar tahmini</div>'
                . '<div class="bmenu"><a href="?act=forec&amp;id=' . $id . '">' . functions::checkout($res['team_1']) . ' - ' . functions::checkout($res['team_2']) . '</a></div>';

            $arg = array(
                'comments_table' => 'book_forecasts_comments',       // Таблица с комментариями
                'likes_table'    => 'book_comments_likes',           // Таблица с лайками
                'url_like'       => '?act=comments&amp;id=' . $id,   // Адрес
                'is_like'        => 1,                               // Включаем лайки к комментам
                'object_table'   => 'bookmaker_forecasts',           // Таблица комментируемых объектов
                'script'         => '?act=comments',                 // Имя скрипта (с параметрами вызова)
                'sub_id_name'    => 'id',                            // Имя идентификатора комментируемого объекта
                'sub_id'         => $id,                             // Идентификатор комментируемого объекта
                'title'          => 'Комментарии'                    // Название раздела
            );
            new comments($arg);

            echo '<div class="menu"><a href="./?act=forec&amp;id=' . $id . '">Orqaga</a></div>';
            break;

        case 'bet':
            $res = mysql_fetch_assoc(mysql_query("SELECT * FROM `bookmaker_matches` WHERE `id` = '$id'"));
            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;Stavka tikish</div>';

            if ($res['time'] > time()) {
                if (mysql_num_rows(mysql_query("SELECT `id` FROM `bookmaker_bets` WHERE `user_id` = '$user_id' AND `match_id` = '$id'")) < 2) {
                    if (isset($_POST['submit'])) {
                        $bet = isset($_POST['bet']) ? functions::checkin($_POST['bet']) : null;
                        $summ = isset($_POST['summ']) ? abs(intval($_POST['summ'])) : 0;

                        if ($datauser['balans'] >= $summ) {
                            mysql_query("INSERT INTO `bookmaker_bets` SET
                              `user_id` = $user_id,
                              `match_id` = $id,
                              `bet` = '" . mysql_real_escape_string($bet) . "',
                              `summ` = $summ");
                            mysql_query("UPDATE `users` SET `balans` = `balans` - $summ WHERE `id` = '$user_id'");
                            header('location: ./?act=list_matches');
                        }
                        else {
                            echo functions::display_error('Sizda bu tahminga tikish uchun pul yetarli emas.');
                        }
                    }
                    else {
                        echo '<div class="bmenu"><p>O\'yin:&nbsp;<b>' . functions::checkout($res['team_1']) . ' - ' . functions::checkout($res['team_2']) . '</b></p>'
                            . '<p>O\'yin vaqti:&nbsp;' . functions::display_date($res['time']) . '</p>'
                            . '<p>Hisob:&nbsp;' . $datauser['balans'] . '</p>'
                            . '</div>'
                            . '<div class="gmenu"><form action="?act=bet&amp;id=' . $id . '" method="post">'
                            . '<p>Sizning stavka:&nbsp;'
                            . '<select name="bet">'
                            . '<option value="П1">'.$res['team_1'].'</option>'
                            . '<option value="Х">Durrang</option>'
                            . '<option value="П2">'.$res['team_2'].'</option>'
                            . '</select></p>'
                            . '<p>Stavka summasi:&nbsp;'
                            . '<select name="summ">'
                            . '<option value="50">50</option>'
                            . '<option value="100">100</option>'
                            . '<option value="150">150</option>'
                            . '<option value="200">200</option>'
                            . '</select></p>'
                            . '<p><input type="submit" name="submit" value="Tikish"></p>'
                            . '</form></div>';
                    }
                }
                else {
                    echo functions::display_error('O\'yinga max. 2 stavka qo\'yish mumkin');
                }
            }
            else {
                echo functions::display_error('Stavka qoldirish vaqti tugadi. Stavka vaqti tugagan');
            }

            echo '<div class="menu"><a href="./?act=list_matches">Orqaga</a></div>';
            break;

        case 'top_p':
        echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;TOP liderlar</div>';

        $total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `balans` != 0"), 0);
        if ($total) {
            $req = mysql_query("SELECT `id`, `name`, `balans` FROM `users` WHERE `balans` != 0 ORDER BY `balans` DESC LIMIT $start, $kmess");
            echo '<table class="table"  width="100%" border="0" cellspacing="1" cellpadding="4">
	            <tr class="un_title">
	            <td align="center"><b>№</b></td>
				<td align="center"><b>Foydalanuvchi</b></td>
				<td align="center"><b>Ball</b></td></tr>';
            $i = 1;
            while ($res = mysql_fetch_assoc($req)) {
               echo $i % 2 ? '<tr class="list1">' : '<tr class="list2">';
                    echo '<td align="center">' . $i . '</td>'
                    . '<td>&#160;<a href="../users/profile.php?user=' . $res['id'] . '">' . $res['name'] . '</a></td>'
                    . '<td align="center"><b>' . $res['balans'] . '</b></td>'
                    . '</tr>';
                $i++;
            }
            echo '</table>';
        }
        else {
            echo '<div class="menu">Reyting bo\'sh</div>';
        }

        echo '<div class="phdr">Hammasi:&nbsp;' . $total . '</div>';
        if ($total > $kmess)
            echo '<div class="topmenu">' . functions::display_pagination('?act=top_p&amp;', $start, $total, $kmess) . '</div>';


        echo '<div class="menu"><a href="./">Orqaga</a></div>';
        break;

        case 'top_f':
            echo '<div class="phdr"><a href="./">Futbol tahminlari</a>&nbsp;|&nbsp;TOP tahmin qoldiruvchilar</div>';

            $total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `forecasts` != 0"), 0);
            if ($total) {
                $req = mysql_query("SELECT `id`, `name`, `forecasts` FROM `users` WHERE `forecasts` != 0 ORDER BY `forecasts` DESC LIMIT $start, $kmess");
                echo '<table class="table"  width="100%" border="0" cellspacing="1" cellpadding="4">
	            <tr class="un_title">
	            <td align="center"><b>№</b></td>
				<td align="center"><b>Foydalanuvchi</b></td>
				<td align="center"><b>Tahminlar</b></td></tr>';
                $i = 1;
                while ($res = mysql_fetch_assoc($req)) {
                    echo $i % 2 ? '<tr class="list1">' : '<tr class="list2">';
                        echo '<td align="center">' . $i . '</td>'
                        . '<td>&#160;<a href="../users/profile.php?user=' . $res['id'] . '">' . $res['name'] . '</a></td>'
                        . '<td align="center"><b>' . $res['forecasts'] . '<b></td>'
                        . '</tr>';
                    $i++;
                }
                echo '</table>';
            }
            else {
                echo '<div class="menu">Reyting bo\'sh</div>';
            }

            echo '<div class="phdr">Hammasi:&nbsp;' . $total . '</div>';
            if ($total > $kmess)
                echo '<div class="topmenu">' . functions::display_pagination('?act=top_f&amp;', $start, $total, $kmess) . '</div>';


            echo '<div class="menu"><a href="./">Orqaga</a></div>';
            break;

        case 'top_c':
            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;TOP fikrlar</div>';

            $total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `comments` != 0"), 0);
            if ($total) {
                $req = mysql_query("SELECT `id`, `name`, `comments` FROM `users` WHERE `comments` != 0 ORDER BY `comments` DESC LIMIT $start, $kmess");
                echo '<table class="table"  width="100%" border="0" cellspacing="1" cellpadding="4">
	            <tr class="un_title">
	            <td align="center"><b>№</b></td>
				<td align="center"><b>Foydalanuvchi</b></td>
				<td align="center"><b>Fikrlar</b></td></tr>';
                $i = 1;
                while ($res = mysql_fetch_assoc($req)) {
                    echo $i % 2 ? '<tr class="list1">' : '<tr class="list2">';
                        echo'<td align="center">' . $i . '</td>'
                        . '<td>&#160;<a href="../users/profile.php?user=' . $res['id'] . '">' . $res['name'] . '</a></td>'
                        . '<td align="center"><b>' . $res['comments'] . '<b></td>'
                        . '</tr>';
                    $i++;
                }
                echo '</table></div>';
            }
            else {
                echo '<div class="menu">Reyting bo\'sh</div>';
            }

            echo '<div class="phdr">Hammasi:&nbsp;' . $total . '</div>';
            if ($total > $kmess)
                echo '<div class="topmenu">' . functions::display_pagination('?act=top_c&amp;', $start, $total, $kmess) . '</div>';


            echo '<div class="menu"><a href="./">Orqaga</a></div>';
            break;

        case 'archive':
            function count_files($dir) {
                $c = 0;
                $d = dir($dir);
                while ($str = $d->read()){
                    if($str{0} != '.'){
                        if(is_dir($dir.'/'.$str)) $c+=count_files($dir.'/'.$str);
                        else $c++;
                    }
                }
                $d->close();
                return $c;
            }
            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;Arxiv</div>';
            $count = count_files('archive/');
            if ($count) {
                function list_files($directory) {
                    $dir = opendir($directory);
                    while ($file = readdir($dir)) {
                        if ($file == '.' || $file == '..')
                            continue;
                        else
                            $array[] = $file;
                    }
                    return $array;
                }
                $arr = list_files('archive/');

                if (isset($_POST['view'])) {
                    $file = file_get_contents($home . '/bookmaker/archive/' . ($_POST['archive']));
                    echo '<div class="gmenu"><p>' . functions::checkout($file, 1, 1) . '</p></div>';
                }

                echo '<div class="gmenu"><form action="?act=archive" method="post">'
                    . '<p>Arxivni tanlang:</p>'
                    . '<p><select name="archive">';
                foreach ($arr as $v) echo '<option value="' . $v . '">' . $v . '</option>';
                echo '</select></p>'
                    . '<p><input type="submit" name="view" value="Ko\'rsatish"></p>'
                    . '</form></div>';
            }
            else {
                echo '<div class="menu">Arxivlar yo\'q</div>';
            }
            echo '<div class="menu"><a href="./">Orqaga</a></div>';
            break;

        case 'stats':
            echo '<div class="phdr"><a href="./">Futbol bashorati</a>&nbsp;|&nbsp;Tugagan matchlar</div>';

            $total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_matches` WHERE `status` = '1'"), 0);
            if ($total) {
                $req = mysql_query("SELECT * FROM `bookmaker_matches` WHERE `status` = '1' ORDER BY `time` DESC LIMIT $start, $kmess");
                $i = 0;
                while ($res = mysql_fetch_assoc($req)) {
                    $arr = explode('|', $res['score']);
                    $total_bets = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_bets` WHERE `match_id` = " . $res['id'] . ""), 0);
                    $win_bets = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_bets` WHERE `match_id` = " . $res['id'] . " AND `win` = '1'"), 0);
                    echo '<div class="list' . ($i % 2 ? 1 : 2) . '">'
                        . functions::image('football.png')
                        . '<b>' . functions::checkout($res['team_1']) . ' - ' . functions::checkout($res['team_2']) . '</b>'
                        . '&nbsp;<span class="gray">(' . functions::display_date($res['time']) . ')</span>'
                        . '&nbsp;<b>(' . $arr[0] . ':' . $arr[1] . ')</b>'
                        . '<div class="sub">Barcha bashoratlar:&nbsp;<span style="color: #0000bb;"><b>' . $total_bets . '</b></span></div>'
                        . '<div class="sub">Yutgan bashoratlar:&nbsp;<span class="green"><b>' . $win_bets . '</b></span></div>'
                        . '</div>';
                    $i++;
                }
            }
            else {
                echo '<div class="menu">Tugagan matchalr yo\'q</div>';
            }

            echo '<div class="phdr">Hammasi:&nbsp;' . $total . '</div>';
            if ($total > $kmess)
                echo '<div class="topmenu">' . functions::display_pagination('?act=stats&amp;', $start, $total, $kmess) . '</div>';

            echo '<div class="menu"><a href="./">Orqaga</a></div>';
            break;

        default:
            $total_matches = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_matches` WHERE `status` = '0'"), 0);
            $played_matches = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_matches` WHERE `status` = '1'"), 0);
            $total_forecasts = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_forecasts` WHERE `status` = '1'"), 0);
            $mod_forecasts = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `bookmaker_forecasts` WHERE `status` = '0'"), 0);
            if ($mod_forecasts)
                $total_forecasts .= ($rights >= 7) ? '&nbsp;/&nbsp;<span class="red">M:' . $mod_forecasts. '</span>' : null;

            echo '<div class="phdr">Futbol bashorati</div>'
                . '<div class="menu">' .  functions::image('rating.png') . '<a href="./?act=top_p">TOP liderlar</a></div>'
                . '<div class="menu">' .  functions::image('rating.png') . '<a href="./?act=top_f">TOP bashoratchilar</a></div>'
                . '<div class="menu">' .  functions::image('rating.png') . '<a href="./?act=top_c">TOP fikrlar</a></div>'
                . '<div class="menu">' .  functions::image('football.png') . '<a href="./?act=list_matches">Bashorat uchun matchlar</a>&nbsp;(' . $total_matches . ')</div>'
                . '<div class="menu">' .  functions::image('football.png') . '<a href="./?act=list_forecasts">Foydalanuvchilar bashoratlari</a>&nbsp;(' . $total_forecasts . ')</div>'
                . '<div class="menu">' .  functions::image('football.png') . '<a href="./?act=stats">Tugagan matchlar</a>&nbsp;(' . $played_matches . ')</div>'
                . '<div class="menu">' .  functions::image('mouse.png') . '<a href="?act=archive">Arxiv</a></div>';
            break;
    }

    if ($rights >= 7) {
        echo '<div class="gmenu quote">'
            . '<a href="admin.php?mod=add">O\'yin qo\'shish</a><br>'
            . '<a href="admin.php?mod=restart">Restart</a>'
            . '</div>';
    }
}

require_once '../incfiles/end.php';