Refactor entry handling: update date format, enhance entry retrieval, and improve HTML structure

This commit is contained in:
marc-go committed 2026-10-07 19:22:40 +02:00
1 parent ff2afb4441
commit fd1b8d9a0b
7 files changed
+15 -7

No files matched your search

+1 -1
View File
@@ -114,7 +114,7 @@ class gbAPI {
$stmt->execute($stmtArgs); $stmt->execute($stmtArgs);
if ($expectResult) { if ($expectResult) {
$result = $stmt->fetch(PDO::FETCH_ASSOC); $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $result; return $result;
} }
+1 -1
View File
@@ -30,7 +30,7 @@ if ($html_allowed == "true") {
$text = htmlspecialchars($input["text"]); $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; $approve = $api->getSetting("approve_entrys") == "true" ? true : false;
if ($approve) { if ($approve) {
+5 -2
View File
@@ -5,7 +5,7 @@ require "../api.php";
$api = new gbAPI(false); $api = new gbAPI(false);
// Get Entrys // 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]); $result = $api->dbCommand($command, true, true, [":status" => 1]);
$entrys = []; $entrys = [];
@@ -20,10 +20,13 @@ if (!$result) {
foreach($result as $row) { foreach($result as $row) {
$entry_name = $row["name"]; $entry_name = $row["name"];
$entry_text = $row["text"]; $entry_text = $row["text"];
$date = new DateTime($row["date"]);
$entry_date = $date->format("d.m.Y H:i:s");
$entry = [ $entry = [
"name" => $entry_name, "name" => $entry_name,
"text" => $entry_text "text" => $entry_text,
"date" => $entry_date
]; ];
$entrys[] = $entry; $entrys[] = $entry;
+1 -1
View File
@@ -9,5 +9,5 @@ $command = "SELECT name, value FROM settings WHERE name = :name";
$result = $api->dbCommand($command, true, true, [":name" => "application_name"]); $result = $api->dbCommand($command, true, true, [":name" => "application_name"]);
$api->answer(200, [ $api->answer(200, [
"application_name" => $result["value"] "application_name" => $result[0]["value"]
]); ]);
Regular → Executable
BIN
View File
Binary file not shown.
+3 -2
View File
@@ -19,10 +19,11 @@ $url = "http://" . APP_DOMAIN . "/api/entrys/get.php";
$response = file_get_contents($url); $response = file_get_contents($url);
$response = json_decode($response, true); $response = json_decode($response, true);
if ($response["data"]["empty"]) { if ($response["data"]["empty"]) {
$html_block = "<p>There aren'n any entrys yet. Be the first one!</p>"; $html_block = "<p>There aren'n any entrys yet. Be the first one!</p>";
}else{ }else{
$entrys = $response["data"]["entrys"]; $entrys = json_decode($response["data"]["entrys"], true);
$html_block = ""; $html_block = "";
foreach($entrys as $entry) { foreach($entrys as $entry) {
@@ -32,7 +33,7 @@ if ($response["data"]["empty"]) {
$html_block .= ' $html_block .= '
<div class="entry"> <div class="entry">
<h3>' . $name . '</h3> <h3 class="md-typescale-display-small">' . $name . '</h3>
<p id="date">' . $date . '</p> <p id="date">' . $date . '</p>
<p>' . $text . '</p> <p>' . $text . '</p>
</div> </div>
@@ -36,6 +36,10 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
#date {
color: gray;
}
</style> </style>
</head> </head>
<body> <body>