<?php
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 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head><title>Городские разборки</title><link rel="stylesheet" href="http://'.$set['site'].'/style/theme/style.css" type="text/css"/><link rel="icon" href="/favicon.ico" type="image/x-icon"/></head><body class="xxx"><div class="content">';
$q_gift = mysql_query("SELECT * FROM `user_podarok` WHERE `user_id` = '$user[id]'");
$gift = mysql_fetch_array($q_gift);
$time = $gift['last_auth'] + 84600;
$now = time();
if(isset($user['id']))
{
$level = file(H."data/exp.txt");

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

$exp_gold = (20+(($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='link-div'>";
echo "<center><a href='/bonus.php' class='link-block-menu'><img src='/images/icon/gold.png'> Ежедневный подарок</a></div></center>";}
echo"<div class='line'></div><div class='logo'><a href='/'><img src='/style/theme/images/logo.gif' width='170' height='25' alt='.' /></a></div><div class='line'></div><div class='block10t'></div>";
echo "

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

<div class='mainPageUserInfo' style='text-align:center;'><a href='/gold/webmoney.php' style='display: inline;' class='link-block-header'><span class='icon'><img src='/images/icon/silver.png' width='16' height='16' alt='.'/> ".number_format($user[silver],NULL,NULL,"'")."</span></a><span class='icon'><img src='/images/icon/level.png' width='16' height='16' alt='.'/><font color=#FFCC99> ".$user[level]."</font></a></span></a><span class='icon'><img src='/images/icon/exp.png' width='16' height='16' alt='.'/><font color=#FFCC99> $user[exp]/$exp</font> </span></a><span class='icon'><img src='/images/icon/mana.png' width='16' height='16' alt='.'/><font color=#FFCC99> ".$user[mana]."</font></span><a href='/showHospital.php' style='display: inline;' class='link-block-header'><span class='icon'><img src='/images/icon/health.png' width='16' height='16' alt='.'/> ".$user[health]."</span></a><a href='/gold/webmoney.php' style='display: inline;' class='link-block-header'><span class='icon'><img src='/images/icon/gold.png' width='16' height='16' alt='.'/> ".number_format($user[gold],NULL,NULL,"'")."</span></a><a href='/Obshenie.php' style='display: inline;' class='link-block-header'><span class='icon'><img src='/images/icon/mail.png' width='16' height='12' alt='.'/></span></a></div><div class='line'></div>
";

if($k_new > 0)echo " | <a href='/user/new_mess.php'><img src='/images/icon/mail.png'></a>";
echo "

<div class='exp_bar'>

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

</div>";
}else{
echo "<div class='line'></div><div class='logo'><a href='/'><img src='/style/theme/images/logo.gif' width='170' height='25' alt='.' /></a></div><div class='line'></div><div class='block10t'></div>";
}
if (isset($_SESSION['message'])){
echo "<div class='block10t'><div class='panelError'><img src='/images/icon/ok.png'> $_SESSION[message]</div></div>";
$_SESSION['message']=NULL;
}
if (isset($_SESSION['err'])){
echo "<div class='error center'> $_SESSION[err]</div>";
$_SESSION['err']=NULL;
}
if(isset($user['id']))
{
if (isset($_SESSION['light'])){
echo "<div class='block_light center'>$_SESSION[light]</div>";
$_SESSION['light']=NULL;
}

if($user['exp'] >= $exp)
{

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");
header('Location: /splash.php');
$_SESSION['light'] = "";
exit();
}
}


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

$g = $s + $ms;


$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` + '1' where `id` = '".$m['id']."'");
}
}
?>