<?php

include 'core/sys.php';
include 'core/func_smiles.php';
//include 'core/browser.php';

if(isset($_GET['4iki'])){
mysql_query("UPDATE `set` SET `value`=`value`+1 WHERE `ind`=7");
}

$all_us = mysql_result(mysql_query("SELECT COUNT(id) FROM `users`"),0);

$count_online = mysql_result(mysql_query("SELECT COUNT(id) FROM `users` WHERE `time`+5000 >'".time()."'"),0);

if($user['id']>0){
	if($_SERVER['REMOTE_ADDR'] != $user['ip']){
mysql_query("UPDATE `users` SET `ip`='".protect($_SERVER['REMOTE_ADDR'])."' WHERE `id`='".$user['id']."'");
	}

	if($_SERVER['HTTP_USER_AGENT']  != $user['ua']){
mysql_query("UPDATE `users` SET `ua`='".protect($_SERVER['HTTP_USER_AGENT'])."' WHERE `id`='".$user['id']."'");
	}
	
$setq = mysql_query("SELECT * FROM `set_my` WHERE `usr` = '$user[id]' LIMIT 1");$set=mysql_fetch_array($setq);if ($set['razb']==0){mysql_query("INSERT INTO `set_my` SET `usr` = '$user[id]', `razb` = '1', `invmax`= '5', `arenainv`= '5'");}
/* Определяем комнату */ 
/*$room_sql = mysql_query("SELECT * FROM `room` ORDER BY `id`");
while($row_room = mysql_fetch_assoc($room_sql)){
if($row_room['user_level2']>$user['level']) break;
}
*/

head('Сердце Тьмы'); 

$in_loc =  mysql_fetch_assoc(mysql_query("SELECT * FROM `room` WHERE `id`='".$user['in_loc']."' LiMIT 1"));
$in_dok =  mysql_fetch_assoc(mysql_query("SELECT * FROM `hel_room` WHERE `id`='".$user['in_loc']."' LiMIT 1"));
$battle = mysql_query('SELECT * FROM `undying` WHERE `start` = "0"');
$battle = mysql_fetch_array($battle);
$battle=$battle['time'] - time();
	
// Логотип
if($_SERVER['PHP_SELF']=='/index.php'){
	if($user['logo']==1 or $user['id']<1){
?>
<div class="cito-name">Сердце Тьмы</div>
<center><img src="img/Star.jpg" width="100%" height="120" alt="*"></center>
</div>
</div><?
	}else{
	echo '';
	}
}

// Анекдоты
// Админ панель
if($user['admins']>0){
echo '
<div class="mini-line"></div>
<div class="block_zero center">
<a href="admins.php">
<div class="head"><b>
<span style="color: #9CC;">
Админ - панель
</span></b>
</div>
</a>
</div>
';
// Рефералы
$count_ref = mysql_result(mysql_query("SELECT COUNT(id) FROM `referal` WHERE `ok`='0'"),0);
	if($count_ref >0){
echo '
<div class="mini-line"></div>
<div class="block_zero center">
<a href="admins.php?refs">
<div class="head">
<span style="color: #9CC;">
Рефералы 
('.$count_ref.')
</span>
</div>
</a>
</div>
';
	}
echo '</div>';
}
// Ежедневный бонус
$day = 60*60*24;
$bonus_t = $user['bonus_time'] + $day;
if(time()>$bonus_t){
echo '
<div class="mini-line"></div>
<div class="block_zero center">
<a href="bonus.php">
<span style="color: #3C3;">
<div class="head">
Получить ежедневный бонус!
</span>
</div>
</a>
</div>';
}
//-----
$journal_u = mysql_result(mysql_query("SELECT COUNT(id) FROM `journal` WHERE `user_id`='".$user['id']."'"),0);
if($user['journal']>0){
$journal_new = ' | <span style="color: #3C3;">+'.$user['journal'].'</span>';
}else{
$journal_new = '';
}
$count_arena = mysql_result(mysql_query("SELECT COUNT(id) FROM `arena`"),0);
$chat_count = mysql_result(mysql_query("SELECT COUNT(id) FROM `chat`"),0);
$new_mess = '';
if($user['new_mess']>0){
$new_mess = '<span style="color: #3C3;">+'.$user['new_mess'].'</span>';
}
$news_count = mysql_result(mysql_query("SELECT COUNT(id) FROM `news`"),0);
// Приветствие
// Аура новичка (типа VIP)

//Вести

if($news_count > 0 AND $user['anekdot']=='4'){
$last_news = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT 1"));
	if(mb_strlen($last_news['text'])>1000){
$last_news['text']=mb_substr($last_news['text'],0,1000).'<a href="news.php">...<a/>';
	}
echo '
<div class="mini-line"></div>
<div class="block_zero center">
<a href="news.php">
<div class="head">
<span style="color: #9C9;">
ВЕСТИ
 ('.clock($last_news['time']).')
</span>
<div class="separ"></div>
<img src="img/other/npc/shero.gif" alt="admin">
<div class="separ"></div>
<span style="color: #9CC;">
 '.smile($last_news['text']).'
 </span>
 </div>
</a>
</div>
';
}
if (isset($_GET['close'])){
mysql_query("UPDATE `users` SET `anekdot` = '5' WHERE `id` = '$user[id]'");
header('Location: index.php');exit;
}
if($news_count > 0 AND $user['anekdot']=='4'){
echo' <center><a href="index.php?close"><span class="btn"><span class="end"><input class="label" type="submit" value="Скрыть"></span></span></a></center>';
}

// Главное меню
?>





<table width="100%"><tr><td width="50%"><a class="btn nav-btn" href="/sxvatki.php"><img src="/img/stat/topor.png" alt="*" width="12" height="12"class="link-icon"/>Схватки</a></td><td width="50%"><a class="btn nav-btn"href="all_us"><img src="/img/stat/topor.png" alt="" width="12"height="12" class="link-icon"/>Общение</a></td></tr></table><table width="100%">
<table width="100%"><tr><td width="50%"><a class="btn nav-btn" href="/led.php"><img src="/img/stat/topor.png" alt="*" width="12" height="12"class="link-icon"/>Бедствие</a></td><td width="50%"><a class="btn nav-btn"href="clan.php"><img src="/img/stat/topor.png" alt="" width="12"height="12" class="link-icon"/>Кланы</a></td></tr></table><table width="100%">
<table width="100%"><tr><td width="50%"><a class="btn nav-btn" href="/zamok"><img src="/img/stat/topor.png" alt="*" width="12" height="12"class="link-icon"/>Замок</a></td><td width="50%"><a class="btn nav-btn"href="hram.php"><img src="/img/stat/topor.png" alt="" width="12"height="12" class="link-icon"/>Храм</a></td></tr></table><table width="100%">
<table width="100%"><tr><td width="50%"><a class="btn nav-btn" href="/hard.php"><img src="/img/stat/topor.png" alt="*" width="12" height="12"class="link-icon"/>Смотрители</a></td><td width="50%"><a class="btn nav-btn"href="dozor.php"><img src="/img/stat/topor.png" alt="" width="12"height="12" class="link-icon"/>Дозор</a></td></tr></table><table width="100%">
<a class="btn nav-btn"href="/astral"><img src="/img/icon/duhi.png"width="21"height="21"><span>Астрал</span></a>
<a class="btn nav-btn"href="/catacombi.php"><img src="/img/icon/duhi.png"width="21"height="21"><span>Подземелье</span></a>






<?




echo'</div>';
echo'<center><div class="b-menu"><table width="100%"><tbody><tr><td colspan="3" ></td></tr><tr><td width="33%"><a class="menu_btn"href="/index.php?"
><img src="/img/astar/city.png"width="32"height="32"><div class="mt5">Город</div></a></td><td width="33%"><a class="menu_btn"href="/my.php"><img src="/img/astar/user.png"width="32" height="32"><div
class="mt5">Персонаж</div><span class="amu-lvl">'.
$user['level'].'</span></a></td>
<td width="33%">
<a class="menu_btn"href="/bag"><img src="/img/astar/inv.png"width="32" height="32"><div class="mt5">Рюкзак</div>
</a></td></tr></tbody></table>
</div></center>';












}
else{

head('Сердце Тьмы');

require_once 'core/online_guest.php'; 

function users ( $all_us, $form1, $form2, $form3 ) {
$all_us = abs ( $all_us ) % 100;
$all1 = $all_us % 10;
if ( $all_us > 10 && $all_us < 20 ) return $form3;
if ( $all1 > 1 && $all1 < 5 ) return $form2;
if ( $all1 == 1 ) return $form1;
return $form3; }

echo '

<div class="foot center">

<font color="silver">

«Сердце Тьмы»

</div>

<div class="line"></div>

<div class="main">

<div class="block_zero center">

<img src="img/glav.jpg" width="310" height="120" alt="logo">

</div>

<div class="mini-line"></div>

<div class="block_zero center">



<div class="separ"></div>

<h1 class="yellow">

С нами уже 
'.$all_us.' '.users($all_us,'игрок','игрока','игроков').'

</h1>

</div>

<div class="mini-line"></div>

<br/>

<center>

<a href="signup.php">

<div class="mt10 form-submit"><input class="btn-big btn-big-red" type="submit" value="Регистрация"></div></form></a>


<br/>

<a href="sign.php">

<div class="mt10 form-submit"><input class="btn-big btn-big-red" type="submit" value="Войти"></
div></form></a>



</span>

</span>

<br/>

<br/>

</div>

<div class="line"></div>

</font>

</div>

';

list ( $ms , $s ) = explode ( chr ( 32 ) , microtime ( ) );

date_default_timezone_set('Europe/Moscow');

?>

<div class="block_zero center">

<span class="small grey">

<?

echo"".round ( ( ( $s + $ms ) - $g ) , 4)." сек., ";

echo date("H:i:s");

?> | Онлайн: <?=$count_online?><?

?>

<br/>

«Сердце Тьмы» @ 2014
 
 <br/>
 
<?
 
// счётчики, реклама --------------







//----------------------------------
 
?>

</div>

</span>

</body>

</html><?

exit;

}

foot();

?>