<?php
defined('PROTECTOR') OR die('Ошибка: нет доступа');

$t=time();
$req = mysql_query("SELECT * FROM `ban` WHERE `usr` = '$log' LIMIT 1");
$avtob = mysql_num_rows($req);
if ($avtob == 1) {
 $ban = mysql_fetch_array($req);
if($ban['ban_time']<$t){
mysql_query("DELETE FROM `ban` WHERE `usr` = '$log'");
}else{
if($ban['block']==1){
$vrem=$ban['ban_time']-time();
echo'<div class="block_zero"><span style="color: #ff3434;">Ваш персонаж заблокирован!<br>Причина: '.$ban['text'].'<br>Осталось: '.Sec2Time($vrem).'<br>Забанил: '.$ban['admin'].'</span></div>';
exit();
}
}
}

if ($user_id=='1'){
include('../files/lvl.php');
if(empty($header)){
$udata = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr` = '$log'"));
echo'<div class="foot">'.$head.'<span style="float: right;"><img src="../image/icon/health.png" alt="*"> '.$udata['hp'].' | <img src="../image/icon/mana.png" alt="*"> '.$udata['mp'].'</span></div>';

if(isset($ol) AND isset($op)){
$exp=round((($udata['exp']-$ol)/($op-$ol))*100);
}else{
$ol=false;
$op=false;
$exp=false;
}

echo '<div class="exp_bar"><div class="progress" style="height:1px; width: '.$exp.'%;"></div></div>';

/*
$proc=($udata['hp']/$udata['hpall'])*100;
$proc2=($udata['mp']/$udata['mpall'])*100;
echo"<div class='stat_bar'><div class='progress blue' style='width:$proc%'></div></div>";
echo"<div class='stat_bar'><div class='progress blue' style='width:$proc2%'></div></div>";
*/

$set = mysql_fetch_assoc(mysql_query("SELECT * FROM `set` WHERE `usr` = '$log'"));
$time=time();
$ab = $set['viptime'] -$time;
if($set['vip']=='on'){
echo'<div class="block_zero center"><a href="vip.php?"><div class="head"><span style="color: #939;">VIP, осталось '.Sec2Time($ab).'</span></div></a></div>';
}

//-----



$req=mysql_query("SELECT * FROM `rydnik` WHERE `usr`='$log'");
$rydnik=mysql_fetch_array($req);
$avto=mysql_num_rows($req);
if($rydnik['over']<=time() AND $udata['s5']=='1'){
$time = date("H:i d.m.y");
$text = "Поиск Артефакта завершён!";
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Хозяйка Медной горы', `user_to` = '$log', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
mysql_query("UPDATE `users` SET `s5` = '0' WHERE `usr` = '$log'");
}

$pohod = mysql_fetch_array(mysql_query("SELECT * FROM `dozor` WHERE `usr` = '$log'"));
$mag = mysql_fetch_array(mysql_query("SELECT * FROM `mag` WHERE `usr` = '$log'"));
if($pohod['over']<=time() AND $mag['vihr2']=='1'){ 
$time = date("H:i d.m.y");
$text = "Вы вернулись из похода!";
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Дозорная башня', `user_to` = '$log', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
mysql_query("UPDATE `mag` SET `vihr2` = '0' WHERE `usr` = '$log'");
}

if (isset($_SESSION['message'])){
echo "<div class='ok center'><img src='/image/icon/ok.png'> $_SESSION[message]</div>";
$_SESSION['message']=NULL;
}
if (isset($_SESSION['err'])){
echo "<div class='error center'><img src='/image/icon/error.png'> $_SESSION[err]</div>";
$_SESSION['err']=NULL;
}



$q = mysql_query("SELECT COUNT(*) FROM `msg_r` WHERE `user_to` = '$log' AND `read` = '1';");
$new_mail = mysql_result($q, 0);
if($new_mail > 0){
echo'<div class="block_zero center"><a href="msg.php?mod=read"><div class="head"><span style="color: #3c3;">Почта +'.$new_mail.'</span></div></a></div>';
}


$pri = mysql_query("SELECT * FROM `zametka` WHERE `id` = '1' AND `status`='on'");
$prim = mysql_num_rows($pri);
$prime = mysql_fetch_array($pri);
if($prim > 0 AND $set['prim']=='on'){
echo'<div class="block_zero center"><a href="index.php?mod=prim"><div class="head"><span style="color: #3c3;">Объявление</span></div></a></div>';
}

if($dueli==1){
$req = mysql_query("SELECT `duid` FROM `userduel` WHERE `usr` = '$log' LIMIT 1");
$duel = mysql_fetch_array($req);
$redu = mysql_query("SELECT * FROM `duel` WHERE `id` = '$duel[duid]' LIMIT 1");
$due = mysql_fetch_array($redu);
if($due['status']=="sob" and $due['time']<$t){
mysql_query("UPDATE `duel` SET `status` = 'begin' WHERE `usr` = '$log' and `id`='$due[id]'") or die (mysql_error());
}
$reduk = mysql_query("SELECT * FROM `duel` WHERE `id` = '$due[id]' LIMIT 1");
$duel = mysql_fetch_array($reduk);
$vremya1=$duel['time']-$t;
$vremy=floor($vremya1/60);
$vremya=$vremya1-($vremy*60);
if($vremya<10){$vremya="0$vremya";}
$vrem="$vremy:$vremya";
if($vremya<1){
//header('Location: fiting.php');exit;
}
if($duel['status']=="sob"){ 
echo'<div class="block_zero center"><a href="duel.php?"><div class="head"><span style="color: #3c3;">Бой в Колизее через '.Sec2Time($vremya1).'</span></div></a></div>';
}
if($duel['status']=="begin" AND $head!=="duel"){ 
echo'<div class="block_zero center"><a href="duel.php?"><div class="head"><span style="color: #3c3;">Идёт бой в Колизее!</span></div></a></div>';
}
}
//**********
$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `status`='1'");
$avto=mysql_num_rows($req);
if($avto==1){
$aur = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `aurs` WHERE `usr`='$log'");
$avto=mysql_num_rows($req);
$aro = mysql_fetch_array($req);

$ab = $aro['actimer'] -time();
echo'<div class="block_zero center"><a href="shopaura.php?"><div class="head"><span style="color: #999;">'.$aur['name'].': осталось '.Sec2Time($ab).'</span></div></a></div>';
echo'</div>';
}

echo'</div><div class="f_bg"></a>';
}
}else{
echo "<div class=\"f_bg\">Ошибка!Вы не авторизованы!<br><a href='index.php?vxod'>Авторизуйтесь</a>
<div>";
include('files/end.php');exit;
}
?>