Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'admin') {
|
|
||||||
header("location: login.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Admin Dashboard - READY BUDDY</title>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css?v=<?php echo time(); ?>">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<h1>Admin Dashboard</h1>
|
|
||||||
<h2>Welcome, Admin <?php echo htmlspecialchars($_SESSION['user_name']); ?>!</h2>
|
|
||||||
<p>This is the admin dashboard. You can manage competitions, users, and more from here.</p>
|
|
||||||
<p><a href="logout.php">Logout</a></p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -1,134 +0,0 @@
|
|||||||
/* General Body Styles */
|
|
||||||
body {
|
|
||||||
font-family: 'Poppins', sans-serif;
|
|
||||||
color: #444;
|
|
||||||
line-height: 1.75;
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
padding-top: 56px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Navigation Bar */
|
|
||||||
.navbar {
|
|
||||||
transition: background-color 0.3s;
|
|
||||||
box-shadow: 0 2px 4px rgba(0,0,0,0.04);
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-brand {
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-link {
|
|
||||||
font-weight: 500;
|
|
||||||
transition: color 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Hero Section */
|
|
||||||
.hero-section {
|
|
||||||
background: linear-gradient(45deg, #007bff, #00d2ff);
|
|
||||||
color: white;
|
|
||||||
padding: 100px 0;
|
|
||||||
text-align: center;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-section h1 {
|
|
||||||
font-size: 3.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-section .lead {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sections */
|
|
||||||
section {
|
|
||||||
padding: 80px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
section h2 {
|
|
||||||
text-align: center;
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 2.5rem;
|
|
||||||
margin-bottom: 60px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
section h2::after {
|
|
||||||
content: '';
|
|
||||||
display: block;
|
|
||||||
width: 60px;
|
|
||||||
height: 4px;
|
|
||||||
background: #007bff;
|
|
||||||
margin: 20px auto 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cards */
|
|
||||||
.card {
|
|
||||||
border: none;
|
|
||||||
border-radius: 15px;
|
|
||||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
|
|
||||||
transition: transform 0.3s, box-shadow 0.3s;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card:hover {
|
|
||||||
transform: translateY(-10px);
|
|
||||||
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-body {
|
|
||||||
padding: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-title {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Buttons */
|
|
||||||
.btn-primary {
|
|
||||||
background-color: #007bff;
|
|
||||||
border-color: #007bff;
|
|
||||||
border-radius: 50px;
|
|
||||||
padding: 12px 30px;
|
|
||||||
font-weight: 600;
|
|
||||||
transition: background-color 0.3s, transform 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
transform: translateY(-3px);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Forms */
|
|
||||||
.form-control {
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 15px;
|
|
||||||
border: 1px solid #ced4da;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-control:focus {
|
|
||||||
border-color: #007bff;
|
|
||||||
box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Footer */
|
|
||||||
footer {
|
|
||||||
background-color: #343a40;
|
|
||||||
color: white;
|
|
||||||
padding: 40px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer a {
|
|
||||||
color: #00d2ff;
|
|
||||||
text-decoration: none;
|
|
||||||
transition: color 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer a:hover {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
|
||||||
// Smooth scrolling for anchor links
|
|
||||||
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
|
||||||
anchor.addEventListener('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
document.querySelector(this.getAttribute('href')).scrollIntoView({
|
|
||||||
behavior: 'smooth'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Contact form submission
|
|
||||||
const contactForm = document.getElementById('contactForm');
|
|
||||||
if (contactForm) {
|
|
||||||
contactForm.addEventListener('submit', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
const form = e.target;
|
|
||||||
const formData = new FormData(form);
|
|
||||||
const formMessages = document.getElementById('form-messages');
|
|
||||||
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
})
|
|
||||||
.then(response => response.text().then(text => ({ status: response.status, text })))
|
|
||||||
.then(({ status, text }) => {
|
|
||||||
if (status === 200) {
|
|
||||||
formMessages.innerHTML = '<div class="alert alert-success">' + text + '</div>';
|
|
||||||
form.reset();
|
|
||||||
} else {
|
|
||||||
formMessages.innerHTML = '<div class="alert alert-danger">' + text + '</div>';
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
|
||||||
formMessages.innerHTML = '<div class="alert alert-danger">Oops! An error occurred.</div>';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->query('SELECT title, description, start_date FROM competitions ORDER BY start_date ASC');
|
|
||||||
$competitions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
foreach ($competitions as $competition) {
|
|
||||||
echo '<div class="col-md-4 mb-4">';
|
|
||||||
echo '<div class="card h-100">';
|
|
||||||
echo '<div class="card-body">';
|
|
||||||
echo '<h5 class="card-title">' . htmlspecialchars($competition['title']) . '</h5>';
|
|
||||||
echo '<p class="card-text">' . htmlspecialchars($competition['description']) . '</p>';
|
|
||||||
echo '<p class="card-text"><small class="text-muted">Starts on: ' . date("F j, Y", strtotime($competition['start_date'])) . '</small></p>';
|
|
||||||
echo '</div>';
|
|
||||||
echo '</div>';
|
|
||||||
echo '</div>';
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
echo '<p class="text-danger">Failed to load competitions.</p>';
|
|
||||||
}
|
|
||||||
56
contact.php
56
contact.php
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
require_once 'db/config.php';
|
|
||||||
require_once 'mail/MailService.php';
|
|
||||||
|
|
||||||
$name = filter_var(trim($_POST["name"]), FILTER_SANITIZE_STRING);
|
|
||||||
$email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
|
|
||||||
$message = filter_var(trim($_POST["message"]), FILTER_SANITIZE_STRING);
|
|
||||||
|
|
||||||
if (empty($name) || !filter_var($email, FILTER_VALIDATE_EMAIL) || empty($message)) {
|
|
||||||
http_response_code(400);
|
|
||||||
echo "Please fill out all fields and provide a valid email address.";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$sql = "INSERT INTO contact_submissions (name, email, message) VALUES (?, ?, ?)";
|
|
||||||
$stmt = $pdo->prepare($sql);
|
|
||||||
$stmt->execute([$name, $email, $message]);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
http_response_code(500);
|
|
||||||
echo "Oops! Something went wrong and we couldn't send your message.";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$to = getenv('MAIL_TO') ?: null;
|
|
||||||
$subject = "New Contact Form Submission from $name";
|
|
||||||
$html_content = "You have received a new message from your website contact form.<br><br>".
|
|
||||||
"<strong>Name:</strong> $name<br>".
|
|
||||||
"<strong>Email:</strong> $email<br>".
|
|
||||||
"<strong>Message:</strong><br>$message";
|
|
||||||
$text_content = "You have received a new message from your website contact form.
|
|
||||||
|
|
||||||
".
|
|
||||||
"Name: $name
|
|
||||||
".
|
|
||||||
"Email: $email
|
|
||||||
".
|
|
||||||
"Message:
|
|
||||||
$message";
|
|
||||||
|
|
||||||
$result = MailService::sendMail($to, $subject, $html_content, $text_content, ['reply_to' => $email]);
|
|
||||||
|
|
||||||
if (!empty($result['success'])) {
|
|
||||||
http_response_code(200);
|
|
||||||
echo "Thank You! Your message has been sent.";
|
|
||||||
} else {
|
|
||||||
http_response_code(500);
|
|
||||||
echo "Oops! Something went wrong and we couldn't send your message.";
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
http_response_code(403);
|
|
||||||
echo "There was a problem with your submission, please try again.";
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `competitions` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`title` varchar(255) NOT NULL,
|
|
||||||
`description` text NOT NULL,
|
|
||||||
`start_date` date NOT NULL,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `contact_submissions` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`name` varchar(255) NOT NULL,
|
|
||||||
`email` varchar(255) NOT NULL,
|
|
||||||
`message` text NOT NULL,
|
|
||||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `users` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`name` varchar(255) NOT NULL,
|
|
||||||
`email` varchar(255) NOT NULL,
|
|
||||||
`password` varchar(255) NOT NULL,
|
|
||||||
`role` enum('user','admin') NOT NULL DEFAULT 'user',
|
|
||||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `email` (`email`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
||||||
|
|
||||||
INSERT INTO `competitions` (`title`, `description`, `start_date`) VALUES
|
|
||||||
('Annual Coding Challenge', 'Showcase your coding skills and win exciting prizes.', '2025-11-15'),
|
|
||||||
('Design Masters Cup', 'The ultimate design competition for creative minds.', '2025-12-01'),
|
|
||||||
('Startup Pitch Contest', 'Pitch your innovative startup idea to a panel of investors.', '2025-11-20');
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `competition_participants` (
|
|
||||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`user_id` INT NOT NULL,
|
|
||||||
`competition_id` INT NOT NULL,
|
|
||||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
|
|
||||||
FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON DELETE CASCADE,
|
|
||||||
UNIQUE KEY `user_competition` (`user_id`, `competition_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `competition_submissions` (
|
|
||||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`user_id` INT NOT NULL,
|
|
||||||
`competition_id` INT NOT NULL,
|
|
||||||
`file_path` VARCHAR(255) NOT NULL,
|
|
||||||
`uploaded_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
|
|
||||||
FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON DELETE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
||||||
279
index.php
279
index.php
@ -1,139 +1,150 @@
|
|||||||
<!DOCTYPE html>
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
@ini_set('display_errors', '1');
|
||||||
|
@error_reporting(E_ALL);
|
||||||
|
@date_default_timezone_set('UTC');
|
||||||
|
|
||||||
|
$phpVersion = PHP_VERSION;
|
||||||
|
$now = date('Y-m-d H:i:s');
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>READY BUDDY</title>
|
<title>New Style</title>
|
||||||
<meta name="description" content="Built with Flatlogic Generator">
|
<?php
|
||||||
<meta name="keywords" content="competitions, challenges, contests, tournaments, prizes, community, skills, leaderboard, submissions, participation, Built with Flatlogic Generator">
|
// Read project preview data from environment
|
||||||
<meta property="og:title" content="READY BUDDY">
|
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||||
<meta property="og:description" content="Built with Flatlogic Generator">
|
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||||
<meta property="og:image" content="">
|
?>
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<?php if ($projectDescription): ?>
|
||||||
<meta name="twitter:image" content="">
|
<!-- Meta description -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
<!-- Open Graph meta tags -->
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<!-- Twitter meta tags -->
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
|
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||||
<link rel="stylesheet" href="assets/css/style.css?v=<?php echo time(); ?>">
|
<?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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
|
<main>
|
||||||
<div class="container">
|
<div class="card">
|
||||||
<a class="navbar-brand" href="#">READY BUDDY</a>
|
<h1>Analyzing your requirements and generating your website…</h1>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="sr-only">Loading…</span>
|
||||||
</button>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||||
<ul class="navbar-nav ms-auto">
|
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||||
<li class="nav-item"><a class="nav-link" href="#hero">Home</a></li>
|
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||||
<li class="nav-item"><a class="nav-link" href="#about">About</a></li>
|
</div>
|
||||||
<li class="nav-item"><a class="nav-link" href="#portfolio">Competitions</a></li>
|
</main>
|
||||||
<li class="nav-item"><a class="nav-link" href="#testimonials">Testimonials</a></li>
|
<footer>
|
||||||
<li class="nav-item"><a class="nav-link" href="#contact">Contact</a></li>
|
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||||
<li class="nav-item"><a class="nav-link btn btn-primary text-white ms-2" href="login.php">Login</a></li>
|
</footer>
|
||||||
<li class="nav-item"><a class="nav-link btn btn-outline-primary ms-2" href="register.php">Register</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<header id="hero" class="hero-section text-center text-white d-flex align-items-center justify-content-center">
|
|
||||||
<div>
|
|
||||||
<h1>Welcome to READY BUDDY</h1>
|
|
||||||
<p class="lead">Your platform for competitive excellence</p>
|
|
||||||
<a href="#portfolio" class="btn btn-primary btn-lg">View Competitions</a>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<section id="about" class="py-5">
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-6">
|
|
||||||
<h2>About Us</h2>
|
|
||||||
<p>READY BUDDY is the ultimate platform for individuals who are passionate about competing and showcasing their talents. Whether you are a coder, a designer, or a startup enthusiast, we provide a space for you to challenge yourself, learn, and grow. Our mission is to foster a vibrant community of competitors and provide a fair and transparent platform for everyone to shine.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="portfolio" class="py-5 bg-light">
|
|
||||||
<div class="container">
|
|
||||||
<h2 class="text-center">Upcoming Competitions</h2>
|
|
||||||
<div class="row">
|
|
||||||
<?php include 'competitions.php'; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="testimonials" class="py-5">
|
|
||||||
<div class="container">
|
|
||||||
<h2 class="text-center">Testimonials</h2>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="card-text">"READY BUDDY helped me to push my limits and learn new skills. The competitions are challenging and fun."</p>
|
|
||||||
<footer class="blockquote-footer">John Doe</footer>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="card-text">"A great platform to connect with like-minded people and compete in a healthy environment."</p>
|
|
||||||
<footer class="blockquote-footer">Jane Smith</footer>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="card-text">"I won my first competition on READY BUDDY! The experience was amazing."</p>
|
|
||||||
<footer class="blockquote-footer">Sam Wilson</footer>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="contact" class="py-5 bg-light">
|
|
||||||
<div class="container">
|
|
||||||
<h2 class="text-center">Contact Us</h2>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8 mx-auto">
|
|
||||||
<form id="contactForm" action="contact.php" method="post">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="name" class="form-label">Name</label>
|
|
||||||
<input type="text" class="form-control" id="name" name="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" required>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="message" class="form-label">Message</label>
|
|
||||||
<textarea class="form-control" id="message" name="message" rows="5" required></textarea>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">Send Message</button>
|
|
||||||
</form>
|
|
||||||
<div id="form-messages" class="mt-3"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<footer class="py-4 bg-dark text-white text-center">
|
|
||||||
<div class="container">
|
|
||||||
<p>© 2025 READY BUDDY. All Rights Reserved.</p>
|
|
||||||
<p><a href="privacy.php" class="text-white">Privacy Policy</a></p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
if (!isset($_SESSION['user_id'])) {
|
|
||||||
header("location: login.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['competition_id'])) {
|
|
||||||
$user_id = $_SESSION['user_id'];
|
|
||||||
$competition_id = $_POST['competition_id'];
|
|
||||||
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("INSERT INTO competition_participants (user_id, competition_id) VALUES (?, ?)");
|
|
||||||
$stmt->execute([$user_id, $competition_id]);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
// Handle potential errors, like trying to join the same competition twice
|
|
||||||
// You might want to log this error or show a message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
header("location: user_dashboard.php");
|
|
||||||
exit;
|
|
||||||
145
login.php
145
login.php
@ -1,145 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
$error = '';
|
|
||||||
|
|
||||||
if (isset($_SESSION['user_id'])) {
|
|
||||||
header("location: index.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
$email = trim($_POST['email']);
|
|
||||||
$password = trim($_POST['password']);
|
|
||||||
|
|
||||||
if (empty($email) || empty($password)) {
|
|
||||||
$error = "Both email and password are required.";
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$sql = "SELECT * FROM users WHERE email = ?";
|
|
||||||
$stmt = $pdo->prepare($sql);
|
|
||||||
$stmt->execute([$email]);
|
|
||||||
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($user && password_verify($password, $user['password'])) {
|
|
||||||
$_SESSION['user_id'] = $user['id'];
|
|
||||||
$_SESSION['user_name'] = $user['name'];
|
|
||||||
$_SESSION['user_role'] = $user['role'];
|
|
||||||
|
|
||||||
if ($user['role'] === 'admin') {
|
|
||||||
header("location: admin_dashboard.php"); // Create this page next
|
|
||||||
} else {
|
|
||||||
header("location: user_dashboard.php"); // Create this page next
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$error = "The email or password you entered is incorrect.";
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$error = "Database error: " . $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Login - READY BUDDY</title>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css?v=<?php echo time(); ?>">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
}
|
|
||||||
.auth-container {
|
|
||||||
background: #fff;
|
|
||||||
padding: 2rem;
|
|
||||||
border-radius: 15px;
|
|
||||||
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
|
|
||||||
width: 100%;
|
|
||||||
max-width: 400px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.auth-container h2 {
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #555;
|
|
||||||
}
|
|
||||||
.form-control {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.75rem;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
.btn-submit {
|
|
||||||
background: linear-gradient(45deg, #0D6EFD, #0D6EFD);
|
|
||||||
color: #fff;
|
|
||||||
padding: 0.75rem;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
width: 100%;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
.btn-submit:hover {
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
.alert {
|
|
||||||
padding: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
background-color: #f8d7da;
|
|
||||||
color: #721c24;
|
|
||||||
border: 1px solid #f5c6cb;
|
|
||||||
}
|
|
||||||
.auth-link {
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="auth-container">
|
|
||||||
<h2>Login to Your Account</h2>
|
|
||||||
<?php if(!empty($error)): ?>
|
|
||||||
<div class="alert"><?php echo $error; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<form action="/login" method="post">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email">Email</label>
|
|
||||||
<input type="email" name="email" id="email" class="form-control" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="password">Password</label>
|
|
||||||
<input type="password" name="password" id="password" class="form-control" required>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn-submit">Login</button>
|
|
||||||
</form>
|
|
||||||
<p class="auth-link">Don't have an account? <a href="register.php">Register here</a></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
session_unset();
|
|
||||||
session_destroy();
|
|
||||||
header("location: login.php");
|
|
||||||
exit;
|
|
||||||
?>
|
|
||||||
17
privacy.php
17
privacy.php
@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Privacy Policy - READY BUDDY</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css?v=<?php echo time(); ?>">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container py-5">
|
|
||||||
<h1>Privacy Policy</h1>
|
|
||||||
<p>This is a placeholder for the Privacy Policy page. You should replace this with your own privacy policy.</p>
|
|
||||||
<a href="index.php">Go back to Home</a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
171
register.php
171
register.php
@ -1,171 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
$error = '';
|
|
||||||
$success = '';
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
$name = trim($_POST['name']);
|
|
||||||
$email = trim($_POST['email']);
|
|
||||||
$password = trim($_POST['password']);
|
|
||||||
$confirm_password = trim($_POST['confirm_password']);
|
|
||||||
$role = trim($_POST['role']);
|
|
||||||
|
|
||||||
if (empty($name) || empty($email) || empty($password) || empty($confirm_password) || empty($role)) {
|
|
||||||
$error = "All fields are required.";
|
|
||||||
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
||||||
$error = "Invalid email format.";
|
|
||||||
} elseif ($password !== $confirm_password) {
|
|
||||||
$error = "Passwords do not match.";
|
|
||||||
} elseif (!in_array($role, ['user', 'admin'])) {
|
|
||||||
$error = "Invalid role selected.";
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$sql = "SELECT id FROM users WHERE email = ?";
|
|
||||||
$stmt = $pdo->prepare($sql);
|
|
||||||
$stmt->execute([$email]);
|
|
||||||
if ($stmt->fetch()) {
|
|
||||||
$error = "Email already exists.";
|
|
||||||
} else {
|
|
||||||
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
|
||||||
$sql = "INSERT INTO users (name, email, password, role) VALUES (?, ?, ?, ?)";
|
|
||||||
$stmt = $pdo->prepare($sql);
|
|
||||||
if ($stmt->execute([$name, $email, $hashed_password, $role])) {
|
|
||||||
$success = "Registration successful! You can now <a href=\"login.php\">login</a>.";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$error = "Something went wrong. Please try again later.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$error = "Database error: " . $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Register - READY BUDDY</title>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css?v=<?php echo time(); ?>">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
}
|
|
||||||
.auth-container {
|
|
||||||
background: #fff;
|
|
||||||
padding: 2rem;
|
|
||||||
border-radius: 15px;
|
|
||||||
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
|
|
||||||
width: 100%;
|
|
||||||
max-width: 400px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.auth-container h2 {
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #555;
|
|
||||||
}
|
|
||||||
.form-control {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.75rem;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
.btn-submit {
|
|
||||||
background: linear-gradient(45deg, #0D6EFD, #0D6EFD);
|
|
||||||
color: #fff;
|
|
||||||
padding: 0.75rem;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
width: 100%;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
.btn-submit:hover {
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
.alert {
|
|
||||||
padding: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
.alert-danger {
|
|
||||||
background-color: #f8d7da;
|
|
||||||
color: #721c24;
|
|
||||||
border: 1px solid #f5c6cb;
|
|
||||||
}
|
|
||||||
.alert-success {
|
|
||||||
background-color: #d4edda;
|
|
||||||
color: #155724;
|
|
||||||
border: 1px solid #c3e6cb;
|
|
||||||
}
|
|
||||||
.auth-link {
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="auth-container">
|
|
||||||
<h2>Create Account</h2>
|
|
||||||
<?php if(!empty($error)): ?>
|
|
||||||
<div class="alert alert-danger"><?php echo $error; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if(!empty($success)): ?>
|
|
||||||
<div class="alert alert-success"><?php echo $success; ?></div>
|
|
||||||
<?php else: ?>
|
|
||||||
<form action="/register" method="post">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="name">Full Name</label>
|
|
||||||
<input type="text" name="name" id="name" class="form-control" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email">Email</label>
|
|
||||||
<input type="email" name="email" id="email" class="form-control" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="password">Password</label>
|
|
||||||
<input type="password" name="password" id="password" class="form-control" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="confirm_password">Confirm Password</label>
|
|
||||||
<input type="password" name="confirm_password" id="confirm_password" class="form-control" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="role">Role</label>
|
|
||||||
<select name="role" id="role" class="form-control" required>
|
|
||||||
<option value="user">User</option>
|
|
||||||
<option value="admin">Admin</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn-submit">Register</button>
|
|
||||||
</form>
|
|
||||||
<?php endif; ?>
|
|
||||||
<p class="auth-link">Already have an account? <a href="login.php">Login here</a></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
29
setup.php
29
setup.php
@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Connect to MySQL without specifying a database
|
|
||||||
$pdo = new PDO('mysql:host='.DB_HOST, DB_USER, DB_PASS, [
|
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Create the database
|
|
||||||
$pdo->exec('CREATE DATABASE IF NOT EXISTS '.DB_NAME);
|
|
||||||
|
|
||||||
// Now connect to the newly created database
|
|
||||||
$pdo = db();
|
|
||||||
|
|
||||||
// Get all migration files and sort them
|
|
||||||
$migration_files = glob('db/migrations/*.sql');
|
|
||||||
sort($migration_files);
|
|
||||||
|
|
||||||
// Execute each migration
|
|
||||||
foreach ($migration_files as $file) {
|
|
||||||
$sql = file_get_contents($file);
|
|
||||||
$pdo->exec($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Database setup and all migrations completed successfully.";
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
die("Database setup failed: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
if (!isset($_SESSION['user_id'])) {
|
|
||||||
header("location: login.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['competition_id']) && isset($_FILES['submission_file'])) {
|
|
||||||
$user_id = $_SESSION['user_id'];
|
|
||||||
$competition_id = $_POST['competition_id'];
|
|
||||||
$file = $_FILES['submission_file'];
|
|
||||||
|
|
||||||
// File upload error handling
|
|
||||||
if ($file['error'] !== UPLOAD_ERR_OK) {
|
|
||||||
// Handle upload error
|
|
||||||
header("location: user_dashboard.php?upload_error=1");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create uploads directory if it doesn't exist
|
|
||||||
$upload_dir = 'uploads/';
|
|
||||||
if (!is_dir($upload_dir)) {
|
|
||||||
mkdir($upload_dir, 0775, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate a unique filename
|
|
||||||
$file_extension = pathinfo($file['name'], PATHINFO_EXTENSION);
|
|
||||||
$unique_filename = uniqid('submission_', true) . '.' . $file_extension;
|
|
||||||
$file_path = $upload_dir . $unique_filename;
|
|
||||||
|
|
||||||
// Move the file to the uploads directory
|
|
||||||
if (move_uploaded_file($file['tmp_name'], $file_path)) {
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("INSERT INTO competition_submissions (user_id, competition_id, file_path) VALUES (?, ?, ?)");
|
|
||||||
$stmt->execute([$user_id, $competition_id, $file_path]);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
// Handle DB error
|
|
||||||
// You might want to log this error
|
|
||||||
// If DB insert fails, you might want to delete the uploaded file
|
|
||||||
unlink($file_path);
|
|
||||||
header("location: user_dashboard.php?upload_error=2");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
header("location: user_dashboard.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
header("location: user_dashboard.php");
|
|
||||||
exit;
|
|
||||||
@ -1,126 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require_once 'db/config.php'; // Ensure DB config is loaded
|
|
||||||
|
|
||||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'user') {
|
|
||||||
if(isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'admin'){
|
|
||||||
header("location: admin_dashboard.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
header("location: login.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_id = $_SESSION['user_id'];
|
|
||||||
|
|
||||||
// Fetch competitions, participations, and submissions
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
|
|
||||||
// Fetch all competitions
|
|
||||||
$stmt = $pdo->query('SELECT id, title, description, start_date FROM competitions ORDER BY start_date ASC');
|
|
||||||
$competitions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
// Fetch competitions the user has joined
|
|
||||||
$stmt = $pdo->prepare('SELECT competition_id FROM competition_participants WHERE user_id = ?');
|
|
||||||
$stmt->execute([$user_id]);
|
|
||||||
$joined_competitions = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
|
|
||||||
|
|
||||||
// Fetch user's submissions
|
|
||||||
$stmt = $pdo->prepare('SELECT competition_id, file_path, uploaded_at FROM competition_submissions WHERE user_id = ?');
|
|
||||||
$stmt->execute([$user_id]);
|
|
||||||
$submissions = $stmt->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$competitions = [];
|
|
||||||
$db_error = "Failed to load competitions.";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>User Dashboard - READY BUDDY</title>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css?v=<?php echo time(); ?>">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header class="navbar">
|
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand" href="index.php">READY BUDDY</a>
|
|
||||||
<nav>
|
|
||||||
<a href="logout.php">Logout</a>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main class="container" style="margin-top: 2rem; margin-bottom: 2rem;">
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
||||||
<h1>User Dashboard</h1>
|
|
||||||
<h2>Welcome, <?php echo htmlspecialchars($_SESSION['user_name']); ?>!</h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>This is your user dashboard. You can view available competitions below.</p>
|
|
||||||
|
|
||||||
<section id="competitions" class="mt-5">
|
|
||||||
<h3>Available Competitions</h3>
|
|
||||||
<div class="row">
|
|
||||||
<?php if (isset($db_error)): ?>
|
|
||||||
<p class="text-danger"><?php echo $db_error; ?></p>
|
|
||||||
<?php elseif (empty($competitions)): ?>
|
|
||||||
<p>No competitions available at the moment.</p>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php foreach ($competitions as $competition): ?>
|
|
||||||
<div class="col-md-4 mb-4">
|
|
||||||
<div class="card h-100">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title"><?php echo htmlspecialchars($competition['title']); ?></h5>
|
|
||||||
<p class="card-text"><?php echo htmlspecialchars($competition['description']); ?></p>
|
|
||||||
<p class="card-text"><small class="text-muted">Starts on: <?php echo date("F j, Y", strtotime($competition['start_date'])); ?></small></p>
|
|
||||||
|
|
||||||
<?php if (in_array($competition['id'], $joined_competitions)): ?>
|
|
||||||
<div class="mt-3">
|
|
||||||
<h5>Your Submissions:</h5>
|
|
||||||
<?php if (isset($submissions[$competition['id']])): ?>
|
|
||||||
<ul>
|
|
||||||
<?php foreach ($submissions[$competition['id']] as $submission): ?>
|
|
||||||
<li><a href="<?php echo htmlspecialchars($submission['file_path']); ?>" target="_blank"><?php echo basename(htmlspecialchars($submission['file_path'])); ?></a> (<?php echo date("F j, Y", strtotime($submission['uploaded_at'])); ?>)</li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
<?php else: ?>
|
|
||||||
<p>No submissions yet.</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form action="upload_submission.php" method="post" enctype="multipart/form-data" class="mt-2">
|
|
||||||
<input type="hidden" name="competition_id" value="<?php echo $competition['id']; ?>">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="file_upload_<?php echo $competition['id']; ?>">Upload File:</label>
|
|
||||||
<input type="file" name="submission_file" id="file_upload_<?php echo $competition['id']; ?>" required>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary btn-sm">Upload</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php else: ?>
|
|
||||||
<form action="join_competition.php" method="post" class="mt-3">
|
|
||||||
<input type="hidden" name="competition_id" value="<?php echo $competition['id']; ?>">
|
|
||||||
<button type="submit" class="btn btn-success">Join Competition</button>
|
|
||||||
</form>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<footer class="footer">
|
|
||||||
<div class="container">
|
|
||||||
<p>© <?php echo date("Y"); ?> READY BUDDY. All rights reserved.</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user