require_once('config.php');
require_once('future.php');
-function json_return($data)
-{
- header('Content-type: application/json; charset="UTF-8"');
- echo json_encode($data);
- exit();
-}
-
$backend = new AJAXBackend();
$data = array();
require_once($fname);
}
+function json_return($data)
+{
+ header('Content-type: application/json; charset="UTF-8"');
+
+ $encoded = json_encode($data);
+
+ if ($encoded === false) {
+ error_log('Wrong encoding: ' . var_export($encoded,true));
+ return json_encode(array('status' => false,
+ 'error' => 'Cannot encode return values, see server log.'));
+ } else {
+ echo $encoded;
+ }
+
+ exit();
+}
+
+
global $db;
$dsn = sprintf('%s:host=%s;dbname=%s', DBDRIVER, DBHOST, DBNAME);