0.2 Read events from file and add/delete events
This commit is contained in:
parent
5af5075ae6
commit
8e8aeb4a48
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
if (!isset($_SESSION['user'])) {
|
|
||||||
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>Dashboard</title>
|
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<div class="d-flex justify-content-between align-items-center pt-3 pb-2 mb-3 border-bottom">
|
|
||||||
<h1 class="h2">Dashboard</h1>
|
|
||||||
<a href="logout.php" class="btn btn-outline-primary">Logout</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Welcome, <?php echo htmlspecialchars($_SESSION['user']['name']); ?>!</h2>
|
|
||||||
|
|
||||||
<div class="mt-4">
|
|
||||||
<h3>Event Schedule</h3>
|
|
||||||
<p><em>(Coming soon)</em></p>
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">#</th>
|
|
||||||
<th scope="col">Event</th>
|
|
||||||
<th scope="col">Date</th>
|
|
||||||
<th scope="col">Time</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">1</th>
|
|
||||||
<td>Team Meeting</td>
|
|
||||||
<td>2025-09-01</td>
|
|
||||||
<td>10:00 AM</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row">2</th>
|
|
||||||
<td>Project Deadline</td>
|
|
||||||
<td>2025-09-05</td>
|
|
||||||
<td>5:00 PM</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
141
delete_event.php
Normal file
141
delete_event.php
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
session_set_cookie_params(['path' => '/']);
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// If the user is not logged in, redirect to the login page
|
||||||
|
if (!isset($_SESSION['user'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$eventsJson = file_get_contents('events.json');
|
||||||
|
$events = json_decode($eventsJson, true);
|
||||||
|
|
||||||
|
$eventId = $_GET['id'] ?? null;
|
||||||
|
|
||||||
|
if ($eventId === null || !isset($events[$eventId])) {
|
||||||
|
// Redirect to index if event not found
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
// Delete the event
|
||||||
|
unset($events[$eventId]);
|
||||||
|
|
||||||
|
// Re-index the array to prevent issues with json_encode
|
||||||
|
$events = array_values($events);
|
||||||
|
|
||||||
|
file_put_contents('events.json', json_encode($events, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = $events[$eventId];
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Delete Event</title>
|
||||||
|
<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.05);
|
||||||
|
--card-border-color: rgba(255, 255, 255, 0.2);
|
||||||
|
--button-text-color: #2575fc;
|
||||||
|
--danger-color: #ff4d4d;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
padding: 2rem;
|
||||||
|
width: 80%;
|
||||||
|
max-width: 600px;
|
||||||
|
}
|
||||||
|
.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);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
.event-details {
|
||||||
|
background: rgba(0,0,0,0.1);
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
.event-title {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
button, a {
|
||||||
|
text-decoration: none;
|
||||||
|
border: none;
|
||||||
|
padding: 1rem 2rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 700;
|
||||||
|
transition: background-color 0.3s, color 0.3s;
|
||||||
|
}
|
||||||
|
.delete-btn {
|
||||||
|
background-color: var(--danger-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
.cancel-link {
|
||||||
|
background-color: var(--text-color);
|
||||||
|
color: var(--button-text-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<div class="card">
|
||||||
|
<h1>Delete Event</h1>
|
||||||
|
<p>Are you sure you want to delete this event? This action cannot be undone.</p>
|
||||||
|
<div class="event-details">
|
||||||
|
<div class="event-title"><?= htmlspecialchars($event['title']) ?></div>
|
||||||
|
<div><?= htmlspecialchars($event['time']) ?></div>
|
||||||
|
</div>
|
||||||
|
<form method="POST" class="actions">
|
||||||
|
<a href="index.php" class="cancel-link">Cancel</a>
|
||||||
|
<button type="submit" class="delete-btn">Yes, Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
143
edit_event.php
Normal file
143
edit_event.php
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
session_set_cookie_params(['path' => '/']);
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// If the user is not logged in, redirect to the login page
|
||||||
|
if (!isset($_SESSION['user'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$eventsJson = file_get_contents('events.json');
|
||||||
|
$events = json_decode($eventsJson, true);
|
||||||
|
|
||||||
|
$eventId = $_GET['id'] ?? null;
|
||||||
|
$event = null;
|
||||||
|
|
||||||
|
if ($eventId !== null && isset($events[$eventId])) {
|
||||||
|
$event = $events[$eventId];
|
||||||
|
} else {
|
||||||
|
// Redirect to index if event not found
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
// Update the event
|
||||||
|
$events[$eventId]['title'] = $_POST['title'] ?? $event['title'];
|
||||||
|
$events[$eventId]['time'] = $_POST['time'] ?? $event['time'];
|
||||||
|
$events[$eventId]['details'] = $_POST['details'] ?? $event['details'];
|
||||||
|
|
||||||
|
file_put_contents('events.json', json_encode($events, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Edit Event</title>
|
||||||
|
<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.05);
|
||||||
|
--card-border-color: rgba(255, 255, 255, 0.2);
|
||||||
|
--button-text-color: #2575fc;
|
||||||
|
--input-bg-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;
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
padding: 2rem;
|
||||||
|
width: 80%;
|
||||||
|
max-width: 600px;
|
||||||
|
}
|
||||||
|
.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);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
input, textarea {
|
||||||
|
width: 100%;
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid var(--card-border-color);
|
||||||
|
background-color: var(--input-bg-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
background-color: var(--text-color);
|
||||||
|
color: var(--button-text-color);
|
||||||
|
border: none;
|
||||||
|
padding: 1rem 2rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 700;
|
||||||
|
transition: background-color 0.3s, color 0.3s;
|
||||||
|
}
|
||||||
|
button:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<div class="card">
|
||||||
|
<h1>Edit Event</h1>
|
||||||
|
<form method="POST">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="title">Event Title</label>
|
||||||
|
<input type="text" id="title" name="title" value="<?= htmlspecialchars($event['title']) ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="time">Event Time</label>
|
||||||
|
<input type="text" id="time" name="time" value="<?= htmlspecialchars($event['time']) ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="details">Event Details</label>
|
||||||
|
<textarea id="details" name="details" rows="4" required><?= htmlspecialchars($event['details']) ?></textarea>
|
||||||
|
</div>
|
||||||
|
<button type="submit">Update Event</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
18
events.json
Normal file
18
events.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"title": "Team Stand-up",
|
||||||
|
"time": "Today, 9:00 AM",
|
||||||
|
"details": "Daily check-in to sync on progress and blockers."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Design Review",
|
||||||
|
"time": "Today, 1:00 PM",
|
||||||
|
"details": "Review the new dashboard mockups and provide feedback."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Deployment",
|
||||||
|
"time": "Today, 4:00 PM",
|
||||||
|
"details": "Deploy the latest changes to the staging environment."
|
||||||
|
}
|
||||||
|
]
|
||||||
146
index.php
146
index.php
@ -3,24 +3,21 @@ declare(strict_types=1);
|
|||||||
session_set_cookie_params(['path' => '/']);
|
session_set_cookie_params(['path' => '/']);
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if (isset($_SESSION['user'])) {
|
// If the user is not logged in, redirect to the login page
|
||||||
header('Location: dashboard.php');
|
if (!isset($_SESSION['user'])) {
|
||||||
|
header('Location: login.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ini_set('display_errors', '1');
|
$user = $_SESSION['user'];
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!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" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>New Style</title>
|
<title>Dashboard</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<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">
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||||
@ -29,8 +26,9 @@ $now = date('Y-m-d H:i:s');
|
|||||||
--bg-color-start: #6a11cb;
|
--bg-color-start: #6a11cb;
|
||||||
--bg-color-end: #2575fc;
|
--bg-color-end: #2575fc;
|
||||||
--text-color: #ffffff;
|
--text-color: #ffffff;
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
--card-bg-color: rgba(255, 255, 255, 0.05);
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
--card-border-color: rgba(255, 255, 255, 0.2);
|
||||||
|
--button-text-color: #2575fc;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -42,26 +40,11 @@ $now = date('Y-m-d H:i:s');
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
text-align: center;
|
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 {
|
main {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
|
width: 80%;
|
||||||
|
max-width: 960px;
|
||||||
}
|
}
|
||||||
.card {
|
.card {
|
||||||
background: var(--card-bg-color);
|
background: var(--card-bg-color);
|
||||||
@ -72,41 +55,104 @@ $now = date('Y-m-d H:i:s');
|
|||||||
-webkit-backdrop-filter: blur(20px);
|
-webkit-backdrop-filter: blur(20px);
|
||||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 3rem;
|
font-size: 2rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
margin: 0 0 1rem;
|
margin: 0;
|
||||||
letter-spacing: -1px;
|
text-align: left;
|
||||||
}
|
}
|
||||||
p {
|
a.logout {
|
||||||
margin: 0.5rem 0;
|
color: var(--text-color);
|
||||||
font-size: 1.1rem;
|
text-decoration: none;
|
||||||
|
border: 1px solid var(--card-border-color);
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: background-color 0.3s, color 0.3s;
|
||||||
}
|
}
|
||||||
code {
|
a.logout:hover {
|
||||||
background: rgba(0,0,0,0.2);
|
background-color: var(--text-color);
|
||||||
padding: 2px 6px;
|
color: var(--button-text-color);
|
||||||
border-radius: 4px;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
||||||
}
|
}
|
||||||
footer {
|
.schedule {
|
||||||
position: absolute;
|
text-align: left;
|
||||||
bottom: 1rem;
|
}
|
||||||
font-size: 0.8rem;
|
h2 {
|
||||||
opacity: 0.7;
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
border-bottom: 1px solid var(--card-border-color);
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
.event {
|
||||||
|
background: rgba(0,0,0,0.1);
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
.event-title {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.event-time {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
opacity: 0.8;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
.event-actions {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
.event-actions a {
|
||||||
|
color: var(--text-color);
|
||||||
|
text-decoration: none;
|
||||||
|
border: 1px solid var(--card-border-color);
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: background-color 0.3s, color 0.3s;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
.event-actions a:hover {
|
||||||
|
background-color: var(--text-color);
|
||||||
|
color: var(--button-text-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h1>Welcome!</h1>
|
<div class="header">
|
||||||
<p>Your project is ready to conquer the peaks.</p>
|
<h1>Welcome, <?= htmlspecialchars($user['name']) ?>!</h1>
|
||||||
<p>PHP version: <code><?= htmlspecialchars($phpVersion) ?></code></p>
|
<a href="logout.php" class="logout">Logout</a>
|
||||||
<p><a href="logout.php">Logout</a></p>
|
</div>
|
||||||
|
|
||||||
|
<div class="schedule">
|
||||||
|
<h2>Event Schedule</h2>
|
||||||
|
<?php
|
||||||
|
$eventsJson = file_get_contents('events.json');
|
||||||
|
$events = json_decode($eventsJson, true);
|
||||||
|
|
||||||
|
if (json_last_error() === JSON_ERROR_NONE && !empty($events)) {
|
||||||
|
foreach ($events as $index => $event) {
|
||||||
|
echo '<div class="event">';
|
||||||
|
echo '<div class="event-title">' . htmlspecialchars($event['title']) . '</div>';
|
||||||
|
echo '<div class="event-time">' . htmlspecialchars($event['time']) . '</div>';
|
||||||
|
echo '<p>' . htmlspecialchars($event['details']) . '</p>';
|
||||||
|
echo '<div class="event-actions">';
|
||||||
|
echo '<a href="edit_event.php?id=' . $index . '">Edit</a>';
|
||||||
|
echo '<a href="delete_event.php?id=' . $index . '">Delete</a>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo '<p>No events scheduled.</p>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -12,7 +12,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
// Dummy authentication
|
// Dummy authentication
|
||||||
if ($username === 'admin' && $password === 'password') {
|
if ($username === 'admin' && $password === 'password') {
|
||||||
$_SESSION['user'] = ['name' => 'Admin'];
|
$_SESSION['user'] = ['name' => 'Admin'];
|
||||||
header('Location: dashboard.php');
|
header('Location: index.php');
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$error = 'Invalid username or password';
|
$error = 'Invalid username or password';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user