top.docRoot='".$docRoot."';top.iceRoot='".$iceRoot."'"; } // Establish the dir ICEcoders running from $ICEcoderDirFullPath = rtrim(str_replace("\\","/",dirname($_SERVER['SCRIPT_FILENAME'])),"/lib"); $rootPrefix = '/'.str_replace("/","\/",preg_quote(str_replace("\\","/",$docRoot))).'/'; $ICEcoderDir = preg_replace($rootPrefix, '', $ICEcoderDirFullPath, 1); // Setup our file security vars $settingsArray = array("findFilesExclude","bannedFiles","allowedIPs"); for ($i=0;$i-1)) { $password = generateHash(strClean($_POST['password'])); $settingsContents = file_get_contents($settingsFile,false,$context); // Replace our empty password with the one submitted by user $settingsContents = str_replace('"password" => "",','"password" => "'.$password.'",',$settingsContents); // Also set the update checker preference $checkUpdates = $_POST['checkUpdates']=="true" ? "true" : "false"; // once to cover the true setting, once to cover false $settingsContents = str_replace('"checkUpdates" => true,','"checkUpdates" => '.$checkUpdates.',',$settingsContents); $settingsContents = str_replace('"checkUpdates" => false,','"checkUpdates" => '.$checkUpdates.',',$settingsContents); // Now update the config file $fh = fopen($settingsFile, 'w') or die("Can't update config file. Please set public write permissions on ".$settingsFile." and press refresh"); fwrite($fh, $settingsContents); fclose($fh); // Set the session user level if ($ICEcoder["multiUser"]) { $_SESSION['username']=$_POST['username']; } $_SESSION['loggedIn'] = true; include(dirname(__FILE__)."/../processes/on-user-new.php"); // Finally, load again as now this file has changed and auto login header('Location: ../'); die('Logging you in...'); } // =================================================== // We're likely showing the login screen at this point // =================================================== } elseif ($ICEcoder['loginRequired'] && $_SESSION['loggedIn'] && $ICEcoder["password"]=="") { header("Location: ../?logout"); die('Logging you out...'); } else { // ================================== // Continue with whatever we're doing // ================================== } ?>