<?

    ob_start();

  list($msec,$sec)
             = explode(chr(32), microtime()); 
  $gtime     = $sec+$msec; 

?>

<!DOCTYPE html><html>
  <head>
<meta http-equiv='content-type' content='text/html; charset=UTF-8'/>

<meta name='author' content='Admin & Воительница'/>
<meta name='keywords' content='битва титанов, титаны, онлайн игра, тивар, tiwar, MMORPG'/> 
<meta name='viewport' content='width=device-width; minimum-scale=1; maximum-scale=1'/>
<link rel='stylesheet' type='text/css' href='/css/main.css?84'/>
<link rel='icon' href='/favicon.ico?2' type='image/x-icon'/>
<link rel='shortcut icon' href='/favicon.ico?2' type='image/x-icon'/>
<title>Битва титанов | Лучшая онлайн игра для мобильных телефонов</title></head><body>


<div class='h' onclick='location.href="/"'>
<?

    if($user) {
	
	
if($user['ests']<=time() && $user['ests']!=NULL){

      mysql_query('UPDATE `users` SET `str` = `str` - 100,
        
                                      `ests` = NULL
        
                                       WHERE `id` = \''.$user['id'].'\'');
									   
}	
	
    
    switch($user['level']) {
    
      case 1:
          $exp = 15;
       break;

      case 2:
          $exp = 55;
       break;

      case 3:
          $exp = 104;
       break;

      case 4:
          $exp = 195;
       break;

      case 5:
          $exp = 298;
       break;

      case 6:
          $exp = 388;
       break;

      case 7:
          $exp = 512;
       break;

      case 8:
          $exp = 881;
       break;

      case 9:
          $exp = 1282;
       break;

      case 10:
          $exp = 1632;
       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 = 32553;
       break;

      case 21:
          $exp = 39951;
       break;

      case 22:
          $exp = 47205;
       break;

      case 23:
          $exp = 58995;
       break;

      case 24:
          $exp = 70894;
       break;

      case 25:
          $exp = 85995;
       break;

      case 26:
          $exp = 99192;
       break;

      case 27:
          $exp = 120172;
       break;

      case 28:
          $exp = 146240;
       break;

      case 29:
          $exp = 180991;
       break;

      case 30:
          $exp = 201027;
       break;

      case 31:
          $exp = 240016;
       break;

      case 32:
          $exp = 273061;
       break;

      case 33:
          $exp = 299979;
       break;

      case 34:
          $exp = 350000;
       break;

      case 35:
          $exp = 500000;

       break;

      case 36:
          $exp = 600000;
       break;

      case 37:
          $exp = 725000;
       break;

      case 38:
          $exp = 850000;
       break;

      case 39:
          $exp = 975000;
       break;

      case 40:
          $exp = 1100000;
       break;

      case 40:
          $exp = 1100000;
       break;

      case 41:
          $exp = 1225000;
       break;

      case 42:
          $exp = 1350000;
       break;

      case 43:
          $exp = 1475000;
       break;

      case 44:
          $exp = 1600000;
       break;

      case 45:
          $exp = 1725000;
       break;

      case 46:
          $exp = 1850000;
       break;

      case 47:
          $exp = 1975000;
       break;
       
      case 48:
          $exp = 2100000;
       break;

      case 49:
          $exp = 2225000;
       break;

      case 50:
          $exp = 2500000;
       break;

      case 51:
          $exp = 2700000;
       break;

      case 52:
          $exp = 2900000;
       break;

      case 53:
          $exp = 3100000;
       break;

      case 54:
          $exp = 3300000;
       break;

      case 55:
          $exp = 3500000;
       break;

      case 56:
          $exp = 3700000;
       break;

      case 57:
          $exp = 3900000;
       break;

      case 58:
          $exp = 4100000;
       break;

      case 59:
          $exp = 4500000;
       break;
      
      case 60:
      
          $exp = 0;
      
        break;

    }
        
        $exp_progress = round(100/($exp/$user['exp']));

    
    if($exp_progress > 100) {
        
     
        $exp_progress = 100;
     
        
    }

    function clan_exp($i) {
    
    switch($i) {
    
      case 1:
          $clan_exp = 30;
       break;

      case 2:
          $clan_exp = 58;
       break;

      case 3:
          $clan_exp = 111;
       break;

      case 4:
          $clan_exp = 210;
       break;

      case 5:
          $clan_exp = 394;
       break;

      case 6:
          $clan_exp = 732;
       break;

      case 7:
          $clan_exp = 1346;
       break;

      case 8:
          $clan_exp = 2449;
       break;

      case 9:
          $clan_exp = 4408;
       break;

      case 10:
          $clan_exp = 7846;
       break;

      case 11:
          $clan_exp = 13808;
       break;

      case 12:
          $clan_exp = 24025;
       break;

      case 13:
          $clan_exp = 41323;
       break;

      case 14:
          $clan_exp = 70249;
       break;

      case 15:
          $clan_exp = 118018;
       break;

      case 16:
          $clan_exp = 195909;
       break;

      case 17:
          $clan_exp = 321290;
       break;

      case 18:
          $clan_exp = 520489;
       break;

      case 19:
          $clan_exp = 832782;
       break;

      case 20:
          $clan_exp = 1315795;
       break;

      case 21:
          $clan_exp = 2052640;
       break;

      case 22:
          $clan_exp = 3161065;
       break;

      case 23:
          $clan_exp = 4804818;
       break;

      case 24:
          $clan_exp = 7207227;
       break;

      case 25:
          $clan_exp = 10666695;
       break;

      case 26:
          $clan_exp = 15573374;
       break;

      case 27:
          $clan_exp = 22425658;
       break;

      case 28:
          $clan_exp = 31844434;
       break;

      case 29:
          $clan_exp = 44582207;
       break;

      case 30:
          $clan_exp = 61500000;
       break;

      case 31:
          $clan_exp = 83700000;
       break;

      case 32:
          $clan_exp = 112100000;
       break;

      case 33:
          $clan_exp = 148000000;
       break;

      case 34:
          $clan_exp = 192400000;
       break;

      case 35:
          $clan_exp = 246300000;
       break;

      case 36:
          $clan_exp = 310300000;

       break;

    }
    
      return $clan_exp;
    
    }
    
    if($clan && $clan['level'] < 36 && $clan['exp'] >= clan_exp($clan['level'])) {
      
      mysql_query('UPDATE `clans` SET `level` = `level` + 1,
                                        `exp` = "0" WHERE `id` = "'.$clan['id'].'"');

    }


  $mail = mysql_result(mysql_query('SELECT COUNT(*) FROM `mail` WHERE `to` = "'.$user['id'].'" AND `read` = "0"'),0);




?>
</div>
<div class='main' style='word-wrap:break-word;'>
<span style='text-shadow:none;'></span>
<div class='head cntr' style='position:relative;' onclick='location.href="/"'>
<span class='ttl fl'><?=$title?></span><span class='bl rght nwr'>

<?
if($mail > 0) {

?>

<a href='/mail/'><img src='/images/icon/mail.png' alt='*'/></a> |

<?

}

?>



<img src='/images/icon/health.png' alt='hp'/> <span class='white'><?=$user['hp']?></span> | 
<img src='/images/icon/mana.png' alt='mp'/> <?=$user['mp']?></span><div class='clr'></div></div>
<div class='exp_bar'><div class='progress' style='width:<?=$exp_progress?>%'></div></div>





</div>
<div class='main' style='word-wrap:break-word;'><span style='text-shadow:none;'></span>
<?

    if($user['level'] < 60 && $user['exp'] >= $exp) {
        
        $g = 10 + ($user['level'] * 5) - 5;
    
    mysql_query('UPDATE `users` SET `level` = `level` + 1,
                                      `exp` = "0",
                                       `hp` = "'.($user['vit'] * 2).'",
                                       `mp` = "'.$user['mana'].'",
                                        `g` = "'.($user['g'] + $g).'" WHERE `id` = "'.$user['id'].'"');

?>


<div class='block_outer center' style='margin:7px 4px 7px 4px;'><img src='/images/icon/2hit.png' alt=''/> 
<span class='dgreen bold'>Поздравляем!</span> 
<img src='/images/icon/2hit.png' alt=''/>
<div class='separ'></div>Ты получил 
<span class='dgreen'><?=$user['level']?></span> уровень!<br/>
<span class='blue'>Награда:</span> 
<img src='/images/icon/gold.png' alt=''/> <?=$g?> золота
<div class='separ'></div>
<span class='yellow'>Тебе доступны <img src='/images/icon/league.png' alt=''/> Дуэли!</span>
<div class='mb10'></div><a class='btn' href='/duel/'>
<span class='end'><span class='label'>Перейти в дуэли</span></span></a></div>





<?
        
    }


if($clan) {

      $clan_msg = mysql_fetch_array(mysql_query('SELECT * FROM `clan_msg` WHERE `clan` = "'.$clan['id'].'" AND `time` >= "'.$clan_memb['time'].'" ORDER BY `time` DESC LIMIT 1'));
  if($clan_msg && mysql_result(mysql_query('SELECT COUNT(*) FROM `clan_msg_read` WHERE `msg` = "'.$clan_msg['id'].'" AND `user` = "'.$user['id'].'"'),0) == 0 ) {
 $clan_msg_user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$clan_msg['user'].'"'));

  if($_GET['clan_msg_read'] == true) {
    
    mysql_query('INSERT INTO `clan_msg_read` (`msg`,
                                             `user`) VALUES ("'.$clan_msg['id'].'",
                                                                 "'.$user['id'].'")');

  header('location: '.$_SERVER['PHP_SELF'].'?');
  
  }

?>


<b>Клановое обьявление</b><br/>
  <?=smiles($clan_msg['text'])?>
  <br/>
  Отправитель: <img src='/images/icon/race/<?=$clan_msg_user['r']?>.png' alt='*'/> <?=$clan_msg_user['login']?><br/>
  <font color='#909090'><?=_times(time() - $clan_msg['time'])?></font>
  <div class='separator'></div>
<a href='?clan_msg_read=true'><font color='#909090'>Скрыть</font></a>


<?

}

}
else
{

  if(mysql_result(mysql_query('SELECT COUNT(*) FROM `clan_invite` WHERE `user` = "'.$user['id'].'"'),0) > 0) {
  
    $_invite = mysql_fetch_array(mysql_query('SELECT * FROM `clan_invite` WHERE `user` = "'.$user['id'].'"'));
$clan_invite = mysql_fetch_array(mysql_query('SELECT * FROM `clans` WHERE `id` = "'.$_invite['clan'].'"'));
        
      if($_GET['invite'] == $clan_invite['id']) {

        mysql_query('INSERT INTO `clan_memb` (`clan`,
                                                `user`,
                                                `time`,
                                         `last_update`) VALUES ("'.$clan_invite['id'].'",  
                                                                       "'.$user['id'].'",
                                                                            "'.time().'",
                                                       "'.(time() + ((60 * 60) * 24)).'")');
                                              
        mysql_query('DELETE FROM `clan_invite` WHERE `user` = "'.$user['id'].'"');

        header('location: /clan/');
        exit;
    
      }
    
    if($_GET['cancel_invite'] == true){
    
      mysql_query('DELETE FROM `clan_invite` WHERE `clan` = "'.$clan_invite['id'].'" AND `user` = "'.$user['id'].'"');
    
      header('location: '.$_SERVER['PHP_SELF'].'?');
      exit;
    
    }

?>


<b>Приглашение в клан</b><br/><br/>

<table cellpadding='0' cellspacing='0' align='center'>
<tr>
<td><img src='/images/icon/clan/gerb/<?=$clan_invite['gerb']?>.png' alt='*'/></td><td valign='top' style='padding-left: 5px; text-align: left;'>
<img src='/images/icon/clan/<?=$clan_invite['r']?>.png' alt='*'/> <a href='/clan/<?=$clan_invite['id']?>/'><?=$clan_invite['name']?></a><br/>
В клане: <b><?=mysql_result(mysql_query('SELECT COUNT(*) FROM `clan_memb` WHERE `clan` = "'.$clan_invite['id'].'"'),0)?></b> человек<br/>
Бонус: <font color='#90c090'>+<?=clan_buff($clan_invite['built_1'])?></font> к сумме
</td>
</tr></table>

<div class='separator'></div>

<a href='?invite=<?=$clan_invite['id']?>' class='button'>Вступить в клан</a><br/><br/>
<a href='?cancel_invite=true'><font color='#909090'>Отказаться</font></a>



<?
    
    }

}

    }
    else
    {

?>
  
    

</div>




<?

    }

?>