File size: 6.2Kb
<?php
$current_page = basename($_SERVER['PHP_SELF']);
function bottom_active($names, $current_page) {
$names = (array)$names;
return in_array($current_page, $names, true) ? 'active' : '';
}
?>
</div>
</main>
<footer class="site-footer">
<div class="container">
© 2025 SoftLove. Найди того, с кем будет по-настоящему мягко и уютно ☕
</div>
</footer>
<?php if (!empty($_SESSION['user_id'])): ?>
<style>
/* нижняя навигация для мобилы */
@media (max-width: 768px) {
.bottom-nav {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #ffffff;
border-top: 1px solid rgba(0,0,0,0.06);
display: flex;
justify-content: space-around;
padding: 6px 0 4px;
z-index: 30;
}
.bottom-nav a {
flex: 1;
text-align: center;
text-decoration: none;
color: #7b7287;
font-size: 11px;
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
}
.bottom-nav-icon {
font-size: 20px;
line-height: 1;
}
.bottom-nav a.active {
color: #ff6b9c;
}
.bottom-nav .unread-badge {
position: absolute;
top: 3px;
right: 20%;
}
.bottom-nav-item {
position: relative;
}
}
</style>
<nav class="bottom-nav">
<a href="/browse.php"
class="bottom-nav-item <?php echo bottom_active(['browse.php'], $current_page); ?>">
<span class="bottom-nav-icon">📡</span>
<span>Анкеты</span>
</a>
<a href="/matches.php"
class="bottom-nav-item <?php echo bottom_active(['matches.php'], $current_page); ?>">
<span class="bottom-nav-icon">👥</span>
<span>Совпадения</span>
</a>
<a href="/dialogs.php"
class="bottom-nav-item <?php echo bottom_active(['dialogs.php','messages.php'], $current_page); ?>">
<span class="bottom-nav-icon">✉</span>
<span>Сообщения</span>
<span id="js-unread-badge-bottom" class="unread-badge"></span>
</a>
<a href="/friends.php"
class="bottom-nav-item <?php echo bottom_active(['friends.php'], $current_page); ?>">
<span class="bottom-nav-icon">🤝</span>
<span>Друзья</span>
<!-- бэйдж для новых заявок в друзья -->
<span id="js-friends-badge-bottom" class="unread-badge"></span>
</a>
<a href="/profile.php"
class="bottom-nav-item <?php echo bottom_active(['profile.php'], $current_page); ?>">
<span class="bottom-nav-icon">👤</span>
<span>Профиль</span>
<!-- бэйдж для новых подарков -->
<span id="js-gifts-badge-bottom" class="unread-badge"></span>
</a>
</nav>
<script>
// обновление счётчиков: сообщений, подарков и заявок в друзья
(function() {
const headerMsgBadge = document.getElementById('js-unread-badge');
const bottomMsgBadge = document.getElementById('js-unread-badge-bottom');
const bottomGiftBadge = document.getElementById('js-gifts-badge-bottom');
const bottomFriendBadge = document.getElementById('js-friends-badge-bottom');
function setBadge(el, count) {
if (!el) return;
if (count > 0) {
el.style.display = 'inline-flex';
el.textContent = count > 99 ? '99+' : count;
} else {
el.style.display = 'none';
}
}
function updateMessages() {
fetch('/messages_unread_count.php', {cache: 'no-store'})
.then(r => r.json())
.then(data => {
const c = Number(data && data.count ? data.count : 0);
setBadge(headerMsgBadge, c);
setBadge(bottomMsgBadge, c);
})
.catch(() => {});
}
function updateGifts() {
fetch('/gifts_unread_count.php', {cache: 'no-store'})
.then(r => r.json())
.then(data => {
const c = Number(data && data.count ? data.count : 0);
setBadge(bottomGiftBadge, c);
})
.catch(() => {});
}
function updateFriendRequests() {
fetch('/friends_requests_count.php', {cache: 'no-store'})
.then(r => r.json())
.then(data => {
const c = Number(data && data.count ? data.count : 0);
setBadge(bottomFriendBadge, c);
})
.catch(() => {});
}
function updateAll() {
updateMessages();
updateGifts();
updateFriendRequests();
}
updateAll();
setInterval(updateAll, 10000);
})();
// боковое меню (бургер)
(function() {
const burger = document.getElementById('js-burger');
const menu = document.getElementById('js-side-menu');
const backdrop = document.getElementById('js-side-backdrop');
const closeBtn = document.getElementById('js-side-close');
if (!burger || !menu || !backdrop) return;
function openMenu() {
menu.classList.add('open');
backdrop.classList.add('open');
}
function closeMenu() {
menu.classList.remove('open');
backdrop.classList.remove('open');
}
burger.addEventListener('click', openMenu);
backdrop.addEventListener('click', closeMenu);
if (closeBtn) closeBtn.addEventListener('click', closeMenu);
})();
</script>
<?php endif; ?>
</body>
</html>