From 6ba55c000b6d90fa99a16ed98a17bd61a484b92c Mon Sep 17 00:00:00 2001 From: Yannic Date: Fri, 26 Sep 2025 21:13:51 +0200 Subject: [PATCH] fixed formatting --- index.php | 509 +++++++++++++++++++++++++------------------------ script.php | 312 +++++++++++++++--------------- submission.php | 58 +++--- 3 files changed, 448 insertions(+), 431 deletions(-) diff --git a/index.php b/index.php index e46d41d..14e3531 100644 --- a/index.php +++ b/index.php @@ -1,260 +1,277 @@ - - - - - Bücherei Verwaltung - - -

Bücherei Verwaltung

-
+$books = getBooks($pdo); +$borrowers = getBorrowers($pdo); +$activeLoans = getActiveLoans($pdo); +$lateLoans = getLateLoans($pdo); + +?> + + + + + Bücherei Verwaltung + + + +

Bücherei Verwaltung

+
+ + + + + +
+

Neues Buch hinzufügen

+
+ +
+
+ +
+
+ + + +
+
+ +
+
+

Neue Exemplare hinzufügen

+
+ +
+
+ +
+
+ + + +
+
+ +
+
+

Ausleiher hinzufügen

+
+ +
+
+ +
+
+ + + +
+
+ +
+
+

Buch verleihen

+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + +
+
+ +
+
+

Buch einsammeln

+
+ +
+
+ +
+
+ +
+
+ + + > +
+
- - - -
-

Neues Buch hinzufügen

-
- -
-
- -
-
- - - -
-
- -
+

Verliehene Bücher

+ + + + + + + + + + + + + + + + + + + +
VornameNachnameKlasse/FunktionBuchExemplarAusleihdatumRückgabe fällig
#format("d.m.Y") ?>format("d.m.Y") ?>
-

Neue Exemplare hinzufügen

-
- -
-
- -
-
- - - -
-
- -
+

Versäumte Rückgaben

+ + + + + + + + + + + + + + + + + + + +
VornameNachnameKlasse/FunktionBuchExemplarAusleihdatumRückgabe fällig
#format("d.m.Y") ?>format("d.m.Y") ?>
-

Ausleiher hinzufügen

-
- -
-
- -
-
- - - -
-
- -
-
-

Buch verleihen

-
- -
-
- -
-
- -
-
- -
-
- - - -
-
- -
-
-

Buch einsammeln

-
- -
-
- -
-
- -
-
- - - > -
-
- - -
-

Verliehene Bücher

- - - - - - - - - - - - - -
VornameNachnameKlasse/FunktionBuchExemplarAusleihdatumRückgabe fällig
#format("d.m.Y")?>format("d.m.Y")?>
-
-

Versäumte Rückgaben

- - - - - - - - - - - - - -
VornameNachnameKlasse/FunktionBuchExemplarAusleihdatumRückgabe fällig
#format("d.m.Y")?>format("d.m.Y")?>
-
- - -
-

Datenbank durchsuchen

-
- - - -
-
- -
-
-
-
+ + +
+

Datenbank durchsuchen

+
+ + + +
+
+ +
+
+ +
+
+ + + - - \ No newline at end of file diff --git a/script.php b/script.php index f78c525..6b00e4b 100644 --- a/script.php +++ b/script.php @@ -1,191 +1,191 @@ \ No newline at end of file diff --git a/submission.php b/submission.php index 60c012b..e5b360d 100644 --- a/submission.php +++ b/submission.php @@ -4,22 +4,22 @@ include "db/functions.php"; session_start(); -if(empty($_SESSION['csrf_token'])){ +if (empty($_SESSION['csrf_token'])) { die("Invalid request: No token supplied."); } -$sessionToken = (string)($_SESSION['csrf_token'] ?? ''); -$postToken = (string)($_POST['csrf_token'] ?? ''); -$getToken = (string)($_GET['csrf_token'] ?? ''); +$sessionToken = (string) ($_SESSION['csrf_token'] ?? ''); +$postToken = (string) ($_POST['csrf_token'] ?? ''); +$getToken = (string) ($_GET['csrf_token'] ?? ''); if ($_SERVER['REQUEST_METHOD'] === 'POST') { - if(!hash_equals($sessionToken, $postToken)){ + if (!hash_equals($sessionToken, $postToken)) { die("Invalid request: Token mismatch."); } //Book Submission - if($_POST['submissionType'] == "book"){ + if ($_POST['submissionType'] == "book") { $title = $_POST['title'] ?? ''; $author = $_POST['author'] ?? ''; $area = $_POST['area'] ?? ''; @@ -30,9 +30,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { echo "

Please fill in all fields.

"; } } - + //Copy Submission - if($_POST['submissionType'] == "copy"){ + if ($_POST['submissionType'] == "copy") { $bookID = $_POST['book'] ?? ''; $amount = $_POST['amount'] ?? ''; $copyCondition = $_POST['condition'] ?? ''; @@ -45,80 +45,80 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } //Borrower Submission - if($_POST['submissionType'] == "borrower"){ + if ($_POST['submissionType'] == "borrower") { $firstname = $_POST['firstname'] ?? ''; $lastname = $_POST['lastname'] ?? ''; $role = $_POST['role'] ?? ''; - if($firstname && $lastname && $role){ + if ($firstname && $lastname && $role) { addBorrower($pdo, $firstname, $lastname, $role); - }else{ + } else { echo "

Please fill in all fields.

"; } } - if($_POST['submissionType'] == "loan"){ + if ($_POST['submissionType'] == "loan") { $copyID = $_POST['copyID'] ?? ''; $borrowerID = $_POST['borrowerID'] ?? ''; $borrowedDate = $_POST['borrowedDate'] ?? ''; $dueDate = $_POST['dueDate']; - if($copyID && $borrowerID && $borrowedDate && $dueDate){ + if ($copyID && $borrowerID && $borrowedDate && $dueDate) { addLoan($pdo, $copyID, $borrowerID, $borrowedDate, $dueDate); - }else{ + } else { echo "

Please fill in all fields.

"; } } - if($_POST['submissionType'] == "return"){ + if ($_POST['submissionType'] == "return") { $copyIDLoanID = explode("-", $_POST['copyID-loanID'], 2); $copyID = $copyIDLoanID[0]; $loanID = $copyIDLoanID[1]; $returnedDate = $_POST['returnedDate']; - if($copyID && $loanID){ + if ($copyID && $loanID) { removeLoan($pdo, $copyID, $loanID, $returnedDate); - }else{ + } else { echo "

Please fill in all fields

"; } } - if($_POST['submissionType'] == "selectRequest"){ + if ($_POST['submissionType'] == "selectRequest") { $selectRequest = $_POST['sqlSelectTextarea']; - if($selectRequest){ + if ($selectRequest) { selectRequest($pdo, $selectRequest); - }else{ + } else { echo "

Please fill in all fields

"; } } } -if($_SERVER['REQUEST_METHOD'] == 'GET'){ +if ($_SERVER['REQUEST_METHOD'] == 'GET') { - if(!hash_equals($sessionToken, $getToken)){ + if (!hash_equals($sessionToken, $getToken)) { die("Invalid request: Token mismatch."); } - if($_GET['submissionType'] == "getCopies"){ + if ($_GET['submissionType'] == "getCopies") { $bookID = $_GET['bookID']; - if($bookID){ + if ($bookID) { $copies = getAvailableCopiesOfBook($pdo, $bookID); - + echo json_encode($copies); - }else{ + } else { echo json_encode([]); } } - if($_GET['submissionType'] == "getReturnCopies"){ + if ($_GET['submissionType'] == "getReturnCopies") { $borrowerID = $_GET['borrowerID']; - if($borrowerID){ + if ($borrowerID) { $copies = getBorrowedCopiesOfBorrower($pdo, $borrowerID); echo json_encode($copies); - }else{ + } else { echo json_encode([]); } }