From 8311cba002dfcaf1836530b978f944f7228ac004 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 21 Sep 2011 17:00:50 +0200 Subject: Replaced Smarty with STE and started the backend. --- ratatoeskr/sys/translation.php | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 ratatoeskr/sys/translation.php (limited to 'ratatoeskr/sys/translation.php') diff --git a/ratatoeskr/sys/translation.php b/ratatoeskr/sys/translation.php new file mode 100644 index 0000000..01f7c6d --- /dev/null +++ b/ratatoeskr/sys/translation.php @@ -0,0 +1,55 @@ +register_tag( + "get_translation", + function($ste, $params, $sub) + { + global $translation; + if((!isset($translation)) or empty($params["for"]) or (!isset($translation[$params["for"]]))) + return ""; + return $translation[$params["for"]]; + } + ); + define(TRANSLATION_PLUGIN_LOADED, True); +} + +/* + * Function: load_language + * Load a language (i.e. set the global $translation variable). + * + * Parameters: + * $lang - The language (2-Letter code, e.g. "en", "de", "it" ...) to load. NULL for default (from database). + */ +function load_language($lang=NULL) +{ + global $ratatoeskr_settings; + if($lang === NULL) + $lang = $ratatoeskr_settings["default_language"]; + + /* + * Because we will include an file defined by the $lang param, we will + * only allow alphabetic characters, so this function should not be + * vulnerable to LFI-Exploits... + */ + $lang = implode("", array_filter(str_split($lang, 1), "ctype_alpha")); + + require(dirname(__FILE__) . "/../translations/$lang.php"); + + $GLOBALS["translation"] = $translation; +} + +?> -- cgit v1.2.3-70-g09d2