diff --git a/src/settings.php b/src/settings.php new file mode 100644 index 0000000..9077d8e --- /dev/null +++ b/src/settings.php @@ -0,0 +1,172 @@ + Disable password protection or Log in."); +} + +if(isset($_POST['save'])) +{ + stop_gpc($_POST); + $t = array(); + $langs = getLangs(); + Config::$params['lang']['options'] = array_keys($langs); + $config['lang'] = _post('lang'); + if(isset($_POST['password']) && $_POST['password'] != '') $config['password'] = $_POST['password']; + elseif(!_post('allowpassword')) $config['password'] = ''; + if(isset($_POST['allowread'])) $config['allowread'] = (int)_post('allowread'); + $config['smartsyntax'] = (int)_post('smartsyntax'); + $config['autotz'] = (int)_post('autotz'); + $config['autotag'] = (int)_post('autotag'); + $config['session'] = _post('session'); + $config['firstdayofweek'] = (int)_post('firstdayofweek'); + $config['duedateformat'] = (int)_post('duedateformat'); + $config['clock'] = (int)_post('clock'); + $config['dateformat'] = _post('dateformat'); + $config['dateformatshort'] = _post('dateformatshort'); + Config::save($config); + $t['saved'] = 1; + echo json_encode($t); + exit; +} + + +function _c($key) +{ + global $config; + return Config::get($key, $config); +} + +function getLangs() +{ + if (!$h = opendir('./lang')) return false; + $a = array(); + while(false !== ($file = readdir($h))) + { + if(preg_match('/(.+)\.php$/', $file, $m) && $file != 'class.default.php') { + $a[$m[1]] = $m[1]; + } + } + closedir($h); + return $a; +} + +function selectOptions($a, $value, $default=null) +{ + if(!$a) return ''; + $s = ''; + if($default !== null && !isset($a[$value])) $value = $default; + foreach($a as $k=>$v) { + $s .= ''; + } + return $s; +} + +?> + +