<?
    
    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'>
<div class='line'></div>
  <li><a href='/mail/'>Новая почта</a></li>
<div class='line'></div>
<div class='list'>
</div>

<?

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

<div class='content'><center><font color=\'#30c030\'>Новая тема в новостях!</font>
<div class='separator'></div>
<img src='/images/icon/forum_2.png' alt=''/> 
<b>Последний день акции!</b> 
<img src='/images/icon/forum_2.png' alt=''/>
<div class='mb10'></div><a class='btn' href='/forum/topic/130/'>
<span class='end'><span class='label'>Посмотреть новость</span></span></a><br>
*/
?>





<div class='content' align='center'><img src='/images/logo_1.png' alt='*'/></div>
<div class='separator'></div>
<center><img src='/images/icon/gold.png' alt=''/> 
Скидка 80% на покупку золотых!
<img src='/images/icon/gold.png' alt=''/>
<div class='mb10'></div><a class='btn' href='/worldkassa/buy.php'>
<span class='end'><span class='label'>Купить золото</span></span></center></a>
<div class='separator'></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='*'/> Долина бессмертных

<?
  
  if($undying) {

   $undying_time = round(($undying['time'] - time()) / 3600);
if($undying_time > 1) {

?>

<font color='#909090'>(< <?=$undying_time?> час<?=($undying_time > 1 ? 'ов':'а')?>)</font></a>

<?

}
else
{

?>

<font color='#909090'>(<?=_time(($undying['time'] - time()))?>)</font></a>

<?

}

  }

?>

  </li>
<?

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

?>
  <li><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>



<?php

$q = mysql_query ('select * from `user_q` WHERE (`user`="' . $user['id'] . '") AND (`complete`="0")');
if (mysql_num_rows ($q) != 0) {
    
    while ($user_q = mysql_fetch_array ($q)) {
            
        // 
        $q_ = mysql_query ('SELECT * FROM `quest` WHERE (`id`="' . $user_q['q'] . '")');
        $quest = mysql_fetch_array ($q_);
        
        if ($user_q['c']==$quest['c'])
            $sage_flag = true;

    }

}

?>



    <li><a href='/sage.php'><img src='/images/icon/quest.png' alt=''/> Хижина мудреца<?= ( $sage_flag ? ' <span style="color:#30c030;">(+)</span>':'' ) ?></a></li>



</div>

<div class='list'>
  <li><a href='/worldkassa/buy.php/' style='display: block;'><img src='/images/icon/gold.png' alt='*'/> Получить золото</a></li>
<li><a href='/exchange.php' style='display: block;'><img src='/images/icon/silver.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'>Впервые на мобильниках.<br> Игра, о которой ходят легенды<br>Теперь к легенде можешь прикоснуться и ты!</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';

?>