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 7f374d7..68f1cac Binary files a/database.db and b/database.db differ 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; + }