mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 09:49:22 +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';
|
return '0';
|
||||||
}
|
}
|
||||||
function setSession($key, $data) {
|
function setSession($key, $data) {
|
||||||
global $config;
|
$_SESSION[config('session_prefix') . $key] = $data;
|
||||||
$_SESSION[$config['session_prefix'] . $key] = $data;
|
|
||||||
}
|
}
|
||||||
function getSession($key) {
|
function getSession($key) {
|
||||||
global $config;
|
$key = config('session_prefix') . $key;
|
||||||
return (isset($_SESSION[$config['session_prefix'] . $key])) ? $_SESSION[$config['session_prefix'] . $key] : false;
|
return isset($_SESSION[$key]) ? $_SESSION[$key] : false;
|
||||||
}
|
}
|
||||||
function unsetSession($key) {
|
function unsetSession($key) {
|
||||||
global $config;
|
unset($_SESSION[config('session_prefix') . $key]);
|
||||||
unset($_SESSION[$config['session_prefix'] . $key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTopPlayers($limit = 5) {
|
function getTopPlayers($limit = 5) {
|
||||||
@ -1026,6 +1024,15 @@ function deleteDirectory($dir) {
|
|||||||
return rmdir($dir);
|
return rmdir($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function config($key) {
|
||||||
|
global $config;
|
||||||
|
if (is_array($key)) {
|
||||||
|
return $config[$key[0]] = $key[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config[$key];
|
||||||
|
}
|
||||||
|
|
||||||
// validator functions
|
// validator functions
|
||||||
require_once LIBS . 'validator.php';
|
require_once LIBS . 'validator.php';
|
||||||
require_once SYSTEM . 'compat.php';
|
require_once SYSTEM . 'compat.php';
|
||||||
|
@ -26,6 +26,11 @@ $function = new Twig_SimpleFunction('hook', function ($hook) {
|
|||||||
});
|
});
|
||||||
$twig->addFunction($function);
|
$twig->addFunction($function);
|
||||||
|
|
||||||
|
$function = new Twig_SimpleFunction('config', function ($key) {
|
||||||
|
return config($key);
|
||||||
|
});
|
||||||
|
$twig->addFunction($function);
|
||||||
|
|
||||||
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
||||||
return urlencode($s);
|
return urlencode($s);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user