From ffcaed889af7d65cadce660d57ed6e44a3e94108 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 28 Feb 2026 18:28:06 +0000 Subject: [PATCH] s21 --- discover.php | 133 ++++++------ edit_profile.php | 225 +++++++++------------ messages.php | 397 +++++++++++------------------------- notifications.php | 125 ++++++------ partners.php | 346 +++++++++---------------------- portfolio.php | 62 ++++-- startup_details.php | 481 ++++++++++++++++++-------------------------- startups.php | 132 +++++------- 8 files changed, 722 insertions(+), 1179 deletions(-) diff --git a/discover.php b/discover.php index 9bb3b61..4c46aa1 100644 --- a/discover.php +++ b/discover.php @@ -1,88 +1,59 @@ prepare("SELECT * FROM users WHERE id = ?"); -$stmt->execute([$current_user_id]); +$stmt->execute([$user_id]); $user = $stmt->fetch(); - -if (!$user) { - session_destroy(); - header("Location: login.php"); - exit; -} +if (!$user) { header('Location: login.php'); exit; } $user_role = $user['role']; +$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; -// Blocked users filter -$stmt = db()->prepare("SELECT blocked_id FROM blocked_users WHERE blocker_id = ?"); -$stmt->execute([$current_user_id]); -$blocked_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); - -$stmt = db()->prepare("SELECT blocker_id FROM blocked_users WHERE blocked_id = ?"); -$stmt->execute([$current_user_id]); -$blocked_by_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); - -$all_blocked = array_unique(array_merge($blocked_ids, $blocked_by_ids)); -$placeholders = empty($all_blocked) ? "0" : implode(',', array_fill(0, count($all_blocked), '?')); - -// Leaderboard: Most Followed (All Time) -$sql = " - 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 - LEFT JOIN startup_followers sf ON s.id = sf.startup_id - WHERE u.id NOT IN ($placeholders) - GROUP BY s.id - ORDER BY followers_count DESC - LIMIT 10 -"; -$stmt = db()->prepare($sql); -$stmt->execute($all_blocked ?: []); +// Leaderboard: Most Followed +$stmt = db()->query(" + SELECT s.*, u.full_name as founder_name, s.followers_count + 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 (All Time) -$sql = " - SELECT s.id, s.name, s.description, u.full_name as founder_name, s.funding_raised as funded_amount +// 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 - WHERE u.id NOT IN ($placeholders) - ORDER BY funded_amount DESC - LIMIT 10 -"; -$stmt = db()->prepare($sql); -$stmt->execute($all_blocked ?: []); + ORDER BY s.funding_raised DESC + LIMIT 3 +"); $mostFunded = $stmt->fetchAll(); -// Search logic +// General Browse $q = $_GET['q'] ?? ''; -$browseStartups = []; -$where = "s.status = 'public' AND u.id NOT IN ($placeholders)"; -$params = $all_blocked ?: []; +$where = "onboarding_completed = 1"; +$params = []; if ($q) { - $where .= " AND (s.name LIKE ? OR s.description LIKE ? OR u.full_name LIKE ?)"; + $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 20 + LIMIT 12 "); $stmt->execute($params); $browseStartups = $stmt->fetchAll(); - -$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; ?> @@ -90,13 +61,15 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; Discovery Hub — <?= htmlspecialchars($platformName) ?> - + + + + + - \ No newline at end of file + diff --git a/edit_profile.php b/edit_profile.php index 70743ec..a017844 100644 --- a/edit_profile.php +++ b/edit_profile.php @@ -1,69 +1,54 @@ prepare("SELECT * FROM users WHERE id = ?"); -$stmt->execute([$_SESSION['user_id']]); +$stmt->execute([$user_id]); $user = $stmt->fetch(); +if (!$user) { header('Location: login.php'); exit; } $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; - $error = ''; $success = ''; -// Check for active funding rounds -$stmt = db()->prepare("SELECT COUNT(*) FROM startups s JOIN funding_rounds fr ON s.id = fr.startup_id WHERE s.founder_id = ? AND fr.status = 'Active'"); -$stmt->execute([$_SESSION['user_id']]); -$activeRoundsCount = $stmt->fetchColumn(); - if ($_SERVER['REQUEST_METHOD'] === 'POST') { - if (isset($_POST['action']) && $_POST['action'] === 'delete_account') { - if ($user['role'] === 'founder' && $activeRoundsCount > 0) { - $error = "You cannot delete your account with active funding rounds. Please finish or cancel them first."; - } else { - // Delete account - db()->beginTransaction(); - try { - // Remove profile (cascades or sets null according to our migration) - $stmt = db()->prepare("DELETE FROM users WHERE id = ?"); - $stmt->execute([$_SESSION['user_id']]); - db()->commit(); - - session_destroy(); - header("Location: login.php?msg=account_deleted"); - exit; - } catch (Exception $e) { - db()->rollBack(); - $error = "Account deletion failed: " . $e->getMessage(); - } - } - } else { - $full_name = trim($_POST['full_name'] ?? ''); - $bio = trim($_POST['bio'] ?? ''); - $interests = trim($_POST['interests'] ?? ''); - $investment_appetite = trim($_POST['investment_appetite'] ?? ''); + if (isset($_POST['action']) && $_POST['action'] === 'update_profile') { + $full_name = trim($_POST['full_name']); + $bio = trim($_POST['bio']); + $university = trim($_POST['university']); + $degree_program = trim($_POST['degree_program']); + $skills = trim($_POST['skills']); + $startup_industries = trim($_POST['startup_industries']); - if (empty($full_name)) { - $error = "Name cannot be empty."; + if ($full_name) { + $stmt = db()->prepare("UPDATE users SET full_name = ?, bio = ?, university = ?, degree_program = ?, skills = ?, startup_industries = ? WHERE id = ?"); + $stmt->execute([$full_name, $bio, $university, $degree_program, $skills, $startup_industries, $user_id]); + $success = "Profile updated successfully!"; + // Refresh user data + $stmt = db()->prepare("SELECT * FROM users WHERE id = ?"); + $stmt->execute([$user_id]); + $user = $stmt->fetch(); } else { - $stmt = db()->prepare("UPDATE users SET full_name = ?, bio = ?, interests = ?, investment_appetite = ? WHERE id = ?"); - try { - $stmt->execute([$full_name, $bio, $interests, $investment_appetite, $_SESSION['user_id']]); - $success = "Profile updated successfully!"; - // Update session if name changed - $_SESSION['full_name'] = $full_name; - // Refresh user data - $stmt = db()->prepare("SELECT * FROM users WHERE id = ?"); - $stmt->execute([$_SESSION['user_id']]); - $user = $stmt->fetch(); - } catch (PDOException $e) { - $error = "Update failed: " . $e->getMessage(); - } + $error = "Full name is required."; + } + } elseif (isset($_POST['action']) && $_POST['action'] === 'delete_account') { + try { + db()->beginTransaction(); + db()->prepare("DELETE FROM startup_followers WHERE user_id = ?")->execute([$user_id]); + db()->prepare("DELETE FROM matches WHERE user1_id = ? OR user2_id = ?")->execute([$user_id, $user_id]); + db()->prepare("DELETE FROM swipes WHERE swiper_id = ? OR swiped_id = ?")->execute([$user_id, $user_id]); + db()->prepare("DELETE FROM notifications WHERE user_id = ?")->execute([$user_id]); + db()->prepare("DELETE FROM users WHERE id = ?")->execute([$user_id]); + db()->commit(); + session_destroy(); + header("Location: login.php?msg=account_deleted"); + exit; + } catch (Exception $e) { + db()->rollBack(); + $error = "Account deletion failed: " . $e->getMessage(); } } } @@ -74,120 +59,106 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { Edit Profile — <?= htmlspecialchars($platformName) ?> - + + + - +
-
+

Edit Profile

Manage your public presence in the community.

- -
- -
- +
+
- -
- -
- - -
+
-
- - + +
+ +
-
- - - University status is verified and cannot be changed. +
+ +
-
- - +
+ +
-
- - +
+ +
- -
- - -
- - +
+ + +
+
+ + +
+
- -
-

Danger Zone

-

Deleting your account is permanent and cannot be undone. All your profile information will be removed, but your startup listings will remain.

- - - - -
- + +
+ +
+

Venture Financials

+
+
£
+
Total Raised All-Time
+
+
+
+
+
+
Investors
+
+
+
+
Followers
+
+
+
Seed
+
Stage
+
+
+
-
-

Active Funding Round

+
+

Active Round

0) ? min(100, ($activeRound['funding_raised'] / $activeRound['funding_goal']) * 100) : 0; ?> -
+
-
-
- £ raised - Target: £ -
- -
-
- - - -
-
- - - -
+
+ £ + £ target
- -
+
+ + + - -
- - +
+ +
+ - -
- -
-
-

No Active Funding Round

- - -
-
- -
-
-

Venture Stats

-
-
-
Backers
- prepare("SELECT COUNT(DISTINCT investor_id) FROM investments WHERE startup_id = ? AND status = 'approved'"); - $stmt->execute([$startup_id]); - $backerCount = $stmt->fetchColumn(); - ?> -
-
-
-
Followers
- prepare("SELECT COUNT(*) FROM startup_followers WHERE startup_id = ?"); - $stmt->execute([$startup_id]); - $followerCount = $stmt->fetchColumn(); - ?> -
-
-
-
-
Total Raised All-Time
-
£
-
-
-

Founder

+

Founder

prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$startup['founder_id']]); $founder = $stmt->fetch(); ?> - -
-
- - - -
- -
- -
-
-
-
-
-
+
+
+
- Send Message - +
+
+
+
+
+ Send Message
- + + \ No newline at end of file diff --git a/startups.php b/startups.php index e5a589a..2b44ddf 100644 --- a/startups.php +++ b/startups.php @@ -1,46 +1,27 @@ prepare("SELECT * FROM users WHERE id = ?"); -$stmt->execute([$_SESSION['user_id']]); +$stmt->execute([$user_id]); $user = $stmt->fetch(); +if (!$user) { header('Location: login.php'); exit; } $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; -// Identify Trending Startups (Top 3 in followers or funding) -$trendingIds = []; - -// Top 3 Followed -$stmt = db()->prepare(" - SELECT s.id - FROM startups s - LEFT JOIN startup_followers sf ON s.id = sf.startup_id - GROUP BY s.id - ORDER BY COUNT(sf.id) DESC - LIMIT 3 -"); -$stmt->execute(); -$topFollowed = $stmt->fetchAll(PDO::FETCH_COLUMN); -$trendingIds = array_merge($trendingIds, $topFollowed); - -// Top 3 Funded (Total) +// Fetch Trending Startups based on total funding raised $stmt = db()->prepare(" SELECT id FROM startups ORDER BY funding_raised DESC - LIMIT 3 + LIMIT 10 "); $stmt->execute(); -$topFunded = $stmt->fetchAll(PDO::FETCH_COLUMN); -$trendingIds = array_unique(array_merge($trendingIds, $topFunded)); +$trendingIds = $stmt->fetchAll(PDO::FETCH_COLUMN); -$myStartups = []; if ($user['role'] === 'founder') { $stmt = db()->prepare(" SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status @@ -49,17 +30,16 @@ if ($user['role'] === 'founder') { WHERE s.founder_id = ? ORDER BY s.created_at DESC "); - $stmt->execute([$_SESSION['user_id']]); + $stmt->execute([$user_id]); $myStartups = $stmt->fetchAll(); } else { - // Investors see all public startups and their active round if any + // Browse all startups for investors $stmt = db()->prepare(" - SELECT s.*, u.full_name as founder_name, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status + SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status, u.full_name as founder_name FROM startups s - LEFT JOIN users u ON s.founder_id = u.id LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active' - WHERE s.status = 'public' - ORDER BY s.created_at DESC + LEFT JOIN users u ON s.founder_id = u.id + ORDER BY s.funding_raised DESC, s.created_at DESC "); $stmt->execute(); $myStartups = $stmt->fetchAll(); @@ -70,8 +50,10 @@ if ($user['role'] === 'founder') { - <?= $user['role'] === 'founder' ? 'My Startups' : 'Browse Startups' ?> — <?= htmlspecialchars($platformName) ?> - + <?= $user['role'] === 'founder' ? 'My Startups' : 'Student Startups' ?> — <?= htmlspecialchars($platformName) ?> + + + + + - \ No newline at end of file +