Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
*/
require_once('./init.php');
require_once('./lang/class.default.php');
require_once('./lang/'.Config::get('lang').'.php');
$lang = new Lang();
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::set('lang', _post('lang'));
if(isset($_POST['password']) && $_POST['password'] != '') Config::set('password', $_POST['password']);
elseif(!_post('allowpassword')) Config::set('password', '');
Config::set('smartsyntax', (int)_post('smartsyntax'));
Config::set('autotz', (int)_post('autotz'));
Config::set('autotag', (int)_post('autotag'));
Config::set('session', _post('session'));
Config::set('firstdayofweek', (int)_post('firstdayofweek'));
Config::set('duedateformat', (int)_post('duedateformat'));
Config::set('clock', (int)_post('clock'));
Config::set('dateformat', _post('dateformat'));
Config::set('dateformatshort', _post('dateformatshort'));
Config::set('title', trim(_post('title')));
Config::save();
$t['saved'] = 1;
echo json_encode($t);
exit;
}
function _c($key)
{
return Config::get($key);
}
function _e($s)
{
global $lang;
echo $lang->get($s);
}
function __($s)
{
global $lang;
return $lang->get($s);
}
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;
}
?>