summaryrefslogtreecommitdiff
path: root/intern/api/termine.php
diff options
context:
space:
mode:
Diffstat (limited to 'intern/api/termine.php')
-rw-r--r--intern/api/termine.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/intern/api/termine.php b/intern/api/termine.php
index 9c9d454..b5ff1db 100644
--- a/intern/api/termine.php
+++ b/intern/api/termine.php
@@ -1,12 +1,25 @@
<?php
+header('Content-Type: application/json');
require_once __DIR__ . '/db.php';
+require_once __DIR__ . '/config.php';
+
+$db = get_db();
+
+if ( false === $db ) {
+ echo file_get_contents($json_file); // Liest veralte JSON Datei
+ error_log (json_encode( array( "error" => true, "reason" => "Can't connect to the database", "build" => time() ) ) );
+ exit;
+}
$res = $db->query('select termin, uhrzeit from proben where date(STR_TO_DATE(termin, "%d.%m.%Y")) > (SELECT CURDATE() );');
$proben = $res->fetchAll(PDO::FETCH_ASSOC);
$res = $db->query('select termin,uhrzeit,beschreibung,anfahrt from konzert order by id desc limit 1;');
$konzert = $res->fetchAll(PDO::FETCH_ASSOC);
-$output = array("konzert" => $konzert, "proben" => $proben);
-header('Content-Type: application/json');
-echo( json_encode($output, JSON_PRETTY_PRINT) );
+$output = array("konzert" => $konzert, "proben" => $proben, "build" => time());
+$data = json_encode($output, JSON_PRETTY_PRINT);
+
+file_put_contents($json_file, $data); // speichert die JSON Datei für den Fall, dass es später Fehler gibt
+
+echo $file;