function form_change_post($dta) { $lang = $dta['lang']; if (preg_match('/^[a-z]{2}\-[a-z]{2}$|^[a-z]{2}$|^\_D\_$/',$lang)==0) { WGSetActivity('main'); return; } if (!WGSetLang($lang)) { WGSetActivity('main'); return; } WGCloseWin(); WGShellExecute("/bin/app/webgui/lang.app"); }
function WGDetectLang($forceReload) { global $ini; if ( !$forceReload and isset($_SESSION['WGLang']) and $_SESSION['WGLang']!='' and $_SESSION['WGLang']!='_D_' ) return; if (isset($ini['webgui']['lang'])) { $defLang = strtolower(trim($ini['webgui']['lang'],' ')); if (!preg_match('/^[a-z]{2}\-[a-z]{2}$|^[a-z]{2}$/',$defLang)==0) $defLang='en'; } else $defLang='en'; $t0 = @$_SERVER['HTTP_ACCEPT_LANGUAGE']; $curLang=false; if ($t0!='') { $t0=explode(',',$t0); $langList=array(); foreach($t0 as $t1) { $t1=trim($t1,' '); $t1=strtolower($t1); list($t1)=explode(';',$t1,2); if (preg_match('/^[a-z]{2}\-[a-z]{2}$/',$t1)!=0) $langList[] =$t1; if (preg_match('/^[a-z]{2}$/',$t1)!=0) $langList[] =$t1; } foreach($langList as $t1) { if ($defLang && $defLang==$t1) $t1='_D_'; if (!file_exists($_SERVER['DOCUMENT_ROOT'].'/etc/lang/'.$t1.'.json')) continue; $curLang=$t1; break; } } if (isset($JSON['data']['lang']) and !$curLang) { $t1=strtolower($JSON['data']['lang']); if (preg_match('/^[a-z]{2}\-[a-z]{2}$|^[a-z]{2}$/',$t1)!=0) $curLang = $t1; } if ($curLang) WGSetLang($curLang); }