[0000078] Opened Exchange rate for editing (without storing) in sales/purchasing...
[fa-stable.git] / includes / lang / language.php
index 1bde610c7a332e8f757eb6b6ede06e1b19a5344b..72a0b3e4e8fd47a2795575086d06c411d46ff7f4 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("");
                }
        }
 
@@ -70,6 +77,7 @@ class language
 
 }
 
+session_name('FrontAccounting');
 session_start();
 // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks
 header("Cache-control: private");
@@ -87,6 +95,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 +115,7 @@ function _set($key,$value)
        get_text::set_var($key,$value);
 }
 
-function redirect($msg) 
+function reload_page($msg) 
 {
 //     header("Location: $_SERVER['PHP_SELF']."");
 //     exit;