<?
    
    include './system/common.php';
    
 include './system/functions.php';
        
      include './system/user.php';
        
    $title = 'Битва титанов';

include './system/h.php';  

    if($user) {

if($mail > 0) {

?>

<div class='list'>
  <li><img src='/images/icon/mail.png' alt='*'/> <a href='/mail/'>Новая почта</a></li>
</div>

<?

}    








?>


  
<div class='content' align='center'><img src='/images/logo_1.png' alt='*'/></div>
<div class='line'></div>
<div class='list'>
  <li><a href='/arena/' style='display: block;'><img src='/images/icon/arena.png' alt='*'/> Арена <?=($user['mp'] > 49 ? '<font color=\'#30c030\'>(+)</font>':'')?></a></li>

<?

  if($user['level'] > 4) {

?>

  <li><a href='/duel/' style='display: block;'><img src='/images/icon/league.png' alt='*'/> Дуэли <?=($user['duel_fights'] > 0 ? '<font color=\'#30c030\'>(+)</font>':'')?></a></li>

<?

  }

  if($user['level'] > 9) {

?>

  <li><a href='/coliseum/' style='display: block;'><img src='/images/icon/coliseum.png' alt='*'/> Колизей</a></li>

<?

  }

  $undying = mysql_query('SELECT * FROM `undying` WHERE `start` = "0" LIMIT 1');
  $undying = mysql_fetch_array($undying);  

?>

  <li><a href='/undying/'><img src='/images/icon/bar.png' alt='*'/> Долина бессмертных</a>

<?
  
if($undying) {

if(($undying['time'] - time())<=301 && ($undying['time'] - time())>0){

?>

<br/><font color='#909090'>Начало через <?=makestime(($undying['time'] - time()))?></font>
<br/><a href='/undying/'>Перейти к сражению</a>

<?

}

  }

?>

  </li>

  <li><a href='/fights/'><img src='/images/icon/arena.png' alt='*'/> Сражения</a></li>
<?

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

?>
  <li class='no_b'><a href='/cave/'><img src='/images/icon/cave.png' alt='*'/> Пещера <?=(($cave['dawn'] == 0 OR $cave['dawn'] == 1 && $cave['time'] <= time() OR $cave['dawn'] == 1 && $cave['gather'] == 1 && $cave['time'] <= time()) ? '<font color="#30c030">(+)</font>':'')?></a></li>

</div>

<div class='line'></div>

<div class='list'>
<?

//  <li><a href='/trade/' style='display: block;'><img src='/images/icon/gold.png' alt='*'/> Получить золото</a></li>
 
?>
 <li><a href='/shop/' style='display: block;'><img src='/images/icon/equip.png' alt='*'/> Магазин снаряжения</a></li>
<?

if($user['level'] > 2) {

?>

  <li><a href='/farm/' style='display: block;'><img src='/images/icon/farm.png' alt='*'/> Поход

<?

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

  if(!$farm OR $farm['h'] == 0 && $farm['time'] == 0 OR $farm['h'] > 0 && $farm['time'] <= time()) {

?>

<font color='#30c030'>(+)</font>

<?

  }
  
  }

?>
  
  </a></li>

  <li><a href='/smith/' style='display: block;'><img src='/images/icon/smith.png' alt='*'/> Кузница</a></li>

  <li class='no_b'><a href='/lab/' style='display: block;'><img src='/images/icon/lab.png' alt='*'/> Лабаратория</a></li>

</div>

<div class='line'></div>

<div class='list'>
  <li><a href='/clans/' style='display: block;'><img src='/images/icon/clan.png' alt='*'/> Кланы</a></li>
  <li class='no_b'><a href='/rating/' style='display: block;'><img src='/images/icon/user.png' alt='*'/> Зал славы</a></li>
</div>


<?

    if(isSet($_GET['exit'])) {
    
        setCookie('id', '');
  setCookie('password', '');
    
    header('location: /');
    
    }
    


    }
    else
    {


$login = _string($_POST['login']);
  $login = strToLower($login);

    $password = _string($_POST['password']);


    if($login && $password) {
    
    $q = mysql_query('SELECT * FROM `users` WHERE `login` = "'.$login.'" AND `password` = "'.$password.'" LIMIT 1');
 
 $user = mysql_fetch_array($q);
      
      if($user) {
    
    setCookie('id', $user['id'], time() + 86400, '/');
setCookie('password', $password, time() + 86400, '/');
    
    
      header('location: /');
      
      }
    
    }

$ref = _string(_num($_GET['ref']));

?>

<div class='content' align='center'>
<img src='/images/logo_1.png' alt='*'/><br/><br/>
<a href='/start/<?=$ref?>/' class='button'>Начать свой путь!</a><br/><br/>
  <font color='#f0c060'>В игре уже <?=n_f(mysql_result(mysql_query('SELECT COUNT(*) FROM `users`'),0))?> персонажей!</font>
</div>

<div class='line'></div>

<div class='content' align='center'>
  <form action='/' method='post'>

    Имя персонажа:<br/>   <input name='login'/><br/>
           Пароль:<br/><input name='password'/><br/>
    
  <input type='submit' value='Войти'/>

  </form>
</div>

<?

    }
    
include './system/f.php';

?>