<?

    ob_start();

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

?>

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="Content-Type" content="application/vnd.wap.xhtml+xml; charset=utf-8"/><link rel="icon" href="/favicon.ico" type="image/x-icon"/>
<link rel="icon" href="http://xaos.mobi/favicon.ico" type="image/x-icon"/><link rel="stylesheet" href="http://213.239.195.28/xaos/style.css" type="text/css"/>
<title><?=$title?></title>
 </head>
<body>

<?

    if($user) {
    
    switch($user['level']) {
    
      case 1:
          $exp = 19;
       break;

      case 2:
          $exp = 98;
       break;

      case 3:
          $exp = 245;
       break;

      case 4:
          $exp = 507;
       break;

      case 5:
          $exp = 938;
       break;

      case 6:
          $exp = 1618;
       break;

      case 7:
          $exp = 2512;
       break;

      case 8:
          $exp = 3960;
       break;

      case 9:
          $exp = 5850;
       break;

      case 10:
          $exp = 12530;
       break;

      case 11:
          $exp = 17450;
       break;

      case 12:
          $exp = 23760;
       break;

      case 13:
          $exp = 31760;
       break;

      case 14:
          $exp = 41770;
       break;

      case 15:
          $exp = 54200;
       break;

      case 16:
          $exp = 69500;
       break;

      case 17:
          $exp = 88240;
       break;

      case 18:
          $exp = 111050;
       break;

      case 19:
          $exp = 138730;
       break;

      case 20:
          $exp = 286020;
       break;

      case 21:
          $exp = 354430;
       break;

      case 22:
          $exp = 435780;
       break;

      case 23:
          $exp = 533970;
       break;

      case 24:
          $exp = 652650;
       break;

      case 25:
          $exp = 955690;
       break;

      case 26:
          $exp = 1170700;
       break;

      case 27:
          $exp = 1420790;
       break;

      case 28:
          $exp = 1740754;
       break;

      case 29:
          $exp = 2130757;
       break;

      case 30:
          $exp = 3490535;
       break;

      case 31:
          $exp = 4330756;
       break;

      case 32:
          $exp = 7760647;
       break;

      case 33:
          $exp = 8550063;
       break;

      case 34:
          $exp = 13220850;
       break;

      case 35:
          $exp = 18920754;

       break;

      case 36:
          $exp = 27970632;
       break;

      case 37:
          $exp = 43760064;
       break;

      case 38:
          $exp = 76490537;
       break;

      case 39:
          $exp = 177170075;
       break;

      case 40:
          $exp = 210240744;
       break;

      case 41:
          $exp = 261108543;
       break;

      case 42:
          $exp = 349330754;
       break;

      case 43:
          $exp = 453310747;
       break;

      case 44:
          $exp = 574920643;
       break;

      case 45:
          $exp = 795770537;
       break;

      case 46:
          $exp = 1060000000;
       break;

      case 47:
          $exp = 1450006578;
       break;
       
      case 48:
          $exp = 1920075475;
       break;

      case 49:
          $exp = 2810547474;
       break;

      case 50:
          $exp = 3860756848;
       break;

      case 51:
          $exp = 5630865478;
       break;

      case 52:
          $exp = 7690748585;
       break;

      case 53:
          $exp = 12590754850;
       break;

      case 54:
          $exp = 27430643760;
       break;

      case 55:
          $exp = 59690754680;
       break;

      case 56:
          $exp = 97270864760;
       break;

      case 57:
          $exp = 140707543600;
       break;

      case 58:
          $exp = 228660000777;
       break;

      case 59:
          $exp = 413457654586;
       break;
      
      case 60:
      
          $exp = 742690876546;
      
        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` = "1"'),0);




?>

<?

    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'] * 10).'",
                                       `mp` = "'.$user['mana'].'",
                                        `g` = "'.($user['g'] + $g).'" WHERE `id` = "'.$user['id'].'"');

?>



<div class="box"><div style="color:white;text-align:center;font-size:18px;">Новый Уровень!</div><div style="text-align:center;color:#a5a5a5;font-size:12px"><div style="color:khaki;font-size:14px"><img src="http://213.239.195.28/xaos/style2/money.png" alt=""/> Золото +<?=$g?></div>Вы получили <?=$user['level']?> уровень.</div><div class="separ2"></div><div class=""></div>

</div>

<?
        
    }

?>



<div class="box"><div class="butt_bott"><img src="http://213.239.195.28/xaos/style/heart.png" alt=""/> <?=$user['hp']?> <img src="http://213.239.195.28/xaos/style/energy.png" alt=""/> <?=$user['mp']?>


<?

if($mail > 0) {

?>

<a href='/mail/'>Н</a>

<?

}

?>


<a href='/inv/bag/'><?=(mysql_result(mysql_query('SELECT COUNT(*) FROM `inv` WHERE `user` = "'.$user['id'].'" AND `equip` = "0" AND `place` = "0" AND `new` = "0"'),0) > 0 ? '<font color=\'#FF0000\'>Рюкзак</font>':'')?></a>




</div>


<div class="exp"><div class="exp_in" style="width:<?=$exp_progress?>%;"></div></div><?title?><?$title?><?title?>




<?
        
    


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'].'?');
  
  }

?>

<div class='block'>
<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>
</div>

<?

}

}
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;
    
    }

?>

<div class='block'>
<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>

</div>

<?
    
    }

}

    }
    else
    {

?>
  




<?

    }

?>