38873-vm/discover.php
Flatlogic Bot d9eba63b0d v26
2026-02-28 18:56:22 +00:00

212 lines
11 KiB
PHP

<?php
require_once 'db/config.php';
session_start();
$user_id = $_SESSION['user_id'] ?? null;
if (!$user_id) { header('Location: login.php'); exit; }
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
if (!$user) { header('Location: login.php'); exit; }
$user_role = $user['role'];
if ($user_role === 'founder') {
header('Location: dashboard.php');
exit;
}
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
// Leaderboard: Most Followed
$stmt = db()->query("
SELECT s.*, u.full_name as founder_name
FROM startups s
JOIN users u ON s.founder_id = u.id
ORDER BY s.followers_count DESC
LIMIT 3
");
$mostFollowed = $stmt->fetchAll();
// Leaderboard: Most Funded (Total funding raised)
$stmt = db()->query("
SELECT s.id, s.name, u.full_name as founder_name, s.funding_raised as funded_amount
FROM startups s
JOIN users u ON s.founder_id = u.id
ORDER BY s.funding_raised DESC
LIMIT 3
");
$mostFunded = $stmt->fetchAll();
// General Browse
$q = $_GET['q'] ?? '';
$where = "u.onboarding_completed = 1";
$params = [];
if ($q) {
$where .= " AND (s.name LIKE ? OR s.description LIKE ? OR s.industry LIKE ?)";
$params[] = "%$q%";
$params[] = "%$q%";
$params[] = "%$q%";
}
$stmt = db()->prepare("
SELECT s.*, u.full_name as founder_name
FROM startups s
JOIN users u ON s.founder_id = u.id
WHERE $where
ORDER BY s.created_at DESC
LIMIT 12
");
$stmt->execute($params);
$browseStartups = $stmt->fetchAll();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Discovery Hub — <?= htmlspecialchars($platformName) ?></title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&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">
<style>
.hub-header { padding: 60px 0 40px; text-align: center; }
.hub-header h1 { font-size: 56px; font-weight: 900; margin-bottom: 12px; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hub-header p { color: var(--text-secondary); font-size: 20px; }
.leaderboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 60px; }
@media (max-width: 900px) { .leaderboard-grid { grid-template-columns: 1fr; } }
.lb-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 24px; padding: 30px; backdrop-filter: blur(20px); }
.lb-title { display: flex; align-items: center; gap: 12px; margin-bottom: 25px; font-size: 20px; font-weight: 700; }
.lb-item { display: flex; align-items: center; gap: 15px; padding: 15px; background: rgba(255,255,255,0.03); border-radius: 16px; margin-bottom: 12px; transition: all 0.3s; text-decoration: none; color: inherit; }
.lb-item:hover { background: rgba(255,255,255,0.06); transform: translateX(8px); border-color: var(--accent-blue); }
.lb-rank { width: 32px; height: 32px; background: var(--surface-color); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent-blue); font-size: 14px; }
.rank-1 { background: gold; color: #000; }
.rank-2 { background: silver; color: #000; }
.rank-3 { background: #cd7f32; color: #000; }
.startup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 25px; }
.startup-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 24px; padding: 30px; transition: all 0.3s; }
.startup-card:hover { transform: translateY(-5px); border-color: var(--accent-blue); }
</style>
</head>
<body>
<header>
<div class="container" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
<a href="dashboard.php" class="logo-container">
<img src="assets/images/logo.svg" alt="<?= htmlspecialchars($platformName) ?> Logo" class="logo-img">
<span class="logo-text"><?= htmlspecialchars($platformName) ?></span>
</a>
<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="startups.php">Browse Startups</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php" class="active">Discovery Hub</a>
<?php endif; ?>
<a href="messages.php">Messages</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<a href="notifications.php" style="color: var(--text-secondary); position: relative; font-size: 18px;">
<i class="fas fa-bell"></i>
</a>
<div style="display: flex; align-items: center; gap: 10px; padding: 5px 12px; background: rgba(255,255,255,0.05); border-radius: 50px; border: 1px solid var(--border-color);">
<div style="width: 24px; height: 24px; background: var(--gradient-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; font-weight: 800;">
<?= substr($user['full_name'], 0, 1) ?>
</div>
<span style="font-size: 13px; font-weight: 600;"><?= htmlspecialchars(explode(' ', $user['full_name'])[0]) ?></span>
</div>
<a href="logout.php" class="btn btn-secondary" style="padding: 8px 16px; font-size: 12px; border-radius: 10px;">Log Out</a>
</div>
</div>
</header>
<main class="container">
<div class="hero-bg">
<div class="hero-blob" style="top: 20%; right: -5%;"></div>
<div class="hero-blob" style="bottom: 10%; left: -5%; width: 500px; height: 500px; background: radial-gradient(circle, rgba(138, 43, 226, 0.1) 0%, rgba(0, 242, 255, 0.1) 100%);"></div>
</div>
<div class="hub-header">
<h1>Discovery Hub</h1>
<p>Explore the best student-led innovation across the network.</p>
</div>
<div class="leaderboard-grid">
<div class="lb-card">
<div class="lb-title"><i class="fas fa-heart" style="color: #ff3b30;"></i> Top Followed</div>
<?php foreach ($mostFollowed as $i => $s): ?>
<a href="startup_details.php?id=<?= $s['id'] ?>" class="lb-item">
<div class="lb-rank rank-<?= $i+1 ?>"><?= $i+1 ?></div>
<div style="flex: 1;">
<div style="font-weight: 700;"><?= htmlspecialchars($s['name']) ?></div>
<div style="font-size: 12px; color: var(--text-secondary);">by <?= htmlspecialchars($s['founder_name']) ?></div>
</div>
<div style="font-weight: 700; color: var(--accent-blue);"><?= number_format($s['followers_count']) ?></div>
</a>
<?php endforeach; ?>
</div>
<div class="lb-card">
<div class="lb-title"><i class="fas fa-rocket" style="color: var(--accent-blue);"></i> Most Funded</div>
<?php foreach ($mostFunded as $i => $s): ?>
<a href="startup_details.php?id=<?= $s['id'] ?>" class="lb-item">
<div class="lb-rank rank-<?= $i+1 ?>"><?= $i+1 ?></div>
<div style="flex: 1;">
<div style="font-weight: 700;"><?= htmlspecialchars($s['name']) ?></div>
<div style="font-size: 12px; color: var(--text-secondary);">by <?= htmlspecialchars($s['founder_name']) ?></div>
</div>
<div style="font-weight: 700; color: #2ecc71;">£<?= number_format($s['funded_amount']) ?></div>
</a>
<?php endforeach; ?>
</div>
</div>
<div style="margin-bottom: 40px; text-align: center;">
<h2 style="margin-bottom: 25px;">Browse All Startups</h2>
<form method="GET" style="display: flex; gap: 10px; max-width: 600px; margin: 0 auto;">
<input type="text" name="q" value="<?= htmlspecialchars($q) ?>" placeholder="Search startups..." class="form-control" style="flex: 1; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff; padding: 12px 20px; border-radius: 12px;">
<button type="submit" class="btn btn-primary">Filter</button>
</form>
</div>
<div class="startup-grid">
<?php foreach ($browseStartups as $s): ?>
<div class="startup-card" onclick="location.href='startup_details.php?id=<?= $s['id'] ?>'" style="cursor: pointer;">
<div style="display: flex; gap: 20px; align-items: center; margin-bottom: 20px;">
<div style="width: 60px; height: 60px; background: var(--gradient-primary); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; color: #fff;">
<?= substr($s['name'], 0, 1) ?>
</div>
<div>
<div style="font-weight: 700; font-size: 20px;"><?= htmlspecialchars($s['name']) ?></div>
<div style="font-size: 13px; color: var(--text-secondary);">by <?= htmlspecialchars($s['founder_name']) ?></div>
</div>
</div>
<p style="color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; line-height: 1.6; height: 42px; overflow: hidden;">
<?= htmlspecialchars(substr($s['description'], 0, 100)) ?>...
</p>
<div style="display: flex; justify-content: space-between; align-items: center;">
<?php if (!empty($s['industry'])): ?>
<span class="badge" style="font-size: 10px;"><?= htmlspecialchars($s['industry']) ?></span>
<?php endif; ?>
<span style="font-weight: 700; color: var(--accent-blue);">£<?= number_format($s['funding_raised']) ?></span>
</div>
</div>
<?php endforeach; ?>
</div>
</main>
<footer style="margin-top: 80px; padding: 60px 0; border-top: 1px solid var(--border-color); background: rgba(0,0,0,0.2);">
<div class="container" style="text-align: center;">
<div class="logo-container" style="justify-content: center; margin-bottom: 25px;">
<img src="assets/images/logo.svg" alt="<?= htmlspecialchars($platformName) ?> Logo" class="logo-img" style="width: 30px; height: 30px;">
<span class="logo-text" style="font-size: 20px;"><?= htmlspecialchars($platformName) ?></span>
</div>
<p style="color: var(--text-secondary); font-size: 14px;">&copy; <?= date('Y') ?> <?= htmlspecialchars($platformName) ?>. All rights reserved.</p>
</div>
</footer>
<script src="assets/js/main.js"></script>
</body>
</html>