<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Expires: " . date("r"));
echo ban();



echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">';
echo '<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">';
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">';
echo '<meta http-equiv="Cache-Control" content="no-cache">
<head><title>'.$header.'</title>';
if($user[diz] == 1){echo'<link rel="stylesheet" href="/style/theme/alternative.css" type="text/css"/>';}
if($user[diz] == 2){echo'<link rel="stylesheet" href="/style/theme/test.css" type="text/css"/>';}
else{echo'<link rel="stylesheet" href="/style/theme/style.css" type="text/css"/>';}
echo'<link rel="icon" href="/favicon.ico" type="image/x-icon"/>
</head>
<body>
<div>';

$q_gift = mysql_query("SELECT * FROM `user_podarok` WHERE `user_id` = '$user[id]'");
$gift = mysql_fetch_array($q_gift);
$time = $gift['last_auth'] + 3600*24;
$now = time();
if(isset($user['id']))
{
$level = file(H."data/exp.txt");

$exp = trim($level[$user[level]+1]);

$exp_gold = (10+(($user['level']-1)*2));

$k_new = mysql_result(mysql_query("SELECT COUNT(*) FROM `users_konts` WHERE `id_user` = '".$user[id]."' AND `new_msg`"),0);








    
if ($time < $now) {
echo "<div class='menuList'>";
echo "<li><center><a href='/bonus'><img src='/images/icon/gift.png'>Бонус</a></center></li></div><div class='line'></div>";}
echo "<div class='main' style='word-wrap:break-word;'>

<span style='text-shadow:none;'></span>

<div class='head center' onclick='location.href=\"/index.php\"'>

<img src='/images/icon/health.png' alt='hp'/> ".(INT)$user[health]." | <img src='/images/icon/mana.png' alt='mp'/> ".(INT)$user[mana]." |
<img src='/images/icon/exp.png' alt='exp'/><span class='grey'> (".round(100/($exp/($user[exp]+1)))."%)</span>";
if($k_new > 0)echo " | <a href='/user/new_mess.php'><img src='/images/icon/mail.png'></a>";
echo "</div>

<div class='exp_bar'>

<div class='progress' style='width:".round(100/($exp/($user[exp]+1)))."%'></div>

</div>";
$q = mysql_query("SELECT * FROM `invite` WHERE `user_id` = '".$user['id']."'");
while($row = mysql_fetch_assoc($q)) {
    $nick = mysql_fetch_assoc(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '".$row['owner_id']."' LIMIT 1"));
    $clan = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '".$row['clan_id']."' LIMIT 1"));
    echo "<div class='player'>
    <center>
    <img src='/images/icon/clan.png'>
    Игрок <a href='/user/".$row[user_id]."'>$nick[nick]</a> приглашает Вас вступить в клан
    <a href='/clan/clan?id=".$row[clan_id]."'>$clan[name]</a><br />
    [<a href='/clan/enter?accept=".$row[id]."'>Принять приглашение</a>/<a href='/clan/enter?decline=".$row[id]."'>Отказаться</a>]
    </center>
    </div>
    <div class='line'></div>";
}
if($user['clan_mess'] > 0) {
    $clans = mysql_fetch_assoc(mysql_query("SELECT * FROM `clans` WHERE `id` = '".$user['clan_id']."' LIMIT 1"));
    $message = htmlspecialchars($clans['message']);
    echo "<div class='player'>
    <center>
    <b>Клановое объявление</b><br />
    $message<br />
<span class='green'>Добавил:</span><a href='/user/".$clans[ad_id]."/'>".$clans[ad_nick]."</a></br>
    <a href='/clan/mess.php'>Ознакомился</a>
    </center>
    </div>
    <div class='line'></div>";
    
}
}else{
echo"<div class='head center'><div class='center'>Битва Титанов</div></div>";
}
if (isset($_SESSION['message'])){
echo "<div class='ok center'><img src='/images/icon/ok.png'> $_SESSION[message]</div>";
$_SESSION['message']=NULL;
}

if (isset($_SESSION['err'])){
echo "<div class='error center'><img src='/images/icon/error.png'> $_SESSION[err]</div>";
$_SESSION['err']=NULL;
}
if (isset($_SESSION['confirm'])){
echo "<hr />$_SESSION[confirm]<hr />";
$_SESSION['confirm']=NULL;
}
if ($_SERVER['PHP_SELF'] !='/index.php') {
echo "<div class='player title'>$header</div><div class='mini-line'></div>";
}
if(isset($user['id']))
{
if (isset($_SESSION['light'])){
echo "<div class='block_light center'>$_SESSION[light]</div>";
$_SESSION['light']=NULL;
}

if($user['exp'] >= $exp)
{
header('Location: /index.php');
mysql_query("update `user` set `level` = '".($user['level']+1)."',`exp`='0',`gold`='".($user['gold']+$exp_gold)."',`health`='".($user['max_health'])."',`mana`='".($user['max_mana'])."' where (`id` = '".$user['id']."') LIMIT 1");

$_SESSION['light'] = "<span class='quality-4'>Вы получили новый уровень!</span><div class='separ'></div><span class='blue'>Награда:</span> <img src='/images/icon/gold.png' alt=''/> $exp_gold золота";
exit();
}
}


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

$g = $s + $ms;


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

$g = $s + $hs;

$manka = mysql_query("SELECT id,mana,max_mana from `user` order by `id` desc");
while($m = mysql_fetch_assoc($manka)){ if($m['mana'] + 1 > $m['max_mana']){
mysql_query("UPDATE `user` set `mana` = '".$m['max_mana']."' where `id` = '".$m['id']."'"); 
}else{
mysql_query("UPDATE `user` set `mana` = `mana` + '0.9' where `id` = '".$m['id']."'");
}
}


$helka = mysql_query("SELECT id,health,max_health from `user` order by `id` desc");
while($m = mysql_fetch_assoc($helka)){ if($m['health'] + 0 > $m['max_health']){
mysql_query("UPDATE `user` set `health` = '".$m['max_health']."' where `id` = '".$m['id']."'"); 
}else{
mysql_query("UPDATE `user` set `health` = `health` + '0.8' where `id` = '".$m['id']."'");
}
}
$us = mysql_fetch_assoc(mysql_query("SELECT * FROM `us_ban` where `usid` = '".$user['id']."' and `type` = 'game' and `time`>'".time()."' "));
$nick = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` where `id` = '".$us['usban']."'"));
if($us['time'] > time()){
header("location:/ ");
}
$us2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `us_ban` where `usid` = '".$user['id']."' and `type` = 'n' and `time`>'".time()."' "));
if($us2['type']=="n"){
?>
Ваш персонаж заблокирован на всегда!
<?
exit();
}
?>