38873-vm/messages.php
Flatlogic Bot 21f3fc7eab v2
2026-02-28 15:08:46 +00:00

90 lines
4.7 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
require_once __DIR__ . '/db/config.php';
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
$stmt = db()->prepare("SELECT m.*, u.full_name as other_user_name FROM messages m JOIN users u ON (m.sender_id = u.id OR m.receiver_id = u.id) WHERE (m.sender_id = ? OR m.receiver_id = ?) AND u.id != ? ORDER BY m.created_at DESC");
$stmt->execute([$_SESSION['user_id'], $_SESSION['user_id'], $_SESSION['user_id']]);
$messages = $stmt->fetchAll();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Messages — <?= htmlspecialchars($platformName) ?></title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
<header>
<div class="container" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
<div class="logo"><?= htmlspecialchars($platformName) ?></div>
<nav class="nav-links">
<?php if ($user['role'] === 'founder'): ?>
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="discover.php">Discover</a>
<a href="portfolio.php">Portfolio</a>
<?php endif; ?>
<a href="messages.php" class="active">Messages</a>
<a href="notifications.php">Notifications</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<a href="dashboard.php" style="color: var(--text-secondary);"><i class="fas fa-th-large"></i></a>
<a href="logout.php" class="btn btn-secondary" style="padding: 8px 16px;">Log Out</a>
</div>
</div>
</header>
<main class="container" style="padding-top: 50px;">
<h1>Messages</h1>
<p style="color: var(--text-secondary); margin-bottom: 40px;">Communicate with founders and investors in the network.</p>
<div style="display: grid; grid-template-columns: 350px 1fr; gap: 30px; height: 600px;">
<div class="card" style="padding: 0; display: flex; flex-direction: column;">
<div style="padding: 20px; border-bottom: 1px solid var(--border-color);">
<input type="text" placeholder="Search conversations..." style="width: 100%; padding: 10px; border-radius: 8px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
</div>
<div style="flex: 1; overflow-y: auto;">
<?php if (empty($messages)): ?>
<div style="text-align: center; padding: 40px 20px; color: var(--text-secondary);">
<p>No conversations yet.</p>
<a href="discover.php" class="btn btn-secondary" style="margin-top: 20px;">Find people</a>
</div>
<?php else: ?>
<?php foreach ($messages as $msg): ?>
<div style="padding: 20px; border-bottom: 1px solid var(--border-color); cursor: pointer; transition: background 0.2s;" onmouseover="this.style.background='var(--surface-color)'" onmouseout="this.style.background='transparent'">
<div style="font-weight: 600; margin-bottom: 5px;"><?= htmlspecialchars($msg['other_user_name']) ?></div>
<div style="font-size: 14px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
<?= htmlspecialchars($msg['content']) ?>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div class="card" style="display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px;">
<i class="fas fa-comments" style="font-size: 80px; color: var(--accent-blue); opacity: 0.1; margin-bottom: 40px;"></i>
<h3>Select a conversation</h3>
<p style="color: var(--text-secondary); max-width: 300px;">Choose a contact on the left to start messaging. Reach out to students, co-founders, or investors.</p>
</div>
</div>
</main>
</body>
</html>