214 lines
10 KiB
PHP
214 lines
10 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
$current_user_id = $_SESSION['user_id'];
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
|
|
$stmt->execute([$current_user_id]);
|
|
$user = $stmt->fetch();
|
|
|
|
if (!$user) {
|
|
session_destroy();
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
$user_role = $user['role'];
|
|
|
|
// Leaderboard: Most Followed This Week
|
|
$stmt = db()->prepare("
|
|
SELECT s.id, s.name, s.description, u.full_name as founder_name, COUNT(sf.id) as followers_count
|
|
FROM startups s
|
|
JOIN users u ON s.founder_id = u.id
|
|
JOIN startup_followers sf ON s.id = sf.startup_id
|
|
WHERE sf.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
GROUP BY s.id
|
|
ORDER BY followers_count DESC
|
|
LIMIT 10
|
|
");
|
|
$stmt->execute();
|
|
$mostFollowed = $stmt->fetchAll();
|
|
|
|
// Leaderboard: Most Funded This Week
|
|
$stmt = db()->prepare("
|
|
SELECT s.id, s.name, s.description, u.full_name as founder_name, SUM(i.amount) as funded_amount
|
|
FROM startups s
|
|
JOIN users u ON s.founder_id = u.id
|
|
JOIN investments i ON s.id = i.startup_id
|
|
WHERE i.status = 'approved' AND i.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
GROUP BY s.id
|
|
ORDER BY funded_amount DESC
|
|
LIMIT 10
|
|
");
|
|
$stmt->execute();
|
|
$mostFunded = $stmt->fetchAll();
|
|
|
|
// Search logic
|
|
$q = $_GET['q'] ?? '';
|
|
$browseStartups = [];
|
|
$where = "s.status = 'public'";
|
|
$params = [];
|
|
if ($q) {
|
|
$where .= " AND (s.name LIKE ? OR s.description LIKE ? OR u.full_name 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 20
|
|
");
|
|
$stmt->execute($params);
|
|
$browseStartups = $stmt->fetchAll();
|
|
|
|
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|
?>
|
|
<!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 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">
|
|
<style>
|
|
.hub-header { padding: 60px 0 40px; text-align: center; }
|
|
.hub-header h1 { font-size: 48px; font-weight: 800; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 12px; }
|
|
.hub-header p { color: var(--text-secondary); font-size: 18px; }
|
|
|
|
.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%;">
|
|
<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="startups.php">Browse Startups</a>
|
|
<a href="portfolio.php">Portfolio</a>
|
|
<?php endif; ?>
|
|
<a href="discover.php" class="active">Discovery Hub</a>
|
|
<a href="messages.php">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; font-size: 13px;">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> Most 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; line-height: 1.6; margin-bottom: 20px; height: 66px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;">
|
|
<?= htmlspecialchars($s['description']) ?>
|
|
</p>
|
|
<div style="display: flex; justify-content: space-between; border-top: 1px solid var(--border-color); padding-top: 20px;">
|
|
<div>
|
|
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase;">Raised</div>
|
|
<div style="font-weight: 700; color: #fff;">£<?= number_format($s['funding_raised']) ?></div>
|
|
</div>
|
|
<button class="btn btn-secondary" style="padding: 8px 16px; font-size: 12px;">Details</button>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</main>
|
|
|
|
<style>
|
|
header { background: rgba(10, 10, 15, 0.8); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border-color); padding: 15px 0; position: sticky; top: 0; z-index: 1000; }
|
|
.nav-links a { color: var(--text-secondary); text-decoration: none; margin: 0 15px; font-size: 14px; font-weight: 500; transition: color 0.2s; }
|
|
.nav-links a:hover, .nav-links a.active { color: #fff; }
|
|
.form-control:focus { outline: none; border-color: var(--accent-blue); }
|
|
</style>
|
|
|
|
</body>
|
|
</html>
|