v4
This commit is contained in:
parent
2ee3cb7a22
commit
1b14267623
42
admin/application_actions.php
Normal file
42
admin/application_actions.php
Normal 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();
|
||||
94
admin/applications.php
Normal file
94
admin/applications.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?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.name AS user_name, u.email AS user_email, e.name 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();
|
||||
|
||||
?>
|
||||
|
||||
<main class="container my-5">
|
||||
<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>Event</th>
|
||||
<th>Applicant</th>
|
||||
<th>Submitted</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (count($applications) > 0): ?>
|
||||
<?php foreach ($applications as $app): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($app['event_name']); ?></td>
|
||||
<td>
|
||||
<?php echo htmlspecialchars($app['user_name']); ?><br>
|
||||
<small class="text-muted"><?php echo htmlspecialchars($app['user_email']); ?></small>
|
||||
</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;
|
||||
default: echo 'secondary';
|
||||
}
|
||||
?>">
|
||||
<?php echo htmlspecialchars(ucfirst($app['status'])); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<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" <?php echo $app['status'] === 'approved' ? 'disabled' : ''; ?>>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" <?php echo $app['status'] === 'rejected' ? 'disabled' : ''; ?>>Reject</button>
|
||||
</form>
|
||||
</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>
|
||||
</main>
|
||||
|
||||
<?php require_once '../includes/footer.php'; ?>
|
||||
39
admin/event_actions.php
Normal file
39
admin/event_actions.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?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 '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;
|
||||
}
|
||||
76
admin/events.php
Normal file
76
admin/events.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?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';
|
||||
?>
|
||||
|
||||
<main class="dashboard-container">
|
||||
<div class="container">
|
||||
<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>Date</th>
|
||||
<th>Location</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 echo htmlspecialchars(date('M d, Y H:i', strtotime($event['event_date']))); ?></td>
|
||||
<td><?php echo htmlspecialchars($event['location']); ?></td>
|
||||
<td><?php echo $event['is_open'] ? 'Yes' : 'No'; ?></td>
|
||||
<td>
|
||||
<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>
|
||||
<!-- Edit and Delete buttons will be added later -->
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php require_once '../includes/footer.php'; ?>
|
||||
45
admin/index.php
Normal file
45
admin/index.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
require_once '../includes/session.php';
|
||||
require_admin();
|
||||
|
||||
require_once '../includes/header.php';
|
||||
?>
|
||||
|
||||
<main class="dashboard-container">
|
||||
<div class="container">
|
||||
<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="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Manage Events</h5>
|
||||
<p class="card-text">Create, edit, and view all promotional events.</p>
|
||||
<a href="events.php" class="btn btn-primary">Go to Events</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Manage Applications</h5>
|
||||
<p class="card-text">Review and approve/reject applications from promoters.</p>
|
||||
<a href="applications.php" class="btn btn-primary">Go to Applications</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Manage Users</h5>
|
||||
<p class="card-text">View and manage all registered users.</p>
|
||||
<a href="#" class="btn btn-primary">Go to Users</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php require_once '../includes/footer.php'; ?>
|
||||
55
apply.php
Normal file
55
apply.php
Normal 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 (?, ?, 'pending')");
|
||||
$stmt->execute([$event_id, $user_id]);
|
||||
|
||||
$_SESSION['flash_message'] = [
|
||||
'type' => 'success',
|
||||
'message' => 'Your application has been submitted successfully!'
|
||||
];
|
||||
|
||||
} 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();
|
||||
77
dashboard.php
Normal file
77
dashboard.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?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';
|
||||
?>
|
||||
|
||||
<main class="container my-5">
|
||||
<h1 class="mb-4">User Dashboard</h1>
|
||||
<p>Welcome back, <?php echo htmlspecialchars($_SESSION['user']['name']); ?>. 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.name 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>Event Date</th>
|
||||
<th>Applied On</th>
|
||||
<th>Status</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', strtotime($app['event_date'])); ?></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;
|
||||
default: echo 'secondary';
|
||||
}
|
||||
?>">
|
||||
<?php echo htmlspecialchars(ucfirst($app['status'])); ?>
|
||||
</span>
|
||||
</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>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
39
db/migrations.php
Normal file
39
db/migrations.php
Normal 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());
|
||||
}
|
||||
12
db/migrations/001_create_users_table.sql
Normal file
12
db/migrations/001_create_users_table.sql
Normal 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"
|
||||
11
db/migrations/002_create_events_table.sql
Normal file
11
db/migrations/002_create_events_table.sql
Normal 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
|
||||
);
|
||||
9
db/migrations/003_create_applications_table.sql
Normal file
9
db/migrations/003_create_applications_table.sql
Normal 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
|
||||
);
|
||||
13
includes/footer.php
Normal file
13
includes/footer.php
Normal file
@ -0,0 +1,13 @@
|
||||
<!-- Footer -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="mb-0">© <?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>
|
||||
61
includes/header.php
Normal file
61
includes/header.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?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">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="/assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Navigation Bar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="index.php">PromoPass</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="index.php">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="index.php#events">Events</a>
|
||||
</li>
|
||||
<?php if (is_logged_in()): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<?php echo is_admin() ? 'admin/index.php' : 'dashboard.php'; ?>">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="logout.php">Logout</a>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="login.php">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link btn btn-primary btn-sm" href="signup.php" style="padding: 8px 16px; color: white;">Sign Up</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
26
includes/session.php
Normal file
26
includes/session.php
Normal 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();
|
||||
}
|
||||
}
|
||||
144
index.php
144
index.php
@ -1,54 +1,4 @@
|
||||
<!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">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Navigation Bar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="#">PromoPass</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#events">Events</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link btn btn-primary btn-sm" href="#" style="padding: 8px 16px; color: white;">Sign Up</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<?php require_once 'includes/header.php'; ?>
|
||||
|
||||
<!-- Hero Section -->
|
||||
<header class="hero">
|
||||
@ -62,58 +12,52 @@
|
||||
<!-- 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
|
||||
// Placeholder data for events
|
||||
$events = [
|
||||
[
|
||||
'title' => 'Cosmic Meadow Festival',
|
||||
'date' => '2025-12-15',
|
||||
'location' => 'Miami, FL',
|
||||
'image' => 'https://images.pexels.com/photos/2263436/pexels-photo-2263436.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2'
|
||||
],
|
||||
[
|
||||
'title' => 'Neon Garden Rave',
|
||||
'date' => '2025-11-28',
|
||||
'location' => 'Las Vegas, NV',
|
||||
'image' => 'https://images.pexels.com/photos/1684151/pexels-photo-1684151.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2'
|
||||
],
|
||||
[
|
||||
'title' => 'Bass Canyon Showcase',
|
||||
'date' => '2026-01-20',
|
||||
'location' => 'Denver, CO',
|
||||
'image' => 'https://images.pexels.com/photos/2118046/pexels-photo-2118046.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2'
|
||||
],
|
||||
[
|
||||
'title' => 'Quantum Valley Experience',
|
||||
'date' => '2026-02-10',
|
||||
'location' => 'New York, NY',
|
||||
'image' => 'https://images.pexels.com/photos/2099023/pexels-photo-2099023.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2'
|
||||
],
|
||||
[
|
||||
'title' => 'Circuit Grounds Tour',
|
||||
'date' => '2026-03-05',
|
||||
'location' => 'Chicago, IL',
|
||||
'image' => 'https://images.pexels.com/photos/2526127/pexels-photo-2526127.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2'
|
||||
],
|
||||
[
|
||||
'title' => 'Wasteland Arena',
|
||||
'date' => '2026-04-18',
|
||||
'location' => 'Los Angeles, CA',
|
||||
'image' => 'https://images.pexels.com/photos/2339031/pexels-photo-2339031.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2'
|
||||
]
|
||||
];
|
||||
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($event['image']); ?>" class="card-img-top" alt="Event Image">
|
||||
<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['date'])); ?> • <?php echo htmlspecialchars($event['location']); ?></p>
|
||||
<a href="#" class="btn btn-secondary">Apply Now</a>
|
||||
<p class="card-text text-muted"><?php echo date("M d, Y", strtotime($event['event_date'])); ?> • <?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'])): ?>
|
||||
<a href="login.php" class="btn btn-secondary">Login to Apply</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -122,16 +66,4 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="mb-0">© <?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>
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
75
login.php
Normal file
75
login.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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'];
|
||||
$_SESSION['user_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';
|
||||
?>
|
||||
|
||||
<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>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
21
logout.php
Normal file
21
logout.php
Normal 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();
|
||||
86
signup.php
Normal file
86
signup.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?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';
|
||||
?>
|
||||
|
||||
<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>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
Loading…
x
Reference in New Issue
Block a user