From 7e40f9c04435b5489cfbbab30f074b3149ab0d2b Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Thu, 13 Nov 2014 17:25:47 +0000 Subject: [PATCH] Save items removed, now handled by XHR --- lib/file-control.php | 128 +------------------------------------------ 1 file changed, 1 insertion(+), 127 deletions(-) diff --git a/lib/file-control.php b/lib/file-control.php index c7f35ca..a15f0be 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -351,95 +351,7 @@ function rrmdir($dir) { reset($objects); rmdir($dir); } -} - -if ($_GET['action']=="save") { - echo 'action="save";'; - // on the form posting via a reload, save the file - if (isset($_POST['contents'])) { - if (!$demoMode && ((file_exists($file) && is_writable($file)) || isset($_POST['newFileName']) && $_POST['newFileName']!="")) { - $filemtime = $serverType=="Linux" ? filemtime($file) : "1000000"; - if (!(isset($_GET['fileMDT']))||$filemtime==$_GET['fileMDT']) { - // Newly created files have the perms set too - $setPerms = (!file_exists($file)) ? true : false; - $fh = fopen($file, 'w') or die($t['Sorry, cannot save']); - // replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding - $contents = $_POST['contents']; - $contents = str_replace("\r\n", $ICEcoder["lineEnding"], $contents); - $contents = str_replace("\r", $ICEcoder["lineEnding"], $contents); - $contents = str_replace("\n", $ICEcoder["lineEnding"], $contents); - // Now write that content, close the file and clear the statcache - fwrite($fh, $contents); - fclose($fh); - if ($setPerms) { - chmod($file,octdec($ICEcoder['newFilePerms'])); - } - clearstatcache(); - $filemtime = $serverType=="Linux" ? filemtime($file) : "1000000"; - echo 'top.ICEcoder.openFileMDTs[top.ICEcoder.selectedTab-1]="'.$filemtime.'";'; - // Reload file manager, rename tab & remove old file highlighting if it was a new file - if (isset($_POST['newFileName']) && $_POST['newFileName']!="") { - echo 'top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\',false,false,false,\'file\');'; - echo 'top.ICEcoder.renameTab(top.ICEcoder.selectedTab,\''.$fileLoc."/".$fileName.'\');'; - if (!strpos($_GET['file'],"[NEW]")) { - // We're saving as a new file, so unhighlight the old name in the file manager if visible - echo "fileLink = top.ICEcoder.filesFrame.contentWindow.document.getElementById('".str_replace("/","|",$fileLoc)."|".basename($_GET['file'])."');"; - echo "if (fileLink) {fileLink.style.backgroundColor = top.ICEcoder.tabBGnormal; fileLink.style.color = top.ICEcoder.tabFGnormalFile};"; - } - } - // Reload previewWindow window if not a Markdown file - echo 'if (top.ICEcoder.previewWindow.location && top.ICEcoder.previewWindow.location.pathname.indexOf(".md")==-1) { - top.ICEcoder.previewWindowLoading = false; - top.ICEcoder.previewWindow.location.reload(true); - // Check on an interval for the page to be complete and if we last saw it loading... - top.ICEcoder.checkPreviewWindowLoadingInt = setInterval(function() { - if (top.ICEcoder.previewWindow.document.readyState != "loading" && top.ICEcoder.previewWindowLoading) { - // We are done loading, so set the loading status to false and load plugins ontop... - top.ICEcoder.previewWindowLoading = false; - // Do the pesticide plugin if it exists - try {top.ICEcoder.doPesticide();} catch(err) {}; - // Do the stats.js plugin if it exists - try {top.ICEcoder.doStatsJS(\'save\');} catch(err) {}; - // Finally, clear the interval - clearInterval(top.ICEcoder.checkPreviewWindowLoadingInt); - } else { - top.ICEcoder.previewWindowLoading = top.ICEcoder.previewWindow.document.readyState == "loading" ? true : false; - } - },4); - - };'; - echo 'top.ICEcoder.setPreviousFiles();setTimeout(function(){top.ICEcoder.indicateChanges()},4);action="doneSave";'; - // Run our custom processes - include_once("../processes/on-file-save.php"); - } else { - $loadedFile = toUTF8noBOM(file_get_contents($file,false,$context),true); - echo '","",htmlentities($loadedFile)).''; - echo ' -
- - - "> -
- - \ No newline at end of file