Checking options parameter for combos
[fa-stable.git] / includes / lang / language.php
index 1bde610c7a332e8f757eb6b6ede06e1b19a5344b..629a15a0c28c176805d8837eb188b47b835eaf3b 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
+       die("Restricted access");
 include_once($path_to_root . "/lang/installed_languages.inc");
 include_once($path_to_root . "/includes/lang/gettext.php");
 
@@ -33,11 +35,16 @@ class language
 
        function set_language($code) 
        {
+           global $comp_path;
+           
                if (isset($_SESSION['languages'][$code]) &&
                        $_SESSION['language'] != $_SESSION['languages'][$code]) 
                {
-                       $_SESSION['language'] = $_SESSION['languages'][$code];
-                       redirect("");
+           
+               // flush cache as we can use several languages in one account
+                   flush_dir($comp_path.'/'.user_company().'/js_cache');
+                   $_SESSION['language'] = $_SESSION['languages'][$code];
+                   reload_page("");
                }
        }
 
@@ -87,6 +94,9 @@ get_text::init();
 get_text::set_language($lang->code, $lang->encoding);
 //get_text::add_domain("wa", $path_to_root . "/lang");
 get_text::add_domain($lang->code, $path_to_root . "/lang");
+// Unnecessary for ajax calls. 
+// Due to bug in php 4.3.10 for this version set globally in php.ini
+ini_set('default_charset', $_SESSION['language']->encoding);
 
 if (!function_exists("_")) 
 {
@@ -104,7 +114,7 @@ function _set($key,$value)
        get_text::set_var($key,$value);
 }
 
-function redirect($msg) 
+function reload_page($msg) 
 {
 //     header("Location: $_SERVER['PHP_SELF']."");
 //     exit;