Stop editing when clicking on sum row
[infodrom.org/service.infodrom.org] / src / future.php
1 <?php
2 function __autoload($class)
3 {
4   if (!defined('CLASS_PATH')) throw new Exception('Class path not defined');
5
6   $fname = CLASS_PATH . '/'.strtolower($class).'.class.php';
7
8   if (!file_exists($fname)) throw new Exception(sprintf('Class %s not found', $class));
9
10   require_once($fname);
11 }
12
13 function json_return($data)
14 {
15   header('Content-type: application/json; charset="UTF-8"');
16
17   $encoded = json_encode($data);
18
19   if ($encoded === false) {
20     error_log('Return ' . var_export($result,true));
21     return json_encode(array('status' => false,
22                              'error' => 'Rückgabedaten können nicht kodiert werden.'));
23   } else
24     echo $encoded;
25
26   exit();
27 }
28
29 function ajax_error($text)
30 {
31   $data = array('status' => false, 'error' => $text);
32   json_return($data);
33 }
34
35 function assert_iso_date($date)
36 {
37   if (strpos($date, '.') === false) return $date;
38   $d = explode('.', $date);
39   return $d[2] . '-' . $d[1] . '-' . $d[0];
40 }
41
42 function assert_german_date($date)
43 {
44   if (is_null($date)) return '';
45   if (strpos($date, '-') === false) return $date;
46   $d = explode('-', $date);
47   return $d[2] . '.' . $d[1] . '.' . $d[0];
48 }
49
50 global $db;
51
52 $dsn = sprintf('%s:host=%s;dbname=%s', DBDRIVER, DBHOST, DBNAME);
53 $db = new Database(DBDRIVER, DBHOST, DBNAME, DBUSER, DBPASS);
54 if (defined('MAIL_ERROR')) $db->setErrorMail(MAIL_ERROR);
55 ?>