X-Git-Url: https://git.infodrom.org/?p=misc%2Fkostenrechnung;a=blobdiff_plain;f=lib%2Fgeneral.php;h=3f82f4a7f499208dfe59d544a36ef0d3d563dc70;hp=6216e34231baa9c3316c008c9f24c25d762bb26d;hb=162cb09efc77d87f8d05a9c3f9d8f6520bea7600;hpb=a8acfd92241470b30b5d73187ca42bf9e7ae586e diff --git a/lib/general.php b/lib/general.php index 6216e34..3f82f4a 100644 --- a/lib/general.php +++ b/lib/general.php @@ -7,6 +7,12 @@ function passwd($login,$pass) function check_session() { + if (!empty($_SESSION['sys']['login']) && !empty($_GET['logout'])) { + session_destroy(); + header('Location: ./?login=true'); + exit(); + } + if (!empty($_POST['login']) && !empty($_POST['passwd'])) { require_once('lib/login.php'); if (check_passwd()) { @@ -29,6 +35,7 @@ function sanitise_filename($file) function load_mask($name) { global $mask; + global $jscode; $name = sanitise_filename($name); $file = $_SESSION['sys']['basedir'] . 'masks/' . $name . '.php'; @@ -118,4 +125,20 @@ function debug_info() return $html; } +function grid_sql($name, $mask) +{ + $fields = array(); + foreach ($mask['list'] as $field => $data) { + if (array_key_exists('sql', $data)) + $fields[] = $data['sql'] . ' AS ' . $field; + else + $fields[] = $field; + } + + $_SESSION['grid_' . $name] = sprintf("SELECT %s FROM %s", + implode(',', $fields), $mask['table']); + if (array_key_exists('join', $mask)) $_SESSION['grid_' . $name] .= ' JOIN ' . join(' JOIN ', $mask['join']); + if (array_key_exists('where', $mask)) $_SESSION['grid_' . $name] .= ' WHERE ' . $mask['where']; +} + ?>