diff --git a/lib/settings-update.php b/lib/settings-update.php index ca70d9d..1b8cc7a 100644 --- a/lib/settings-update.php +++ b/lib/settings-update.php @@ -10,11 +10,15 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset $repPosStart = strpos($settingsContents,'"root"'); $repPosEnd = strpos($settingsContents,'"plugins"'); + // Has there been a language change? + $languageUserChanged = $ICEcoder['languageUser'] != $_POST['languageUser']; + // Prepare all our vars $ICEcoder["root"] = xssClean($_POST['root'],"html"); $ICEcoder["checkUpdates"] = isset($_POST['checkUpdates']) && $_POST['checkUpdates'] ? "true" : "false"; $ICEcoder["openLastFiles"] = isset($_POST['openLastFiles']) && $_POST['openLastFiles'] ? "true" : "false"; $ICEcoder["updateDiffOnSave"] = isset($_POST['updateDiffOnSave']) && $_POST['updateDiffOnSave'] ? "true" : "false"; + $ICEcoder["languageUser"] = strClean($_POST['languageUser']); $ICEcoder["findFilesExclude"] = 'array("'.str_replace(',','","',str_replace(" ","",strClean($_POST['findFilesExclude']))).'")'; $ICEcoder["codeAssist"] = isset($_POST['codeAssist']) && $_POST['codeAssist'] ? "true" : "false"; $ICEcoder["visibleTabs"] = isset($_POST['visibleTabs']) && $_POST['visibleTabs'] ? "true" : "false"; @@ -36,12 +40,12 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset $ICEcoder["bugFileMaxLines"] = intval($_POST['bugFileMaxLines']); $ICEcoder["githubAuthToken"] = strClean($_POST['githubAuthToken']); - $settingsArray = array("root","checkUpdates","openLastFiles","updateDiffOnSave","findFilesExclude","codeAssist","visibleTabs","lockedNav","tagWrapperCommand","autoComplete","password","bannedFiles","bannedPaths","allowedIPs","theme","fontSize","lineWrapping","indentWithTabs","indentSize","pluginPanelAligned","bugFilePaths","bugFileCheckTimer","bugFileMaxLines","githubAuthToken"); + $settingsArray = array("root","checkUpdates","openLastFiles","updateDiffOnSave","languageUser","findFilesExclude","codeAssist","visibleTabs","lockedNav","tagWrapperCommand","autoComplete","password","bannedFiles","bannedPaths","allowedIPs","theme","fontSize","lineWrapping","indentWithTabs","indentSize","pluginPanelAligned","bugFilePaths","bugFileCheckTimer","bugFileMaxLines","githubAuthToken"); $settingsNew = ""; for ($i=0;$i '; // Wrap certain values in double quotes - $settingWrap = $settingsArray[$i]=="root"||$settingsArray[$i]=="password"||$settingsArray[$i]=="theme"||$settingsArray[$i]=="fontSize"||$settingsArray[$i]=="tagWrapperCommand"||$settingsArray[$i]=="autoComplete"||$settingsArray[$i]=="pluginPanelAligned"||$settingsArray[$i]=="githubAuthToken" ? '"' : ''; + $settingWrap = $settingsArray[$i]=="root"||$settingsArray[$i]=="password"||$settingsArray[$i]=="languageUser"||$settingsArray[$i]=="theme"||$settingsArray[$i]=="fontSize"||$settingsArray[$i]=="tagWrapperCommand"||$settingsArray[$i]=="autoComplete"||$settingsArray[$i]=="pluginPanelAligned"||$settingsArray[$i]=="githubAuthToken" ? '"' : ''; $settingsNew .= $settingWrap.$ICEcoder[$settingsArray[$i]].$settingWrap.','.PHP_EOL; } @@ -85,6 +89,12 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset $githubAuthTokenSet = $ICEcoder["githubAuthToken"] != "" ? "true" : "false"; + // If we've changed langugage, reload ICEcoder now + if ($languageUserChanged) { + echo ''; + die('Reloading ICEcoder after language change'); + } + // With all that worked out, we can now hide the settings screen and apply the new settings $jsBugFilePaths = "['".str_replace(",","','",str_replace(" ","",strClean($_POST['bugFilePaths'])))."']"; echo ""; diff --git a/lib/settings.php b/lib/settings.php index d4ae84f..9c84c1c 100644 --- a/lib/settings.php +++ b/lib/settings.php @@ -41,12 +41,18 @@ If ($ICEcoderUserSettings["versionNo"] != $ICEcoderSettings["versionNo"]) { $ICEcoder = $ICEcoderSettings + $ICEcoderUserSettings; // Include language file -// Load English first as foundation -include(dirname(__FILE__)."/../lang/english.php"); -$englishText = $text; -// Load chosen language ontop to replace English -include(dirname(__FILE__)."/../lang/english.php"); -$text = array_replace_recursive($englishText, $text); +// Load base first as foundation +if (strpos(str_replace("\\","/",realpath(dirname(__FILE__)."/../lang/".$ICEcoder['languageBase'])),str_replace("\\","/",realpath($ICEcoder['docRoot']))) !== 0) { + die('Sorry, bad base language path'); +} +if (strpos(str_replace("\\","/",realpath(dirname(__FILE__)."/../lang/".$ICEcoder['languageUser'])),str_replace("\\","/",realpath($ICEcoder['docRoot']))) !== 0) { + die('Sorry, bad user language path'); +} +include(dirname(__FILE__)."/../lang/".$ICEcoder['languageBase']); +$baseText = $text; +// Load chosen language ontop to replace base +include(dirname(__FILE__)."/../lang/".$ICEcoder['languageUser']); +$text = array_replace_recursive($baseText, $text); $_SESSION['text'] = $text; // Login not required or we're in demo mode and have password set in our settings, log us straight in