diff --git a/lib/file-control-xhr.php b/lib/file-control-xhr.php index f6d4daa..786a1cb 100644 --- a/lib/file-control-xhr.php +++ b/lib/file-control-xhr.php @@ -4,6 +4,14 @@ include("settings.php"); include("ftp-control.php"); $t = $text['file-control']; +// Load the LZ String PHP libs and define using LZString +include(dirname(__FILE__)."/../LZCompressor/LZContext.php"); +include(dirname(__FILE__)."/../LZCompressor/LZData.php"); +include(dirname(__FILE__)."/../LZCompressor/LZReverseDictionary.php"); +include(dirname(__FILE__)."/../LZCompressor/LZString.php"); +include(dirname(__FILE__)."/../LZCompressor/LZUtil.php"); +use LZCompressor\LZString as LZString; + // =============================== // SET OUR ERROR INFO TO A DEFAULT // =============================== @@ -33,6 +41,14 @@ if (isset($_POST['newFileName']) && $_POST['newFileName']!="") { $errorMsg = $t['Sorry, bad filename...']; }; +// If we have changes or whole content, we need to LZ decompress them +if (isset($_POST['changes'])) { + $_POST['changes'] = LZString::decompressFromBase64($_POST['changes']); +} +if (isset($_POST['contents'])) { + $_POST['contents'] = LZString::decompressFromBase64($_POST['contents']); +} + // If we have file(s) to work with... if (!$error) { // Replace pipes with slashes, after cleaning the chars @@ -228,7 +244,7 @@ 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='.$_POST["timeStart"].'&file='.$fileURL.'&newFileName=\'+newFileName.replace(/\\\+/g,"%2B")+\'&contents=\'+top.ICEcoder.saveAsContent); + xhr.send(\'timeStart='.$_POST["timeStart"].'&file='.$fileURL.'&newFileName=\'+newFileName.replace(/\\\+/g,"%2B")+\'&contents=\'+encodeURIComponent(top.LZString.compressToBase64(top.ICEcoder.saveAsContent))); top.ICEcoder.serverMessage("'.$t['Saving'].'
" + "'.($finalAction == "Save" ? "newFileName" : "'".$fileName."'").'"); } }