40 lines
773 B
PHP
40 lines
773 B
PHP
<?php
|
|
// Load Main Library
|
|
require "../api.php";
|
|
|
|
$api = new gbAPI(false);
|
|
|
|
// Get Entrys
|
|
$command = "SELECT * FROM entrys WHERE status = :status ORDER BY date DESC";
|
|
$result = $api->dbCommand($command, true, true, [":status" => 1]);
|
|
|
|
$entrys = [];
|
|
|
|
if (!$result) {
|
|
$api->answer(200, [
|
|
"entrys" => [],
|
|
"empty" => true
|
|
]);
|
|
}
|
|
|
|
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,
|
|
"date" => $entry_date
|
|
];
|
|
|
|
$entrys[] = $entry;
|
|
}
|
|
|
|
$json = json_encode($entrys);
|
|
|
|
$api->answer(200, [
|
|
"entrys" => $json,
|
|
"empty" => false
|
|
]); |