Compare commits

...

3 Commits

Author SHA1 Message Date
Flatlogic Bot
f05220da7c tre 2025-11-19 23:45:40 +00:00
Flatlogic Bot
1b14267623 v4 2025-11-19 22:24:36 +00:00
Flatlogic Bot
2ee3cb7a22 version 1 2025-11-19 21:59:09 +00:00
38 changed files with 1664 additions and 151 deletions

View File

@ -0,0 +1,42 @@
<?php
require_once '../includes/session.php';
require_login();
require_admin();
require_once '../db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$application_id = $_POST['application_id'] ?? null;
$action = $_POST['action'] ?? null;
if ($application_id && ($action === 'approve' || $action === 'reject')) {
$pdo = db();
$new_status = ($action === 'approve') ? 'approved' : 'rejected';
$stmt = $pdo->prepare('UPDATE applications SET status = ? WHERE id = ?');
if ($stmt->execute([$new_status, $application_id])) {
$_SESSION['flash_message'] = [
'type' => 'success',
'message' => 'Application status has been updated.'
];
} else {
$_SESSION['flash_message'] = [
'type' => 'danger',
'message' => 'Failed to update application status.'
];
}
} else {
$_SESSION['flash_message'] = [
'type' => 'danger',
'message' => 'Invalid request.'
];
}
} else {
$_SESSION['flash_message'] = [
'type' => 'danger',
'message' => 'Invalid request method.'
];
}
header('Location: applications.php');
exit();

117
admin/applications.php Normal file
View File

@ -0,0 +1,117 @@
<?php
require_once '../includes/session.php';
require_login();
require_admin();
require_once '../db/config.php';
require_once '../includes/header.php';
$pdo = db();
// Fetch all applications with user and event info
$stmt = $pdo->query('SELECT a.id, a.status, a.created_at, u.email AS user_name, u.email AS user_email, e.title AS event_name
FROM applications a
JOIN users u ON a.user_id = u.id
JOIN events e ON a.event_id = e.id
ORDER BY a.created_at DESC');
$applications = $stmt->fetchAll();
?>
<div class="main-content">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Manage Applications</h1>
</div>
<?php if (isset($_SESSION['flash_message'])): ?>
<div class="alert alert-<?php echo $_SESSION['flash_message']['type']; ?> alert-dismissible fade show" role="alert">
<?php echo $_SESSION['flash_message']['message']; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['flash_message']); ?>
<?php endif; ?>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Applicant</th>
<th>Event</th>
<th>Status</th>
<th>Proof</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (count($applications) > 0): ?>
<?php foreach ($applications as $app): ?>
<tr>
<td>
<?php echo htmlspecialchars($app['user_name']); ?><br>
<small class="text-muted"><?php echo htmlspecialchars($app['user_email']); ?></small>
</td>
<td><?php echo htmlspecialchars($app['event_name']); ?></td>
<td>
<span class="badge bg-<?php
switch ($app['status']) {
case 'approved': echo 'success'; break;
case 'rejected': echo 'danger'; break;
case 'pending_approval': echo 'warning'; break;
case 'awaiting_proof': echo 'info'; break;
default: echo 'secondary';
}
?>">
<?php echo htmlspecialchars(str_replace('_', ' ', ucfirst($app['status']))); ?>
</span>
</td>
<td>
<?php
// Fetch proofs for the application
$proofs_stmt = $pdo->prepare('SELECT file_path, created_at FROM application_proofs WHERE application_id = ? ORDER BY created_at DESC');
$proofs_stmt->execute([$app['id']]);
$proofs = $proofs_stmt->fetchAll();
if (count($proofs) > 0) {
echo '<ul class="list-unstyled mb-0">';
foreach ($proofs as $proof) {
echo '<li><a href="/' . htmlspecialchars($proof['file_path']) . '" target="_blank">View Proof</a> <small class="text-muted">(' . htmlspecialchars($proof['created_at']) . ')</small></li>';
}
echo '</ul>';
} else {
echo '-';
}
?>
</td>
<td>
<?php if ($app['status'] === 'pending_approval'): ?>
<form action="application_actions.php" method="POST" class="d-inline-block">
<input type="hidden" name="application_id" value="<?php echo $app['id']; ?>">
<input type="hidden" name="action" value="approve">
<button type="submit" class="btn btn-sm btn-success">Approve</button>
</form>
<form action="application_actions.php" method="POST" class="d-inline-block">
<input type="hidden" name="application_id" value="<?php echo $app['id']; ?>">
<input type="hidden" name="action" value="reject">
<button type="submit" class="btn btn-sm btn-danger">Reject</button>
</form>
<?php else: ?>
-
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="text-center">No applications found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php require_once '../includes/footer.php'; ?>

72
admin/event_actions.php Normal file
View File

@ -0,0 +1,72 @@
<?php
require_once '../includes/session.php';
require_admin();
require_once '../db/config.php';
$action = $_GET['action'] ?? null;
$pdo = db();
switch ($action) {
case 'create':
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = $_POST['title'] ?? '';
$description = $_POST['description'] ?? '';
$event_date = $_POST['event_date'] ?? '';
$location = $_POST['location'] ?? '';
$stmt = $pdo->prepare('INSERT INTO events (title, description, event_date, location) VALUES (?, ?, ?, ?)');
$stmt->execute([$title, $description, $event_date, $location]);
header('Location: events.php');
exit;
}
break;
case 'edit':
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$event_id = $_POST['event_id'] ?? null;
$name = $_POST['name'] ?? '';
$description = $_POST['description'] ?? '';
$date = $_POST['date'] ?? '';
$location = $_POST['location'] ?? '';
$capacity = $_POST['capacity'] ?? 0;
if ($event_id) {
// Handle image upload
$image_url = $_POST['existing_image_url'] ?? null;
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
$upload_dir = '../assets/images/events/';
if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0775, true);
}
$image_name = uniqid() . '-' . basename($_FILES['image']['name']);
$target_path = $upload_dir . $image_name;
if (move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
$image_url = 'assets/images/events/' . $image_name;
}
}
$stmt = $pdo->prepare('UPDATE events SET name = ?, description = ?, date = ?, location = ?, capacity = ?, image_url = ? WHERE id = ?');
$stmt->execute([$name, $description, $date, $location, $capacity, $image_url, $event_id]);
}
header('Location: events.php');
exit;
}
break;
case 'toggle_open':
$id = $_GET['id'] ?? null;
if ($id) {
$stmt = $pdo->prepare('UPDATE events SET is_open = !is_open WHERE id = ?');
$stmt->execute([$id]);
}
header('Location: events.php');
exit;
// Add cases for update and delete later
default:
header('Location: events.php');
exit;
}

78
admin/event_edit.php Normal file
View File

@ -0,0 +1,78 @@
<?php
require_once '../includes/session.php';
require_login();
require_admin();
require_once '../db/config.php';
$event_id = $_GET['id'] ?? null;
if (!$event_id) {
header('Location: events.php');
exit();
}
$pdo = db();
$stmt = $pdo->prepare('SELECT * FROM events WHERE id = ?');
$stmt->execute([$event_id]);
$event = $stmt->fetch();
if (!$event) {
header('Location: events.php');
exit();
}
require_once '../includes/header.php';
?>
<main class="container my-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Edit Event</h1>
<a href="events.php" class="btn btn-secondary">Back to Events</a>
</div>
<div class="card">
<div class="card-body">
<form action="event_actions.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="edit">
<input type="hidden" name="event_id" value="<?php echo $event['id']; ?>">
<div class="mb-3">
<label for="name" class="form-label">Event Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($event['name']); ?>" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" rows="5" required><?php echo htmlspecialchars($event['description']); ?></textarea>
</div>
<div class="mb-3">
<label for="date" class="form-label">Date</label>
<input type="datetime-local" class="form-control" id="date" name="date" value="<?php echo date('Y-m-d\TH:i', strtotime($event['date'])); ?>" required>
</div>
<div class="mb-3">
<label for="location" class="form-label">Location</label>
<input type="text" class="form-control" id="location" name="location" value="<?php echo htmlspecialchars($event['location']); ?>" required>
</div>
<div class="mb-3">
<label for="capacity" class="form-label">Capacity</label>
<input type="number" class="form-control" id="capacity" name="capacity" value="<?php echo htmlspecialchars($event['capacity']); ?>" min="1">
</div>
<div class="mb-3">
<label for="image" class="form-label">Event Image</label>
<input type="file" class="form-control" id="image" name="image">
<?php if ($event['image_url']): ?>
<img src="../<?php echo htmlspecialchars($event['image_url']); ?>" alt="Event Image" class="img-fluid mt-3" style="max-height: 200px;">
<?php endif; ?>
</div>
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
</div>
</main>
<?php require_once '../includes/footer.php'; ?>

82
admin/events.php Normal file
View File

@ -0,0 +1,82 @@
<?php
require_once '../includes/session.php';
require_admin();
require_once '../db/config.php';
// Fetch all events
$pdo = db();
$stmt = $pdo->query('SELECT * FROM events ORDER BY event_date DESC');
$events = $stmt->fetchAll();
require_once '../includes/header.php';
?>
<div class="main-content">
<h1 class="my-5">Manage Events</h1>
<div class="card mb-5">
<div class="card-body">
<h5 class="card-title">Create New Event</h5>
<form action="event_actions.php?action=create" method="POST">
<div class="mb-3">
<label for="title" class="form-label">Event Title</label>
<input type="text" class="form-control" id="title" name="title" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" rows="3"></textarea>
</div>
<div class="mb-3">
<label for="event_date" class="form-label">Event Date</label>
<input type="datetime-local" class="form-control" id="event_date" name="event_date" required>
</div>
<div class="mb-3">
<label for="location" class="form-label">Location</label>
<input type="text" class="form-control" id="location" name="location">
</div>
<button type="submit" class="btn btn-primary">Create Event</button>
</form>
</div>
</div>
<h2 class="my-4">Existing Events</h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Title</th>
<th>Image</th>
<th>Date</th>
<th>Location</th>
<th>Capacity</th>
<th>Open for Applications</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($events as $event): ?>
<tr>
<td><?php echo htmlspecialchars($event['title']); ?></td>
<td>
<?php if ($event['image_url']): ?>
<img src="../<?php echo htmlspecialchars($event['image_url']); ?>" alt="Event Image" style="max-height: 50px;">
<?php endif; ?>
</td>
<td><?php echo htmlspecialchars(date('M d, Y H:i', strtotime($event['event_date']))); ?></td>
<td><?php echo htmlspecialchars($event['location']); ?></td>
<td><?php echo htmlspecialchars($event['capacity']); ?></td>
<td><?php echo $event['is_open'] ? 'Yes' : 'No'; ?></td>
<td>
<a href="event_edit.php?id=<?php echo $event['id']; ?>" class="btn btn-sm btn-primary">Edit</a>
<a href="event_actions.php?action=toggle_open&id=<?php echo $event['id']; ?>" class="btn btn-sm btn-secondary">
<?php echo $event['is_open'] ? 'Close' : 'Open'; ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php require_once '../includes/footer.php'; ?>

55
admin/index.php Normal file
View File

@ -0,0 +1,55 @@
<?php
require_once '../includes/session.php';
require_admin();
require_once '../db/config.php';
// Fetch counts for the dashboard
try {
$total_users = db()->query('SELECT COUNT(*) FROM users')->fetchColumn();
$total_events = db()->query('SELECT COUNT(*) FROM events')->fetchColumn();
$total_applications = db()->query('SELECT COUNT(*) FROM applications')->fetchColumn();
} catch (PDOException $e) {
// Handle database errors gracefully
error_log('Dashboard Error: ' . $e->getMessage());
$total_users = $total_events = $total_applications = 'N/A';
}
require_once '../includes/header.php';
?>
<div class="main-content">
<h1 class="my-5">Admin Dashboard</h1>
<p>Welcome, admin! From here you can manage events, applications, and users.</p>
<div class="row">
<div class="col-md-4">
<div class="summary-card">
<div class="card-body">
<div class="card-icon"><i class="fas fa-users"></i></div>
<h5 class="card-title">Total Users</h5>
<p class="card-text"><?php echo $total_users; ?></p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="summary-card">
<div class="card-body">
<div class="card-icon"><i class="fas fa-calendar-alt"></i></div>
<h5 class="card-title">Total Events</h5>
<p class="card-text"><?php echo $total_events; ?></p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="summary-card">
<div class="card-body">
<div class="card-icon"><i class="fas fa-file-alt"></i></div>
<h5 class="card-title">Total Applications</h5>
<p class="card-text"><?php echo $total_applications; ?></p>
</div>
</div>
</div>
</div>
</div>
<?php require_once '../includes/footer.php'; ?>

67
admin/user_actions.php Normal file
View File

@ -0,0 +1,67 @@
<?php
require_once '../includes/session.php';
require_login();
require_admin();
require_once '../db/config.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: index.php');
exit();
}
$action = $_POST['action'] ?? '' ;
$user_id = $_POST['user_id'] ?? null;
if (!$user_id) {
header('Location: users.php');
exit();
}
$pdo = db();
try {
switch ($action) {
case 'update':
$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
$role = $_POST['role'] ?? 'user';
// Basic validation
if (empty($name) || empty($email) || !in_array($role, ['user', 'admin'])) {
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Invalid input.'];
header('Location: user_edit.php?id=' . $user_id);
exit();
}
$stmt = $pdo->prepare('UPDATE users SET name = ?, email = ?, role = ? WHERE id = ?');
$stmt->execute([$name, $email, $role, $user_id]);
$_SESSION['flash_message'] = ['type' => 'success', 'message' => 'User updated successfully.'];
break;
case 'delete':
// Prevent admin from deleting themselves
if ($user_id == $_SESSION['user']['id']) {
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'You cannot delete your own account.'];
header('Location: users.php');
exit();
}
$stmt = $pdo->prepare('DELETE FROM users WHERE id = ?');
$stmt->execute([$user_id]);
$_SESSION['flash_message'] = ['type' => 'success', 'message' => 'User deleted successfully.'];
break;
default:
$_SESSION['flash_message'] = ['type' => 'warning', 'message' => 'Invalid action.'];
break;
}
} catch (PDOException $e) {
// error_log($e->getMessage());
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'A database error occurred.'];
}
header('Location: users.php');
exit();

61
admin/user_edit.php Normal file
View File

@ -0,0 +1,61 @@
<?php
require_once '../includes/session.php';
require_login();
require_admin();
require_once '../db/config.php';
require_once '../includes/header.php';
$user_id = $_GET['id'] ?? null;
if (!$user_id) {
header('Location: users.php');
exit();
}
$pdo = db();
$stmt = $pdo->prepare('SELECT id, name, email, role FROM users WHERE id = ?');
$stmt->execute([$user_id]);
$user = $stmt->fetch();
if (!$user) {
header('Location: users.php');
exit();
}
?>
<main class="container my-5">
<h1>Edit User: <?php echo htmlspecialchars($user['name']); ?></h1>
<div class="card">
<div class="card-body">
<form action="user_actions.php" method="POST">
<input type="hidden" name="action" value="update">
<input type="hidden" name="user_id" value="<?php echo $user['id']; ?>">
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($user['name']); ?>" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($user['email']); ?>" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select" id="role" name="role">
<option value="user" <?php echo ($user['role'] === 'user') ? 'selected' : ''; ?>>User</option>
<option value="admin" <?php echo ($user['role'] === 'admin') ? 'selected' : ''; ?>>Admin</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Save Changes</button>
<a href="users.php" class="btn btn-secondary">Cancel</a>
</form>
</div>
</div>
</main>
<?php require_once '../includes/footer.php'; ?>

73
admin/users.php Normal file
View File

@ -0,0 +1,73 @@
<?php
require_once '../includes/session.php';
require_login();
require_admin();
require_once '../db/config.php';
require_once '../includes/header.php';
$pdo = db();
// Fetch all users
$stmt = $pdo->query('SELECT id, email, role, created_at FROM users ORDER BY created_at DESC');
$users = $stmt->fetchAll();
?>
<div class="main-content">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Manage Users</h1>
</div>
<?php if (isset($_SESSION['flash_message'])): ?>
<div class="alert alert-<?php echo $_SESSION['flash_message']['type']; ?> alert-dismissible fade show" role="alert">
<?php echo $_SESSION['flash_message']['message']; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['flash_message']); ?>
<?php endif; ?>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th>Joined</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (count($users) > 0): ?>
<?php foreach ($users as $user): ?>
<tr>
<td><?php echo htmlspecialchars($user['email']); ?></td>
<td><?php echo htmlspecialchars($user['email']); ?></td>
<td><?php echo htmlspecialchars(ucfirst($user['role'])); ?></td>
<td><?php echo date('M j, Y', strtotime($user['created_at'])); ?></td>
<td>
<a href="user_edit.php?id=<?php echo $user['id']; ?>" class="btn btn-sm btn-primary">Edit</a>
<form action="user_actions.php" method="POST" class="d-inline-block" onsubmit="return confirm('Are you sure you want to delete this user?');">
<input type="hidden" name="user_id" value="<?php echo $user['id']; ?>">
<input type="hidden" name="action" value="delete">
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
</form>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" class="text-center">No users found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php require_once '../includes/footer.php'; ?>

55
apply.php Normal file
View File

@ -0,0 +1,55 @@
<?php
require_once 'includes/session.php';
// 1. Check if user is logged in
if (!isset($_SESSION['user']['id'])) {
header('Location: login.php');
exit();
}
// 2. Check for POST request and event_id
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['event_id'])) {
header('Location: index.php');
exit();
}
require_once 'db/config.php';
$event_id = $_POST['event_id'];
$user_id = $_SESSION['user']['id'];
try {
$pdo = db();
// 3. Double-check for existing application
$stmt = $pdo->prepare("SELECT id FROM applications WHERE event_id = ? AND user_id = ?");
$stmt->execute([$event_id, $user_id]);
if ($stmt->fetch()) {
$_SESSION['flash_message'] = [
'type' => 'warning',
'message' => 'You have already applied to this event.'
];
header('Location: index.php#events');
exit();
}
// 4. Insert new application
$stmt = $pdo->prepare("INSERT INTO applications (event_id, user_id, status) VALUES (?, ?, 'awaiting_proof')");
$stmt->execute([$event_id, $user_id]);
$_SESSION['flash_message'] = [
'type' => 'success',
'message' => 'You have successfully applied! Please upload your proof in the dashboard.'
];
} catch (PDOException $e) {
// error_log($e->getMessage()); // Log error for debugging
$_SESSION['flash_message'] = [
'type' => 'danger',
'message' => 'A database error occurred. Please try again.'
];
}
// 5. Redirect back to the events section
header('Location: index.php#events');
exit();

315
assets/css/custom.css Normal file
View File

@ -0,0 +1,315 @@
/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700&family=Roboto:wght@400;500&display=swap');
/* --- Base & Theme --- */
body {
background-color: #121212;
color: #FFFFFF;
font-family: 'Roboto', sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Poppins', sans-serif;
font-weight: 700;
}
.navbar-dark .navbar-brand {
font-family: 'Poppins', sans-serif;
font-weight: 700;
color: #FFFFFF;
}
.navbar {
background-color: rgba(30, 30, 30, 0.7);
backdrop-filter: blur(10px);
}
/* --- Hero Section --- */
.hero {
padding: 100px 0;
text-align: center;
background: linear-gradient(180deg, rgba(18, 18, 18, 0) 0%, #121212 100%), url('https://images.pexels.com/photos/1105666/pexels-photo-1105666.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2') no-repeat center center;
background-size: cover;
}
.hero h1 {
font-size: 3.5rem;
color: #FFFFFF;
text-shadow: 0 2px 15px rgba(0, 0, 0, 0.5);
}
.hero p {
font-size: 1.25rem;
color: #A0A0A0;
margin-bottom: 30px;
}
/* --- Buttons --- */
.btn-primary {
background-color: #9E00FF;
border-color: #9E00FF;
padding: 12px 30px;
font-weight: 500;
border-radius: 8px;
transition: all 0.3s ease;
}
.btn-primary:hover {
background-color: #C46BFF;
border-color: #C46BFF;
transform: translateY(-2px);
box-shadow: 0 4px 20px rgba(158, 0, 255, 0.3);
}
.btn-secondary {
background-color: #00F5D4;
border-color: #00F5D4;
color: #121212;
padding: 10px 25px;
font-weight: 500;
border-radius: 8px;
transition: all 0.3s ease;
}
.btn-secondary:hover {
background-color: #5BFFF0;
border-color: #5BFFF0;
transform: translateY(-2px);
box-shadow: 0 4px 20px rgba(0, 245, 212, 0.3);
}
/* --- Event Cards --- */
.event-section {
padding: 80px 0;
}
.event-card {
background-color: #1E1E1E;
border: 1px solid #282828;
border-radius: 12px;
overflow: hidden;
transition: all 0.3s ease;
margin-bottom: 30px;
}
.event-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
border-color: #9E00FF;
}
.event-card img {
height: 200px;
object-fit: cover;
}
.event-card .card-body {
padding: 25px;
}
.event-card .card-title {
color: #FFFFFF;
font-size: 1.5rem;
margin-bottom: 10px;
}
.event-card .card-text {
color: #A0A0A0;
margin-bottom: 20px;
}
/* --- Footer --- */
.footer {
background-color: #1E1E1E;
padding: 40px 0;
text-align: center;
border-top: 1px solid #282828;
margin-top: 50px;
}
/* --- Admin Dashboard --- */
.admin-container {
display: flex;
min-height: 100vh;
}
.sidebar {
width: 250px;
background-color: #1E1E1E;
color: #FFFFFF;
padding: 20px;
display: flex;
flex-direction: column;
}
.sidebar .brand {
font-family: 'Poppins', sans-serif;
font-weight: 700;
font-size: 1.5rem;
color: #FFFFFF;
text-align: center;
margin-bottom: 30px;
text-decoration: none;
}
.sidebar .nav-link {
color: #A0A0A0;
text-decoration: none;
padding: 15px 20px;
margin-bottom: 10px;
border-radius: 8px;
transition: all 0.3s ease;
}
.sidebar .nav-link i {
margin-right: 15px;
}
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
background-color: #9E00FF;
color: #FFFFFF;
}
.content-wrapper {
flex-grow: 1;
padding: 30px;
background-color: #121212;
color: #FFFFFF;
}
.main-content {
background-color: #1E1E1E;
padding: 30px;
border-radius: 12px;
color: #FFFFFF;
}
.summary-card {
background-color: #1E1E1E;
border-radius: 12px;
padding: 25px;
margin-bottom: 30px;
display: flex;
align-items: center;
border: 1px solid #282828;
}
.summary-card .card-icon {
font-size: 2.5rem;
color: #9E00FF;
margin-right: 20px;
}
.summary-card .card-title {
font-size: 1rem;
color: #A0A0A0;
margin-bottom: 5px;
}
.summary-card .card-text {
font-size: 2rem;
font-weight: 700;
color: #FFFFFF;
}
.admin-footer {
background-color: #FFFFFF;
color: #121212;
border-top: 1px solid #E0E0E0;
}
/* --- Auth Cards --- */
.auth-card {
background-color: #1E1E1E;
border: 1px solid #282828;
border-radius: 12px;
padding: 40px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.auth-card .card-title {
color: #FFFFFF;
font-size: 2rem;
margin-bottom: 20px;
}
.form-label {
color: #A0A0A0;
}
.form-control {
background-color: #282828;
border-color: #383838;
color: #FFFFFF;
}
.form-control:focus {
background-color: #282828;
border-color: #9E00FF;
color: #FFFFFF;
box-shadow: 0 0 0 0.25rem rgba(158, 0, 255, 0.25);
}
/* --- Responsive Design --- */
.sidebar-toggler {
position: fixed;
top: 15px;
left: 15px;
z-index: 1000;
background-color: rgba(30, 30, 30, 0.8);
border: 1px solid #383838;
color: #FFFFFF;
width: 50px;
height: 50px;
border-radius: 8px;
font-size: 1.5rem;
}
@media (max-width: 991.98px) {
.sidebar {
position: fixed;
left: -250px;
top: 0;
height: 100%;
z-index: 999;
transition: left 0.3s ease-in-out;
}
.admin-container.sidebar-show .sidebar {
left: 0;
}
.content-wrapper {
padding-left: 15px;
padding-right: 15px;
}
.hero h1 {
font-size: 2.5rem;
}
.hero p {
font-size: 1rem;
}
.summary-card {
flex-direction: column;
text-align: center;
}
.summary-card .card-icon {
margin-right: 0;
margin-bottom: 15px;
}
}
/* --- Responsive Tables --- */
.table-responsive {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}

10
assets/js/main.js Normal file
View File

@ -0,0 +1,10 @@
document.addEventListener('DOMContentLoaded', function() {
const sidebarToggler = document.getElementById('sidebarToggler');
const adminContainer = document.querySelector('.admin-container');
if (sidebarToggler && adminContainer) {
sidebarToggler.addEventListener('click', function() {
adminContainer.classList.toggle('sidebar-show');
});
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

106
dashboard.php Normal file
View File

@ -0,0 +1,106 @@
<?php
require_once 'includes/session.php';
require_login();
// Redirect admin users to the admin dashboard
if (is_admin()) {
header('Location: admin/index.php');
exit();
}
require_once 'includes/header.php';
?>
<div class="main-content">
<main class="container my-5">
<h1 class="mb-4">User Dashboard</h1>
<p>Welcome back, <?php echo htmlspecialchars($_SESSION['user']['email']); ?>. Here you can view your applications and manage your profile.</p>
<hr class="my-5">
<h2 class="mb-4">My Applications</h2>
<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->prepare(
'SELECT a.id, a.status, a.created_at, e.title AS event_name, e.event_date
FROM applications a
JOIN events e ON a.event_id = e.id
WHERE a.user_id = ?
ORDER BY a.created_at DESC'
);
$stmt->execute([$_SESSION['user']['id']]);
$applications = $stmt->fetchAll();
if (count($applications) > 0):
?>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th>Event</th>
<th>Applied On</th>
<th>Status</th>
<th>Action / Proof</th>
</tr>
</thead>
<tbody>
<?php foreach ($applications as $app): ?>
<tr>
<td><?php echo htmlspecialchars($app['event_name']); ?></td>
<td><?php echo date('M j, Y, g:i a', strtotime($app['created_at'])); ?></td>
<td>
<span class="badge bg-<?php
switch ($app['status']) {
case 'approved': echo 'success'; break;
case 'rejected': echo 'danger'; break;
case 'pending_approval': echo 'warning'; break;
default: echo 'secondary';
}
?>">
<?php echo htmlspecialchars(str_replace('_', ' ', ucfirst($app['status']))); ?>
</span>
</td>
<td>
<?php
// Fetch proofs for the application
$proofs_stmt = $pdo->prepare('SELECT file_path FROM application_proofs WHERE application_id = ? ORDER BY uploaded_at DESC');
$proofs_stmt->execute([$app['id']]);
$proofs = $proofs_stmt->fetchAll();
if (count($proofs) > 0) {
echo '<ul class="list-unstyled mb-0">';
foreach ($proofs as $proof) {
echo '<li><a href="' . htmlspecialchars($proof['file_path']) . '" target="_blank">View Proof</a></li>';
}
echo '</ul>';
}
if ($app['status'] == 'awaiting_proof' || $app['status'] == 'pending_approval') { ?>
<form action="upload_proof.php" method="post" enctype="multipart/form-data" class="mt-2">
<input type="hidden" name="application_id" value="<?php echo $app['id']; ?>">
<div class="input-group">
<input type="file" name="proof_screenshot" class="form-control form-control-sm" required>
<button type="submit" class="btn btn-primary btn-sm">Upload</button>
</div>
</form>
<?php } elseif (count($proofs) == 0) {
echo '-';
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="alert alert-info">
You have not applied to any events yet. <a href="/index.php#events">Find events to apply for.</a>
</div>
<?php endif; ?>
</main>
</div>
<?php require_once 'includes/footer.php'; ?>

View File

@ -1,9 +1,9 @@
<?php
// Generated by setup_mariadb_project.sh — edit as needed.
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_35705');
define('DB_USER', 'app_35705');
define('DB_PASS', 'cdc156d8-b1ec-4426-86fb-b1e546c1a442');
define('DB_NAME', 'app_35861');
define('DB_USER', 'app_35861');
define('DB_PASS', 'fffb69b2-2523-4f34-9039-ec8241df87ca');
function db() {
static $pdo;

39
db/migrations.php Normal file
View File

@ -0,0 +1,39 @@
<?php
require_once 'config.php';
try {
$pdo = db();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Create migrations table if it doesn't exist
$pdo->exec("CREATE TABLE IF NOT EXISTS migrations (
id INT AUTO_INCREMENT PRIMARY KEY,
migration VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
// Get all executed migrations
$executedMigrations = $pdo->query("SELECT migration FROM migrations")->fetchAll(PDO::FETCH_COLUMN);
$migrationFiles = glob(__DIR__ . '/migrations/*.sql');
sort($migrationFiles);
foreach ($migrationFiles as $file) {
$migrationName = basename($file);
if (!in_array($migrationName, $executedMigrations)) {
$sql = file_get_contents($file);
$pdo->exec($sql);
// Record the migration
$stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)");
$stmt->execute([$migrationName]);
echo "Migration successful: {$migrationName}" . PHP_EOL;
}
}
echo "All migrations are up to date." . PHP_EOL;
} catch (PDOException $e) {
die("Migration failed: " . $e->getMessage());
}

View File

@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('admin', 'user') NOT NULL DEFAULT 'user',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert the super-admin user
INSERT INTO users (email, password, role)
VALUES ('dylan@sacredhiveofficial.com', '$2y$10$o4vTWS/X7cKvcsum4aIU0.5jzbtvHqKDqrSvZ64JgKNi5r5aJBJxy', 'admin');
-- Note: The password is "test123"

View File

@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS events (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
event_date DATETIME,
location VARCHAR(255),
image_url VARCHAR(255),
is_open BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS applications (
id INT AUTO_INCREMENT PRIMARY KEY,
event_id INT NOT NULL,
user_id INT NOT NULL,
status ENUM('pending', 'approved', 'rejected') NOT NULL DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

View File

@ -0,0 +1,3 @@
ALTER TABLE events
ADD COLUMN capacity INT(11) DEFAULT 0,
ADD COLUMN image_url VARCHAR(255) DEFAULT NULL;

View File

@ -0,0 +1,3 @@
ALTER TABLE `applications`
ADD COLUMN `proof_screenshot_path` VARCHAR(255) NULL,
ADD COLUMN `proof_status` VARCHAR(50) NOT NULL DEFAULT 'pending_upload';

View File

@ -0,0 +1,3 @@
ALTER TABLE `applications`
CHANGE `status` `status` ENUM('awaiting_proof', 'pending_approval', 'approved', 'rejected') NOT NULL DEFAULT 'awaiting_proof',
DROP COLUMN `proof_status`;

View File

@ -0,0 +1,8 @@
-- Step 1: Add 'awaiting_proof' to the ENUM to allow the update
ALTER TABLE `applications` MODIFY `status` ENUM('pending', 'awaiting_proof', 'pending_approval', 'approved', 'rejected') NOT NULL;
-- Step 2: Update existing 'pending' values
UPDATE `applications` SET `status` = 'awaiting_proof' WHERE `status` = 'pending';
-- Step 3: Remove 'pending' from the ENUM
ALTER TABLE `applications` MODIFY `status` ENUM('awaiting_proof', 'pending_approval', 'approved', 'rejected') NOT NULL DEFAULT 'awaiting_proof';

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS `application_proofs` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`application_id` INT NOT NULL,
`file_path` VARCHAR(255) NOT NULL,
`uploaded_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`application_id`) REFERENCES `applications`(`id`) ON DELETE CASCADE
);
ALTER TABLE `applications` DROP COLUMN `proof_screenshot_path`;

View File

@ -0,0 +1 @@
ALTER TABLE `application_proofs` ADD `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;

16
includes/footer.php Normal file
View File

@ -0,0 +1,16 @@
</div> <!-- .content-wrapper -->
</div> <!-- .admin-container -->
<!-- Footer -->
<footer class="footer">
<div class="container-fluid">
<p class="mb-0">&copy; <?php echo date("Y"); ?> PromoPass. All Rights Reserved. Built with Flatlogic.</p>
</div>
</footer>
<!-- Bootstrap 5 JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JS -->
<script src="/assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

55
includes/header.php Normal file
View File

@ -0,0 +1,55 @@
"""<?php require_once 'session.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PromoPass - The Ultimate Festival & Event Access Pass</title>
<meta name="description" content="Apply for guest list spots and promo opportunities at music festivals and club events. Built with Flatlogic Generator.">
<meta name="keywords" content="festival promo, event promotion, guest list, music festivals, influencer marketing, club events, promo pass, event access, Built with Flatlogic Generator">
<!-- Social Media Meta Tags -->
<meta property="og:title" content="PromoPass - The Ultimate Festival & Event Access Pass">
<meta property="og:description" content="Apply for guest list spots and promo opportunities at top music festivals and club events.">
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
<meta property="og:url" content="/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome for icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="/assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<div class="admin-container">
<div class="sidebar">
<a href="/index.php" class="brand">PromoPass</a>
<?php if (is_admin()): ?>
<a href="/admin/" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'index.php' && strpos($_SERVER['REQUEST_URI'], '/admin/') !== false ? 'active' : ''; ?>"><i class="fas fa-tachometer-alt"></i> Dashboard</a>
<a href="/admin/events.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'events.php' ? 'active' : ''; ?>"><i class="fas fa-calendar-alt"></i> Events</a>
<a href="/admin/applications.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'applications.php' ? 'active' : ''; ?>"><i class="fas fa-file-alt"></i> Applications</a>
<a href="/admin/users.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'users.php' ? 'active' : ''; ?>"><i class="fas fa-users"></i> Users</a>
<a href="/logout.php" class="nav-link"><i class="fas fa-sign-out-alt"></i> Logout</a>
<?php elseif (is_logged_in()): ?>
<a href="/index.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'index.php' ? 'active' : ''; ?>"><i class="fas fa-home"></i> Home</a>
<a href="/dashboard.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'dashboard.php' ? 'active' : ''; ?>"><i class="fas fa-user-circle"></i> My Dashboard</a>
<a href="/logout.php" class="nav-link"><i class="fas fa-sign-out-alt"></i> Logout</a>
<?php else: ?>
<a href="/index.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'index.php' ? 'active' : ''; ?>"><i class="fas fa-home"></i> Home</a>
<a href="/login.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'login.php' ? 'active' : ''; ?>"><i class="fas fa-sign-in-alt"></i> Login</a>
<a href="/signup.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) == 'signup.php' ? 'active' : ''; ?>"><i class="fas fa-user-plus"></i> Sign Up</a>
<?php endif; ?>
</div>
<div class="content-wrapper">
<button class="sidebar-toggler d-lg-none" type="button" id="sidebarToggler">
<i class="fas fa-bars"></i>
</button>
""

26
includes/session.php Normal file
View File

@ -0,0 +1,26 @@
<?php
session_start();
require_once __DIR__ . '/../db/config.php';
function is_logged_in() {
return isset($_SESSION['user']['id']);
}
function is_admin() {
return is_logged_in() && isset($_SESSION['user']['role']) && $_SESSION['user']['role'] === 'admin';
}
function require_login() {
if (!is_logged_in()) {
header('Location: login.php');
exit();
}
}
function require_admin() {
if (!is_admin()) {
header('Location: ../index.php'); // Redirect non-admins to the home page
exit();
}
}

219
index.php
View File

@ -1,150 +1,73 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
<?php require_once 'includes/header.php'; ?>
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
<div class="main-content">
<!-- Hero Section -->
<header class="hero">
<div class="container">
<h1 class="display-3">The Ultimate Festival & Event Access Pass</h1>
<p class="lead">Your gateway to exclusive guest lists and promotional opportunities at the hottest events.</p>
<a href="#events" class="btn btn-primary btn-lg">Browse Events</a>
</div>
</header>
<!-- Events Section -->
<main id="events" class="event-section">
<div class="container">
<?php if (isset($_SESSION['flash_message'])): ?>
<div class="alert alert-<?php echo $_SESSION['flash_message']['type']; ?> alert-dismissible fade show" role="alert">
<?php echo $_SESSION['flash_message']['message']; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['flash_message']); ?>
<?php endif; ?>
<h2 class="text-center mb-5">Open Events</h2>
<div class="row">
<?php
require_once 'db/config.php';
// Fetch open events from the database
$pdo = db();
$stmt = $pdo->query('SELECT * FROM events WHERE is_open = TRUE ORDER BY event_date ASC');
$events = $stmt->fetchAll();
// If user is logged in, get their applications
$user_applications = [];
if (isset($_SESSION['user']['id'])) {
$app_stmt = $pdo->prepare('SELECT event_id FROM applications WHERE user_id = ?');
$app_stmt->execute([$_SESSION['user']['id']]);
$user_applications = $app_stmt->fetchAll(PDO::FETCH_COLUMN);
}
foreach ($events as $event):
$imageUrl = !empty($event['image_url']) ? $event['image_url'] : 'https://images.pexels.com/photos/2263436/pexels-photo-2263436.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2';
?>
<div class="col-lg-4 col-md-6">
<div class="card event-card">
<img src="<?php echo htmlspecialchars($imageUrl); ?>" class="card-img-top" alt="Event Image">
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($event['title']); ?></h5>
<p class="card-text text-muted"><?php echo date("M d, Y", strtotime($event['event_date'])); ?> &bull; <?php echo htmlspecialchars($event['location']); ?></p>
<?php if (isset($_SESSION['user']['id']) && $_SESSION['user']['role'] === 'user'): ?>
<?php if (in_array($event['id'], $user_applications)): ?>
<button class="btn btn-success" disabled>Applied</button>
<?php else: ?>
<form action="apply.php" method="POST" style="display: inline;">
<input type="hidden" name="event_id" value="<?php echo $event['id']; ?>">
<button type="submit" class="btn btn-secondary">Apply Now</button>
</form>
<?php endif; ?>
<?php elseif (!isset($_SESSION['user']['id'])):
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<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;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>
<a href="login.php" class="btn btn-secondary">Login to Apply</a>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</main>
</div>
<?php require_once 'includes/footer.php'; ?>

79
login.php Normal file
View File

@ -0,0 +1,79 @@
<?php
require_once 'includes/session.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
if (empty($email) || empty($password)) {
$error = 'Please fill in all fields.';
} else {
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user'] = [
'id' => $user['id'],
'email' => $user['email'],
'role' => $user['role']
];
if ($user['role'] === 'admin') {
header('Location: admin/index.php');
} else {
header('Location: dashboard.php');
}
exit();
} else {
$error = 'Invalid email or password.';
}
} catch (PDOException $e) {
$error = 'Database error. Please try again later.';
// error_log($e->getMessage()); // It's good practice to log the actual error
}
}
}
require_once 'includes/header.php';
?>
<div class="main-content">
<main class="form-container">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6 col-lg-4">
<div class="card auth-card">
<div class="card-body">
<h2 class="card-title text-center">Login</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form action="login.php" method="POST">
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<p class="mt-3 text-center">Don't have an account? <a href="signup.php">Sign up</a></p>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<?php require_once 'includes/footer.php'; ?>

21
logout.php Normal file
View File

@ -0,0 +1,21 @@
<?php
require_once 'includes/session.php';
// Unset all of the session variables.
$_SESSION = [];
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
header('Location: index.php');
exit();

87
signup.php Normal file
View File

@ -0,0 +1,87 @@
<?php
require_once 'includes/session.php';
$error = '';
$success = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
$confirm_password = $_POST['confirm_password'] ?? '';
if (empty($email) || empty($password) || empty($confirm_password)) {
$error = 'Please fill in all fields.';
} elseif ($password !== $confirm_password) {
$error = 'Passwords do not match.';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = 'Invalid email format.';
} else {
try {
$pdo = db();
// Check if email already exists
$stmt = $pdo->prepare("SELECT COUNT(*) FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetchColumn() > 0) {
$error = 'An account with this email already exists.';
} else {
// Insert new user
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (email, password, role) VALUES (?, ?, 'user')");
if ($stmt->execute([$email, $hashed_password])) {
$success = 'Account created successfully! You can now <a href="login.php">login</a>.';
} else {
$error = 'Failed to create account. Please try again.';
}
}
} catch (PDOException $e) {
$error = 'Database error. Please try again later.';
// error_log($e->getMessage());
}
}
}
require_once 'includes/header.php';
?>
<div class="main-content">
<main class="form-container">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6 col-lg-4">
<div class="card auth-card">
<div class="card-body">
<h2 class="card-title text-center">Sign Up</h2>
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<?php if ($success): ?>
<div class="alert alert-success"><?php echo $success; ?></div>
<?php else: // Hide form on success ?>
<form action="signup.php" method="POST">
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="confirm_password" class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Create Account</button>
</div>
</form>
<?php endif; ?>
<p class="mt-3 text-center">Already have an account? <a href="login.php">Login</a></p>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<?php require_once 'includes/footer.php'; ?>

View File

@ -0,0 +1,5 @@
<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->query("SELECT * FROM migrations");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));

70
upload_proof.php Normal file
View File

@ -0,0 +1,70 @@
<?php
require_once 'includes/session.php';
require_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: dashboard.php');
exit();
}
if (!isset($_POST['application_id']) || !isset($_FILES['proof_screenshot'])) {
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Invalid request.'];
header('Location: dashboard.php');
exit();
}
$application_id = $_POST['application_id'];
$user_id = $_SESSION['user']['id'];
$file = $_FILES['proof_screenshot'];
require_once 'db/config.php';
$pdo = db();
// Verify application belongs to the user
$stmt = $pdo->prepare("SELECT id FROM applications WHERE id = ? AND user_id = ? AND (status = 'awaiting_proof' OR status = 'pending_approval')");
$stmt->execute([$application_id, $user_id]);
if (!$stmt->fetch()) {
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Invalid application or you are not allowed to perform this action.'];
header('Location: dashboard.php');
exit();
}
// File upload handling
if ($file['error'] !== UPLOAD_ERR_OK) {
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Error uploading file.'];
header('Location: dashboard.php');
exit();
}
$allowed_types = ['image/jpeg', 'image/png', 'image/gif'];
if (!in_array($file['type'], $allowed_types)) {
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Invalid file type. Only JPG, PNG, and GIF are allowed.'];
header('Location: dashboard.php');
exit();
}
if ($file['size'] > 5 * 1024 * 1024) { // 5 MB limit
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'File is too large. Maximum size is 5MB.'];
header('Location: dashboard.php');
exit();
}
$upload_dir = 'uploads/proofs/';
$filename = uniqid() . '-' . basename($file['name']);
$destination = $upload_dir . $filename;
if (move_uploaded_file($file['tmp_name'], $destination)) {
// Update database
$stmt = $pdo->prepare("INSERT INTO application_proofs (application_id, file_path) VALUES (?, ?)");
$stmt->execute([$application_id, $destination]);
$stmt = $pdo->prepare("UPDATE applications SET status = 'pending_approval' WHERE id = ?");
$stmt->execute([$application_id]);
$_SESSION['flash_message'] = ['type' => 'success', 'message' => 'Proof uploaded successfully. It is now pending review.'];
} else {
$_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Failed to move uploaded file.'];
}
header('Location: dashboard.php');
exit();

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB