From 8edab80394ec7ce9b96950f9df26ae92d9ef13c3 Mon Sep 17 00:00:00 2001 From: Konstantin Protzen Date: Tue, 31 Oct 2023 22:36:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/edit/delete-class.js | 13 ----- homework/add/add-class.js | 8 +-- homework/add/add.php | 10 ++-- homework/add/index.php | 40 +++++++-------- homework/add/style.css | 24 ++++----- homework/edit/edit-class.js | 10 ++-- homework/edit/edit.php | 8 +-- homework/edit/index.php | 44 ++++++++-------- homework/edit/style.css | 26 +++++----- homework/index.php | 10 ++-- index.php | 14 +++--- res/php/PHPMailer-master/README.md | 26 ++++++++-- res/php/PHPMailer-master/src/PHPMailer.php | 47 +++++++++-------- res/php/PHPMailer-master/src/POP3.php | 4 +- settings/add-year/add-year.php | 32 ++++++------ settings/add-year/index.php | 10 ++-- settings/add-year/script.js | 8 +-- settings/delete_grades.php | 2 +- settings/export_grades.php | 32 ++++++------ settings/index.php | 2 +- settings/manage-year/delete.php | 4 +- settings/manage-year/index.php | 2 +- .../add/add-subject.js | 14 +++--- {classes => subjects}/add/add.php | 20 ++++---- {classes => subjects}/add/index.php | 16 +++--- {classes => subjects}/add/style.css | 16 +++--- {classes => subjects}/add/test-switch.js | 0 subjects/edit/delete-class.js | 13 +++++ {classes => subjects}/edit/delete.php | 22 ++++---- {classes => subjects}/edit/index.php | 48 +++++++++--------- {classes => subjects}/edit/modify-class.js | 18 +++---- {classes => subjects}/edit/modify.php | 32 ++++++------ {classes => subjects}/edit/style.css | 26 +++++----- {classes => subjects}/edit/test-switch.js | 0 {classes => subjects}/edit/view-cycler.js | 0 {classes => subjects}/grades/add/add-grade.js | 4 +- {classes => subjects}/grades/add/add.php | 20 ++++---- .../grades/add/choose-grade.js | 0 .../grades/add/choose-points.js | 0 .../grades/add/choose-type.js | 0 {classes => subjects}/grades/add/grades.css | 0 {classes => subjects}/grades/add/index.php | 30 +++++------ {classes => subjects}/grades/add/points.css | 0 {classes => subjects}/grades/add/style.css | 16 +++--- .../grades/edit/add-grade.js | 0 .../grades/edit/choose-grade.js | 0 .../grades/edit/choose-points.js | 0 .../grades/edit/choose-type.js | 0 .../grades/edit/delete-grade.js | 0 {classes => subjects}/grades/edit/delete.php | 6 +-- {classes => subjects}/grades/edit/edit.php | 6 +-- {classes => subjects}/grades/edit/grades.css | 0 {classes => subjects}/grades/edit/index.php | 14 +++--- {classes => subjects}/grades/edit/points.css | 0 {classes => subjects}/grades/edit/style.css | 16 +++--- {classes => subjects}/grades/index.php | 50 +++++++++---------- {classes => subjects}/grades/style.css | 16 +++--- {classes => subjects}/grades/view-cycler.js | 0 {classes => subjects}/index.php | 48 +++++++++--------- {classes => subjects}/style.css | 24 ++++----- 60 files changed, 433 insertions(+), 418 deletions(-) delete mode 100644 classes/edit/delete-class.js rename classes/add/add-class.js => subjects/add/add-subject.js (67%) rename {classes => subjects}/add/add.php (67%) rename {classes => subjects}/add/index.php (94%) rename {classes => subjects}/add/style.css (93%) rename {classes => subjects}/add/test-switch.js (100%) create mode 100644 subjects/edit/delete-class.js rename {classes => subjects}/edit/delete.php (55%) rename {classes => subjects}/edit/index.php (85%) rename {classes => subjects}/edit/modify-class.js (61%) rename {classes => subjects}/edit/modify.php (58%) rename {classes => subjects}/edit/style.css (89%) rename {classes => subjects}/edit/test-switch.js (100%) rename {classes => subjects}/edit/view-cycler.js (100%) rename {classes => subjects}/grades/add/add-grade.js (75%) rename {classes => subjects}/grades/add/add.php (79%) rename {classes => subjects}/grades/add/choose-grade.js (100%) rename {classes => subjects}/grades/add/choose-points.js (100%) rename {classes => subjects}/grades/add/choose-type.js (100%) rename {classes => subjects}/grades/add/grades.css (100%) rename {classes => subjects}/grades/add/index.php (88%) rename {classes => subjects}/grades/add/points.css (100%) rename {classes => subjects}/grades/add/style.css (90%) rename {classes => subjects}/grades/edit/add-grade.js (100%) rename {classes => subjects}/grades/edit/choose-grade.js (100%) rename {classes => subjects}/grades/edit/choose-points.js (100%) rename {classes => subjects}/grades/edit/choose-type.js (100%) rename {classes => subjects}/grades/edit/delete-grade.js (100%) rename {classes => subjects}/grades/edit/delete.php (91%) rename {classes => subjects}/grades/edit/edit.php (95%) rename {classes => subjects}/grades/edit/grades.css (100%) rename {classes => subjects}/grades/edit/index.php (95%) rename {classes => subjects}/grades/edit/points.css (100%) rename {classes => subjects}/grades/edit/style.css (90%) rename {classes => subjects}/grades/index.php (83%) rename {classes => subjects}/grades/style.css (83%) rename {classes => subjects}/grades/view-cycler.js (100%) rename {classes => subjects}/index.php (70%) rename {classes => subjects}/style.css (75%) diff --git a/classes/edit/delete-class.js b/classes/edit/delete-class.js deleted file mode 100644 index ca74e01..0000000 --- a/classes/edit/delete-class.js +++ /dev/null @@ -1,13 +0,0 @@ -function deleteClass() { - const confirmation = confirm("Are you sure you want to delete this class?"); - if (confirmation) $.ajax({ - url: "./delete.php", - type: "POST", - data: { id: classID }, - success: function(data) { - console.log(data); - if (data == "success") location.assign("/classes/"); - else alert("There was an error deleting this class."); - } - }); -} \ No newline at end of file diff --git a/homework/add/add-class.js b/homework/add/add-class.js index a3af8d0..b187fea 100644 --- a/homework/add/add-class.js +++ b/homework/add/add-class.js @@ -1,9 +1,9 @@ -const class_selector = document.getElementById('class-selector'); +const subject_selector = document.getElementById('subject-selector'); const task_input = document.getElementById('task-input'); const date_input_input = document.getElementById('date_input-input'); -const class_add_button = document.querySelector('.class_add'); +const subject_add_button = document.querySelector('.subject_add'); -class_add_button.addEventListener('click', () => { +subject_add_button.addEventListener('click', () => { // check if task is empty if (task_input.value == "") { task_input.style.border = "1px solid red"; @@ -15,7 +15,7 @@ class_add_button.addEventListener('click', () => { url: './add.php', type: 'POST', data: { - class: class_selector.value, + subject: subject_selector.value, type: type, date_due: date_input_input.value, task: task_input.value diff --git a/homework/add/add.php b/homework/add/add.php index d7b8cd6..fb72921 100644 --- a/homework/add/add.php +++ b/homework/add/add.php @@ -19,13 +19,13 @@ if (mysqli_connect_errno()) die("Error with the Database"); // Get input -$class = $_POST["class"]; +$subject = $_POST["subject"]; $type = $_POST["type"]; $date_due = $_POST["date_due"]; $task = $_POST["task"]; // Check if necessary input is given -if (!isset($class) || strlen($class) == 0) die("missing-class"); +if (!isset($subject) || strlen($subject) == 0) die("missing-subject"); if (!isset($type)) die("missing-type"); if (!($type == "b" || $type == "v" || $type == "w" || $type == "o")) die("invalid-type"); if (!isset($date_due) || strlen($date_due) == 0) die("missing-date_due"); @@ -38,9 +38,9 @@ // Create given-date $date_given = date("Y-m-d"); -// Add class to DB and get inserted ID -if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["homework"] . ' (user_id, class, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { - $stmt->bind_param('sisssss', $_SESSION["user_id"], $class, $date_given, $date_due, $task, $type, $_SESSION["setting_years"]); +// Add subject to DB and get inserted ID +if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["homework"] . ' (user_id, subject, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { + $stmt->bind_param('sisssss', $_SESSION["user_id"], $subject, $date_given, $date_due, $task, $type, $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); exit("success"); diff --git a/homework/add/index.php b/homework/add/index.php index c7ab278..7c7b043 100644 --- a/homework/add/index.php +++ b/homework/add/index.php @@ -18,19 +18,19 @@ ); if (mysqli_connect_errno()) exit("Error with the Database"); -// Get all classes -$classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ?")) { +// Get all subjects +$subjectlist = array(); +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ?")) { $stmt->bind_param("s", $_SESSION["user_id"]); $stmt->execute(); - $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); + $stmt->bind_result($subject_name, $subject_color, $subject_id, $subject_last_used, $subject_grade_average); while ($stmt->fetch()) { - $classlist[] = array( - "name" => $class_name, - "color" => $class_color, - "id" => $class_id, - "last_used" => $class_last_used, - "average" => $class_grade_average + $subjectlist[] = array( + "name" => $subject_name, + "color" => $subject_color, + "id" => $subject_id, + "last_used" => $subject_last_used, + "average" => $subject_grade_average ); } $stmt->close(); @@ -82,16 +82,16 @@
-
-
-
- Class +
+
+
+ Subject
-
- ' . $class["name"] . ''; + foreach ($subjectlist as $subject) { + echo ''; } ?> @@ -135,14 +135,14 @@
-
+
Add task
- + diff --git a/homework/add/style.css b/homework/add/style.css index 53a382d..1c09445 100644 --- a/homework/add/style.css +++ b/homework/add/style.css @@ -6,15 +6,15 @@ main { grid-template-rows: 1fr min-content; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class-main_content" "class_add"; + grid-template-areas: "subject-main_content" "subject_add"; } #view_toggle { transition: 0.5s; } -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow-x: hidden; overflow-y: auto; } @@ -47,9 +47,9 @@ main { } -/* Class section */ +/* subject section */ -.class { +.subject { display: flex; flex-direction: column; background-color: var(--background2-color); @@ -58,16 +58,16 @@ main { padding: 1rem; } -.class-title { +.subject-title { font-size: 1.5rem; margin-bottom: 0.5rem; } -.class-container { +.subject-container { display: flex; } -.class-container>select { +.subject-container>select { flex-grow: 1; resize: vertical; border-radius: 0.5rem; @@ -199,11 +199,11 @@ main { /* -Button to add classes +Button to add subjects */ -.class_add { - grid-area: class_add; +.subject_add { + grid-area: subject_add; display: grid; place-items: center; padding: 1rem; @@ -213,6 +213,6 @@ Button to add classes cursor: pointer; } -.class_add>div>i { +.subject_add>div>i { color: var(--accent-color); } \ No newline at end of file diff --git a/homework/edit/edit-class.js b/homework/edit/edit-class.js index 18199a4..d6e73b2 100644 --- a/homework/edit/edit-class.js +++ b/homework/edit/edit-class.js @@ -1,11 +1,11 @@ -const class_selector = document.getElementById('class-selector'); +const subject_selector = document.getElementById('subject-selector'); const task_input = document.getElementById('task-input'); const date_input_input = document.getElementById('date_input-input'); -const class_edit_button = document.getElementById('task_save'); +const subject_edit_button = document.getElementById('task_save'); const task_mark_undone_button = document.getElementById('task_mark_undone'); const task_delete_button = document.getElementById('task_delete'); -class_edit_button.addEventListener('click', () => { +subject_edit_button.addEventListener('click', () => { // check if task is empty if (task_input.value == "") { task_input.style.border = "1px solid red"; @@ -17,7 +17,7 @@ class_edit_button.addEventListener('click', () => { url: './edit.php', type: 'POST', data: { - class: class_selector.value, + subject: subject_selector.value, type: type, task_id: task_id, date_due: date_input_input.value, @@ -48,7 +48,7 @@ task_mark_undone_button.addEventListener('click', () => { url: './edit.php', type: 'POST', data: { - class: class_selector.value, + subject: subject_selector.value, type: type, task_id: task_id, date_due: date_input_input.value, diff --git a/homework/edit/edit.php b/homework/edit/edit.php index 3dff7e0..f604b31 100644 --- a/homework/edit/edit.php +++ b/homework/edit/edit.php @@ -19,14 +19,14 @@ if (mysqli_connect_errno()) die("Error with the Database"); // Get input -$class = $_POST["class"]; +$subject = $_POST["subject"]; $type = $_POST["type"]; $date_due = $_POST["date_due"]; $task = $_POST["task"]; $task_id = $_POST["task_id"]; // Check if necessary input is given -if (!isset($class) || strlen($class) == 0) die("missing-class"); +if (!isset($subject) || strlen($subject) == 0) die("missing-subject"); if (!isset($type)) die("missing-type"); if (!($type == "b" || $type == "v" || $type == "w" || $type == "o")) die("invalid-type"); if (!isset($date_due) || strlen($date_due) == 0) die("missing-date_due"); @@ -40,8 +40,8 @@ $date_given = date("Y-m-d"); // Update task in DB -if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["homework"] . ' SET class = ?, given = ?, deadline = ?, text = ?, type = ? WHERE entry_id = ? AND user_id = ?')) { - $stmt->bind_param('sssssis', $class, $date_given, $date_due, $task, $type, $task_id, $_SESSION["user_id"]); +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["homework"] . ' SET subject = ?, given = ?, deadline = ?, text = ?, type = ? WHERE entry_id = ? AND user_id = ?')) { + $stmt->bind_param('sssssis', $subject, $date_given, $date_due, $task, $type, $task_id, $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); exit("success"); diff --git a/homework/edit/index.php b/homework/edit/index.php index a9881f6..d5af0d4 100644 --- a/homework/edit/index.php +++ b/homework/edit/index.php @@ -10,7 +10,7 @@ if (!isset($_GET["task"])) header("Location: /homework"); $task_id = htmlspecialchars($_GET["task"]); // Check if task is a-z or 0-9 -if (!preg_match("/^[a-z0-9]*$/", $task_id)) header("Location: /classes"); +if (!preg_match("/^[a-z0-9]*$/", $task_id)) header("Location: /subjects"); // Get config @@ -25,26 +25,26 @@ ); if (mysqli_connect_errno()) exit("Error with the Database"); -// Get all classes -$classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ?")) { +// Get all subjects +$subjectlist = array(); +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ?")) { $stmt->bind_param("s", $_SESSION["user_id"]); $stmt->execute(); - $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); + $stmt->bind_result($subject_name, $subject_color, $subject_id, $subject_last_used, $subject_grade_average); while ($stmt->fetch()) { - $classlist[] = array( - "name" => $class_name, - "color" => $class_color, - "id" => $class_id, - "last_used" => $class_last_used, - "average" => $class_grade_average + $subjectlist[] = array( + "name" => $subject_name, + "color" => $subject_color, + "id" => $subject_id, + "last_used" => $subject_last_used, + "average" => $subject_grade_average ); } $stmt->close(); } // Get task -if ($stmt = $con->prepare("SELECT class, type, text, deadline FROM " . $config["db"]["tables"]["homework"] . " WHERE entry_id = ? AND user_id = ?")) { +if ($stmt = $con->prepare("SELECT subject, type, text, deadline FROM " . $config["db"]["tables"]["homework"] . " WHERE entry_id = ? AND user_id = ?")) { $stmt->bind_param("is", $task_id, $_SESSION["user_id"]); $stmt->execute(); $result = $stmt->get_result(); @@ -98,16 +98,16 @@
-
-
-
- Class +
+
+
+ Subject
-
- ' . $class["name"] . ''; + foreach ($subjectlist as $subject) { + if ($task["subject"] == $class["id"]) echo ''; else echo ''; } ?> @@ -152,7 +152,7 @@
-
+
@@ -165,7 +165,7 @@ - + diff --git a/homework/edit/style.css b/homework/edit/style.css index 02e07e3..e2cef96 100644 --- a/homework/edit/style.css +++ b/homework/edit/style.css @@ -6,15 +6,15 @@ main { grid-template-rows: 1fr min-content; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class-main_content" "class_edit"; + grid-template-areas: "subject-main_content" "subject_edit"; } #view_toggle { transition: 0.5s; } -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow-x: hidden; overflow-y: auto; } @@ -47,9 +47,9 @@ main { } -/* Class section */ +/* subject section */ -.class { +.subject { display: flex; flex-direction: column; background-color: var(--background2-color); @@ -58,16 +58,16 @@ main { padding: 1rem; } -.class-title { +.subject-title { font-size: 1.5rem; margin-bottom: 0.5rem; } -.class-container { +.subject-container { display: flex; } -.class-container>select { +.subject-container>select { flex-grow: 1; resize: vertical; border-radius: 0.5rem; @@ -199,11 +199,11 @@ main { /* -Button to edit classes +Button to edit subjects */ -.class_edit { - grid-area: class_edit; +.subject_edit { + grid-area: subject_edit; display: flex; flex-direction: row; padding: 1rem; @@ -213,12 +213,12 @@ Button to edit classes cursor: pointer; } -.class_edit div { +.subject_edit div { flex-grow: 1; text-align: center; } -.class_edit>div>i { +.subject_edit>div>i { color: var(--accent-color); font-size: 1.5rem; cursor: pointer; diff --git a/homework/index.php b/homework/index.php index ff94b2f..2889adf 100644 --- a/homework/index.php +++ b/homework/index.php @@ -33,12 +33,12 @@ $homework = $result->fetch_all(MYSQLI_ASSOC); } -// Get all classes -if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? and year = ?")) { +// Get all subjects +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ? and year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $result = $stmt->get_result(); - $classes = $result->fetch_all(MYSQLI_ASSOC); + $subjects = $result->fetch_all(MYSQLI_ASSOC); } // Order homework by deadline in arrays - arrays by date @@ -96,7 +96,7 @@
- + @@ -115,7 +115,7 @@ foreach ($hw_dategroup as $hw_entry) { echo '
'; echo '
'; - foreach ($classes as $class) if ($class["id"] == $hw_entry["class"]) echo $class["name"]; + foreach ($subjects as $subject) if ($subject["id"] == $hw_entry["class"]) echo $subject["name"]; echo '
' . $hw_entry["text"] . '
'; echo '
'; if ($hw_entry["status"] == 0) echo '
'; diff --git a/index.php b/index.php index 0e7f675..7f55afe 100644 --- a/index.php +++ b/index.php @@ -51,12 +51,12 @@ $stmt->close(); } -// Get all classes -if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { +// Get all subjects +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $result = $stmt->get_result(); - $classes = $result->fetch_all(MYSQLI_ASSOC); + $subjects = $result->fetch_all(MYSQLI_ASSOC); } // Count grades if ($stmt = $con->prepare("SELECT COUNT(*) FROM " . $config["db"]["tables"]["grades"] . " WHERE user_id = ? AND year = ?")) { @@ -77,7 +77,7 @@ } // Calculate average -if ($stmt = $con->prepare("SELECT average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("SELECT average FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->bind_result($average); @@ -132,7 +132,7 @@
- + @@ -178,8 +178,8 @@ '; - echo '
'; - foreach ($classes as $class) if ($class["id"] == $hw_task["class"]) echo $class["name"]; + echo '
'; + foreach ($subjects as $subject) if ($subject["id"] == $hw_task["subject"]) echo $subject["name"]; echo '
' . $hw_task["text"] . '
'; echo '
'; if ($hw_task["status"] == 0) echo '
'; diff --git a/res/php/PHPMailer-master/README.md b/res/php/PHPMailer-master/README.md index 53e66f1..a28173f 100644 --- a/res/php/PHPMailer-master/README.md +++ b/res/php/PHPMailer-master/README.md @@ -13,6 +13,7 @@ [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/PHPMailer/PHPMailer/badge)](https://api.securityscorecards.dev/projects/github.com/PHPMailer/PHPMailer) ## Features + - Probably the world's most popular code for sending email from PHP! - Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more - Integrated SMTP support – send without a local mail server @@ -30,20 +31,23 @@ - Much more! ## Why you might need it + Many PHP developers need to send email from their code. The only PHP function that supports this directly is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments. Formatting email correctly is surprisingly difficult. There are myriad overlapping (and conflicting) standards, requiring tight adherence to horribly complicated formatting and encoding rules – the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong, if not unsafe! The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP client allows email sending on all platforms without needing a local mail server. Be aware though, that the `mail()` function should be avoided when possible; it's both faster and [safer](https://exploitbox.io/paper/Pwning-PHP-Mail-Function-For-Fun-And-RCE.html) to use SMTP to localhost. -*Please* don't be tempted to do it yourself – if you don't use PHPMailer, there are many other excellent libraries that +_Please_ don't be tempted to do it yourself – if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own. Try [SwiftMailer](https://swiftmailer.symfony.com/) , [Laminas/Mail](https://docs.laminas.dev/laminas-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail), etc. ## License + This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read [LICENSE](https://github.com/PHPMailer/PHPMailer/blob/master/LICENSE) for information on the software availability and distribution. ## Installation & loading + PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file: ```json @@ -76,19 +80,22 @@ require 'path/to/PHPMailer/src/SMTP.php'; If you're not using the `SMTP` class explicitly (you're probably not), you don't need a `use` line for the SMTP class. Even if you're not using exceptions, you do still need to load the `Exception` class as it is used internally. ## Legacy versions + PHPMailer 5.2 (which is compatible with PHP 5.0 — 7.0) is no longer supported, even for security updates. You will find the latest version of 5.2 in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable). If you're using PHP 5.5 or later (which you should be), switch to the 6.x releases. ### Upgrading from 5.2 + The biggest changes are that source files are now in the `src/` folder, and PHPMailer now declares the namespace `PHPMailer\PHPMailer`. This has several important effects – [read the upgrade guide](https://github.com/PHPMailer/PHPMailer/tree/master/UPGRADING.md) for more details. ### Minimal installation -While installing the entire package manually or with Composer is simple, convenient, and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP (*very* unlikely!), you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer! + +While installing the entire package manually or with Composer is simple, convenient, and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP (_very_ unlikely!), you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer! ## A Simple Example ```php setLanguage('fr', '/optional/path/to/language/directory/'); We welcome corrections and new languages – if you're looking for corrections, run the [PHPMailerLangTest.php](https://github.com/PHPMailer/PHPMailer/tree/master/test/PHPMailerLangTest.php) script in the tests folder and it will show any missing translations. ## Documentation + Start reading at the [GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki). If you're having trouble, head for [the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting) as it's frequently updated. Examples of how to use PHPMailer for common scenarios can be found in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder. If you're looking for a good starting point, we recommend you start with [the Gmail example](https://github.com/PHPMailer/PHPMailer/tree/master/examples/gmail.phps). @@ -166,6 +175,7 @@ You can generate complete API-level documentation by running `phpdoc` in the top If the documentation doesn't cover what you need, search the [many questions on Stack Overflow](http://stackoverflow.com/questions/tagged/phpmailer), and before you ask a question about "SMTP Error: Could not connect to SMTP host.", [read the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). ## Tests + [PHPMailer tests](https://github.com/PHPMailer/PHPMailer/tree/master/test/) use PHPUnit 9, with [a polyfill](https://github.com/Yoast/PHPUnit-Polyfills) to let 9-style tests run on older PHPUnit and PHP versions. [![Test status](https://github.com/PHPMailer/PHPMailer/workflows/Tests/badge.svg)](https://github.com/PHPMailer/PHPMailer/actions) @@ -173,11 +183,13 @@ If the documentation doesn't cover what you need, search the [many questions on If this isn't passing, is there something you can do to help? ## Security + Please disclose any vulnerabilities found responsibly – report security issues to the maintainers privately. -See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) and [PHPMailer's security advisories on GitHub](https://github.com/PHPMailer/PHPMailer/security). +See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) and [PHPMailer's security advisories on GitHub](https://github.com/PHPMailer/PHPMailer/security). ## Contributing + Please submit bug reports, suggestions, and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues). We're particularly interested in fixing edge cases, expanding test coverage, and updating translations. @@ -190,9 +202,10 @@ If you have git clones from prior to the move to the PHPMailer GitHub organisati git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git ``` -Please *don't* use the SourceForge or Google Code projects any more; they are obsolete and no longer maintained. +Please _don't_ use the SourceForge or Google Code projects any more; they are obsolete and no longer maintained. ## Sponsorship + Development time and resources for PHPMailer are provided by [Smartmessages.net](https://info.smartmessages.net/), the world's only privacy-first email marketing system.
Smartmessages.net privacy-first email marketing logo @@ -209,9 +222,11 @@ improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-phpmailer-phpmailer?utm_source=packagist-phpmailer-phpmailer&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) ## Changelog + See [changelog](changelog.md). ## History + - PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/). - [Marcus Bointon](https://github.com/Synchro) (`coolbru` on SF) and Andy Prevost (`codeworxtech`) took over the project in 2004. - Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski. @@ -220,6 +235,7 @@ See [changelog](changelog.md). - PHPMailer moves to [the PHPMailer organisation](https://github.com/PHPMailer) on GitHub in 2013. ### What's changed since moving from SourceForge? + - Official successor to the SourceForge and Google Code projects. - Test suite. - Continuous integration with GitHub Actions. diff --git a/res/php/PHPMailer-master/src/PHPMailer.php b/res/php/PHPMailer-master/src/PHPMailer.php index a644d2c..189307d 100644 --- a/res/php/PHPMailer-master/src/PHPMailer.php +++ b/res/php/PHPMailer-master/src/PHPMailer.php @@ -150,7 +150,7 @@ class PHPMailer /** * An iCal message part body. * Only supported in simple alt or alt_inline message types - * To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator. + * To generate iCal event structures, use subjects like EasyPeasyICS or iCalcreator. * * @see http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/ * @see http://kigkonsult.se/iCalcreator/ @@ -926,7 +926,7 @@ protected function edebug($str) $str = preg_replace('/\r\n|\r/m', "\n", $str); echo gmdate('Y-m-d H:i:s'), "\t", - //Trim trailing space + //Trim trailing space trim( //Indent for readability, except for trailing break str_replace( @@ -1311,7 +1311,7 @@ public function setFrom($address, $name = '', $auto = true) if ( (false === $pos) || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) - && !static::validateAddress($address)) + && !static::validateAddress($address)) ) { $error_message = sprintf( '%s (From): %s', @@ -1406,14 +1406,14 @@ public static function validateAddress($address, $patternselect = null) */ return (bool) preg_match( '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . - '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . - '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . - '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . - '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . - '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . - '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . - '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . - '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . + '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address ); case 'html5': @@ -1424,7 +1424,7 @@ public static function validateAddress($address, $patternselect = null) */ return (bool) preg_match( '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . - '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', + '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', $address ); case 'php': @@ -2638,8 +2638,7 @@ public function createHeader() //sendmail and mail() extract Bcc from the header before sending if ( - ( - 'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer + ('sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer ) && count($this->bcc) > 0 ) { @@ -2661,10 +2660,10 @@ public function createHeader() '' !== $this->MessageID && preg_match( '/^<((([a-z\d!#$%&\'*+\/=?^_`{|}~-]+(\.[a-z\d!#$%&\'*+\/=?^_`{|}~-]+)*)' . - '|("(([\x01-\x08\x0B\x0C\x0E-\x1F\x7F]|[\x21\x23-\x5B\x5D-\x7E])' . - '|(\\[\x01-\x09\x0B\x0C\x0E-\x7F]))*"))@(([a-z\d!#$%&\'*+\/=?^_`{|}~-]+' . - '(\.[a-z\d!#$%&\'*+\/=?^_`{|}~-]+)*)|(\[(([\x01-\x08\x0B\x0C\x0E-\x1F\x7F]' . - '|[\x21-\x5A\x5E-\x7E])|(\\[\x01-\x09\x0B\x0C\x0E-\x7F]))*\])))>$/Di', + '|("(([\x01-\x08\x0B\x0C\x0E-\x1F\x7F]|[\x21\x23-\x5B\x5D-\x7E])' . + '|(\\[\x01-\x09\x0B\x0C\x0E-\x7F]))*"))@(([a-z\d!#$%&\'*+\/=?^_`{|}~-]+' . + '(\.[a-z\d!#$%&\'*+\/=?^_`{|}~-]+)*)|(\[(([\x01-\x08\x0B\x0C\x0E-\x1F\x7F]' . + '|[\x21-\x5A\x5E-\x7E])|(\\[\x01-\x09\x0B\x0C\x0E-\x7F]))*\])))>$/Di', $this->MessageID ) ) { @@ -3434,7 +3433,7 @@ public function encodeString($str, $encoding = self::ENCODING_BASE64) case static::ENCODING_8BIT: $encoded = static::normalizeBreaks($str); //Make sure it ends with a line break - if (substr($encoded, -(strlen(static::$LE))) !== static::$LE) { + if (substr($encoded, - (strlen(static::$LE))) !== static::$LE) { $encoded .= static::$LE; } break; @@ -3481,10 +3480,10 @@ public function encodeHeader($str, $position = 'text') } $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); break; - /* @noinspection PhpMissingBreakStatementInspection */ + /* @noinspection PhpMissingBreakStatementInspection */ case 'comment': $matchcount = preg_match_all('/[()"]/', $str, $matches); - //fallthrough + //fallthrough case 'text': default: $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); @@ -3654,14 +3653,14 @@ public function encodeQ($str, $position = 'text') //RFC 2047 section 5.3 $pattern = '^A-Za-z0-9!*+\/ -'; break; - /* + /* * RFC 2047 section 5.2. * Build $pattern without including delimiters and [] */ - /* @noinspection PhpMissingBreakStatementInspection */ + /* @noinspection PhpMissingBreakStatementInspection */ case 'comment': $pattern = '\(\)"'; - /* Intentional fall through */ + /* Intentional fall through */ case 'text': default: //RFC 2047 section 5.1 diff --git a/res/php/PHPMailer-master/src/POP3.php b/res/php/PHPMailer-master/src/POP3.php index d025689..10297ca 100644 --- a/res/php/PHPMailer-master/src/POP3.php +++ b/res/php/PHPMailer-master/src/POP3.php @@ -32,7 +32,7 @@ * 3) This is really ancient technology; you should only need to use it to talk to very old systems. * 4) This POP3 class is deliberately lightweight and incomplete, implementing just * enough to do authentication. - * If you want a more complete class there are other POP3 classes for PHP available. + * If you want a more complete class there are other POP3 subjects for PHP available. * * @author Richard Davey (original author) * @author Marcus Bointon (Synchro/coolbru) @@ -461,7 +461,7 @@ protected function catchWarning($errno, $errstr, $errfile, $errline) { $this->setError( 'Connecting to the POP3 server raised a PHP warning:' . - "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline" + "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline" ); } } diff --git a/settings/add-year/add-year.php b/settings/add-year/add-year.php index 024124b..cf0f6f9 100644 --- a/settings/add-year/add-year.php +++ b/settings/add-year/add-year.php @@ -39,14 +39,14 @@ $year_id .= $chars[rand(0, strlen($chars) - 1)]; } -// Get transfer classes -if (isset($_POST["transfer_classes"])) { - $transfer_classes = $_POST["transfer_classes"]; - $sql_string = "SELECT * FROM classes WHERE year = ? AND user_id = ?"; +// Get transfer subjects +if (isset($_POST["transfer_subjects"])) { + $transfer_subjects = $_POST["transfer_subjects"]; + $sql_string = "SELECT * FROM subjects WHERE year = ? AND user_id = ?"; $sql_types = "ss"; - if (count($transfer_classes) > 0) { + if (count($transfer_subjects) > 0) { $sql_string .= " AND id IN ("; - foreach ($transfer_classes as $class) { + foreach ($transfer_subjects as $subject) { $sql_string .= "?, "; $sql_types .= "s"; } @@ -54,28 +54,28 @@ $sql_string .= ")"; } if ($stmt = $con->prepare($sql_string)) { - $stmt->bind_param($sql_types, $_SESSION["setting_years"], $_SESSION["user_id"], ...$transfer_classes); + $stmt->bind_param($sql_types, $_SESSION["setting_years"], $_SESSION["user_id"], ...$transfer_subjects); $stmt->execute(); $result = $stmt->get_result(); - $classes = $result->fetch_all(MYSQLI_ASSOC); + $subjects = $result->fetch_all(MYSQLI_ASSOC); $stmt->close(); } - // Insert new classes - foreach ($classes as $class) { + // Insert new subjects + foreach ($subjects as $subject) { $regenerate = true; - $class_id = ""; + $subject_id = ""; while ($regenerate) { for ($i = 0; $i < 8; $i++) { - $class_id .= $chars[rand(0, strlen($chars) - 1)]; + $subject_id .= $chars[rand(0, strlen($chars) - 1)]; } - if ($stmt = $con->prepare("SELECT id FROM " . $config["db"]["tables"]["classes"] . " WHERE id = ?")) { - $stmt->bind_param("s", $class_id); + if ($stmt = $con->prepare("SELECT id FROM " . $config["db"]["tables"]["subjects"] . " WHERE id = ?")) { + $stmt->bind_param("s", $subject_id); $stmt->execute(); if ($stmt->get_result()->num_rows == 0) { $stmt->close(); $regenerate = false; - if ($stmt = $con->prepare("INSERT INTO " . $config["db"]["tables"]["classes"] . " (id, name, color, user_id, grade_k, grade_m, grade_t, grade_s, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) { - $stmt->bind_param("sssssssss", $class_id, $class["name"], $class["color"], $_SESSION["user_id"], $class["grade_k"], $class["grade_m"], $class["grade_t"], $class["grade_s"], $year_id); + if ($stmt = $con->prepare("INSERT INTO " . $config["db"]["tables"]["subjects"] . " (id, name, color, user_id, grade_k, grade_m, grade_t, grade_s, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) { + $stmt->bind_param("sssssssss", $subject_id, $subject["name"], $subject["color"], $_SESSION["user_id"], $subject["grade_k"], $subject["grade_m"], $subject["grade_t"], $subject["grade_s"], $year_id); $stmt->execute(); $stmt->close(); } diff --git a/settings/add-year/index.php b/settings/add-year/index.php index a9a2bc2..970bda8 100644 --- a/settings/add-year/index.php +++ b/settings/add-year/index.php @@ -30,12 +30,12 @@ $stmt->close(); } -// Get classes -if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { +// Get subjects +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $result = $stmt->get_result(); - $classes = $result->fetch_all(MYSQLI_ASSOC); + $subjects = $result->fetch_all(MYSQLI_ASSOC); } // DB Con close @@ -100,8 +100,8 @@
- Copy Classes
- " . htmlspecialchars($class["name"]) . "
"; ?>
+ Copy subjects
+ " . htmlspecialchars($subject["name"]) . "
"; ?>
diff --git a/settings/add-year/script.js b/settings/add-year/script.js index 432187b..01394d1 100644 --- a/settings/add-year/script.js +++ b/settings/add-year/script.js @@ -1,10 +1,10 @@ const submit_button = document.getElementById("submit_button"); submit_button.addEventListener("click", function () { - let transferClasses = []; - for (const checkbox of document.getElementsByClassName("copy_class_checkbox")) { + let transfersubjects = []; + for (const checkbox of document.getElementsByClassName("copy_subject_checkbox")) { if (checkbox.checked) { - transferClasses.push(checkbox.value); + transfersubjects.push(checkbox.value); } } const year_name = document.getElementById("year-name-input").value; @@ -17,7 +17,7 @@ submit_button.addEventListener("click", function () { url: "add-year.php", data: { year_name: year_name, - transfer_classes: transferClasses + transfer_subjects: transfersubjects }, success: function (response) { if (response == "success") { diff --git a/settings/delete_grades.php b/settings/delete_grades.php index acc76b6..87a4da6 100644 --- a/settings/delete_grades.php +++ b/settings/delete_grades.php @@ -26,7 +26,7 @@ } // Set all averages to 0 -if ($stmt = $con->prepare("UPDATE " . $config["db"]["tables"]["classes"] . " SET average = 0 WHERE user_id = ?")) { +if ($stmt = $con->prepare("UPDATE " . $config["db"]["tables"]["subjects"] . " SET average = 0 WHERE user_id = ?")) { $stmt->bind_param("s", $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); diff --git a/settings/export_grades.php b/settings/export_grades.php index 45a85d2..c94241e 100644 --- a/settings/export_grades.php +++ b/settings/export_grades.php @@ -18,19 +18,19 @@ ); if (mysqli_connect_errno()) exit("Error with the Database"); -// Get all classes -$classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ? ORDER BY average ASC")) { +// Get all subjects +$subjectlist = array(); +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ? AND year = ? ORDER BY average ASC")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); - $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); + $stmt->bind_result($subject_name, $subject_color, $subject_id, $subject_last_used, $subject_grade_average); while ($stmt->fetch()) { - $classlist[] = array( - "name" => $class_name, - "color" => $class_color, - "id" => $class_id, - "last_used" => $class_last_used, - "average" => $class_grade_average + $subjectlist[] = array( + "name" => $subject_name, + "color" => $subject_color, + "id" => $subject_id, + "last_used" => $subject_last_used, + "average" => $subject_grade_average ); } $stmt->close(); @@ -62,11 +62,11 @@ // - - - - - - - // // Grades // // - - - - - - - // -foreach ($classlist as $class) { - // Class-Header +foreach ($subjectlist as $subject) { + // Subject-Header $pdf->SetFont('Arial', 'B', 15); - if ($class["average"] != 0) $title = $class["name"] . ' - ' . iconv('utf-8', 'cp1252', 'Ø ') . number_format($class["average"], $_SESSION["setting_rounding"], '.', ''); - else $title = $class["name"]; + if ($subject["average"] != 0) $title = $subject["name"] . ' - ' . iconv('utf-8', 'cp1252', 'Ø ') . number_format($subject["average"], $_SESSION["setting_rounding"], '.', ''); + else $title = $subject["name"]; $pdf->Cell(0, 10, $title, 0, 0, 'L'); $pdf->Ln(7.5); $pdf->SetTextColor(0, 0, 0); @@ -79,8 +79,8 @@ $pdf->Ln(); // Get grades $grades = array(); - if ($stmt = $con->prepare('SELECT id, user_id, class, note, type, date, grade FROM grades WHERE class = ?')) { - $stmt->bind_param('s', $class["id"]); + if ($stmt = $con->prepare('SELECT id, user_id, subject, note, type, date, grade FROM grades WHERE subject = ?')) { + $stmt->bind_param('s', $subject["id"]); $stmt->execute(); $result = $stmt->get_result(); foreach ($result as $row) { diff --git a/settings/index.php b/settings/index.php index 02ab86b..284ea89 100644 --- a/settings/index.php +++ b/settings/index.php @@ -259,7 +259,7 @@ Sorting settings
- Classes + subjects
onclick="setSorting('average');"> Average diff --git a/settings/manage-year/delete.php b/settings/manage-year/delete.php index 390d17a..801dec9 100644 --- a/settings/manage-year/delete.php +++ b/settings/manage-year/delete.php @@ -25,8 +25,8 @@ $stmt->close(); } -// Delete all classes -if ($stmt = $con->prepare("DELETE FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { +// Delete all subjects +if ($stmt = $con->prepare("DELETE FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); diff --git a/settings/manage-year/index.php b/settings/manage-year/index.php index 7f21f8b..437769e 100644 --- a/settings/manage-year/index.php +++ b/settings/manage-year/index.php @@ -99,7 +99,7 @@
Update Year
Delete this Year
-

Warning: When you click on delete, all classes, grades and homework entries for the current chosen year will be deleted.

+

Warning: When you click on delete, all subjects, grades and homework entries for the current chosen year will be deleted.

- +
-
+
- Classname + Subject-Name
- +
@@ -129,14 +129,14 @@
-
-
Create class
+
+
Create subject
- + diff --git a/classes/add/style.css b/subjects/add/style.css similarity index 93% rename from classes/add/style.css rename to subjects/add/style.css index f0deb7a..d1b7174 100644 --- a/classes/add/style.css +++ b/subjects/add/style.css @@ -6,15 +6,15 @@ main { grid-template-rows: 1fr min-content; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class-main_content" "class_add"; + grid-template-areas: "subject-main_content" "subject_add"; } #view_toggle { transition: 0.5s; } -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow-x: hidden; overflow-y: auto; } @@ -42,7 +42,7 @@ main { } -/* Classname section */ +/* Subjectname section */ .name { display: flex; @@ -190,11 +190,11 @@ main { /* -Button to add classes +Button to add subjects */ -.class_add { - grid-area: class_add; +.subject_add { + grid-area: subject_add; display: grid; place-items: center; padding: 1rem; @@ -204,6 +204,6 @@ Button to add classes cursor: pointer; } -.class_add>div>i { +.subject_add>div>i { color: var(--accent-color); } \ No newline at end of file diff --git a/classes/add/test-switch.js b/subjects/add/test-switch.js similarity index 100% rename from classes/add/test-switch.js rename to subjects/add/test-switch.js diff --git a/subjects/edit/delete-class.js b/subjects/edit/delete-class.js new file mode 100644 index 0000000..3d5c1ee --- /dev/null +++ b/subjects/edit/delete-class.js @@ -0,0 +1,13 @@ +function deleteSubject() { + const confirmation = confirm("Are you sure you want to delete this subject?"); + if (confirmation) $.ajax({ + url: "./delete.php", + type: "POST", + data: { id: subjectID }, + success: function (data) { + console.log(data); + if (data == "success") location.assign("/subjects/"); + else alert("There was an error deleting this subject."); + } + }); +} \ No newline at end of file diff --git a/classes/edit/delete.php b/subjects/edit/delete.php similarity index 55% rename from classes/edit/delete.php rename to subjects/edit/delete.php index f2b4c57..47dcdfa 100644 --- a/classes/edit/delete.php +++ b/subjects/edit/delete.php @@ -18,25 +18,25 @@ if (mysqli_connect_errno()) die("Error with the Database"); // Get input -$class_id = $_POST["id"]; -if ($class_id === "") die("no id given"); +$subject_id = $_POST["id"]; +if ($subject_id === "") die("no id given"); -// Delete class if belonging to user, then check if one was deleted -if ($stmt = $con->prepare('DELETE FROM classes WHERE id = ? AND user_id = ?')) { - $stmt->bind_param('is', $class_id, $_SESSION["user_id"]); +// Delete subject if belonging to user, then check if one was deleted +if ($stmt = $con->prepare('DELETE FROM subjects WHERE id = ? AND user_id = ?')) { + $stmt->bind_param('is', $subject_id, $_SESSION["user_id"]); $stmt->execute(); - if ($stmt->affected_rows === 0) die("no class deleted"); + if ($stmt->affected_rows === 0) die("no subject deleted"); else if ($stmt->affected_rows === 1) { - if ($stmt->prepare('DELETE FROM homework WHERE class = ? AND user_id = ?')) { - $stmt->bind_param('ss', $class_id, $_SESSION["user_id"]); + if ($stmt->prepare('DELETE FROM homework WHERE subject = ? AND user_id = ?')) { + $stmt->bind_param('ss', $subject_id, $_SESSION["user_id"]); $stmt->execute(); - if ($stmt->prepare('DELETE FROM grades WHERE class = ? AND user_id = ?')) { - $stmt->bind_param('ss', $class_id, $_SESSION["user_id"]); + if ($stmt->prepare('DELETE FROM grades WHERE subject = ? AND user_id = ?')) { + $stmt->bind_param('ss', $subject_id, $_SESSION["user_id"]); $stmt->execute(); exit("success"); } else die("Error with the Database"); } - } else die("too many classes deleted"); + } else die("too many subjects deleted"); } else { die("Error with the Database"); } diff --git a/classes/edit/index.php b/subjects/edit/index.php similarity index 85% rename from classes/edit/index.php rename to subjects/edit/index.php index a9be10a..0ceeca3 100644 --- a/classes/edit/index.php +++ b/subjects/edit/index.php @@ -1,10 +1,10 @@ prepare('SELECT name, color, user_id, last_used, grade_k, grade_m, grade_t, grade_s FROM classes WHERE id = ?')) { - $stmt->bind_param('s', $class_id); +// Get subject +if ($stmt = $con->prepare('SELECT name, color, user_id, last_used, grade_k, grade_m, grade_t, grade_s FROM subjects WHERE id = ?')) { + $stmt->bind_param('s', $subject_id); $stmt->execute(); $stmt->store_result(); - $stmt->bind_result($class_name, $class_color, $user_id, $last_used, $grade_k, $grade_m, $grade_t, $grade_s); + $stmt->bind_result($subject_name, $subject_color, $user_id, $last_used, $grade_k, $grade_m, $grade_t, $grade_s); $stmt->fetch(); if ($user_id !== $_SESSION["user_id"]) { $name = ""; @@ -54,7 +54,7 @@ - <?= $class_name ?> | Noten-App + <?= $subject_name ?> | Noten-App @@ -77,35 +77,35 @@
-
+

-
- +
+
-
+
STATS
- Classname + Subject-Name
- +
@@ -157,15 +157,15 @@
- Class-Color + Subject-Color
- +
- Delete class + Delete subject
@@ -173,14 +173,14 @@
- +
- - + + diff --git a/classes/edit/modify-class.js b/subjects/edit/modify-class.js similarity index 61% rename from classes/edit/modify-class.js rename to subjects/edit/modify-class.js index 83d270e..7cbbc09 100644 --- a/classes/edit/modify-class.js +++ b/subjects/edit/modify-class.js @@ -1,30 +1,30 @@ -const classname_input = document.getElementById('name-input'); +const subject_name_input = document.getElementById('name-input'); const grading_option_type_k = document.getElementById('grading_option-type_k'); const grading_option_type_m = document.getElementById('grading_option-type_m'); const grading_option_type_t = document.getElementById('grading_option-type_t'); const grading_option_type_s = document.getElementById('grading_option-type_s'); -const classcolor_input = document.getElementById('color_input-input'); -const class_save_button = document.getElementById('save_class') -const classID = document.getElementById('classID').innerText; +const subject_color_input = document.getElementById('color_input-input'); +const subject_save_button = document.getElementById('save_subject') +const subjectID = document.getElementById('subjectID').innerText; -class_save_button.addEventListener('click', () => { +subject_save_button.addEventListener('click', () => { $.ajax({ url: './modify.php', type: 'POST', data: { - classID: classID, - className: classname_input.value, + subjectID: subjectID, + subjectName: subject_name_input.value, testCustom: test_custom, gradingTypeK: grading_option_type_k.value, gradingTypeM: grading_option_type_m.value, gradingTypeT: grading_option_type_t.value, gradingTypeS: grading_option_type_s.value, - classColor: classcolor_input.value + subjectColor: subject_color_input.value }, success: (data) => { console.log(data); if (data == "success") { - location.assign("/classes/class?class=" + classID); + location.assign("/subjects/subject?subject=" + subjectID); } else { console.log(data); } diff --git a/classes/edit/modify.php b/subjects/edit/modify.php similarity index 58% rename from classes/edit/modify.php rename to subjects/edit/modify.php index 596810a..14c8961 100644 --- a/classes/edit/modify.php +++ b/subjects/edit/modify.php @@ -19,33 +19,33 @@ if (mysqli_connect_errno()) die("Error with the Database"); // Get input -$className = $_POST["className"]; +$subjectName = $_POST["subjectName"]; $testCustom = $_POST["testCustom"]; $gradingTypeK = $_POST["gradingTypeK"]; $gradingTypeM = $_POST["gradingTypeM"]; $gradingTypeT = $_POST["gradingTypeT"]; $gradingTypeS = $_POST["gradingTypeS"]; -$classColor = $_POST["classColor"]; -$classID = $_POST["classID"]; +$subjectColor = $_POST["subjectColor"]; +$subjectID = $_POST["subjectID"]; // Check if necessary input is given -if (!isset($className) || strlen($className) == 0) die("missing-classname"); +if (!isset($subjectName) || strlen($subjectName) == 0) die("missing-subjectname"); if (!isset($testCustom)) die("missing-testcustom"); if (!isset($gradingTypeK)) die("missing-gradingtypeK"); if (!isset($gradingTypeM)) die("missing-gradingtypeM"); if ($testCustom == "true" && !isset($gradingTypeT)) die("missing-gradingtypeT"); if (!isset($gradingTypeS)) die("missing-gradingtypeS"); -if (!isset($classColor)) die("missing-classcolor"); -if (!isset($classID)) die("missing-classid"); +if (!isset($subjectColor)) die("missing-subjectcolor"); +if (!isset($subjectID)) die("missing-subjectid"); -// Check if class exists and belongs to user -if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["classes"] . ' WHERE id = ?')) { - $stmt->bind_param('i', $classID); +// Check if subject exists and belongs to user +if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["subjects"] . ' WHERE id = ?')) { + $stmt->bind_param('i', $subjectID); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($userID); $stmt->fetch(); - if ($userID !== $_SESSION["user_id"]) die("missing-class"); + if ($userID !== $_SESSION["user_id"]) die("missing-subject"); $stmt->close(); } else die("Error with the Database"); @@ -54,14 +54,14 @@ else $gradingTypeT = strval($gradingTypeT); // Remove # from color -$classColor = str_replace("#", "", $classColor); +$subjectColor = str_replace("#", "", $subjectColor); -// Make an sql statement to update the class -// exit("UPDATE ".$config["db"]["tables"]["classes"]." SET name = '".$className."', color = '".$classColor."', grade_k = ".$gradingTypeK.", grade_m = ".$gradingTypeM.", grade_t = '".$gradingTypeT."', grade_s = ".$gradingTypeS." WHERE id = ".$classID); +// Make an sql statement to update the subject +// exit("UPDATE ".$config["db"]["tables"]["subjects"]." SET name = '".$subjectName."', color = '".$subjectColor."', grade_k = ".$gradingTypeK.", grade_m = ".$gradingTypeM.", grade_t = '".$gradingTypeT."', grade_s = ".$gradingTypeS." WHERE id = ".$subjectID); -// Update class in DB -if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET name = ?, color = ?, grade_k = ?, grade_m = ?, grade_t = ?, grade_s = ? WHERE id = ?')) { - $stmt->bind_param('ssiisii', $className, $classColor, $gradingTypeK, $gradingTypeM, $gradingTypeT, $gradingTypeS, $classID); +// Update subject in DB +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["subjects"] . ' SET name = ?, color = ?, grade_k = ?, grade_m = ?, grade_t = ?, grade_s = ? WHERE id = ?')) { + $stmt->bind_param('ssiisii', $subjectName, $subjectColor, $gradingTypeK, $gradingTypeM, $gradingTypeT, $gradingTypeS, $subjectID); $stmt->execute(); $stmt->close(); exit("success"); diff --git a/classes/edit/style.css b/subjects/edit/style.css similarity index 89% rename from classes/edit/style.css rename to subjects/edit/style.css index 222dcee..40d55ba 100644 --- a/classes/edit/style.css +++ b/subjects/edit/style.css @@ -6,22 +6,22 @@ main { grid-template-rows: min-content 1fr min-content; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class_title class_edit" "class-main_content class-main_content" "grade_add grade_add"; + grid-template-areas: "subject_title subject_edit" "subject-main_content subject-main_content" "grade_add grade_add"; } -.class_title { - grid-area: class_title; +.subject_title { + grid-area: subject_title; } -.class_edit { - grid-area: class_edit; +.subject_edit { + grid-area: subject_edit; font-size: 2rem; padding: 1rem; display: flex; gap: 1rem; } -.class_title h1 { +.subject_title h1 { margin: 1rem; } @@ -37,18 +37,18 @@ main { Main views */ -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow: hidden; padding: 0.5rem; } -.class-main_content>div>div { +.subject-main_content>div>div { border-radius: 0.5rem; margin-bottom: 0.5rem; } -.class-main_content>div>div:last-child { +.subject-main_content>div>div:last-child { margin-bottom: 0; } @@ -64,8 +64,8 @@ Main views color: var(--accent-color); } -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow-x: hidden; overflow-y: auto; } @@ -93,7 +93,7 @@ Main views } -/* Classname section */ +/* subjectname section */ .name { display: flex; diff --git a/classes/edit/test-switch.js b/subjects/edit/test-switch.js similarity index 100% rename from classes/edit/test-switch.js rename to subjects/edit/test-switch.js diff --git a/classes/edit/view-cycler.js b/subjects/edit/view-cycler.js similarity index 100% rename from classes/edit/view-cycler.js rename to subjects/edit/view-cycler.js diff --git a/classes/grades/add/add-grade.js b/subjects/grades/add/add-grade.js similarity index 75% rename from classes/grades/add/add-grade.js rename to subjects/grades/add/add-grade.js index 3e38b3d..ea38f72 100644 --- a/classes/grades/add/add-grade.js +++ b/subjects/grades/add/add-grade.js @@ -12,10 +12,10 @@ grade_add_button.addEventListener('click', () => { date: date_input_input.value, note: note_input.value, type: typeGrade, - class: document.getElementById('class_id').innerText + class: document.getElementById('subject_id').innerText }, success: (data) => { - if (data === 'success') location.assign("/classes/grades/?class=" + document.getElementById('class_id').innerText); + if (data === 'success') location.assign("/subjects/grades/?subject=" + document.getElementById('subject_id').innerText); else { console.log(data); } diff --git a/classes/grades/add/add.php b/subjects/grades/add/add.php similarity index 79% rename from classes/grades/add/add.php rename to subjects/grades/add/add.php index 0ec3d6c..fd13500 100644 --- a/classes/grades/add/add.php +++ b/subjects/grades/add/add.php @@ -24,17 +24,17 @@ $date = $_POST["date"]; $note = $_POST["note"]; $type = $_POST["type"]; -$class_id = $_POST["class"]; +$subject_id = $_POST["subject"]; // Check if necessary input is given if (!isset($grade)) die("missing-grade"); if (!isset($date)) die("missing-date"); if (!isset($type)) die("missing-type"); -if (!isset($class_id)) die("missing-class"); +if (!isset($subject_id)) die("missing-subject"); -// Check if class is owned by user -if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["classes"] . ' WHERE id = ?')) { - $stmt->bind_param('i', $class_id); +// Check if subject is owned by user +if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["subjects"] . ' WHERE id = ?')) { + $stmt->bind_param('i', $subject_id); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($user_id); @@ -67,14 +67,14 @@ if (strlen($note) > 25) die("invalid-note"); // Add grade -if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["grades"] . ' (user_id, class, note, type, date, grade, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { - $stmt->bind_param('sisssss', $_SESSION["user_id"], $class_id, $note, $type, $date, $grade_float, $_SESSION["setting_years"]); +if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["grades"] . ' (user_id, subject, note, type, date, grade, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { + $stmt->bind_param('sisssss', $_SESSION["user_id"], $subject_id, $note, $type, $date, $grade_float, $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); - // Change class last used - if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET last_used = ? WHERE id = ?')) { - $stmt->bind_param('si', $date, $class_id); + // Change subject last used + if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["subjects"] . ' SET last_used = ? WHERE id = ?')) { + $stmt->bind_param('si', $date, $subject_id); $stmt->execute(); $stmt->close(); exit("success"); diff --git a/classes/grades/add/choose-grade.js b/subjects/grades/add/choose-grade.js similarity index 100% rename from classes/grades/add/choose-grade.js rename to subjects/grades/add/choose-grade.js diff --git a/classes/grades/add/choose-points.js b/subjects/grades/add/choose-points.js similarity index 100% rename from classes/grades/add/choose-points.js rename to subjects/grades/add/choose-points.js diff --git a/classes/grades/add/choose-type.js b/subjects/grades/add/choose-type.js similarity index 100% rename from classes/grades/add/choose-type.js rename to subjects/grades/add/choose-type.js diff --git a/classes/grades/add/grades.css b/subjects/grades/add/grades.css similarity index 100% rename from classes/grades/add/grades.css rename to subjects/grades/add/grades.css diff --git a/classes/grades/add/index.php b/subjects/grades/add/index.php similarity index 88% rename from classes/grades/add/index.php rename to subjects/grades/add/index.php index e1e5424..72e977e 100644 --- a/classes/grades/add/index.php +++ b/subjects/grades/add/index.php @@ -1,10 +1,10 @@ prepare('SELECT name, color, user_id, last_used, grade_k, grade_m, grade_s FROM classes WHERE id = ?')) { - $stmt->bind_param('s', $class_id); +// Get subject +if ($stmt = $con->prepare('SELECT name, color, user_id, last_used, grade_k, grade_m, grade_s FROM subjects WHERE id = ?')) { + $stmt->bind_param('s', $subject_id); $stmt->execute(); $stmt->store_result(); - $stmt->bind_result($class_name, $class_color, $user_id, $last_used, $grade_k, $grade_m, $grade_s); + $stmt->bind_result($subject_name, $subject_color, $user_id, $last_used, $grade_k, $grade_m, $grade_s); $stmt->fetch(); if ($user_id !== $_SESSION["user_id"]) { $name = ""; @@ -54,7 +54,7 @@ - Add grade - <?= $class_name ?> | Noten-App + Add grade - <?= $subject_name ?> | Noten-App @@ -84,17 +84,17 @@
- +
-
-

+
+

-
+
Type @@ -162,7 +162,7 @@
Add new grade
- +
diff --git a/classes/grades/add/points.css b/subjects/grades/add/points.css similarity index 100% rename from classes/grades/add/points.css rename to subjects/grades/add/points.css diff --git a/classes/grades/add/style.css b/subjects/grades/add/style.css similarity index 90% rename from classes/grades/add/style.css rename to subjects/grades/add/style.css index a48a2ff..9fa9de6 100644 --- a/classes/grades/add/style.css +++ b/subjects/grades/add/style.css @@ -6,22 +6,22 @@ main { grid-template-rows: min-content 1fr min-content; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class_title class_edit" "class-main_content class-main_content" "grade_add grade_add"; + grid-template-areas: "subject_title subject_edit" "subject-main_content subject-main_content" "grade_add grade_add"; } -.class_title { - grid-area: class_title; +.subject_title { + grid-area: subject_title; } -.class_edit { - grid-area: class_edit; +.subject_edit { + grid-area: subject_edit; font-size: 2rem; padding: 1rem; display: flex; gap: 1rem; } -.class_title h1 { +.subject_title h1 { margin: 1rem; } @@ -29,8 +29,8 @@ main { transition: 0.5s; } -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow-x: hidden; overflow-y: auto; } diff --git a/classes/grades/edit/add-grade.js b/subjects/grades/edit/add-grade.js similarity index 100% rename from classes/grades/edit/add-grade.js rename to subjects/grades/edit/add-grade.js diff --git a/classes/grades/edit/choose-grade.js b/subjects/grades/edit/choose-grade.js similarity index 100% rename from classes/grades/edit/choose-grade.js rename to subjects/grades/edit/choose-grade.js diff --git a/classes/grades/edit/choose-points.js b/subjects/grades/edit/choose-points.js similarity index 100% rename from classes/grades/edit/choose-points.js rename to subjects/grades/edit/choose-points.js diff --git a/classes/grades/edit/choose-type.js b/subjects/grades/edit/choose-type.js similarity index 100% rename from classes/grades/edit/choose-type.js rename to subjects/grades/edit/choose-type.js diff --git a/classes/grades/edit/delete-grade.js b/subjects/grades/edit/delete-grade.js similarity index 100% rename from classes/grades/edit/delete-grade.js rename to subjects/grades/edit/delete-grade.js diff --git a/classes/grades/edit/delete.php b/subjects/grades/edit/delete.php similarity index 91% rename from classes/grades/edit/delete.php rename to subjects/grades/edit/delete.php index cf1feed..2c2ef21 100644 --- a/classes/grades/edit/delete.php +++ b/subjects/grades/edit/delete.php @@ -40,9 +40,9 @@ $stmt->execute(); $stmt->close(); - // Change class last used - if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET last_used = ? WHERE id = ?')) { - $stmt->bind_param('si', $date, $class_id); + // Change subject last used + if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["subjects"] . ' SET last_used = ? WHERE id = ?')) { + $stmt->bind_param('si', $date, $subject_id); $stmt->execute(); $stmt->close(); exit("success"); diff --git a/classes/grades/edit/edit.php b/subjects/grades/edit/edit.php similarity index 95% rename from classes/grades/edit/edit.php rename to subjects/grades/edit/edit.php index 5f4fe6d..4517e9c 100644 --- a/classes/grades/edit/edit.php +++ b/subjects/grades/edit/edit.php @@ -75,9 +75,9 @@ $stmt->execute(); $stmt->close(); - // Change class last used - if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET last_used = ? WHERE id = ?')) { - $stmt->bind_param('si', $date, $class_id); + // Change subject last used + if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["subjects"] . ' SET last_used = ? WHERE id = ?')) { + $stmt->bind_param('si', $date, $subject_id); $stmt->execute(); $stmt->close(); exit("success"); diff --git a/classes/grades/edit/grades.css b/subjects/grades/edit/grades.css similarity index 100% rename from classes/grades/edit/grades.css rename to subjects/grades/edit/grades.css diff --git a/classes/grades/edit/index.php b/subjects/grades/edit/index.php similarity index 95% rename from classes/grades/edit/index.php rename to subjects/grades/edit/index.php index 7b65939..9a6e51b 100644 --- a/classes/grades/edit/index.php +++ b/subjects/grades/edit/index.php @@ -1,6 +1,6 @@ prepare('SELECT user_id, class, note, type, date, grade FROM ' . $config["db"]["tables"]["grades"] . ' WHERE id = ?')) { +if ($stmt = $con->prepare('SELECT user_id, subject, note, type, date, grade FROM ' . $config["db"]["tables"]["grades"] . ' WHERE id = ?')) { $stmt->bind_param('s', $grade_id); $stmt->execute(); $stmt->store_result(); - $stmt->bind_result($user_id, $class, $note, $type, $date, $grade); + $stmt->bind_result($user_id, $subject, $note, $type, $date, $grade); $stmt->fetch(); if ($user_id !== $_SESSION["user_id"]) exit("ERROR2"); $stmt->close(); @@ -51,7 +51,7 @@ - Edit grade - <?= $class_name ?> | Noten-App + Edit grade - <?= $subject_name ?> | Noten-App @@ -88,10 +88,10 @@
-
+

Editing Grade

-
+
Type @@ -196,7 +196,7 @@ break; } } else { - // switch (calcToPoints(false, $class["average"])) { + // switch (calcToPoints(false, $subject["average"])) { // case 15: // echo 'openModifiers(15); // modify(0);'; diff --git a/classes/grades/edit/points.css b/subjects/grades/edit/points.css similarity index 100% rename from classes/grades/edit/points.css rename to subjects/grades/edit/points.css diff --git a/classes/grades/edit/style.css b/subjects/grades/edit/style.css similarity index 90% rename from classes/grades/edit/style.css rename to subjects/grades/edit/style.css index b044aa1..734d879 100644 --- a/classes/grades/edit/style.css +++ b/subjects/grades/edit/style.css @@ -6,22 +6,22 @@ main { grid-template-rows: min-content 1fr min-content; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class_title class_edit" "class-main_content class-main_content" "grade_add grade_add"; + grid-template-areas: "subject_title subject_edit" "subject-main_content subject-main_content" "grade_add grade_add"; } -.class_title { - grid-area: class_title; +.subject_title { + grid-area: subject_title; } -.class_edit { - grid-area: class_edit; +.subject_edit { + grid-area: subject_edit; font-size: 2rem; padding: 1rem; display: flex; gap: 1rem; } -.class_title h1 { +.subject_title h1 { margin: 1rem; } @@ -29,8 +29,8 @@ main { transition: 0.5s; } -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow-x: hidden; overflow-y: auto; } diff --git a/classes/grades/index.php b/subjects/grades/index.php similarity index 83% rename from classes/grades/index.php rename to subjects/grades/index.php index 5676b19..dfd22a0 100644 --- a/classes/grades/index.php +++ b/subjects/grades/index.php @@ -1,10 +1,10 @@ prepare('SELECT name, color, user_id, last_used, grade_k, grade_m, grade_t, grade_s FROM classes WHERE id = ?')) { - $stmt->bind_param('s', $class_id); +// Get subject +if ($stmt = $con->prepare('SELECT name, color, user_id, last_used, grade_k, grade_m, grade_t, grade_s FROM subjects WHERE id = ?')) { + $stmt->bind_param('s', $subject_id); $stmt->execute(); $stmt->store_result(); - $stmt->bind_result($class_name, $class_color, $user_id, $last_used, $grade_k, $grade_m, $grade_t, $grade_s); + $stmt->bind_result($subject_name, $subject_color, $user_id, $last_used, $grade_k, $grade_m, $grade_t, $grade_s); $stmt->fetch(); if ($user_id !== $_SESSION["user_id"]) { $name = ""; @@ -48,8 +48,8 @@ // Get grades $grades = array(); -if ($stmt = $con->prepare('SELECT id, user_id, class, note, type, date, grade FROM grades WHERE class = ?')) { - $stmt->bind_param('s', $class_id); +if ($stmt = $con->prepare('SELECT id, user_id, subject, note, type, date, grade FROM grades WHERE subject = ?')) { + $stmt->bind_param('s', $subject_id); $stmt->execute(); $result = $stmt->get_result(); foreach ($result as $row) { @@ -59,7 +59,7 @@ $name = ""; $user_id = ""; $id = ""; - $class = ""; + $subject = ""; $note = ""; $date = ""; $grade = ""; @@ -131,9 +131,9 @@ if (!($grade_sum == 0 || $weight_sum == 0)) { // Calculate average $average = $grade_sum / $weight_sum; - // Insert average into class - if ($stmt = $con->prepare('UPDATE classes SET average = ? WHERE id = ?')) { - $stmt->bind_param('si', $average, $class_id); + // Insert average into subject + if ($stmt = $con->prepare('UPDATE subjects SET average = ? WHERE id = ?')) { + $stmt->bind_param('si', $average, $subject_id); $stmt->execute(); $stmt->close(); } else { @@ -142,8 +142,8 @@ } // If no grades but average is given -> delete average if ($num_of_k + $num_of_m + $num_of_t + $num_of_s == 0) { - if ($stmt = $con->prepare('UPDATE classes SET average = 0 WHERE id = ?')) { - $stmt->bind_param('i', $class_id); + if ($stmt = $con->prepare('UPDATE subjects SET average = 0 WHERE id = ?')) { + $stmt->bind_param('i', $subject_id); $stmt->execute(); $stmt->close(); } else { @@ -162,7 +162,7 @@ - <?= $class_name ?> | Noten-App + <?= $subject_name ?> | Noten-App @@ -197,18 +197,18 @@
-
-

+
+

-
+
- +
-
+
'; + echo '
'; echo '
'; if (systemRun("punkte")) echo (calcToPoints(true, $grade["grade"])); else echo $grade["grade"]; @@ -239,7 +239,7 @@
-
+
Add grade
diff --git a/classes/grades/style.css b/subjects/grades/style.css similarity index 83% rename from classes/grades/style.css rename to subjects/grades/style.css index e88db69..df88614 100644 --- a/classes/grades/style.css +++ b/subjects/grades/style.css @@ -6,22 +6,22 @@ main { grid-template-rows: min-content 1fr min-content; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class_title class_edit" "class-main_content class-main_content" "grade_add grade_add"; + grid-template-areas: "subject_title subject_edit" "subject-main_content subject-main_content" "grade_add grade_add"; } -.class_title { - grid-area: class_title; +.subject_title { + grid-area: subject_title; } -.class_edit { - grid-area: class_edit; +.subject_edit { + grid-area: subject_edit; font-size: 2rem; padding: 1rem; display: flex; gap: 1rem; } -.class_title h1 { +.subject_title h1 { margin: 1rem; } @@ -30,8 +30,8 @@ main { Main views */ -.class-main_content { - grid-area: class-main_content; +.subject-main_content { + grid-area: subject-main_content; overflow: hidden; } diff --git a/classes/grades/view-cycler.js b/subjects/grades/view-cycler.js similarity index 100% rename from classes/grades/view-cycler.js rename to subjects/grades/view-cycler.js diff --git a/classes/index.php b/subjects/index.php similarity index 70% rename from classes/index.php rename to subjects/index.php index 555cc00..e2d00d9 100644 --- a/classes/index.php +++ b/subjects/index.php @@ -27,19 +27,19 @@ else if ($sorting == "alphabet") $sorting_appendix = " ORDER BY name ASC"; else if ($sorting == "lastuse") $sorting_appendix = " ORDER BY last_used DESC"; -// Get all classes -$classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?" . $sorting_appendix)) { +// Get all subjects +$subjectlist = array(); +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["subjects"] . " WHERE user_id = ? AND year = ?" . $sorting_appendix)) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); - $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); + $stmt->bind_result($subject_name, $subject_color, $subject_id, $subject_last_used, $subject_grade_average); while ($stmt->fetch()) { - $classlist[] = array( - "name" => $class_name, - "color" => $class_color, - "id" => $class_id, - "last_used" => $class_last_used, - "average" => $class_grade_average + $subjectlist[] = array( + "name" => $subject_name, + "color" => $subject_color, + "id" => $subject_id, + "last_used" => $subject_last_used, + "average" => $subject_grade_average ); } $stmt->close(); @@ -48,7 +48,7 @@ // DB Con close $con->close(); -// var_dump($classlist); +// var_dump($subjectlist); ?> @@ -58,7 +58,7 @@ - Classes | Noten-App + subjects | Noten-App @@ -91,31 +91,31 @@
- +
-
+
'; - echo '
' . $class["name"] . '
'; - if ($class["average"] != 0) { - echo '
∅ '; - if (systemRun("punkte")) echo (number_format(calcToPoints(false, $class["average"]), $_SESSION["setting_rounding"], '.', '')); - else echo number_format($class["average"], $_SESSION["setting_rounding"], '.', ''); + foreach ($subjectlist as $subject) { + echo '
'; + echo '
' . $subject["name"] . '
'; + if ($subject["average"] != 0) { + echo '
∅ '; + if (systemRun("punkte")) echo (number_format(calcToPoints(false, $subject["average"]), $_SESSION["setting_rounding"], '.', '')); + else echo number_format($subject["average"], $_SESSION["setting_rounding"], '.', ''); echo '
'; } echo '
'; } ?>
-
-
Create class
+
+
Create subject
diff --git a/classes/style.css b/subjects/style.css similarity index 75% rename from classes/style.css rename to subjects/style.css index dc4f2f5..8c4004a 100644 --- a/classes/style.css +++ b/subjects/style.css @@ -5,15 +5,15 @@ main { } -/* Classlist */ +/* subjectlist */ -.class_list { +.subject_list { width: 100%; height: calc(100% - var(--navbar-height)); overflow: auto; } -.class_entry { +.subject_entry { width: calc(100% - 1rem); margin: 0.5rem; display: grid; @@ -21,19 +21,19 @@ main { grid-template-rows: 1fr; gap: 0px 0px; grid-auto-flow: row; - grid-template-areas: "class_entry-name class_entry-average"; + grid-template-areas: "subject_entry-name subject_entry-average"; background-color: var(--background2-color); padding: 1rem; border-radius: 0.5rem; border-bottom: 0.25rem solid; } -.class_entry-name { - grid-area: class_entry-name; +.subject_entry-name { + grid-area: subject_entry-name; } -.class_entry-average { - grid-area: class_entry-average; +.subject_entry-average { + grid-area: subject_entry-average; text-align: end; } @@ -42,8 +42,8 @@ main { Button to add grades */ -.class_add { - grid-area: class_add; +.subject_add { + grid-area: subject_add; display: grid; place-items: center; padding: 1rem; @@ -53,7 +53,7 @@ Button to add grades cursor: pointer; } -.class_add>div>i { +.subject_add>div>i { color: var(--accent-color); } @@ -61,6 +61,6 @@ Button to add grades /* Nav */ nav { - /* Add a little border with the background color to the top of the navbar to generate contrast between the navigation and the classes */ + /* Add a little border with the background color to the top of the navbar to generate contrast between the navigation and the subjects */ border-top: 0.25rem solid var(--background-color) } \ No newline at end of file