<?php
require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
$page_title = 'Мой профиль';
require_once('conf/head.php');
if ((isset($_SESSION['id'])) and (isset($_SESSION['nick'])))  {
$user_id = abs(intval($_SESSION['id']));
$query_loc = "update users set location = 'me' where id = '$user_id' limit 1";
$result_loc = mysqli_query($dbc, $query_loc) or die ('Ошибка передачи запроса к БД');
require_once('conf/top.php');
}
$query = "Select * from users where id = '$user_id' limit 1";
$result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД');
$row = mysqli_fetch_array($result);
$mentor_time = $row['mentor_time'];
$mentor_type = $row['mentor_type'];
$pistols_yron = 0;
$weapons_yron = 0;
$pistols_tochn = 0;
$weapons_tochn = 0;
$hp_cl = 0;
$prochn_cl = 0;
$last_active = $row['last_active'];
$last_active = strtotime("$last_active");
$now = (date("Y-m-d H:i:s"));
$now = strtotime("$now");
$razn_last_act = ($now - $last_active);
?><br/>
<center> <p class="profile" style="border-top:1px solid #000000; background-color:#000000;">Воин <span class="net"><?php
if ($row['gruppa'] == 'svoboda')  {?><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php }
if ($row['gruppa'] == 'dolg') {?><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php }
if ($row['gruppa'] == 'naemniki') {?><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php }
if ($row['gruppa'] == 'renegat') {?><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php }
if ($row['gruppa'] == 'chistoenebo') {?><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php }
echo ' '.$row['nick'].'</span></p></center>';
 if ($row['vip'] ==1) {?><center><div style="background-color: #0B0B0B;"><img src="img/avatars/<?php echo $row['avatar']; ?>" width="150" height="210" border="0" class="upl" style="border: 3px outset gold;"/></a></center><?php }
 if ($row['vip'] < 1) {?><center><div style="background-color: #0B0B0B;"><img src="img/avatars/<?php echo $row['avatar']; ?>" width="150" height="210" border="0" /></a></center><p></span></p><?php }
 if($row['viptime'] < time()){
 $pdo->exec("UPDATE `users` SET `vip` = '0', `viptime` ='0' where `id`='".$user_id."'");}
if($row['viptime'] > time())
{
$time=$row['viptime']-time();
echo'<div style="background-color: #1E1E1E;">
<p style="border-top: solid 1px #444e4f"></p>';
echo"<font color='gold'> Вип закончиться через:</font><span class='bonus'> ";
$row[viptime]=$row[viptime]-time();
if($row[viptime]<60){
echo "$row[viptime] сек.</br>";

}elseif($row[viptime]>=60 and $row[viptime]<3600){
$row[viptime]=round($row[viptime]/60);
echo "$row[viptime] мин.<br>";

}elseif($row[viptime]>=3600 and $row[viptime]<86400){
$row[viptime]=round($row[viptime]/3600);
echo "$row[viptime] час.<br>";}
else{
$row[viptime]=round($row[viptime]/86400);
echo "$row[viptime] дн.<br>";}


echo'</span><p style="border-top: solid 1px #444e4f"></p></div><div class="stats"></div>';
}

?>

<div style="background-color: #1E1E1E;">
 <p><span class="darkkhaki"><img src="img/ico/money.png" width="12" height="12"/> Золота: <span class="white"><?php echo $row['money']; ?></span></p>
 <p><span class="darkkhaki"><img src="img/ico/materials.png" width="12" height="12"/> Серебра: <span class="white"><?php echo $row['habar']; ?></span></p>
<?php
  
  $time = (date("Y-m-d H:i:s"));
  $time = strtotime("$time");
  $antirad_time = $row['antirad_time'];
  $antirad_time = strtotime("$antirad_time");
  $antirad_time = ($time - $antirad_time);
  if ($antirad_time <= 7200) {
  $echo_time = (7200 - $antirad_time);
  $hours_time = ($echo_time/3600);
  $hours_time = floor($hours_time);
  $minutes_time = ($echo_time - (3600 * $hours_time));
  $minutes_time = ($minutes_time/60);
  $minutes_time = floor($minutes_time);
  $seconds = ($echo_time - ($hours_time*3600) - ($minutes_time*60));
  ?><span class="darkkhaki"><img src="img/ico/antirad.png" width="12" height="12"/>Зелье:</span> <span class="bonus">[<?php echo "$hours_time:$minutes_time:$seconds";?>]</span><?php 
  } 
   ?>
 <p><span class="darkkhaki"><img src="img/ico/point.png" width="12" height="12"/> Активность: <span class="white"><?php echo $row['activ']; ?></span></p>
<?php

$query_lvl = "Select lvl, opit from opit order by lvl desc";
$result_lvl = mysqli_query($dbc, $query_lvl) or die ('Ошибка передачи запроса к БД');
$row_lvl = mysqli_fetch_array($result_lvl);
$big_next_lvl = $row_lvl['opit'];
$lvl=$row_lvl['lvl'];
while (($row['opit']/100)< $row_lvl['opit']) {
$next_lvl = $row_lvl['opit'];
$lvl=($lvl-1);
	  $row_lvl = mysqli_fetch_array($result_lvl);
	  }
	  if ($next_lvl == 0) {
	    $next_lvl = "$big_next_lvl" ;
	  } 
	  $inv2="$lvl";
?></span>
	<p><span class="darkkhaki"><img src="img/ico/star.png" width="12" height="12"/> Опыт: </span><span class="white"><?php 
	if ($lvl <=2) {
	$opit = $row['opit'];
	echo ($opit);  $next_lvl = ($next_lvl*100); echo " / $next_lvl";?></><?php

	} 
	else {
	$opit = ($row['opit']/100);
	$opit = round($opit,0);
	echo ($opit/100); ?>к<?php $next_lvl = ($next_lvl/100); echo " / $next_lvl";?>к</> 
	<?php
	}
echo'<span class="net"> ('.$exp.'%)</span></p>';
	  ?></div></span>
<p style="border-top: solid 1px #444e4f"></p>
<p class="net">Охота:</p>
<div style="background-color: #1E1E1E;">
<p class="podmenu" style="border-top:1px solid #444e4f; background-color:#1c252f;"></p>
<?php
if ($row[glas_ploti]== '0' and $row[noga_snorka] =='0' and $row[hvost_psa] =='0' and $row[k_kabana] == '0' and $row[sch_krovik] == '0' and $row[hvost_sobaki] == '0'){echo '<p>Нет трофеев';}

if($row[glas_ploti]> '0'){ echo '<p>Посох: <span class="white">'.$row[glas_ploti].' штук</span>';}
if($row[noga_snorka] >'0'){echo '<p>Стрелы: <span class="white">'.$row[noga_snorka].' штук</span>';}
if($row[hvost_psa] >'0'){ echo '<p>Глаз: <span class="white">'.$row[hvost_psa].' штук</span>';}
if($row[k_kabana]> '0'){echo '<p>Кость: <span class="white">'.$row[k_kabana].' штук</span>';}
if($row[sch_krovik] > '0'){ echo '<p>Хвост: <span class="white">'.$row[sch_krovik].' штук</span>';}
if($row[hvost_sobaki]>'0'){echo '<p>Рука зомби: <span class="white">'.$row[hvost_sobaki].' штук</span>';}
 

	?>
<p class="podmenu" style="border-top:1px solid #444e4f; background-color:#1c252f;"></p>
</div>

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




<table class="foot" width="100%" border="0" cellpadding="0" cellspacing="0" style="padding-top: 5px;">
<tbody>
<tr>
<td width="33%">
<a class="big-but" href="profile.php?id=<?php echo $row['id']; ?>">
<div class="imgwrap"><img src="img/ico/profile.png"></div>
<span>Профиль</span></a>
</td>	
<td width="33%">
<a class="big-but" href="events.php">
<div class="imgwrap"><img src="img/ico/star.png"></div><span>События</span></a>
</td>
<td width="33%">
<a class="big-but" href="profi.php">
<div class="imgwrap"><img src="img/ico/ok.png"></div><span>Професии</span></a>
</td>
</tr><tr><td width="33%">
<a class="big-but" href="sumka.php">
<div class="imgwrap"><img src="img/ico/sumka.png" width="15" height="15"/></div><span>Сумка</span></a>
</td><td width="33%">
<a class="big-but" href="pripas.php">
<div class="imgwrap"><img src="img/ico/link.png"></div><span>Припасы</span></a>
</td><td width="33%">
<a class="big-but" href="bag.php">
<div class="imgwrap"><img src="img/ico/bag.png" width="15" height="15"/></div><span>Рюкзак<?php
$query_c = "Select user_id from things where place=0 and user_id = '$user_id' limit 20";
$result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
$count = mysqli_num_rows($result_c);
echo"($count)";
?></span></a>
</td>
</tr><tr><td width="33%">
<a class="big-but" href="stash.php">
<div class="imgwrap"><img src="img/ico/sumka.png" width="15" height="15"/></div><span>Тайник
<?php
$query_c = "Select user_id from things where place=1 and user_id = '$user_id' limit 20";
$result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
$count = mysqli_num_rows($result_c);
echo"($count)";
?></span></a>
</td><td width="33%">
<a class="big-but" href="auc.php">
<div class="imgwrap"><img src="img/ico/auc.png"></div><span>Аукцион
<?php
$query_c = "Select user_id from things where place=3 and user_id = '$user_id' limit 20";
$result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
$count = mysqli_num_rows($result_c);
echo"($count)";
?></span></a>
</td><td width="33%">
<a class="big-but" href="clothes.php?id=<?php echo $row['id']; ?>">
<div class="imgwrap"><img src="img/ico/shield.png"></div><span>Снаряжение</span></a>
</td>
</tr>
</tbody></table>

<table class="foot" width="100%" border="0" cellpadding="0" cellspacing="0" style="padding-top: 5px;"><tbody><tr><td width="33%">
<a class="big-but" href="msg.php">
<div class="imgwrap"><img src="img/ico/letter.png"></div><span>Почта</span></a>
</td><td width="33%">
<a class="big-but" href="ank_cr.php">
<div class="imgwrap"><img src="img/anketa.png"></div><span>Анкета</span></a>
</td><td width="33%">
<a class="big-but" href="nadpisi.php">
<div class="imgwrap"><img src="img/ico/status.png"></div><span>Надписи</a></span>
</td>
</tr><tr><td width="33%">
<a class="big-but" href="avatars.php">
<div class="imgwrap"><img src="img/ico/avatar.png"></div><span>Аватар</span></a>
</td><td width="33%">
<a class="big-but" href="paymoney.php">
<div class="imgwrap"><img src="img/ico/bonus.gif"></div><span>Купить золото</span></a>
</td><td width="33%">
<a class="big-but" href="ref.php">
<div class="imgwrap"><img src="img/ico/chel.png"></div><span>Пригласить</span></a>
</td>
</tr><tr><td width="33%">
<a class="big-but" href="settings.php">
<div class="imgwrap"><img src="img/ico/nastroiki.png" width="15" height="15"/></div><span>Настройки</span></a>
</td><td width="33%">
<a class="big-but" href="exit.php">
<div class="imgwrap"><img src="img/ico/out.png"></div><span>Выход</span></a>
</tr></tbody>
</table>
  <?php
   
  require_once('conf/navig.php');
    require_once('conf/foot.php');
	mysqli_close($dbc);
  ?>
</body>