require_once($fname);
}
+function json_return($data)
+{
+ header('Content-type: application/json; charset="UTF-8"');
+
+ $encoded = json_encode($data);
+
+ if ($encoded === false) {
+ error_log('Return ' . var_export($result,true));
+ return json_encode(array('status' => false,
+ 'error' => 'Rückgabedaten können nicht kodiert werden.'));
+ } else
+ echo $encoded;
+
+ exit();
+}
+
+function ajax_error($text)
+{
+ $data = array('status' => false, 'error' => $text);
+ json_return($data);
+}
+
+function assert_iso_date($date)
+{
+ if (strpos($date, '.') === false) return $date;
+ $d = explode('.', $date);
+ return $d[2] . '-' . $d[1] . '-' . $d[0];
+}
+
+function assert_german_date($date)
+{
+ if (is_null($date)) return '';
+ if (strpos($date, '-') === false) return $date;
+ $d = explode('-', $date);
+ return $d[2] . '.' . $d[1] . '.' . $d[0];
+}
+
global $db;
$dsn = sprintf('%s:host=%s;dbname=%s', DBDRIVER, DBHOST, DBNAME);