diff --git a/system/functions.php b/system/functions.php index 168bf0d2..c57e53bd 100644 --- a/system/functions.php +++ b/system/functions.php @@ -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'; diff --git a/system/twig.php b/system/twig.php index 5d30bcfe..ae78ab8c 100644 --- a/system/twig.php +++ b/system/twig.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); });