Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
*/
require_once('./init.php');
if($needAuth && !is_logged())
{
die("Access denied!
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'] = '';
$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['title'] = trim(_post('title'));
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;
}
?>