From 400ef8cfce2985dc41146473936acb73cc951414 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Sat, 25 Apr 2015 10:14:34 +0100 Subject: [PATCH] Swap write order, better file check with alert --- lib/settings-update.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/settings-update.php b/lib/settings-update.php index 1760813..d7cc105 100644 --- a/lib/settings-update.php +++ b/lib/settings-update.php @@ -41,7 +41,7 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset $ICEcoder["bugFileMaxLines"] = intval($_POST['bugFileMaxLines']); $ICEcoder["githubAuthToken"] = strClean($_POST['githubAuthToken']); - $settingsArray = array("root","checkUpdates","openLastFiles","updateDiffOnSave","languageUser","findFilesExclude","codeAssist","visibleTabs","lockedNav","tagWrapperCommand","autoComplete","password","bannedFiles","bannedPaths","allowedIPs","theme","fontSize","lineWrapping","indentWithTabs","indentSize","indentAuto","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","indentAuto","indentSize","pluginPanelAligned","bugFilePaths","bugFileCheckTimer","bugFileMaxLines","githubAuthToken"); $settingsNew = ""; for ($i=0;$i '; @@ -85,9 +85,13 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset $generalSettingsContents = str_replace('"enableRegistration" => true','"enableRegistration" => '.$isEnableRegistration,$generalSettingsContents); $generalSettingsContents = str_replace('"enableRegistration" => false','"enableRegistration" => '.$isEnableRegistration,$generalSettingsContents); - $fConfigSettings = fopen($configSettings, 'w') or die($t['Cannot update config']." ".$configSettings." ".$t['and press refresh']); - fwrite($fConfigSettings, $generalSettingsContents); - fclose($fConfigSettings); + if (is_writeable($configSettings)) { + $fConfigSettings = fopen($configSettings, 'w'); + fwrite($fConfigSettings, $generalSettingsContents); + fclose($fConfigSettings); + } else { + echo ""; + } $githubAuthTokenSet = $ICEcoder["githubAuthToken"] != "" ? "true" : "false";