top. and parent. revised in file-control-xhr.php

This commit is contained in:
mattpass
2020-02-28 17:16:33 +00:00
parent 86967a57f8
commit a5898f9fc4

View File

@@ -103,7 +103,7 @@ if (isset($ftpSite)) {
ftpStart();
// Show user warning if no good connection
if (!$ftpConn || !$ftpLogin) {
$doNext .= 'top.ICEcoder.message("Sorry, no FTP connection to '.$ftpHost.' for user '.$ftpUser.'");';
$doNext .= 'ICEcoder.message("Sorry, no FTP connection to '.$ftpHost.' for user '.$ftpUser.'");';
}
}
@@ -186,24 +186,24 @@ if (!$error && $_GET['action']=="save") {
$fileMDTURLPart = isset($_GET["fileMDT"]) && $_GET["fileMDT"]!="undefined" ? "&fileMDT=".numClean($_GET['fileMDT']) : "";
$fileVersionURLPart = isset($_GET["fileVersion"]) && $_GET["fileVersion"]!="undefined" ? "&fileVersion=".numClean($_GET['fileVersion']) : "";
$doNext .= '
top.ICEcoder.serverMessage();
ICEcoder.serverMessage();
fileLoc = "'.$fileLoc.'";
overwriteOK = false;
noConflictSave = false;
newFileName = top.ICEcoder.getInput("'.$t['Enter filename to...'].' "+(fileLoc!="" ? fileLoc : "/"),"");
newFileName = ICEcoder.getInput("'.$t['Enter filename to...'].' "+(fileLoc!="" ? fileLoc : "/"),"");
if (newFileName) {
if (newFileName.substr(0,1)!="/") {newFileName = "/" + newFileName};
newFileName = fileLoc + newFileName;
/* Check if file/dir exists */
top.ICEcoder.lastFileDirCheckStatusObj = false;
top.ICEcoder.checkExists(newFileName);
ICEcoder.lastFileDirCheckStatusObj = false;
ICEcoder.checkExists(newFileName);
var thisInt = setInterval(function() {
if (top.ICEcoder.lastFileDirCheckStatusObj != false) {
if (ICEcoder.lastFileDirCheckStatusObj != false) {
clearInterval(thisInt);
if (top.ICEcoder.lastFileDirCheckStatusObj.file && top.ICEcoder.lastFileDirCheckStatusObj.file.exists) {
overwriteOK = top.ICEcoder.ask("'.$t['That file exists...'].'");
if (ICEcoder.lastFileDirCheckStatusObj.file && ICEcoder.lastFileDirCheckStatusObj.file.exists) {
overwriteOK = ICEcoder.ask("'.$t['That file exists...'].'");
} else {
noConflictSave = true;
};
@@ -213,7 +213,7 @@ if (!$error && $_GET['action']=="save") {
newFileName = "'.(isset($ftpSite) ? "" : $docRoot).'" + newFileName;
saveURL = "lib/file-control-xhr.php?action=save'.$fileMDTURLPart.$fileVersionURLPart.'&csrf='.$_GET["csrf"].'";
var xhr = top.ICEcoder.xhrObj();
var xhr = ICEcoder.xhrObj();
xhr.onreadystatechange=function() {
if (xhr.readyState==4 && xhr.status==200) {
@@ -225,7 +225,7 @@ if (!$error && $_GET['action']=="save") {
/* console.log(statusObj); */
if (statusObj.status.error) {
top.ICEcoder.message(statusObj.status.errorMsg);
ICEcoder.message(statusObj.status.errorMsg);
} else {
eval(statusObj.action.doNext);
}
@@ -237,8 +237,8 @@ if (!$error && $_GET['action']=="save") {
/* console.log(\'Calling \'+saveURL+\' via XHR\'); */
xhr.open("POST",saveURL,true);
xhr.setRequestHeader(\'Content-type\', \'application/x-www-form-urlencoded\');
xhr.send(\'timeStart='.numClean($_POST["timeStart"]).'&file='.$fileURL.'&newFileName=\'+newFileName.replace(/\\\+/g,"%2B")+\'&contents=\'+encodeURIComponent(top.ICEcoder.saveAsContent));
top.ICEcoder.serverMessage("<b>'.$t['Saving'].'</b><br>" + "'.($finalAction == "Save" ? "newFileName" : "'".$fileName."'").'");
xhr.send(\'timeStart='.numClean($_POST["timeStart"]).'&file='.$fileURL.'&newFileName=\'+newFileName.replace(/\\\+/g,"%2B")+\'&contents=\'+encodeURIComponent(ICEcoder.saveAsContent));
ICEcoder.serverMessage("<b>'.$t['Saving'].'</b><br>" + "'.($finalAction == "Save" ? "newFileName" : "'".$fileName."'").'");
}
}
},10);
@@ -246,8 +246,8 @@ if (!$error && $_GET['action']=="save") {
/* UI dialog cancelling and saving contents for save as looparound */
if (!newFileName || newFileName && !overwriteOK) {
top.ICEcoder.saveAsContent = top.document.getElementById(\'saveTemp1\').value;
top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);
ICEcoder.saveAsContent = document.getElementById(\'saveTemp1\').value;
ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);
}';
// ===================
@@ -311,10 +311,10 @@ if (!$error && $_GET['action']=="save") {
}
// Write our file contents
if (!ftpWriteFile($ftpConn, $ftpFilepath, $contents, $ftpMode)) {
$doNext .= 'top.ICEcoder.message("Sorry, could not write '.$ftpFilepath.' at '.$ftpHost.'");';
$doNext .= 'ICEcoder.message("Sorry, could not write '.$ftpFilepath.' at '.$ftpHost.'");';
} else {
$doNext .= 'top.ICEcoder.openFileMDTs[top.ICEcoder.selectedTab-1]="'.$filemtime.'";';
$doNext .= '(function() {var x=top.ICEcoder.openFileVersions; var y=top.ICEcoder.selectedTab-1; x[y] = "undefined" != typeof x[y] ? x[y]+1 : 1})();top.ICEcoder.updateVersionsDisplay();';
$doNext .= 'ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]="'.$filemtime.'";';
$doNext .= '(function() {var x=ICEcoder.openFileVersions; var y=ICEcoder.selectedTab-1; x[y] = "undefined" != typeof x[y] ? x[y]+1 : 1})();ICEcoder.updateVersionsDisplay();';
}
// Local saving
} else {
@@ -357,8 +357,8 @@ if (!$error && $_GET['action']=="save") {
}
clearstatcache();
$filemtime = $serverType=="Linux" ? filemtime($file) : "1000000";
$doNext .= 'top.ICEcoder.openFileMDTs[top.ICEcoder.selectedTab-1]="'.$filemtime.'";';
$doNext .= '(function() {var x=top.ICEcoder.openFileVersions; var y=top.ICEcoder.selectedTab-1; x[y] = "undefined" != typeof x[y] ? x[y]+1 : 1})();top.ICEcoder.updateVersionsDisplay();';
$doNext .= 'ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]="'.$filemtime.'";';
$doNext .= '(function() {var x=ICEcoder.openFileVersions; var y=ICEcoder.selectedTab-1; x[y] = "undefined" != typeof x[y] ? x[y]+1 : 1})();ICEcoder.updateVersionsDisplay();';
}
// Save a version controlled backup source of the file
@@ -447,30 +447,30 @@ if (!$error && $_GET['action']=="save") {
// Reload file manager, rename tab & remove old file highlighting if it was a new file
if (isset($_POST['newFileName']) && $_POST['newFileName']!="") {
$doNext .= 'top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\',false,false,false,\'file\');';
$doNext .= 'top.ICEcoder.renameTab(top.ICEcoder.selectedTab,\''.$fileLoc."/".$fileName.'\');';
$doNext .= 'ICEcoder.selectedFiles=[];ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\',false,false,false,\'file\');';
$doNext .= 'ICEcoder.renameTab(ICEcoder.selectedTab,\''.$fileLoc."/".$fileName.'\');';
if (!strpos($_REQUEST['file'],"[NEW]")) {
// We're saving as a new file, so unhighlight the old name in the file manager if visible
$doNext .= "fileLink = top.ICEcoder.filesFrame.contentWindow.document.getElementById('".str_replace("/","|",$fileLoc)."|".basename($_REQUEST['file'])."');";
$doNext .= "if (fileLink) {fileLink.style.backgroundColor = top.ICEcoder.tabBGnormal; fileLink.style.color = top.ICEcoder.tabFGnormalFile};";
$doNext .= "fileLink = ICEcoder.filesFrame.contentWindow.document.getElementById('".str_replace("/","|",$fileLoc)."|".basename($_REQUEST['file'])."');";
$doNext .= "if (fileLink) {fileLink.style.backgroundColor = ICEcoder.tabBGnormal; fileLink.style.color = ICEcoder.tabFGnormalFile};";
}
}
// Reload previewWindow window if not a Markdown file
// In doing this, we check on an interval for the page to be complete and if we last saw it loading
// When we are done loading, so set the loading status to false and load plugins ontop...
$doNext .= 'if (top.ICEcoder.previewWindow.location && top.ICEcoder.previewWindow.location.pathname && top.ICEcoder.previewWindow.location.pathname.indexOf(".md")==-1) {
top.ICEcoder.previewWindowLoading = false;
top.ICEcoder.previewWindow.location.reload(true);
// When we are done loading, so set the loading status to false and load plugins on..
$doNext .= 'if (ICEcoder.previewWindow.location && ICEcoder.previewWindow.location.pathname && ICEcoder.previewWindow.location.pathname.indexOf(".md")==-1) {
ICEcoder.previewWindowLoading = false;
ICEcoder.previewWindow.location.reload(true);
top.ICEcoder.checkPreviewWindowLoadingInt = setInterval(function() {
if (top.ICEcoder.previewWindow.document.readyState != "loading" && top.ICEcoder.previewWindowLoading) {
top.ICEcoder.previewWindowLoading = false;
try {top.ICEcoder.doPesticide();} catch(err) {};
try {top.ICEcoder.doStatsJS(\'save\');} catch(err) {};
try {top.ICEcoder.doResponsive();} catch(err) {};
clearInterval(top.ICEcoder.checkPreviewWindowLoadingInt);
ICEcoder.checkPreviewWindowLoadingInt = setInterval(function() {
if (ICEcoder.previewWindow.document.readyState != "loading" && ICEcoder.previewWindowLoading) {
ICEcoder.previewWindowLoading = false;
try {ICEcoder.doPesticide();} catch(err) {};
try {ICEcoder.doStatsJS(\'save\');} catch(err) {};
try {ICEcoder.doResponsive();} catch(err) {};
clearInterval(ICEcoder.checkPreviewWindowLoadingInt);
} else {
top.ICEcoder.previewWindowLoading = top.ICEcoder.previewWindow.document.readyState == "loading" ? true : false;
ICEcoder.previewWindowLoading = ICEcoder.previewWindow.document.readyState == "loading" ? true : false;
}
},4);
@@ -478,20 +478,20 @@ if (!$error && $_GET['action']=="save") {
// Copy over content to diff pane if we have that setting on
$doNext .= '
cM = top.ICEcoder.getcMInstance();
cMdiff = top.ICEcoder.getcMdiffInstance();
if (top.ICEcoder.updateDiffOnSave) {
cM = ICEcoder.getcMInstance();
cMdiff = ICEcoder.getcMdiffInstance();
if (ICEcoder.updateDiffOnSave) {
cMdiff.setValue(cM.getValue());
};
';
// Finally, set previous files, indicate changes, set saved points and redo tabs
$doNext .= '
top.ICEcoder.setPreviousFiles();
setTimeout(function(){top.ICEcoder.indicateChanges()},4);
top.ICEcoder.savedPoints[top.ICEcoder.selectedTab-1] = cM.changeGeneration();
top.ICEcoder.savedContents[top.ICEcoder.selectedTab-1] = cM.getValue();
top.ICEcoder.redoTabHighlight(top.ICEcoder.selectedTab);';
ICEcoder.setPreviousFiles();
setTimeout(function(){ICEcoder.indicateChanges()},4);
ICEcoder.savedPoints[ICEcoder.selectedTab-1] = cM.changeGeneration();
ICEcoder.savedContents[ICEcoder.selectedTab-1] = cM.getValue();
ICEcoder.redoTabHighlight(ICEcoder.selectedTab);';
// Run our custom processes
include_once("../processes/on-file-save.php");
@@ -507,21 +507,21 @@ if (!$error && $_GET['action']=="save") {
$doNext .= '
var loadedFile = document.createElement("textarea");
loadedFile.value = "'.str_replace('"','\\\"',str_replace("\r","\\\\r",str_replace("\n","\\\\n",str_replace("</textarea>","<ICEcoder:/:textarea>",$loadedFile)))).'";
var refreshFile = top.ICEcoder.ask("'.$t['Sorry, this file...'].'\\\n'.$file.'\\\n\\\n'.$t['Reload this file...'].'");
var refreshFile = ICEcoder.ask("'.$t['Sorry, this file...'].'\\\n'.$file.'\\\n\\\n'.$t['Reload this file...'].'");
if (refreshFile) {
var cM = top.ICEcoder.getcMInstance();
var thisTab = top.ICEcoder.selectedTab;
var cM = ICEcoder.getcMInstance();
var thisTab = ICEcoder.selectedTab;
var userVersionFile = cM.getValue();
/* Revert back to original */
cM.setValue(loadedFile.value);
top.ICEcoder.savedPoints[thisTab-1] = cM.changeGeneration();
top.ICEcoder.savedContents[thisTab-1] = cM.getValue();
top.ICEcoder.openFileMDTs[top.ICEcoder.selectedTab-1] = "'.$filemtime.'";
top.ICEcoder.openFileVersions[top.ICEcoder.selectedTab-1] = "'.$fileCountInfo['count'].'";
ICEcoder.savedPoints[thisTab-1] = cM.changeGeneration();
ICEcoder.savedContents[thisTab-1] = cM.getValue();
ICEcoder.openFileMDTs[ICEcoder.selectedTab-1] = "'.$filemtime.'";
ICEcoder.openFileVersions[ICEcoder.selectedTab-1] = "'.$fileCountInfo['count'].'";
cM.clearHistory();
/* Now for the new version in the diff pane */
top.ICEcoder.setSplitPane(\'on\');
var cMdiff = top.ICEcoder.getcMdiffInstance();
ICEcoder.setSplitPane(\'on\');
var cMdiff = ICEcoder.getcMdiffInstance();
cMdiff.setValue(userVersionFile);
};';
$finalAction = "nothing";
@@ -533,9 +533,9 @@ if (!$error && $_GET['action']=="save") {
} else {
$finalAction = "nothing";
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot save']."\\\\n".$file."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot save']."\\\\n".$file."');";
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
}
};
@@ -550,7 +550,7 @@ if (!$error && $_GET['action']=="newFolder") {
if (isset($ftpSite)) {
$ftpFilepath = ltrim($fileLoc."/".$fileName,"/");
if (!ftpMkDir($ftpConn, octdec($ICEcoder['newDirPerms']), $ftpFilepath)) {
$doNext .= 'top.ICEcoder.message("Sorry, could not create dir '.$ftpFilepath.' at '.$ftpHost.'");';
$doNext .= 'ICEcoder.message("Sorry, could not create dir '.$ftpFilepath.' at '.$ftpHost.'");';
} else {
$updateFM = true;
}
@@ -562,16 +562,16 @@ if (!$error && $_GET['action']=="newFolder") {
}
// Update file manager on success
if ($updateFM) {
$doNext .= 'top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\',false,false,false,\'folder\');';
$doNext .= 'ICEcoder.selectedFiles=[];ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\',false,false,false,\'folder\');';
}
$finalAction = "newFolder";
// Run our custom processes
include_once("../processes/on-new-dir.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot create...']."\\\\n".$fileLoc."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot create...']."\\\\n".$fileLoc."');";
$finalAction = "nothing";
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// ================
@@ -592,7 +592,7 @@ if (!$error && $_GET['action']=="move") {
// FTP
if (isset($ftpSite)) {
if (!ftpRename($ftpConn, $srcDir, $tgtDir)) {
$doNext .= 'top.ICEcoder.message("Sorry, could not rename '.$srcDir.' to '.$tgtDir.'");';
$doNext .= 'ICEcoder.message("Sorry, could not rename '.$srcDir.' to '.$tgtDir.'");';
} else {
$ftpFileDirInfo = ftpGetFileInfo($ftpConn, ltrim($fileLoc,"/"), $fileName);
$fileOrFolder = $ftpFileDirInfo['type'] == "directory" ? "folder" : "file";
@@ -608,20 +608,20 @@ if (!$error && $_GET['action']=="move") {
}
// Update file manager on success
if ($updateFM) {
$doNext .= 'top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'move\',\''.$fileLoc.'\',\''.$fileName.'\',\'\',\''.str_replace($iceRoot,"",str_replace("|","/",$_GET['oldFileName'])).'\',false,\''.$fileOrFolder.'\');';
$doNext .= 'ICEcoder.selectedFiles=[];ICEcoder.updateFileManagerList(\'move\',\''.$fileLoc.'\',\''.$fileName.'\',\'\',\''.str_replace($iceRoot,"",str_replace("|","/",$_GET['oldFileName'])).'\',false,\''.$fileOrFolder.'\');';
}
$finalAction = "move";
// Run our custom processes
include_once("../processes/on-file-dir-move.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot move']."\\\\n".str_replace("|","/",$_GET['oldFileName'])."\\\\n\\\\n".$t['Maybe public write...']."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot move']."\\\\n".str_replace("|","/",$_GET['oldFileName'])."\\\\n\\\\n".$t['Maybe public write...']."');";
$finalAction = "nothing";
}
} else {
$doNext .= "";
$finalAction = "nothing";
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// ==================
@@ -635,7 +635,7 @@ if (!$error && $_GET['action']=="rename") {
if (isset($ftpSite)) {
$ftpFilepath = ltrim($fileLoc."/".$fileName,"/");
if (!ftpRename($ftpConn, ltrim($_GET['oldFileName'],"/"), $ftpFilepath)) {
$doNext .= 'top.ICEcoder.message("Sorry, could not rename '.ltrim($_GET['oldFileName'],"/").' to '.$ftpFilepath.'");';
$doNext .= 'ICEcoder.message("Sorry, could not rename '.ltrim($_GET['oldFileName'],"/").' to '.$ftpFilepath.'");';
} else {
$updateFM = true;
}
@@ -646,16 +646,16 @@ if (!$error && $_GET['action']=="rename") {
}
// Update file manager on success
if ($updateFM) {
$doNext .= 'top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'rename\',\''.$fileLoc.'\',\''.$fileName.'\',\'\',\''.str_replace($iceRoot,"",$_GET['oldFileName']).'\');';
$doNext .= 'ICEcoder.selectedFiles=[];ICEcoder.updateFileManagerList(\'rename\',\''.$fileLoc.'\',\''.$fileName.'\',\'\',\''.str_replace($iceRoot,"",$_GET['oldFileName']).'\');';
}
$finalAction = "rename";
// Run our custom processes
include_once("../processes/on-file-dir-rename.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot rename']."\\\\n".$_GET['oldFileName']."\\\\n\\\\n".$t['Maybe public write...']."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot rename']."\\\\n".$_GET['oldFileName']."\\\\n\\\\n".$t['Maybe public write...']."');";
$finalAction = "nothing";
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// =================
@@ -704,15 +704,15 @@ if (!isset($ftpSite) && !$error && $_GET['action']=="paste") {
}
}
// Reload file manager
$doNext .= 'top.ICEcoder.updateFileManagerList(\'add\',\''.str_replace("|","/",$_GET['location']).'\',\''.basename($dest).'\',false,false,false,\''.$fileOrFolder.'\');';
$doNext .= 'ICEcoder.updateFileManagerList(\'add\',\''.str_replace("|","/",$_GET['location']).'\',\''.basename($dest).'\',false,false,false,\''.$fileOrFolder.'\');';
$finalAction = "pasteFile";
// Run our custom processes
include_once("../processes/on-file-dir-paste.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot copy']." \\\\n".str_replace($docRoot,"",$source)."\\\\n ".$t['into']." \\\\n".str_replace($docRoot,"",$dest)."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot copy']." \\\\n".str_replace($docRoot,"",$source)."\\\\n ".$t['into']." \\\\n".str_replace($docRoot,"",$dest)."');";
$finalAction = "nothing";
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// ==============
@@ -736,10 +736,10 @@ if (!isset($ftpSite) && !$error && $_GET['action']=="upload") {
$setPerms = $ICEcoder['newFilePerms'];
}
if ($this->upload($current,$this->uploadFile,$setPerms)) {
$doNext .= 'top.ICEcoder.updateFileManagerList(\'add\',top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,\'/\'),\''.str_replace("'","\'",$fileName).'\',false,false,true,\'file\'); top.ICEcoder.serverMessage("'.$t['Uploaded file(s) OK'].'");setTimeout(function(){top.ICEcoder.serverMessage();},2000);';
$doNext .= 'ICEcoder.updateFileManagerList(\'add\',ICEcoder.selectedFiles[ICEcoder.selectedFiles.length-1].replace(/\|/g,\'/\'),\''.str_replace("'","\'",$fileName).'\',false,false,true,\'file\'); ICEcoder.serverMessage("'.$t['Uploaded file(s) OK'].'");setTimeout(function(){ICEcoder.serverMessage();},2000);';
$finalAction = "upload";
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot upload']." \\\\n".$fileName."\\\\n ".$t['into']." \\\\n'+top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,'/'));";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot upload']." \\\\n".$fileName."\\\\n ".$t['into']." \\\\n'+ICEcoder.selectedFiles[ICEcoder.selectedFiles.length-1].replace(/\|/g,'/'));";
$finalAction = "nothing";
}
}
@@ -770,11 +770,11 @@ if (!isset($ftpSite) && !$error && $_GET['action']=="upload") {
// Run our custom processes
include_once("../processes/on-file-upload.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot upload...']."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot upload...']."');";
$finalAction = "nothing";
}
$doNext .= "top.ICEcoder.hideFileMenu();top.document.getElementById('fileInput').value='';top.ICEcoder.showHide('hide',top.document.getElementById('loadingMask'));";
$doNext .= "ICEcoder.hideFileMenu();document.getElementById('fileInput').value='';ICEcoder.showHide('hide',document.getElementById('loadingMask'));";
// Upload is not handled by XHR methods, but form post, so we need to manually trigger $doNext in a script tag
echo "<script>".$doNext."</script>";
@@ -795,16 +795,16 @@ if (!$error && $_GET['action']=="delete") {
if (!$demoMode && ftpDelete($ftpConn,$itemType,$itemPath)) {
if ($fileLoc=="" || $fileLoc=="\\") {$fileLoc="/";};
// Reload file manager
$doNext .= 'top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'delete\',\''.$fileLoc.'\',\''.$fileName.'\');';
$doNext .= 'ICEcoder.selectedFiles=[];ICEcoder.updateFileManagerList(\'delete\',\''.$fileLoc.'\',\''.$fileName.'\');';
$finalAction = "delete";
// Run our custom processes
include_once("../processes/on-file-dir-delete.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot delete']."\\\\n".$fileLoc."/".$fileName."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot delete']."\\\\n".$fileLoc."/".$fileName."');";
$finalAction = "nothing";
}
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot delete more...']."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot delete more...']."');";
$finalAction = "nothing";
}
// Local
@@ -815,7 +815,7 @@ if (!$error && $_GET['action']=="delete") {
$fullPath = $docRoot.$iceRoot.$fullPath;
if (rtrim($fullPath,"/") == rtrim($docRoot,"/")) {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot delete...']."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot delete...']."');";
} else if (!$demoMode && is_writable($fullPath)) {
if (is_dir($fullPath)) {
rrmdir($fullPath);
@@ -829,17 +829,17 @@ if (!$error && $_GET['action']=="delete") {
$fileLoc = dirname(str_replace($docRoot,"",$fullPath));
if ($fileLoc=="" || $fileLoc=="\\") {$fileLoc="/";};
// Reload file manager
$doNext .= 'top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'delete\',\''.$fileLoc.'\',\''.$fileName.'\');';
$doNext .= 'ICEcoder.selectedFiles=[];ICEcoder.updateFileManagerList(\'delete\',\''.$fileLoc.'\',\''.$fileName.'\');';
$finalAction = "delete";
// Run our custom processes
include_once("../processes/on-file-dir-delete.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot delete']."\\\\n".str_replace($docRoot,"",$fullPath)."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot delete']."\\\\n".str_replace($docRoot,"",$fullPath)."');";
$finalAction = "nothing";
}
}
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// The function to recursively remove folders & files
@@ -881,10 +881,10 @@ if (!isset($ftpSite) && !$error && $_GET['action']=="replaceText") {
// Run our custom processes
include_once("../processes/on-file-replace-text.php");
} else {
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot replace...']."\\\\n".$file."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot replace...']."\\\\n".$file."');";
$finalAction = "nothing";
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// ==========================
@@ -898,17 +898,17 @@ if (!isset($ftpSite) && !$error && $_GET['action']=="getRemoteFile") {
$remoteFile = str_replace("\r\n", $ICEcoder["lineEnding"], $remoteFile);
$remoteFile = str_replace("\r", $ICEcoder["lineEnding"], $remoteFile);
$remoteFile = str_replace("\n", $ICEcoder["lineEnding"], $remoteFile);
$doNext .= 'top.ICEcoder.newTab();';
$doNext .= 'top.ICEcoder.getcMInstance().setValue(\''.str_replace("\r","",str_replace("\t","\\\\t",str_replace("\n","\\\\n",str_replace("'","\\\\'",str_replace("\\","\\\\",preg_quote($remoteFile)))))).'\');';
$doNext .= 'top.ICEcoder.goToLine('.$lineNumber.');';
$doNext .= 'ICEcoder.newTab();';
$doNext .= 'ICEcoder.getcMInstance().setValue(\''.str_replace("\r","",str_replace("\t","\\\\t",str_replace("\n","\\\\n",str_replace("'","\\\\'",str_replace("\\","\\\\",preg_quote($remoteFile)))))).'\');';
$doNext .= 'ICEcoder.goToLine('.$lineNumber.');';
$finalAction = "getRemoteFile";
// Run our custom processes
include_once("../processes/on-get-remote-file.php");
} else {
$finalAction = "nothing";
$doNext .= 'top.ICEcoder.message(\''.$t['Sorry, could not...'].' '.$file.'\');';
$doNext .= 'ICEcoder.message(\''.$t['Sorry, could not...'].' '.$file.'\');';
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// =======================
@@ -922,7 +922,7 @@ if (!$error && $_GET['action']=="perms") {
if (isset($ftpSite)) {
$ftpFilepath = ltrim($fileLoc."/".$fileName,"/");
if (!ftpPerms($ftpConn, octdec(numClean($_GET['perms'])), $ftpFilepath)) {
$doNext .= 'top.ICEcoder.message("Sorry, could not set perms on '.$ftpFilepath.' at '.$ftpHost.'");';
$doNext .= 'ICEcoder.message("Sorry, could not set perms on '.$ftpFilepath.' at '.$ftpHost.'");';
} else {
$updateFM = true;
}
@@ -934,16 +934,16 @@ if (!$error && $_GET['action']=="perms") {
}
// Update file manager on success
if ($updateFM) {
$doNext .= 'top.ICEcoder.updateFileManagerList(\'chmod\',\''.$fileLoc.'\',\''.$fileName.'\',\''.numClean($_GET['perms']).'\');';
$doNext .= 'ICEcoder.updateFileManagerList(\'chmod\',\''.$fileLoc.'\',\''.$fileName.'\',\''.numClean($_GET['perms']).'\');';
}
$finalAction = "perms";
// Run our custom processes
include_once("../processes/on-file-dir-perms.php");
} else {
$finalAction = "nothing";
$doNext .= "top.ICEcoder.message('".$t['Sorry, cannot change...']." \\n".$file."');";
$doNext .= "ICEcoder.message('".$t['Sorry, cannot change...']." \\n".$file."');";
}
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// ====================
@@ -951,10 +951,10 @@ if (!$error && $_GET['action']=="perms") {
// ====================
if (!isset($ftpSite) && !$error && $_GET['action']=="checkExists") {
// This action is called under seperate AJAX call and the responseText object stored in top.ICEcoder.lastFileDirCheckStatusObj
// This action is called under seperate AJAX call and the responseText object stored in ICEcoder.lastFileDirCheckStatusObj
// Nothing really done here though, we do something with the responseText
$finalAction = "checkExists";
$doNext .= 'top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);';
$doNext .= 'ICEcoder.serverMessage();ICEcoder.serverQueue("del",0);';
};
// ===================
@@ -1012,7 +1012,7 @@ echo '{
"timeEnd": 0,
"timeTaken": 0,
"csrf": "'.xssClean($_GET['csrf'],"html").'",
"doNext" : "'.preg_replace('/\r|\n/','',str_replace(' ','',str_replace('"','\"',$doNext))).'top.ICEcoder.switchMode();"
"doNext" : "'.preg_replace('/\r|\n/','',str_replace(' ','',str_replace('"','\"',$doNext))).'ICEcoder.switchMode();"
},
"status": {
"error" : '.($error ? 'true' : 'false').',