📄 Source: index.php
<?php
require_once 'includes/config.php';
require_once 'includes/db.php';
require_once 'includes/auth.php';
require_once 'includes/functions.php';
$user = getCurrentUser();
$forums = getForums();
$activeForums = array_filter($forums, function($f) {
return $f['status'] === 'open';
});
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo SITE_NAME; ?> - Application Forums</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<div class="theme-switcher">
<button class="theme-btn" data-theme="light" title="Light mode">☀️</button>
<button class="theme-btn" data-theme="dark" title="Dark mode">🌙</button>
</div>
<div class="container">
<header class="header">
<div class="header-top">
<h1>📋 <?php echo SITE_NAME; ?></h1>
<div class="header-actions">
<?php if ($user): ?>
<span class="user-greeting">👋 Hi, <?php echo htmlspecialchars($user['username']); ?></span>
<a href="profile.php" class="btn-secondary">👤 Profile</a>
<a href="my-applications.php" class="btn-secondary">📄 My Apps</a>
<?php
$userForums = getForumsByUser($user['id']);
if (!empty($userForums)):
?>
<a href="dashboard.php" class="btn-secondary">📊 My Forums</a>
<?php endif; ?>
<a href="logout.php" class="btn-secondary" style="background: var(--error); color: white;">🚪 Logout</a>
<?php else: ?>
<a href="login.php" class="btn-primary">🔐 Login</a>
<?php endif; ?>
</div>
</div>
<p class="subhead">Browse and apply to available application forums</p>
</header>
<?php if (isset($_GET['error'])): ?>
<div class="error-message">⚠️ <?php echo htmlspecialchars($_GET['error']); ?></div>
<?php endif; ?>
<?php if (isset($_GET['success'])): ?>
<div class="success-message">✅ <?php echo htmlspecialchars($_GET['success']); ?></div>
<?php endif; ?>
<!-- Create Forum - Available to EVERYONE (logged in) -->
<?php if ($user): ?>
<div style="margin-bottom: 1.5rem;">
<a href="create-forum.php" class="btn-primary" style="width: 100%; text-align: center; display: block; background: var(--btn-success);">
➕ Create New Application Forum
</a>
</div>
<?php else: ?>
<div style="margin-bottom: 1.5rem; text-align: center; padding: 1rem; background: var(--bg-card); border-radius: 1rem; border: 1px solid var(--border-color);">
<p style="color: var(--text-secondary);">
🔐 <a href="login.php" style="color: var(--info);">Login</a> to create your own application forum
</p>
</div>
<?php endif; ?>
<div class="forums-grid">
<?php if (empty($activeForums)): ?>
<div class="empty-state">
<p>📭 No active application forums available</p>
<?php if ($user): ?>
<a href="create-forum.php" class="btn-primary" style="margin-top: 1rem; display: inline-block;">Create One Now</a>
<?php endif; ?>
</div>
<?php else: ?>
<?php foreach ($activeForums as $forum): ?>
<div class="forum-card">
<div class="forum-header">
<h3><?php echo htmlspecialchars($forum['title']); ?></h3>
<span class="forum-platform"><?php echo getPlatformLabel($forum['platform']); ?></span>
</div>
<?php if (!empty($forum['description'])): ?>
<p class="forum-description"><?php echo htmlspecialchars($forum['description']); ?></p>
<?php endif; ?>
<div class="forum-meta">
<span>📝 <?php echo count($forum['questions']); ?> questions</span>
<span>📅 <?php echo timeAgo($forum['created_at']); ?></span>
<span>⏱️ <?php echo $forum['time_limit']; ?>min</span>
<span>📊 <?php echo count($forum['submissions']); ?> submissions</span>
<?php if ($user && canManageForum($forum['id'], $user['id'])): ?>
<span style="color: var(--info);">👔 You manage this</span>
<?php endif; ?>
</div>
<?php if ($user): ?>
<?php if (hasUserSubmitted($forum['id'], $user['id'])): ?>
<div class="already-applied">✅ You've already applied to this forum</div>
<?php else: ?>
<a href="apply.php?id=<?php echo $forum['id']; ?>" class="btn-primary apply-btn">Apply Now →</a>
<?php endif; ?>
<?php if (canManageForum($forum['id'], $user['id'])): ?>
<a href="dashboard.php?forum_id=<?php echo $forum['id']; ?>" class="btn-secondary" style="margin-top: 0.5rem; width: 100%; text-align: center;">📊 Manage</a>
<?php endif; ?>
<?php else: ?>
<a href="login.php?redirect=apply.php?id=<?php echo $forum['id']; ?>" class="btn-primary apply-btn">Login to Apply</a>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<footer class="footer">
<p>📋 <?php echo SITE_NAME; ?> v1.0 | Anyone can create forums, owners can add admins</p>
</footer>
</div>
<script src="assets/script.js"></script>
</body>
</html>
← Back