File size: 2.56Kb
<?php
require_once 'db.php';
if (empty($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$user_id = (int)$_SESSION['user_id'];
if (is_banned($user_id)) {
include 'header.php';
echo '<p>Ваш аккаунт заблокирован.</p>';
include 'footer.php';
exit;
}
// пользователи с активными историями (не истёкшими)
$result = $mysqli->query("
SELECT u.id, u.name, u.photo, MIN(s.id) AS any_story,
MAX(s.created_at) AS last_story_at
FROM stories s
JOIN users u ON u.id = s.user_id
WHERE s.expires_at > NOW()
GROUP BY u.id, u.name, u.photo
ORDER BY last_story_at DESC
");
include 'header.php';
?>
<style>
.stories-feed-page{margin-top:18px;}
.stories-strip{
display:flex;
gap:16px;
overflow-x:auto;
padding:10px 0 8px;
}
.story-bubble{
flex:0 0 auto;
text-align:center;
text-decoration:none;
color:#403b4b;
}
.story-avatar{
width:68px;height:68px;border-radius:999px;object-fit:cover;
border:3px solid #ff7aa8;box-sizing:border-box;
}
.story-avatar-placeholder{
width:68px;height:68px;border-radius:999px;
background:linear-gradient(135deg,#ffe5f0,#f5ebff);
display:flex;align-items:center;justify-content:center;font-size:26px;
border:3px solid #ff7aa8;box-sizing:border-box;
}
.story-name{margin-top:4px;font-size:12px;max-width:72px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.story-actions{margin-top:16px;margin-bottom:10px;}
</style>
<div class="stories-feed-page">
<h1>Истории</h1>
<div class="story-actions">
<a href="story_add.php" class="btn-primary">Добавить историю</a>
</div>
<?php if ($result->num_rows === 0): ?>
<p>Пока никто не выложил историю. Будьте первым!</p>
<?php else: ?>
<div class="stories-strip">
<?php while ($u = $result->fetch_assoc()): ?>
<a href="stories_view.php?user_id=<?= (int)$u['id'] ?>" class="story-bubble">
<?php if ($u['photo']): ?>
<img src="/assets/img/<?= htmlspecialchars($u['photo']) ?>" class="story-avatar" alt="">
<?php else: ?>
<div class="story-avatar-placeholder">🙂</div>
<?php endif; ?>
<div class="story-name"><?= htmlspecialchars($u['name'] ?: 'Без имени') ?></div>
</a>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
<?php include 'footer.php'; ?>