<?php
ob_start();
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;

if (!isset($_GET['nick'])) {
header ('location: /');
exit;
}
$query = DB :: $dbs -> query ("SELECT * FROM `blogger` WHERE `id` = ?", [abs((int)$_GET['nick'])]);
if ($query -> rowCount () == 0) {
header ('location: /');
exit;
}
$a = $query -> fetch ();
$title->SetTitle(''.homeurl.' - Страница ' . $a['nick'].'');
///Подключаем шапку
$title->GetHeader();
$level = strtr($a['level'], [0=>'Пользователи', 1=>'Модераторы', 2=>'Модераторы',3=>'Администраторы', 4=>'Гл. Администраторы', 5=>'Разработчики']);

$spec = strtr($a['spec'], [0=>'Мастер', 1=>'Кодер', 2=>'Дизайнер', 3=>'Хостер', 4=>'Продавец', 5=>'Программист']);
$row = strtr($a['row'], [0=>'Новичок', 1=>'Постоялец', 2=>'Старожил', 3=>'PRO', 4=>'MASTER', 5=>'Знаток']);

echo '<div class="container-fluid page_header"><div class="container"><div class="row"><div class="col-xs-12 col-sm-8 col-md-9 col-lg-9"><h1>Просмотр профиля ' . $a['nick'].' </h1><ol class="breadcrumb" xmlns:v="http://'.homeurl.'/#"><li typeof="v:Breadcrumb"><a href="/" rel="v:url" property="v:title">'.homeurl.'</a></li><li class="active" typeof="v:Breadcrumb"><span property="v:title">Профиль ' . $a['nick'].'</span></li></ol></div></div></div></div>';
echo'<div class="container page_body"><div class="row"><div class="col-xs-12 page_content col-lg-9"><div class="navbar page_content_navbar collapse hidden-lg"><div class="container-fluid"><div class="navbar-collapse"></div></div></div><div class="text_box hidden-lg pr_block_small hidden"></div><div class="container-fluid cols_table">';
echo '<div class="catSides"><a href="/"><i class="md-format-list-bulleted"></i> Главная </a> - Страница ' . $a['nick'].'</div>';

echo'<div class="user_brief" data-login="' . $a['nick'].'" style="padding:20px; word-wrap: break-word;"><div class="userpic">';
$online = ($a['last']>time()-3600 ? '<span class="online">'. vr($a['last']).'</span>':'<span class="offline">'.($a['id'] == 1 ? $visit.'' : vr($a['last']).'').'</span>');
if (!empty($a['ava'])) {
echo '<img class="img-responsive" src="/'.$a['ava'].'" alt="' . $a['name'] . ' ' . $a['family'] . '" title="' . $a['name'] . ' ' . $a['family'] . '">';
}
echo'</div><div><div class="username">';
if ($a['mosh'] == 1) {
echo'<div class="row3"><b><font color="red">Пользователь находится в черном списке сайта!</b></font></div>';
}
echo'<b>' . $a['name'] . ' ' . $a['family'] . ' (' . $spec. ')</b></div>
     <div>'.calc_age($a['birthday']).', ' . $a['country'] . '/' . $a['city'] . '</div>

<div class="text-muted" id="online_' . $a['nick'] . '">'.$online.'</div>
<div class="text-muted" id="reg_' . $a['nick'] . '"> Зарегистрирован: ' . ($a['sex']=='Муж'?'':'а') . ' '.vr($a['reg']).'</div>
<div class="text-muted">Провел' . ($a['sex']=='Муж'?'':'а') . ' на сайте '.timecount($a['total_onl']).'</div><div style="margin-top: 5px; word-wrap: break-word;"></div></div></div>

<div class="catSides"><i class="md-format-list-bulleted"></i> Достижения и информация</div><div class="row text_box">';
if ($a['id'] !=$b['id']) {
echo'&#187;   <a href="/messages?do=send&nick='.$a['id'].'"> Отправить сообщение</a></br>';
}
echo'
&#187;   <b>Статус</b>: <a href="/modules/index.html?i=status"><b>' . $row . '</a></b> | ID: <b>' . $a['id'] . '</b> </br>
&#187;   <b>Группа</b>: <font color=red><b>' . $level . '</b></font>';
if ($a['jur']==1) {
echo'<br/>&#187;   <b style="color: green;">  Журналист газеты</b>';
}
echo '</br>';
echo '&#187;   Награды ' . $a['nick'].': ';
$medals = DB::$dbs->query("SELECT * FROM medals WHERE user_id = ? ORDER BY time DESC",[$a['id']]);
if ($medals->rowCount()>0) {
echo'<a href="/info/medals.html?id='.$a['id'].'"><b>'.DB::$dbs->querySingle("SELECT COUNT(id) FROM medals WHERE user_id = ?",[$a['id']]).'</b></a> ';
} else { echo' Не награжден!';
}
echo'</br>&#187;  <b>Виртуальный счёт</b>: Всего Gears: <b>' . $a['gears'] . '</b>
</div>';
echo'<div class="catSides"><i class="md-format-list-bulleted"></i> Личные данные</div>';
$query = DB :: $dbs -> query ("SELECT * FROM `nicks` WHERE (`us`='" . $a['id'] . "')");
echo'<div class="row text_box"><div class="slide" style="padding: 0px;cursor: pointer; "> <i class="md-shuffle"></i> История ников: (' . $query -> rowCount () .')</a></div>
<div class="view" style="padding: 10px;font: normal 16px Georgia, Times, serif; ">';
$query = DB :: $dbs -> query ("SELECT * FROM `nicks` WHERE (`us`='" . $a['id'] . "')");
if($query -> rowCount () == 0) { echo Nick ($a['id']) . ' не менял ник!';  } else {
$query = DB :: $dbs -> query ("SELECT * FROM `nicks` WHERE (`us`='" . $a['id'] . "') ORDER BY `id` DESC");
while ($nick = $query -> fetch ()) {
echo '<b>' . $nick['old'] . '</b> -> <b>' . $nick['new'] . '</b><br>Сменил: ' . Nick ($nick['kem']) . ' (' . vr ($nick['time']) . ')<hr/>';
}}
echo'</div></div>';
echo'<div class="row text_box"><div class="slide" style="padding: 0px;cursor: pointer; "> <i class="md-shuffle"></i> Анкетные данные</a></div>
<div class="view" style="padding: 10px;font: normal 16px Georgia, Times, serif; ">';
if (!empty ($a['name'])) {
echo '&#187;  Имя в реале: ' . $a['name'] . ' ' . $a['family'] . '</br>'; 
}
echo '&#187;  Пол: ' . $a['sex'] . '</br>';
if (!empty ($a['country'])) {
echo '&#187;  Страна: ' . $a['country'] . '</br>';
}
if (!empty ($a['city'])) {
echo '&#187;  Город: ' . $a['city'] . '</br>';
}
echo '&#187;  Дата рождения: ' . $a['birthday'] . '</br>';
if (!empty ($a['rodz'])) {
echo '&#187;  Род занятий: ' . text($a['rodz']) . '</br>';
}
if (!empty ($a['about'])) {
echo '&#187;  О себе: ' . text($a['about']) . '</br>';
}
if (!empty ($a['inter'])) {
echo '&#187;  Интересы: ' . text($a['inter']) . '</br>';
}
if (!empty ($a['oper'])) {
echo '&#187;  Оператор: ' . $a['oper'] . '</br>';
}
if (!empty ($a['model'])) {
echo '&#187;  Модель телефона: ' . $a['model'] . '</br>';
}
echo'</div></div>';
echo'<div class="row text_box"><div class="slide" style="padding: 0px;cursor: pointer; "> <i class="md-shuffle"></i> Контактные данные</a></div>
<div class="view" style="padding: 10px;font: normal 16px Georgia, Times, serif; ">';
if (!empty ($a['icq'])) {
echo '&#187;  Номер ICQ: ' . $a['icq'] . '</br>';
}
if (!empty ($a['mobtel'])) {
echo'&#187;  Моб.тел: ' . $a['mobtel'] . '</br>';
}
if (!empty ($a['skype'])) {
echo'&#187;  Skype: ' . $a['skype'] . '</br>';
}
if (!empty ($a['email'])) {
echo'&#187;  E-mail: ' . $a['email'] . '</br>';
}
if (!empty ($a['vk'])) {
echo'&#187;  Страница VK: ' . $a['vk'] . '</br>';
}
echo'</div></div>';
echo'<div class="row text_box"><div class="slide" style="padding: 0px;cursor: pointer; "> <i class="md-shuffle"></i> Платежные реквизиты</a></div>
<div class="view" style="padding: 10px;font: normal 16px Georgia, Times, serif; ">';
if($a['wmid'] == NULL){
echo '<div class="error">WMID не заполнен! Не рекомендуем проводить денежные операции! </div>';
} else {
echo '&#187;   WMID: <a href="https://passport.webmoney.ru/asp/certView.asp?wmid='.$a['wmid'].'">'.$a['wmid'].' </a><br/>
&#187;   BL <img src="https://bl.wmtransfer.com/img/bl/'.$a['wmid'].'?w=35&h=18" /><br/>
&#187;   Претензии/Отзывы: <img src="http://arbitrage.webmoney.ru/xml/AL.aspx?wmid='.$a['wmid'].'" /><br/>
&#187;   WMR: <a href="http://search.wmtransfer.com/?w=w&q=R'.$a['wmr'].'">'.$a['wmr'].'</a><br/>
&#187;   <b>'.($a['wm']==0?'<font color="red">WMID Не подтвержден!</font>':'<font color="green">WMID подтвержден!</font>').'</b>';
}
echo'</div></div>';
echo '<div class="row text_box"><a href="/info/rating.html?id='.$a['id'].'"><i class="md-shuffle"></i> Репутация мастера (<b><font color="green">'.DB :: $dbs -> querySingle("SELECT COUNT(id) FROM arbitage WHERE user_id = ? AND status = ? AND type = ?",[$a['id'],0,1]).'</font></b>/<b><font color="red">'.DB :: $dbs -> querySingle("SELECT COUNT(id) FROM arbitage WHERE user_id = ? AND status = ? AND type = ?",[$a['id'],0,2]).'</font></b>)</div></a>';

echo'<div class="catSides"><i class="md-format-list-bulleted"></i> Активность на сайте</div>';
if (DB :: $dbs ->querySingle ("SELECT COUNT(id) FROM `codes_code` WHERE (`user_id` = '" . $a['id'] . "')") > 0) echo'<a href="/info/codes.html?id='.$a['id'].'"><div class="row text_box"><i class="md-shuffle"></i>  Добавил полезных кодов:  ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `codes_code` WHERE (`user_id` = '" . $a['id'] . "')") . '</a></div>';
if (DB :: $dbs ->querySingle ("SELECT COUNT(id) FROM `downs` WHERE (`user_id` = '" . $a['id'] . "')") > 0) echo'<a href="/info/files.html?id='.$a['id'].'"><div class="row text_box"><i class="md-shuffle"></i>  Загрузил скриптов: ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `downs` WHERE (`user_id` = '" . $a['id'] . "')") . ' </a></div>';
if (DB :: $dbs ->querySingle ("SELECT COUNT(id) FROM `magazin_file` WHERE (`user_id` = '" . $a['id'] . "')") > 0) echo '<a href="/info/tovars.html?id='.$a['id'].'"><div class="row text_box"><i class="md-shuffle"></i>   Товаров в магазине: ' . DB :: $dbs ->querySingle ("SELECT COUNT(id) FROM `magazin_file` WHERE (`user_id` = '" . $a['id'] . "')") . '</a></div>';
echo'<a href="/info/expired.html?id='.$a['id'].'"><div class="row text_box"><i class="md-shuffle"></i>   История наказаний: ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `nar` WHERE (`user_id` = '" . $a['id'] . "')") . '</a></div>';
echo'<a href="/info/viewthems.html?id='.$a['id'].'"><div class="row text_box"><i class="md-shuffle"></i>   Темы на форуме:  ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_topic` WHERE (`user_id` = '" . $a['id'] . "')") . '</a></div>';
echo'<a href="/info/viewposts.html?id='.$a['id'].'"><div class="row text_box"><i class="md-shuffle"></i>   Сообщений на форумe:  ' . DB :: $dbs -> querySingle("SELECT COUNT(*) FROM `forum_mess` WHERE (`user_id`='" . $a['id'] . "')") . '</a></div>';
echo'<a href="/gallery/personal.html?id=' . $a['id'] . '"><div class="row text_box"><i class="md-shuffle"></i>  Персональная галерея  ' . $a['nick'] . '</a></div>';
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

echo'<div class="catSides"> <i class="md-format-list-bulleted"></i>  Личные новости</div>';
if ($b == true) {
if ($a['id']==$b['id']) { 
echo'<div class="list-group-item media"><form action="/users/' . $a['id'] . '?send" method="post">';
quickpaste('text');
quickpanel();
echo'</br></br><textarea name="text" class="form-control" rows="3" placeholder="О чем вы думаете...? "></textarea></br><button type="submit" class="btn btn-primary btn-lg btn-block">Отправить</button></div></form>';                
                if (isset ($_GET['send'])) { 
                $_POST['text'] = htmlspecialchars (addslashes (trim ($_POST['text']))); 
                if (empty ($_POST['text'])) { 
                echo '<div class="alert alert-danger" role="alert">Вы не ввели текст новости..</div>'; 
                       }else { 
         if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `new` WHERE (`us`='" . $b['id'] . "') AND (`t`>'" . (time () - 0) . "')") != 0) { 
                                        echo '<div class="alert alert-danger" role="alert">Вы пишите слишком часто!</div>'; 
                                }  else { 
DB :: $dbs -> query ("INSERT INTO `new` (`us`,`kem`,`text`,`t`) VALUES ('" . $a['id'] . "', '" . $b['id'] . "', ?, '" . time () . "')", [$_POST['text']]); 
                                        header ('location: /users/' . $a['id']); 
                                } 
                        } 
                } 
 } 
        if (isset ($_GET['del'])) { 
                if ($b['level'] > 0) {
                        $query = DB :: $dbs -> query ("SELECT * FROM `new` WHERE (`id`=?)", array (intval ($_GET['del']))); 
                        if ($query -> rowCount () != 0) { 
                                $new = $query -> fetch (); 
                                if ($new['us']==$a['id']) { 
                                        DB :: $dbs -> query ("DELETE FROM `new` WHERE (`id`='" . $new['id'] . "')"); 
                                        DB :: $dbs -> query ("DELETE FROM `new_komm` WHERE (`id_new`='" . $new['id'] . "')"); 
                                } 
                        } 
                } 
                header ('location: /users/' . $a['id']); 
        } 
        
        $items = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `new` WHERE (`us`='" . $a['id'] . "')"); 
        if ($items == 0) { 
       echo '<div class="alert alert-danger" role="alert">Новостей нет..</div>'; 
        } else { 
        $query = DB :: $dbs -> query ("SELECT * FROM `new` WHERE (`us`='" . $a['id'] . "') ORDER BY `id` DESC LIMIT 5"); 
            while ($new = $query -> fetch ()) { 
                         

                    echo'<div class="catSides">';
if (!empty($a['ava'])) { echo '<a href="/'.$a['ava'].'"><img class="img-circle"src="/'.$a['ava'].'" alt="' . $a['name'] . ' ' . $a['family'] . '" title="' . $a['name'] . ' ' . $a['family'] . '" style="width: 45px; height: 45px;"></a>';} else {echo'<a href="/assets/img/4.jpg"><img  class="img-circle" src="/assets/img/4.jpg" style="width: 16px; height: 16px;"></a>';}


                                            echo''.Nick ($new['kem']) . '</a>
                                                <span class="text-white h6">(' . vr ($new['t']) . ')</span>
                                            </div>
                                        
                                <div class="row text_box">
                                  <blockquote class="mb-10">';
                       if (!empty ($new['text'])) { 
                                echo text ($new['text']); 
                        } 
if ($b['level'] > 0) {
                                
                              echo ' <a href="?id=' . $a['id'] . '&del=' . $new['id'] . '">[Удл]</a>'; 
                        } 
                              echo'</blockquote>

                                     </div>
                                    <div class="inner-all bg-success">
                                        <i class="md md-comment"></i> Обсуждение новости
                                    </div>
                                <div class="row text_box">
                                    <form action="/feed/komm.php?id=' . $new['id'] . '&add" method="post"class="form-horizontal inner-all">
                                        <div class="form-group has-feedback no-margin">
                                            <input name="komm" class="form-control" type="text" placeholder="Пишите коммент...">
                                            <button type="submit" class="btn btn-theme fa fa-search form-control-feedback"></button>
                                        </div>
                                    </form>
                               </div> ';
                        
                        $itemss = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `new_komm` WHERE (`id_new`='" . $new['id'] . "')"); 
                        if ($itemss != 0) {                                  
                     $q = DB :: $dbs -> query ("SELECT * FROM `new_komm` WHERE (`id_new`='" . $new['id'] . "') ORDER BY `id` DESC LIMIT 5"); 
                                while ($komm = $q -> fetch ()) { 
                                        $kommus = DB :: $dbs -> queryFetch ("SELECT * FROM `blogger` WHERE (`id`='" . $komm['id'] . "')"); 
                                
echo'<div class="row text_box">
                                         '.Nick ($komm['us']) . ' (' . vr ($komm['t']) . ')';
if ($komm['us']!=$b['id']) { 
                              echo ' [<a href="/feed/komm.php?id=' . $new['id'] . '&komu=' . $komm['us'] . '">Отв</a>] '; 
                                        } 
                                        if ($b['level'] > 0) { 
                                                echo ' [<a href="/feed/komm.php?id=' . $new['id'] . '&del=' . $komm['id'] . '">Удл</a>] '; 
                                        } 
                                           echo' <small class="block text-muted"><br/>';
                                echo 'Комментарий: <b>' . text ($komm['text']) . '</b><br/>'; 
echo'</small></div>';                                        
                                         
                                       
                                } 
                                if ($itemss>1) { 
echo '<div class="catSides"><i class="md-format-list-bulleted"></i>   <a href="/feed/komm.php?id=' . $new['id'] . '"style="text-decoration:none; color:white;">Показать все комментарии</a> (' . $itemss . ')</div>'; 
                                }    
                        }    
                } 
                if ($items>=5) { 
echo '<div class="list-group-item media"> <i class="zmdi zmdi-apps"></i>  <a href="/feed/news.php?id=' . $a['id'] . '">Больше новостей</a> (' . $items . ')</div>'; 
                } 
        
                 }
        }
////////////////////////////////////////////////////////////////////////////////////////////////////////

if ($b['level'] > 0) {
echo'<div class="catSides"><i class="md-format-list-bulleted"></i> Админ - панель</div>';
if ($a['id'] != $b['id']) echo '<div class="row text_box"><i class="md-shuffle"></i><a href="/panel/ban.php?id=' . $a['id'] . '"> Выдать банн!</a></div>';
echo '<div class="row text_box">&#187; IP: <b>' . $a[ 'ip' ] . '</a></b>';
if ($b['level'] > 2) { echo' <a href="/panel/klon.php?ip='.$a['ip'].'"> [!!!]</a>'; }
$tst = DB::$dbs->querySingle("SELECT COUNT(id) FROM blogger WHERE ip = ?", [$a['ip']]);
$IP = ($tst > 0) ? '<span class="color:#FF3030;"><a href="/panel/klon.php?ip='.$a['ip'].'">' .$a['ip'] . '</a></span>' : $a['ip'];
echo'</br>&#187; Софт: <b>' . $a['soft'] . '</b></div>';
if ($a['level'] <= $b['level']) echo'<div class="row text_box"><i class="md-shuffle"></i><a href="/panel/redact.php?id=' . $a['id'] . '">Управление пользователем</a></div>';
}

///Подключаем меню
$title->GetMenu();


///Подключаем футер
$title->GetFooter();
?>