mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
* add global helper config($key) function + twig binding
This commit is contained in:
parent
b828b8e44a
commit
de36cfd2eb
@ -948,16 +948,14 @@ function get_browser_real_ip() {
|
||||
return '0';
|
||||
}
|
||||
function setSession($key, $data) {
|
||||
global $config;
|
||||
$_SESSION[$config['session_prefix'] . $key] = $data;
|
||||
$_SESSION[config('session_prefix') . $key] = $data;
|
||||
}
|
||||
function getSession($key) {
|
||||
global $config;
|
||||
return (isset($_SESSION[$config['session_prefix'] . $key])) ? $_SESSION[$config['session_prefix'] . $key] : false;
|
||||
$key = config('session_prefix') . $key;
|
||||
return isset($_SESSION[$key]) ? $_SESSION[$key] : false;
|
||||
}
|
||||
function unsetSession($key) {
|
||||
global $config;
|
||||
unset($_SESSION[$config['session_prefix'] . $key]);
|
||||
unset($_SESSION[config('session_prefix') . $key]);
|
||||
}
|
||||
|
||||
function getTopPlayers($limit = 5) {
|
||||
@ -1026,6 +1024,15 @@ function deleteDirectory($dir) {
|
||||
return rmdir($dir);
|
||||
}
|
||||
|
||||
function config($key) {
|
||||
global $config;
|
||||
if (is_array($key)) {
|
||||
return $config[$key[0]] = $key[1];
|
||||
}
|
||||
|
||||
return $config[$key];
|
||||
}
|
||||
|
||||
// validator functions
|
||||
require_once LIBS . 'validator.php';
|
||||
require_once SYSTEM . 'compat.php';
|
||||
|
@ -26,6 +26,11 @@ $function = new Twig_SimpleFunction('hook', function ($hook) {
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
$function = new Twig_SimpleFunction('config', function ($key) {
|
||||
return config($key);
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
||||
return urlencode($s);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user