<?php

//include_once 'system/head.php';

include 'head.php';


$url = $_SERVER['REQUEST_URI']; ?>

</head>
<body>
<?php
if (isset($ban)) {
    $err = "На вас наложен, бан осталось " . tl($ban['last'] - time());
}
if (isset($user['id'])) {

    if ($user['uid_ok'] == true) {
        echo '<div style="font-family:arial,helvetica,sans-serif;background-color:#ed812b;">
  <a href="https://m.ok.ru" style="display:block;font-size:large;padding:.5em .3em;line-height:26px;color:#fff;text-decoration:none;">одноклассники</a>
 </div>';
    }
    
    if ($user['online'] < time() - 300) {
        header('Location: ?');
    }
    switch ($user['level']) {

        case 1:
            $exp = 5;
            break;

        case 2:
            $exp = 15;
            break;

        case 3:
            $exp = 20;
            break;

        case 4:
            $exp = 25;
            break;

        case 5:
            $exp = 35;
            break;

        case 6:
            $exp = 80;
            break;

        case 7:
            $exp = 100;
            break;

        case 8:
            $exp = 881;
            break;

        case 9:
            $exp = 1282;
            break;

        case 10:
            $exp = 1932;
            break;

        case 11:
            $exp = 2287;
            break;

        case 12:
            $exp = 3045;
            break;

        case 13:
            $exp = 4756;
            break;

        case 14:
            $exp = 6390;
            break;

        case 15:
            $exp = 8927;
            break;

        case 16:
            $exp = 11960;
            break;

        case 17:
            $exp = 14515;
            break;

        case 18:
            $exp = 19023;
            break;

        case 19:
            $exp = 25966;
            break;

        case 20:
            $exp = 325530;
            break;

        case 21:
            $exp = 399510;
            break;

        case 22:
            $exp = 472050;
            break;

        case 23:
            $exp = 589950;
            break;

        case 24:
            $exp = 708940;
            break;

        case 25:
            $exp = 859950;
            break;

        case 26:
            $exp = 991920;
            break;

        case 27:
            $exp = 1201720;
            break;

        case 28:
            $exp = 1462400;
            break;

        case 29:
            $exp = 1809910;
            break;

        case 30:
            $exp = 2010270;
            break;

        case 31:
            $exp = 2400160;
            break;

        case 32:
            $exp = 2730610;
            break;

        case 33:
            $exp = 2999790;
            break;

        case 34:
            $exp = 3500000;
            break;

        case 35:
            $exp = 5000000;

            break;

        case 36:
            $exp = 6000000;
            break;

        case 37:
            $exp = 7250000;
            break;

        case 38:
            $exp = 10000000;
            break;

        case 39:
            $exp = 12500000;
            break;

        case 40:
            $exp = 15000000;
            break;

        case 40:
            $exp = 18000000;
            break;

        case 41:
            $exp = 202500000;
            break;

        case 42:
            $exp = 235000000;
            break;

        case 43:
            $exp = 347500000;
            break;

        case 44:
            $exp = 560000000;
            break;

        case 45:
            $exp = 672500000;
            break;

        case 46:
            $exp = 785000000;
            break;

        case 47:
            $exp = 897500000;
            break;

        case 48:
            $exp = 1210000000;
            break;

        case 49:
            $exp = 1622500000;
            break;

        case 50:
            $exp = 1950000000;
            break;

        case 51:
            $exp = 270000000;
            break;

        case 52:
            $exp = 290000000;
            break;

        case 53:
            $exp = 31000000;
            break;

        case 54:
            $exp = 330000000;
            break;

        case 55:
            $exp = 350000000;
            break;

        case 56:
            $exp = 370000000;
            break;

        case 57:
            $exp = 390000000;
            break;

        case 58:
            $exp = 410000000;
            break;

        case 59:
            $exp = 450000000;
            break;

        case 60:

            $exp = 10000000000;
            break;

    }
    function clan_exp($i) {

        switch ($i) {

            case 1:
                $clan_exp = 3;
                break;

            case 2:
                $clan_exp = 5;
                break;

            case 3:
                $clan_exp = 11;
                break;

            case 4:
                $clan_exp = 21;
                break;

            case 5:
                $clan_exp = 39;
                break;

            case 6:
                $clan_exp = 73;
                break;

            case 7:
                $clan_exp = 134;
                break;

            case 8:
                $clan_exp = 244;
                break;

            case 9:
                $clan_exp = 440;
                break;

            case 10:
                $clan_exp = 784;
                break;

            case 11:
                $clan_exp = 1380;
                break;

            case 12:
                $clan_exp = 2402;
                break;

            case 13:
                $clan_exp = 4132;
                break;

            case 14:
                $clan_exp = 7024;
                break;

            case 15:
                $clan_exp = 11801;
                break;

            case 16:
                $clan_exp = 19590;
                break;

            case 17:
                $clan_exp = 33212;
                break;

            case 18:
                $clan_exp = 52048;
                break;

            case 19:
                $clan_exp = 83278;
                break;

            case 20:
                $clan_exp = 131579;
                break;

            case 21:
                $clan_exp = 205264;
                break;

            case 22:
                $clan_exp = 316106;
                break;

            case 23:
                $clan_exp = 480481;
                break;

            case 24:
                $clan_exp = 720722;
                break;

            case 25:
                $clan_exp = 1066669;
                break;

            case 26:
                $clan_exp = 1557337;
                break;

            case 27:
                $clan_exp = 2242565;
                break;

            case 28:
                $clan_exp = 3184443;
                break;

            case 29:
                $clan_exp = 4458220;
                break;

            case 30:
                $clan_exp = 6150000;
                break;

            case 31:
                $clan_exp = 8370000;
                break;

            case 32:
                $clan_exp = 11210000;
                break;

            case 33:
                $clan_exp = 14800000;
                break;

            case 34:
                $clan_exp = 19240000;
                break;

            case 35:
                $clan_exp = 24630000;
                break;

            case 36:
                $clan_exp = 3103000000;

                break;

            default:
                $exp_plus = pow(1.3, ($i - 36));
                $clan_exp = 3103000000 * $exp_plus;
                break;

        }

        return $clan_exp * 4;

    }

    $myClan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '" . $user['id_clan'] . "' LIMIT 1"));
    if ($myClan and $myClan['exp'] >= clan_exp($myClan['level'])) {
        mysql_query("update `clans` set
`level` = '" . ($myClan['level'] + 1) . "',
`exp` = '" . ($myClan['exp'] - $myClan['exp']) . "'
where (`id` = '" . $myClan['id'] . "')");
        $log = 'Клан получил новый ' . ico('icons', 'level.png') . ' уровень';

        mysql_query("INSERT INTO `clan_journal` SET `clan` = '$myClan[id]', `time` = '" . time() . "', `text` = '$log' ");

    }


    /*
    if($user['access']< 2){

        echo" <div class='block_c'> Fatal error </div>";

            echo" <div class='block_c'> Server don't connect </div>";
                    echo" <div class='foot center'> True again <br>
                    <div class='cbtn green w30 cntr'><span class='cb_end'><span class='cb_ttl'><a href='?inv'>Обновить</div></span></span></a><br>";


          echo "   <a href='https://vk.com/semdannn'><img src='/images/icons/vk.png'>";




        break;

    }
    */
 //echo "<div class='header_b'>";
echo "<center><img src='/images/pims.png' style='width:100%; margin-bottom: -1px> </a></center>";
    echo div('header');  
echo "<center><img src='/img/rsdfg.png'> </a></center></div>"; 
echo "<div class='header'>";
    $new_msg = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `out` = '" . $myID . "' AND `online` = '1'"), 0);

    $health = n_f($user['max_health'], 1);

    if ($new_msg > 0 and $_SERVER['PHP_SELF'] != '/mail.php') {
        $mail = "<a href='/mail/'  data-ajax>" . ico('icons', 'mail.png') . " + $new_msg </a>";
    } else {
        $mail = '';
    }

    if (mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user_2` = '" . $myID . "' AND `status` = '0'"), 0) > 0) {
        $friends = "<a href='/friends/?new'  data-ajax>" . ico('icons', 'friends.png') . "</a>";
    } else {
        $friends = '';
    }
//echo "<div class='btn_1'>";
    $refresh = ico('icons', 'refresh.png');
    echo ' <span class="lime"> <img src="/images/icons/health.png" width="5%">  ' . n_f($user['health']) . ' </span>  <span class="gold"> <img src="/images/icons/str.png" width="5%">   ' . n_f($user['str']) . '  </span>  <span class="gold"> <img src="/images/icons/def.png" width="5%">   ' . n_f($user['def']) . '   </span> ' . $mail . ' ' . $friends . ' <a href="?r=' . $LinkKey . '"> ' . $refresh . '</a>';
    //echo "</div></div>";
    //echo div('header');  
echo "<center><img src='/img/rsdfg.png'> </a></center></div>";
    if ($user['level'] != 60) {
        $progress = round($user['exp'] / $exp * 100, 1);
        if ($progress > 100) {
            $progress = 100;
        }
       // echo '<div class="exp"><div class="exp_in" style="width: ' . $progress . '% "><br></div></div></div>';












 












        //echo div('header');

        //if ($user['id_clan'] > 0) {
            //if ($_SERVER['PHP_SELF'] !== '/battleclans/index.php') {
                //$bt = mysql_query("SELECT * FROM `clan_battles` ORDER BY `endtime` DESC LIMIT 1");
                //$btl = mysql_fetch_assoc($bt);
                //$btlnum = mysql_num_rows($bt);
                //if ($btl['battletime'] >= time() AND $btlnum > 0) {
                    //echo '<div class = "box">';
                   // echo "<center><font color='red'><b>Начинается битва кланов</b></font></center>";
                    //echo '<center>' . tl($btl['battletime'] - time()) . '</center>';
                    //echo "<center><a href='/battleclans/' class='btn_grey'>Перейти</span></span></a></center>";
                    //echo '</div>';
                    //$time_btl = $btl['battletime'] - time();
                    //$btltime = '[До начала: ' . date("i:s", $time_btl) . ']';
                //}
            //} else {
                //$btltime = null;
            //}
        //}

        //echo "</div>";


        //echo div('wrapper gold')." ".color('lime')."Вы </font><br><span style='float:center;'> ".ico('icons','str.png')."
        // ".$user['str']." ".ico('icons','health.png')."  ".$fights['health']."  ".ico('icons','def.png')."    ".$user['def']."</span>";
        // echo "<div class='exp_bar'><div class='progress_life' style='width:$progressUser%'></div></div></div>";


        //  }else{
        // $batle = mysql_query("SELECT * FROM `bashna` WHERE `id` = '1' ORDER BY `id` LIMIT 1");
        //$batle = mysql_fetch_array($batle);
        //if($batle['resp_boss'] < time()){

        //$timeOrk = "На севере появился орк из леса  <br><div class='btn_grey'><span class='cb_end'><span class='cb_ttl'><a href='/battle_ork/' > Отправиться и сразиться </div></span></span> </a>";

        //}else

        // $timeOrk = " <br><span style ='float:right;'>".isTimer($batle['resp_boss'])."</span>";
        //echo div('header');
        //echo $timeOrk;
        //echo "</div>";


        //echo div('block_c');

        //echo " <div class='btn_grey'><span class='cb_end'><span class='cb_ttl'><a href='?next'> Отправиться </div></span></span></a>";
        //echo "</div>";


        // }


        if ($user['announcement_read'] == 1) {

            $clan_msg = mysql_fetch_array(mysql_query('SELECT * FROM `clans` WHERE `id` = "' . $user['id_clan'] . '" '));

            if (isset($_GET['read'])) {

                header('location: ' . $_SERVER['PHP_SELF'] . '?');
                $_SESSION['msg'] = "<div class='block_c'> Вы скрыли сообщение </div>";
                mysql_query("update `users` set `announcement_read` = '0' where (`id` = '" . $myID . "')");


            }

            echo "
<div class='header'>
<div class='title'>Клановое обьявление</b></div>
 $clan_msg[announcement]<

<center><a  class='seach' href='?read'><font color='#909090'>Скрыть</font></a></center>
</div>";


        }


        if ($user['level'] != 60 && $user['exp'] >= $exp) {
            $a = 10 + ($user['level'] * 5) - 5;
            mysql_query("update `users` set
`level` = '" . ($user['level'] + 1) . "',
`exp` = '" . ($user['exp'] - $user['exp']) . "',
`almaz` = '" . ($user['almaz'] + $a) . "',
`health` = '" . ($user['max_health']) . "'

where (`id` = '" . $myID . "')");


            //if($user['level'] == 5)
            //mysql_query("UPDATE `users` SET    `avatar`='1'  WHERE `id` = '".$user['id']."'");

            //if($user['level'] == 15)
            //mysql_query("UPDATE `users` SET    `avatar`='2'  WHERE `id` = '".$user['id']."'");

            //if($user['level'] == 20)
            //mysql_query("UPDATE `users` SET    `avatar`='3'  WHERE `id` = '".$user['id']."'");

            //if($user['level'] == 25  )
            //mysql_query("UPDATE `users` SET    `avatar`='4'  WHERE `id` = '".$user['id']."'");


            $text = '
<span class="info">Вы получили новый уровень!</span>
<span class="money">Награда: <img src="/images/icons/almaz.png"></span> ' . $a . ' алмазов
';


            //mysql_query("INSERT INTO `mail` SET `in` = '1', `out` = '$myID', `text` = '$text' , `time` = '" . time() . "' , `online` = '1'");

           // $prof = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '1'"));

            //$kont = mysql_fetch_assoc(mysql_query("SELECT * FROM `kont` WHERE `id_user` = '" . $myID . "' && `id_kont` = '1' LIMIT 1"));
            //if ($kont['id_kont'] != $prof['id']) {
              //  mysql_query("INSERT INTO `kont` SET `id_user` = '$myID', `id_kont` = '1', `time` = '" . time() . "'");
          //  } else {
               // mysql_query("update `kont` set `time` = '" . time() . "' WHERE `id_user` = '" . $myID . "' && `id_kont` = '1'");
          //  }


            $text = '<div class="block_c">
<span class="info">Вы получили новый уровень!<br></span>

<span class="money">Награда: <img src="/images/icons/almaz.png"></span> ' . $a . ' алмазов
</div>';

            $_SESSION['msg'] = $text;


        }
        mysql_query("update `users` set `fix_mesto` = '" . $title . "'   where (`id` = '" . $myID . "')");
        //mysql_query("update `users` set `agent` = '".detect_browser()."'   where (`id` = '".$myID."')");
    }

}

if (isset($_SESSION['msg'])) {
    echo msg($_SESSION['msg']);
    unset($_SESSION['msg']);
}

if (isset($_SESSION['message'])) {
    echo '<div class="header"> ' . htmlspecialchars($_SESSION['message']) . ' </div>';
    unset($_SESSION['message']);
}

if (isset($_SESSION['fight'])) {
    echo fight($_SESSION['fight']);
    unset($_SESSION['fight']);
}

if (isset($_SESSION['sunduk'])) {
    echo msg($_SESSION['sunduk']);
    unset($_SESSION['sunduk']);
}

if (isset($_SESSION['item'])) {
    echo msg($_SESSION['item']);
    unset($_SESSION['item']);
}

if (isset($_GET['ref'])) {
    $_SESSION['ref'] = intval($_GET['ref']);
}

/*
$member = mysql_query('SELECT * FROM `coliseum_member` WHERE `user` = "'.$user['id'].'" ORDER BY `time` DESC LIMIT 1');
$member = mysql_fetch_array($member);

$coliseum = 'Колизей';
if($member && $user['fix_mesto'] != $coliseum && $member['dead'] == 0){
echo'
<div class="wrapper center">
<table style="width:100%;">
<tbody><tr><td class="center">
<li> <div class="cbtn gold center mt3"><span class="cb_end"><span class="cb_ttl">
<a href="/coliseum/"> <span class="gold">Вы Учавствуете в бое в колизее</span></a></span></span>
</div></li></td></tr></tbody></table></div>';
}
*/


?>
<style>
    html, Body {
        font-style: normal;
        font-size: medium;
        background-attachment: fixed;
        margin: 0 auto;

        text-decoration: none;
        color: #999;
        position: relative;
        cursor: url('//bitger.ru/cur/Normal.cur'),
        auto;
    }

    a {
        cursor: url('//bitger.ru/cur/Link.cur'),
        auto;

    }

</style>