main part

This commit is contained in:
Flatlogic Bot 2025-09-02 19:37:21 +00:00
parent 32dbd98193
commit 5926dbfc54
15 changed files with 453 additions and 113 deletions

19
add_course.php Normal file
View File

@ -0,0 +1,19 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$courses_json = file_get_contents('data/courses.json');
$courses = json_decode($courses_json, true);
$new_course = [
'name' => $_POST['name'],
'description' => $_POST['description'],
'instructor' => $_POST['instructor'],
];
$courses[] = $new_course;
file_put_contents('data/courses.json', json_encode($courses, JSON_PRETTY_PRINT));
header('Location: courses.php');
exit;
}
?>

18
add_instructor.php Normal file
View File

@ -0,0 +1,18 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$instructors_json = file_get_contents('data/instructors.json');
$instructors = json_decode($instructors_json, true);
$new_instructor = [
'name' => $_POST['name'],
'email' => $_POST['email'],
];
$instructors[] = $new_instructor;
file_put_contents('data/instructors.json', json_encode($instructors, JSON_PRETTY_PRINT));
header('Location: instructors.php');
exit;
}
?>

18
add_student.php Normal file
View File

@ -0,0 +1,18 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$students_json = file_get_contents('data/students.json');
$students = json_decode($students_json, true);
$new_student = [
'name' => $_POST['name'],
'email' => $_POST['email'],
];
$students[] = $new_student;
file_put_contents('data/students.json', json_encode($students, JSON_PRETTY_PRINT));
header('Location: students.php');
exit;
}
?>

82
courses.php Normal file
View File

@ -0,0 +1,82 @@
<?php include 'header.php'; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Courses</h1>
<button class="btn btn-primary" data-toggle="modal" data-target="#addCourseModal"><i class="fas fa-plus"></i> Add New Course</button>
</div>
<?php
$courses_json = file_get_contents('data/courses.json');
$courses = json_decode($courses_json, true);
$instructors_json = file_get_contents('data/instructors.json');
$instructors = json_decode($instructors_json, true);
?>
<div class="row">
<?php if (!empty($courses)):
foreach ($courses as $course):
?>
<div class="col-md-4 mb-4">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0"><?= htmlspecialchars($course['name']) ?></h5>
</div>
<div class="card-body">
<p class="card-text"><?= htmlspecialchars($course['description']) ?></p>
<p class="card-text"><small class="text-muted">Instructor: <?= htmlspecialchars($course['instructor'] ?? 'N/A') ?></small></p>
</div>
</div>
</div>
<?php
endforeach;
else:
?>
<div class="col">
<div class="card">
<div class="card-body">
<p class="card-text">No courses found. Click 'Add New Course' to get started!</p>
</div>
</div>
</div>
<?php endif; ?>
</div>
<!-- Add Course Modal -->
<div class="modal fade" id="addCourseModal" tabindex="-1" aria-labelledby="addCourseModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addCourseModalLabel">Add a new course</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="add_course.php" method="post">
<div class="form-group">
<label for="name">Course Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description" name="description" rows="3" required></textarea>
</div>
<div class="form-group">
<label for="instructor">Instructor</label>
<select class="form-control" id="instructor" name="instructor" required>
<option value="">Select Instructor</option>
<?php if (!empty($instructors)): ?>
<?php foreach ($instructors as $instructor): ?>
<option value="<?= htmlspecialchars($instructor['name']) ?>"><?= htmlspecialchars($instructor['name']) ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
<button type="submit" class="btn btn-primary">Add Course</button>
</form>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>

61
custom.css Normal file
View File

@ -0,0 +1,61 @@
/* custom.css */
:root {
--primary-color: #6a11cb;
--secondary-color: #2575fc;
--background-color: #f4f7f6;
--font-color: #333;
--card-bg-color: #ffffff;
--shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
--transition: all 0.3s ease;
}
body {
font-family: 'Poppins', sans-serif;
background-color: var(--background-color);
color: var(--font-color);
}
.navbar {
background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
box-shadow: var(--shadow);
}
.jumbotron {
background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
color: white;
border-radius: 15px;
}
.card {
border: none;
border-radius: 15px;
box-shadow: var(--shadow);
transition: var(--transition);
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.card-header {
background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
color: white;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
.btn-primary {
background-color: var(--primary-color);
border: none;
transition: var(--transition);
}
.btn-primary:hover {
background-color: var(--secondary-color);
}
.modal-content {
border-radius: 15px;
}

11
data/courses.json Normal file
View File

@ -0,0 +1,11 @@
[
{
"name": "test ",
"description": "test"
},
{
"name": "CSV Test",
"description": "CSV TestCSV TestCSV TestCSV TestCSV TestCSV TestCSV TestCSV Test",
"instructor": "Alex"
}
]

View File

@ -0,0 +1 @@
[]

1
data/enrollments.json Normal file
View File

@ -0,0 +1 @@
[]

6
data/instructors.json Normal file
View File

@ -0,0 +1,6 @@
[
{
"name": "Alex",
"email": "Blarior@gmail.com"
}
]

1
data/students.json Normal file
View File

@ -0,0 +1 @@
[]

13
footer.php Normal file
View File

@ -0,0 +1,13 @@
</div>
<footer class="footer mt-auto py-3 bg-light">
<div class="container text-center">
<span class="text-muted">© <?= date('Y') ?> Online Learning Platform</span>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

37
header.php Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Online Learning Platform</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="custom.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="index.php">Online Learning Platform</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="index.php"><i class="fas fa-home"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="courses.php"><i class="fas fa-book-open"></i> Courses</a>
</li>
<li class="nav-item">
<a class="nav-link" href="students.php"><i class="fas fa-user-graduate"></i> Students</a>
</li>
<li class="nav-item">
<a class="nav-link" href="instructors.php"><i class="fas fa-chalkboard-teacher"></i> Instructors</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-4">

158
index.php
View File

@ -1,115 +1,47 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
<?php include 'header.php'; ?>
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</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: #ffecd2;
--bg-color-end: #fcb69f;
--text-color: #333333;
--card-bg-color: rgba(255, 255, 255, 0.5);
--card-border-color: rgba(0, 0, 0, 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(0,0,0,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);
animation: float 6s ease-in-out infinite, fadeIn 1s ease-out forwards;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
animation: fadeIn 1.5s ease-out forwards;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
animation: fadeIn 2s ease-out forwards;
}
@keyframes float {
0% { transform: translateY(0px); }
50% { transform: translateY(-10px); }
100% { transform: translateY(0px); }
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head>
<body>
<main>
<div class="card">
<h1>Welcome!</h1>
<p>Your project is ready to conquer the peaks.</p>
<p>PHP version: <code><?= htmlspecialchars($phpVersion) ?></code></p>
<div class="jumbotron text-center">
<h1 class="display-4">Welcome to the Future of Learning!</h1>
<p class="lead">Your all-in-one platform for managing courses, students, and instructors.</p>
<hr class="my-4">
<p>Seamlessly manage every aspect of your educational experience from a single dashboard.</p>
<a class="btn btn-primary btn-lg" href="courses.php" role="button"><i class="fas fa-book-open"></i> Explore Courses</a>
</div>
<div class="row text-center">
<div class="col-md-4">
<div class="card">
<img src="https://picsum.photos/seed/courses/400/200" class="card-img-top" alt="Courses">
<div class="card-body">
<i class="fas fa-book-open fa-3x mb-3"></i>
<h5 class="card-title">Courses</h5>
<p class="card-text">Create, edit, and manage your course offerings.</p>
<a href="courses.php" class="btn btn-primary">Manage Courses</a>
</div>
</div>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</body>
</html>
<div class="col-md-4">
<div class="card">
<img src="https://picsum.photos/seed/students/400/200" class="card-img-top" alt="Students">
<div class="card-body">
<i class="fas fa-user-graduate fa-3x mb-3"></i>
<h5 class="card-title">Students</h5>
<p class="card-text">Track student progress and manage enrollments.</p>
<a href="students.php" class="btn btn-primary">Manage Students</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<img src="https://picsum.photos/seed/instructors/400/200" class="card-img-top" alt="Instructors">
<div class="card-body">
<i class="fas fa-chalkboard-teacher fa-3x mb-3"></i>
<h5 class="card-title">Instructors</h5>
<p class="card-text">Maintain profiles for all your teaching staff.</p>
<a href="instructors.php" class="btn btn-primary">Manage Instructors</a>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>

70
instructors.php Normal file
View File

@ -0,0 +1,70 @@
<?php include 'header.php'; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Instructors</h1>
<button class="btn btn-primary" data-toggle="modal" data-target="#addInstructorModal"><i class="fas fa-plus"></i> Add New Instructor</button>
</div>
<?php
$instructors_json = file_get_contents('data/instructors.json');
$instructors = json_decode($instructors_json, true);
?>
<div class="card">
<div class="card-body">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th>Instructor Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php if (!empty($instructors)):
foreach ($instructors as $instructor):
?>
<tr>
<td><?= htmlspecialchars($instructor['name']) ?></td>
<td><?= htmlspecialchars($instructor['email']) ?></td>
</tr>
<?php
endforeach;
else:
?>
<tr>
<td colspan="2">No instructors found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<!-- Add Instructor Modal -->
<div class="modal fade" id="addInstructorModal" tabindex="-1" aria-labelledby="addInstructorModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addInstructorModalLabel">Add a new instructor</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="add_instructor.php" method="post">
<div class="form-group">
<label for="name">Instructor Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<button type="submit" class="btn btn-primary">Add Instructor</button>
</form>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>

70
students.php Normal file
View File

@ -0,0 +1,70 @@
<?php include 'header.php'; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Students</h1>
<button class="btn btn-primary" data-toggle="modal" data-target="#addStudentModal"><i class="fas fa-plus"></i> Add New Student</button>
</div>
<?php
$students_json = file_get_contents('data/students.json');
$students = json_decode($students_json, true);
?>
<div class="card">
<div class="card-body">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th>Student Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php if (!empty($students)):
foreach ($students as $student):
?>
<tr>
<td><?= htmlspecialchars($student['name']) ?></td>
<td><?= htmlspecialchars($student['email']) ?></td>
</tr>
<?php
endforeach;
else:
?>
<tr>
<td colspan="2">No students found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<!-- Add Student Modal -->
<div class="modal fade" id="addStudentModal" tabindex="-1" aria-labelledby="addStudentModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addStudentModalLabel">Add a new student</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="add_student.php" method="post">
<div class="form-group">
<label for="name">Student Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<button type="submit" class="btn btn-primary">Add Student</button>
</form>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>