<?php
if (isset($ID)) {
  $ank = $sql -> fetch("SELECT * FROM `users` WHERE `id` = '$ID' LIMIT 1");
}


if (!isset($ank['id']) && isset($user)) {
  $ank = $user;
}

if ($level > $ank['level'] || ($level > 0 && $ank['id'] == $user['id'])) {
  $view = true;
}


$lev_name = array('0' => __('Гость'), '1' => __('Пользователь'), '2' => __('Модератор'), '3' => __('Администратор'), '4' => __('Администратор'));


if (isset($user) && $level == 4 && isset($_GET['banbase'])) {
$_SESSION['message'] = $ank['login'].' добавлен в banbase.ru ';
require FUNC . 'Banbase.php';
$arr = array('wmid' => $ank['wmid'], 'icq' => $ank['icq'], 'email' => $ank['email'], 'name' => $ank['login'], 'descr' => $_POST['descr']);
$result = Banbase::add($arr);
//unset($_POST['descr']);

//header('Location: /wm/'.$ank['login']);
}



$system['title'] = __('Профиль') . ' ' . login($ank['id'], 0);
require SYS . 'header.php';
$sban = $sql -> fetch("SELECT * FROM `ban` WHERE `id_ban` = '".$ank['id']."' AND `time` > '$time' ORDER BY `time` DESC LIMIT 1");

if (isset($sban['id'])) {
?>
  <div class="profile">
    <span class="off"><b><?= __('Пользователь заблокирован')?></b></span><br />
    <?= login($sban['id_user'], 1)?> (<?= __('до')?> <?= vremja($sban['time'])?>)<br />
    <?= __('Причина')?>: <?= text_out($sban['msg'])?><br />
  </div>
<?php
}

if (!isset($sban['id']) || $level > 1) {
?>
<div class="profile">
<?php
if($ank['rating']>=0 && $ank['rating']<=10){echo '<img src="/_images/status/1-min.png" align="right"/>';}

if($ank['rating']>=11 && $ank['rating']<=50){echo '<img src="/_images/status/2-min.png" align="right"/>';}

if($ank['rating']>=51 && $ank['rating']<=100){echo '<img src="/_images/status/3-min.png" align="right"/>';}

if($ank['rating']>=101 && $ank['rating']<=99999999999){echo '<img src="/_images/status/4-min.png" align="right"/>';}
?>
  <span class="ank_n">&raquo; <?= __('Зарегистрирован')?></span> <span class="ank_d"><?= vremja($ank['date_reg'])?></span><br />
  <span class="ank_n">&raquo; <?= __('Последнее посещение')?></span> <span class="ank_d"><?= vremja($ank['date_last'])?></span><br />
  <? if ($ank['level'] > 1) { ?>
  <span class="ank_n">&raquo; <?= __('Должность')?>:</span> <span class="ank_d"><?= $lev_name[$ank['level']]?></span><br />
<?
}
?>
</div>
<?php


if (isset($user) && $level == 4 && isset($_GET['banbaseadd'])) {
?>
  <form action="/wm/<?= $ank['login']?>&amp;banbase" method="POST" style="margin: 2px;" enctype="multipart/form-data">

  <textarea style="width: 75%;" name="descr" id="descr" placeholder="Написать Причину..."></textarea><br />

  <button type="submit" class="btn">Добавить в Базу</button>
  
  </form>
<?php
}

/// подключаем Бан Базу
//include_once FUNC. 'banbaseUser.php';

?>

  <div class="profile">
    <div class="div_3">
  <?= avatar($ank['id'], 2, 0)?><br />
	</div>
  <? if ($level > 0 && $user['id'] != $ank['id']) { ?>
    <a class="div_3" href="/?func=user.mail&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-envelope icon-white"></i> <?
}else{
?><i class="icon-envelope"></i> <?
}
?>
<?= __('Написать сообщение')?></a>
    <? if ($sql -> selectCount("SELECT COUNT(*) FROM `shop_spy` WHERE `id_author` = '$ank[id]' AND `id_user` = '$user[id]'") == 0) { ?>
      <a class="div_3" href="/?func=user.spy&amp;set=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-bullhorn icon-white"></i> <?
}else{
?><i class="icon-bullhorn"></i> <?
}
?>
<?= __('Подписаться на новости')?></a>
    <? } ?>
  <? } ?>

  <?
  $votes = $sql -> fetch("
  SELECT COUNT(*) AS pos,
  (SELECT COUNT(*) FROM `user_votes` WHERE `id_ank` = '$ank[id]' AND `type` = '0' AND `view` = '1') AS 'otr'
  FROM `user_votes` WHERE `id_ank` = '$ank[id]' AND `type` = '1' AND `view` = '1'");
  ?>
  <a class="div_3" href="/?func=user.votes&id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-filter icon-white"></i> <?
}else{
?><i class="icon-filter"></i> <?
}
?>
<?= __('Арбитраж')?> [<span class="on"><?= $votes['pos']?></span>/<span class="off"><?= $votes['otr']?></span>]</a>
  
  <a class="div_3" href="/?func=user.spyid&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-bullhorn icon-white"></i> <?
}else{
?><i class="icon-bullhorn"></i> <?
}
?>
<?= __('Подписчики')?> <?= login($ank['id'])?> (<?= $sql -> selectCount("SELECT COUNT(*) FROM `shop_spy` WHERE `id_author` = '$ank[id]'")?>)</a>
  </div>


  <div class="profile">
  <? if ($level > 3) : ?>
  <span class="ank_n">Деньги: </span> <span class="ank_d"><?= $ank['wmr']?>₽</span> <br />
  <? endif ?>
  <span class="ank_n">ID:</span> <span class="ank_d"><?= $ank['id']?></span><br />
  <? if ($ank['status']) { ?>
  <span class="ank_n"><?= __('О себе')?>:</span> <span class="ank_d"><?= text($ank['status'])?></span> <?= ($level > $ank['level'] ? ' | <a href="/?func=user.status&amp;id=' . $ank['id'] . '"><i class="icon-pencil"></i> ' . __('ред.') . '</a>' : '')?><br />
  <? } ?>
  <span class="ank_n"><?= __('Рейтинг')?>:</span> <span class="ank_d"><?= text($ank['rating']/100)?></span><br />

   <? if ($ank['cash']!=NULL) { ?>
   <span class="ank_n"><?= __('Профиль')?>:</span> <span class="ank_d"> <img src="/_images/icon/<?=($ank['cash'] == 0 ? 'nat138':'nat140')?>.gif" /> <?= ($ank['cash'] == 0 ? __('Заказчик') : __('Исполнитель'))?>
   <?}?>  

   </div>


  <div class="profile">
  <span class="ank_n"><?= __('Имя')?>:</span> <span class="ank_d"><?= text($ank['name'])?></span><br />


  <? if ($ank['view_family'] == 1 || isset($view)) { ?>
  <span class="ank_n"><?= __('Фамилия')?>:</span> <span class="ank_d"><?= text($ank['family'])?></span><br />
  <? } ?>

  <? if ($ank['view_date_r'] == 1 || isset($view)) { ?>
  <span class="ank_n"><?= __('Дата рождения')?>:</span> <span class="ank_d"><?= $ank['ank_d_r']?>.<?= $ank['ank_m_r']?>.<?= $ank['ank_g_r']?></span><br />
  <? } ?>

  <? if ($ank['view_country'] == 1 || isset($view)) { ?>
  <?
  $country = $sql -> fetch("SELECT * FROM `countries` WHERE `id` = '$ank[country]' LIMIT 1");
  ?>
  <span class="ank_n"><?= __('Страна')?>:</span> <span class="ank_d"><?= $country['name']?></span><br />
  <? } ?>

  <? if ($ank['city'] && ($ank['view_city'] == 1 || isset($view))) { ?>
  <?= ($ank['city'] ? '<span class="ank_n">' . __('Город') . ':</span> <span class="ank_d">' . text($ank['city']) . '</span><br />' : '')?>
  <? } ?>

  <span class="ank_n"><?= __('Пол')?>:</span> <span class="ank_d"><?= ($ank['pol'] == 0 ? __('Женский') : __('Мужской'))?></span><br />
  </div>

  <div class="profile">
  <? if ($ank['icq'] && ($ank['view_icq'] == 1 || isset($view))) { ?>
  <?= ($ank['icq'] ? '<span class="ank_n">ICQ:</span> <span class="ank_d">' . $ank['icq'] . '</span><br />' : '')?>
  <? } ?>

  <? if ($ank['skype'] && ($ank['view_skype'] == 1 || isset($view))) { ?>
  <?= ($ank['skype'] ? '<span class="ank_n">Skype:</span> <span class="ank_d">' . text($ank['skype']) . '</span><br />' : '')?>
  <? } ?>

  <? /*if ($ank['view_email'] == 1 || isset($view))*/ if ($level > 2) { ?>
  <span class="ank_n">Email:</span> <span class="ank_d"><?= text($ank['email'])?></span><br />
  <? } ?>

  <? if ($ank['sites'] && ($ank['view_sites'] == 1 || isset($view))) { ?>
  <span class="ank_n"><?= __('Сайт')?>:</span> <a href="http://<?= text($ank['sites'])?>"><?= text($ank['sites'])?></a><br />
  <? } ?>
   <? if ($ank['telegram'] && ($ank['view_telegram'] == 1 || isset($view))) { ?>
  <span class="ank_n"><?= __('Telegram')?>:</span> <a href="https://telegram.im/<?= text($ank['telegram'])?>"><?= text($ank['telegram'])?></a><br />
  <? } ?>
  
  <? if ($ank['vkcom'] && ($ank['view_vkcom'] == 1 || isset($view))) { ?>
  <span class="ank_n"><?= __('ВКонтакте')?>:</span> <a href="https://vk.com/<?= text($ank['vkcom'])?>"><?= text($ank['vkcom'])?></a>
  <? } ?></div> 
  
  <? 
if ($ank['wmid']>0) {
echo "<div class='profile'>WMID: <a target='_blank' href='https://passport.webmoney.ru/asp/CertView.asp?wmid=".$ank['wmid']."'>".$ank['wmid']."</a><br />
BL: <img src='//bl.wmtransfer.com/img/bl/".$ank['wmid']."?w=35&h=18&bg=0XDBE2E9' alt='' class='icon'/><br />
Претензии | Отзывы<br />
<a href='//arbitrage.webmoney.ru/asp/claims.asp?wmid=".$ank['wmid']."'><img src='https://arbitrage.webmoney.ru/xml/AL.aspx?wmid=".$ank['wmid']."' alt='' class='icon'/></a></div>";
}
  
  
  
/*if (is_file(ROOT . '_images/wmid/' . $ank['wmid'] . '.png') && @filemtime(ROOT . '_images/wmid/' . $ank['wmid'] . '.png') > time() - (60 * 60 * 24)) { 
  ?>
  
     <a href="http://passport.webmoney.ru/asp/certview.asp?wmid=<?= $ank['wmid']?>" target="_blank"><img src="/_images/wmid/<?= $ank['wmid']?>.png" style="max-width: 100%;" /></a><br />
<?
} elseif ((!is_file(ROOT . '_images/wmid/' . $ank['wmid'] . '.png') && $ank['wmid']) || ($ank['wmid'] && @filemtime(ROOT . '_images/wmid/' . $ank['wmid'] . '.png') < time() - (60 * 60 * 24))) {
      @unlink(ROOT . '_images/wmid/' . $ank['wmid'] . '.png');
      require FUNC . 'incfunc.wmid.php';
      $array = wmid_info($ank['wmid'], 'wmid');
      if (isset($array['wmid'])) {
        @save_wmid_img($array); 
      }
    } */?>

  <? if ($level > 1) { ?><div class='profile'>
  <span class="ank_n"><?= __('IP адрес')?>:</span> <span class="ank_d"><?= long2ip($ank['ip'])?></span><br />
  <? include_once FUNC. 'geolocal.php';?>
<span class="ank_n"><?= __('Браузер')?>:</span> <span class="ank_d"><?= $ank['ua']?></span></div>
  <? } ?>

  
<?$ИсторияНиков= $sql -> selectCount("SELECT COUNT(*) FROM `nick_histore` WHERE `id_user` = '".$ank['id']."' AND `id_kont` = '".$ank['id']."'");?>
  <div class="foot">
  <a class="div_3" href="/seller/<?= $ank['my_links']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-shopping-cart icon-white"></i> <?
}else{
?><i class="icon-shopping-cart"></i> <?
}
?>
<?= __('Товары в магазине')?> (<?= $sql -> selectCount("SELECT COUNT(*) FROM `shop_goods` WHERE `id_user` = '$ank[id]'  AND `unlink` = '0'")?>)</a>
  
<a class="div_3" href="/?func=nick.histore&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-edit icon-white"></i> <?
}else{
?><i class="icon-edit"></i> <?
}
?>
<?= __('История ников')?> (<?= $ИсторияНиков ?>) </a> 
<?
//AND `active` = '1'
  if ($level > 1 && $level > $ank['level'] && ($user['id'] != $ank['id'] || $level == 4)) { 
    $login = login($ank['id'], 0);
    if (!isset($_GET['action'])) {
      ?><a class="div_3" href="/?func=user.profile&amp;id=<?= $ank['id']?>&amp;action">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-hand-right icon-white"></i> <?
}else{
?><i class="icon-hand-right"></i> <?
}
?>
<?= __('Действие над')?> <?= $login?></a><? 
    } else { 
      if ($level > 1) { ?>
        <a class="div_3" href="/?func=user.ban&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-ban-circle icon-white"></i> <?
}else{
?><i class="icon-ban-circle"></i> <?
}
?>
<?= __('Заблокировать аккаунт')?></a>
        <a class="div_3" href="/?func=user.edit&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-edit icon-white"></i> <?
}else{
?><i class="icon-edit"></i> <?
}
?>
<?= __('Редактировать профиль')?></a>
      <? }
      
      if ($level == 4) { ?>

        <a class="div_3" href="/wm/<?= $ank['login']?>&amp;banbaseadd">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-inbox icon-white"></i> <?
}else{
?><i class="icon-inbox"></i> <?
}
?>
<?= __('Добавить в Бан-Базу')?></a>

        <a class="div_3" href="/?func=shop.bought&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-inbox icon-white"></i> <?
}else{
?><i class="icon-inbox"></i> <?
}
?>
<?= __('Покупки')?> <?= $login?></a>
        <a class="div_3" href="/?func=billing.log&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-briefcase icon-white"></i> <?
}else{
?><i class="icon-briefcase"></i> <?
}
?>
<?= __('Расчетный лист')?> <?= $login?></a>
        <a class="div_3" href="/?func=user.cash&amp;id=<?= $ank['id']?>">
<?
if (isset($user) && $user['design']== 'slate'){
?><i class="icon-th icon-white"></i> <?
}else{
?><i class="icon-th"></i> <?
}
?>

<?= __('Касса')?> <?= $login?></a>
<?
/*
?>
<a href="/?func=admin.userdelete&amp;id=<?= $ank['id']?>">
<?

if (isset($user) && $user['design']== 'slate'){
?><i class="icon-trash icon-white"></i> <?
}else{
?><i class="icon-trash"></i> <?
}
?>
<?= __('Удалить пользователя')?></a><br />
<?
      */
	  }
    }
  }
  ?>
  </div>
<?
}
?>