From fd1b8d9a0b9ce64c7cdce84363fc25e6afa2e7b1 Mon Sep 17 00:00:00 2001 From: marc-go Date: Wed, 7 Oct 2026 19:22:40 +0200 Subject: [PATCH] Refactor entry handling: update date format, enhance entry retrieval, and improve HTML structure --- api/api.php | 2 +- api/entrys/add.php | 2 +- api/entrys/get.php | 7 +++++-- api/settings/appname.php | 2 +- database.db | Bin 24576 -> 24576 bytes public/index.php | 5 +++-- .../entrys_frontend/entrys_frontend.html | 4 ++++ 7 files changed, 15 insertions(+), 7 deletions(-) mode change 100644 => 100755 database.db diff --git a/api/api.php b/api/api.php index 075e5e5..562bdc1 100755 --- a/api/api.php +++ b/api/api.php @@ -114,7 +114,7 @@ class gbAPI { $stmt->execute($stmtArgs); if ($expectResult) { - $result = $stmt->fetch(PDO::FETCH_ASSOC); + $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } diff --git a/api/entrys/add.php b/api/entrys/add.php index ae22129..c7909c6 100644 --- a/api/entrys/add.php +++ b/api/entrys/add.php @@ -30,7 +30,7 @@ if ($html_allowed == "true") { $text = htmlspecialchars($input["text"]); } -$date = date("d.m.Y"); +$date = date("Y-m-d H:i:s"); $approve = $api->getSetting("approve_entrys") == "true" ? true : false; if ($approve) { diff --git a/api/entrys/get.php b/api/entrys/get.php index 4d77df6..913c57f 100644 --- a/api/entrys/get.php +++ b/api/entrys/get.php @@ -5,7 +5,7 @@ require "../api.php"; $api = new gbAPI(false); // Get Entrys -$command = "SELECT * FROM entrys WHERE status = :status"; +$command = "SELECT * FROM entrys WHERE status = :status ORDER BY date DESC"; $result = $api->dbCommand($command, true, true, [":status" => 1]); $entrys = []; @@ -20,10 +20,13 @@ if (!$result) { foreach($result as $row) { $entry_name = $row["name"]; $entry_text = $row["text"]; + $date = new DateTime($row["date"]); + $entry_date = $date->format("d.m.Y H:i:s"); $entry = [ "name" => $entry_name, - "text" => $entry_text + "text" => $entry_text, + "date" => $entry_date ]; $entrys[] = $entry; diff --git a/api/settings/appname.php b/api/settings/appname.php index edefd54..a71996f 100644 --- a/api/settings/appname.php +++ b/api/settings/appname.php @@ -9,5 +9,5 @@ $command = "SELECT name, value FROM settings WHERE name = :name"; $result = $api->dbCommand($command, true, true, [":name" => "application_name"]); $api->answer(200, [ - "application_name" => $result["value"] + "application_name" => $result[0]["value"] ]); \ No newline at end of file diff --git a/database.db b/database.db old mode 100644 new mode 100755 index 7f374d78bbd62d9f15aa79b7496b970ff1ca5d0a..68f1cac33196670b83fe24a1eeb9b0ad6d567f41 GIT binary patch delta 115 zcmZoTz}Rqrae_1>&qNt#MxKoc%k(+!Fz|olf5Crev!KE`ejYAnW=Y1>ypp2IV&=&& z>}5EZ_)jzNKjS|Ql-|#;E6L2pAS$lN>6=)TT#{N`Vq{>hXK0{jWME__!32~NMMxQ# KZ~o!WApii|WFY$h delta 150 zcmZoTz}Rqrae_1>=R_H2M$U~1%k(+!GVp)nf5Cruv!KFxer`@?W=YP}ypp2I;>j=U zW!M<`moo4#-7F|Dn?E>`k)1)bQB;xBH?b&LEvLk~IJqdZphPXb#G0!-GcP5-TrV*v jwWvfxt*|t|#5yQ70}3I0O=~WYCVhl11GCLP{5b>w7AP>^ diff --git a/public/index.php b/public/index.php index f7f65ca..18b703e 100755 --- a/public/index.php +++ b/public/index.php @@ -19,10 +19,11 @@ $url = "http://" . APP_DOMAIN . "/api/entrys/get.php"; $response = file_get_contents($url); $response = json_decode($response, true); + if ($response["data"]["empty"]) { $html_block = "

There aren'n any entrys yet. Be the first one!

"; }else{ - $entrys = $response["data"]["entrys"]; + $entrys = json_decode($response["data"]["entrys"], true); $html_block = ""; foreach($entrys as $entry) { @@ -32,7 +33,7 @@ if ($response["data"]["empty"]) { $html_block .= '
-

' . $name . '

+

' . $name . '

' . $date . '

' . $text . '

diff --git a/public/templates/entrys_frontend/entrys_frontend.html b/public/templates/entrys_frontend/entrys_frontend.html index 90e1292..8d95aad 100755 --- a/public/templates/entrys_frontend/entrys_frontend.html +++ b/public/templates/entrys_frontend/entrys_frontend.html @@ -36,6 +36,10 @@ justify-content: center; align-items: center; } + + #date { + color: gray; + }