nativegallery/views/pages/Profile/Index.php

278 lines
17 KiB
PHP
Raw Normal View History

2024-07-05 06:33:46 +03:00
<?php
use \App\Services\{Auth, DB, Date};
use \App\Models\User;
2024-07-05 12:21:52 +03:00
$userprofile = new User(explode('/', $_SERVER['REQUEST_URI'])[2]);
2024-07-05 06:33:46 +03:00
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
</head>
<body>
<div id="backgr"></div>
<table class="tmain">
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
<tr>
<td class="main">
2024-07-10 13:15:24 +03:00
<?php
2024-07-11 22:45:27 +03:00
if ((int)$userprofile->i('id') === (int)explode('/', $_SERVER['REQUEST_URI'])[2]) { ?>
2024-07-10 13:23:05 +03:00
<h1><?= htmlspecialchars($userprofile->i('username')) ?><?php if ($userprofile->i('admin') === 1) { echo '<img width="32" src="/static/img/star.png">'; } ?></h1>
2024-07-05 06:33:46 +03:00
<?php
if ($userprofile->i('admin') === 1) {
echo 'Администратор сервера';
} else if ($userprofile->i('admin') === 2) {
echo 'Фотомодератор';
}
2024-07-05 12:21:52 +03:00
if ($userprofile->i('id') === Auth::userid()) { ?>
2024-07-05 06:33:46 +03:00
<p><b><a href="/lk/profile">Редактировать мой профиль</a></b></p>
<?php } ?>
2024-07-12 00:51:16 +03:00
<div class="p20" style="padding-right:12px">
2024-07-05 06:33:46 +03:00
<table width="100%">
<tr>
2024-07-08 22:33:27 +03:00
<?php if ($userprofile->content('badge') !== null) { ?>
<div style="float:left; border:solid 1px #3b7dc1; padding:6px 10px 7px; margin-bottom:13px; background-color:#0199ff44"><b><?=nl2br($userprofile->content('badge'))?></div><br>
<?php } ?>
2024-07-12 00:45:53 +03:00
<td style="vertical-align:top; width:100%" valign="top" width="100%">
2024-07-08 22:33:27 +03:00
<table style="margin-bottom: 15px;">
<colgroup><col width="170px">
</colgroup>
2024-07-05 06:33:46 +03:00
<col width="170px">
<?php
2024-07-05 12:21:52 +03:00
if ($userprofile->content('location') !== null) { ?>
2024-07-05 06:33:46 +03:00
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Откуда:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars($userprofile->content('location')) ?></td>
2024-07-05 06:33:46 +03:00
</tr>
<?php } ?>
2024-07-05 15:03:35 +03:00
<?php
if (json_decode($userprofile->i('content'), true)['aboutlive']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Откуда:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutlive']['value']) ?></td>
2024-07-05 15:03:35 +03:00
</tr>
<?php } ?>
2024-07-08 22:33:27 +03:00
<?php
if (json_decode($userprofile->i('content'), true)['aboutbirthday']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">День рождения:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutbirthday']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
</col></table>
<table style="margin-bottom: 15px;">
<colgroup><col width="170px">
</colgroup>
<?php
if (json_decode($userprofile->i('content'), true)['aboutlangs']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Владение языками:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutlangs']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['abouttelegram']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Telegram:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['abouttelegram']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutvk']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">ВКонтакте:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutvk']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['abouttwitter']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Twitter/X:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['abouttwitter']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutyoutube']['value'] != null) { ?>
<tr>
2024-07-11 22:45:27 +03:00
<td class="sm" style="padding:3px 10px 3px 0">YouTube:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutyoutube']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutemail']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Почта:</td>
2024-07-11 22:45:27 +03:00
<td><a href="emailto:<?=htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutemail']['value'])?>"><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutemail']['value']) ?></a></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutinstagram']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Instagram:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutinstagram']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['abouttransphoto']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">TransPhoto:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['abouttransphoto']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutwebsite']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Личный сайт:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutwebsite']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
</table>
<table style="margin-bottom: 15px;">
<colgroup><col width="170px">
</colgroup>
<?php
if (json_decode($userprofile->i('content'), true)['aboutfavs_trains']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Любимые модели поездов:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutfavs_trains']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutfavs_countries']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Любимые страны:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutfavs_countries']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
<?php
if (json_decode($userprofile->i('content'), true)['aboutfavs_cities']['value'] != null) { ?>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Любимые города:</td>
2024-07-10 13:23:05 +03:00
<td><?= htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutfavs_cities']['value']) ?></td>
2024-07-08 22:33:27 +03:00
</tr>
<?php } ?>
</table>
<table>
<colgroup><col width="170px">
</colgroup>
2024-07-05 06:33:46 +03:00
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Дата регистрации:</td>
2024-07-05 12:21:52 +03:00
<td><span class="sm"><?= Date::zmdate($userprofile->content('regdate')) ?></span></td>
2024-07-05 06:33:46 +03:00
</tr>
<tr>
<td class="sm" style="padding:3px 10px 3px 0">Был на сайте:</td>
2024-07-05 12:21:52 +03:00
<td><span class="sm"><?= Date::zmdate($userprofile->i('online')) ?> <?php if (time() - 300 <= $userprofile->i('online')) { ?>(<b>online</b>)<?php } ?></span></td>
2024-07-05 06:33:46 +03:00
</tr>
</table>
2024-07-12 00:51:16 +03:00
<br />
2024-07-05 06:33:46 +03:00
<div class="sm" style="float:right"><a href="/lk/ticket.php?action=add&amp;aid=140"></a></div>
2024-07-05 15:03:35 +03:00
<?php
if (json_decode($userprofile->i('content'), true)['aboutmemo']['value'] != null) { ?>
<div class="p20">
<h4>О себе</h4>
2024-07-21 04:43:25 +03:00
<?php
$bbcode= new ChrisKonnertz\BBCode\BBCode();
$rendered = $bbcode->render(nl2br(htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutmemo']['value'])));
echo $rendered;
?>
2024-07-05 15:03:35 +03:00
</div>
<?php } ?>
2024-07-12 00:51:16 +03:00
</td>
2024-07-05 15:03:35 +03:00
2024-07-05 06:33:46 +03:00
<td valign="top" align="right">
<script>
function getBodyScrollTop() {
return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
function showUserPhoto() {
2024-07-05 12:21:52 +03:00
_getID('userphoto_big_img').src = '<?= $userprofile->i('photourl') ?>';
2024-07-05 06:33:46 +03:00
_getID('userphoto_big_div').style.top = '' + (getBodyScrollTop() + 10) + 'px';
_getID('userphoto_big_div').style.display = 'block';
}
function hideUserPhoto() {
_getID('userphoto_big_div').style.display = 'none';
}
document.onclick = function(e) {
e = e || window.event;
E = e.target || e.srcElement;
if (E.id != 'userphoto_big_div' && E.id != 'userphoto_img') {
_getID('userphoto_big_div').style.display = 'none';
}
}
</script>
<div id="userphoto_big_div" style="position:absolute; display:none; border:1px solid gray; padding:10px; background-color:white; margin:auto; text-align:center; right:100px; z-index:3000" class="p5 shadow"><a href="#" onclick="hideUserPhoto(); return false"><img src="" id="userphoto_big_img" border="0" style="vertical-align:middle"></a>
<div style="margin-top:8px"><a class="dot" href="#" onclick="hideUserPhoto(); return false">закрыть</a></div>
</div>
2024-07-11 22:45:27 +03:00
<a href="<?= $userprofile->i('photourl') ?>" onclick="showUserPhoto(); return false;"><img onerror="this.src = '/static/img/avatar.png'; this.onerror = null;" src="<?= $userprofile->i('photourl') ?>" alt="" id="userphoto_img" class="f" style="width:auto; max-width:100px"></a>
2024-07-12 00:51:16 +03:00
</td>
2024-07-05 06:33:46 +03:00
</tr>
</table>
2024-07-12 00:51:16 +03:00
</div>
<div style="margin-top: 25px;"><b><a href="/search?id=<?=$userprofile->i('id')?>">Найти все фотографии, сделанные этим пользователем</a></b></div>
2024-07-19 01:37:41 +03:00
<?php
if ($userprofile->i('id') != Auth::userid()) { ?>
<script>
$(document).ready(function()
{
$('.toggle, .toggle-label').on('click', function()
{
var toggle = $('.toggle').toggleClass('on');
var subscr_cnt = $('#subscr_cnt');
var cnt = parseInt(subscr_cnt.text());
subscr_cnt.html(toggle.is('.on') ? cnt+1 : cnt-1);
$.get('/api/subscribe', { action: 'subscribe', id: <?=$userprofile->i('id')?>, subj: 'a' }, function (r)
{
if (r != 0 && r != 1)
{
toggle.toggleClass('on');
alert(r);
}
else toggle.attr('class', (r == 1) ? 'toggle on' : 'toggle');
});
});
});
</script>
<?php
if (DB::query('SELECT follower_id FROM followers WHERE user_id=:userid AND follower_id=:followerid', array(':userid' => $userprofile->i('id'), ':followerid' => Auth::userid()))) {
$class = 'on';
}
?>
<div style="margin-top: 8px;"><div class="toggle <?=$class?>"><div class="handle"></div></div> &nbsp;<label class="toggle-label"><b>Подписка на новые фотографии этого автора</b> (подписаны: <b id="subscr_cnt"><?=DB::query('SELECT COUNT(*) FROM followers WHERE user_id=:uid', array(':uid'=>$userprofile->i('id')))[0]['COUNT(*)'];?></b>)</label></div>
2024-07-19 01:37:41 +03:00
<?php } else { ?>
<div style="margin-top: 8px;">Пользователей, подписанных на мои фотографии: <b><?=DB::query('SELECT COUNT(*) FROM followers WHERE user_id=:uid', array(':uid'=>$userprofile->i('id')))[0]['COUNT(*)'];?></b></div>
2024-07-19 01:37:41 +03:00
<?php } ?>
2024-07-10 13:15:24 +03:00
<?php } else { ?>
<center><h1>Пользователь не найден</h1></center>
<center><img src="/static/img/404.jpg"></center>
<?php } ?>
2024-07-12 00:51:16 +03:00
</td>
2024-07-05 06:33:46 +03:00
</tr>
2024-07-08 20:10:00 +03:00
<tr>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
</tr>
2024-07-05 06:33:46 +03:00
</table>
</body>
</html>