<?php

include '../system/bd.php';
include '../system/cook.php';
include ("./system/head1.php");
if(isset($_SESSION['auth']) && $_SESSION['auth']==1){
include '../system/user.php';
include './system/user.php';
include '../system/func.php';
include './system/func.php';
include './system/hp.php';
include '../system/head1.php';


if($user[save] ==1 || 
   $user[save] ==2 ||
   $user[save] ==3 ||
   $user[save] ==4 ||
   $user[save] ==5){
header ("Location: start.php?go=step_$user[save]");
}


if($user){

     switch($user[lvl]) {
    
      case 1:
          $exp = 29;
       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 = 0;
       break;    
}
$exp_progress = round(100/($exp/$user[exp]));

    
    if($exp_progress > 100) {
        
     
        $exp_progress = 100;
    }
    }else{
$us=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id`='".intval($_GET['id'])."'"));
}

  
    if($clans){
     switch($cl[exp]) {

      case 1:
          $clan_exp = 300;
       break;

      case 2:
          $clan_exp = 50000;
       break;

      case 3:
          $clan_exp = 1110000;
       break;

      case 4:
          $clan_exp = 2100000;
       break;

      case 5:
          $clan_exp = 0;
       break;

 }
$exp_p = round(10/$cl[exp]);

    
    if($exp_p > 100) {
        
     
        $exp_p = 100;
    }
   }else{
$cl=mysql_fetch_assoc(mysql_query("SELECT * FROM `clans` WHERE `id`='".$user[clan]."'"));
}

///////


      
if($user)
{
echo "<span style='float: right;'> ";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `to`='".$user['id']."' AND `read`='0'"),0) && !isset($mail)){
	echo"
 <img src='../img/icon/mail.png'>";
}
echo"
<img src='/img/icon/gold.png' alt='*'/> ".number_format ($user[gold])."
<img src='/img/icon/silver.png' alt='*'/> ".number_format ($user[silver])."
</span>";
echo"
<img src='/img/icon/hp.png' alt='*'/> ".number_format ($user[hpfull])."
<img src='/img/icon/mp.png' alt='*'/> ".number_format ($user[mp])."  ";


}










echo' 
<div class="progress-black">
    <div class="progress-green" style="width:'.$exp_progress.'%;"></div></div>';
if($user[lvl] < 60 && $user[exp] >= $exp) {
    $g = 10+($user[lvl]*5)-5;
    mysql_query('UPDATE `user` SET 
`lvl` = `lvl` + "1", 
`gold`=`gold`+"'.$g.'",
`exp` = "0",
`mp`=`mpfull`,
`hp`=`hpfull`,
`spells` = `spells` + "1"
WHERE `id` = "'.$user[id].'"');


echo"
<font color='#f05010'>Вы получили новый уровень!</font>";
}
include './system/bonus.php';



}else{
header ("Location: index.php"); exit;
}
?>
