From 09fde0c3e5f63d6716d9b5bff50bddebc1f64dca Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 16 Mar 2016 13:27:48 +0000 Subject: [PATCH 01/24] Only get statusObj if we have status 200 A non 200 event means there may not be a statusObj, which in turn causes an error which causes a JS jam --- lib/ice-coder.js | 76 +++++++++++++++++++++++--------------------- lib/ice-coder.min.js | 8 ++--- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 6a8609c..f293ab8 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -1638,27 +1638,28 @@ var ICEcoder = { xhr = top.ICEcoder.xhrObj(); xhr.onreadystatechange=function() { if (xhr.readyState==4) { - // Parse the response as a JSON object - statusObj = JSON.parse(xhr.responseText); - - // Set the action end time and time taken in JSON object - statusObj.action.timeEnd = new Date().getTime(); - statusObj.action.timeTaken = statusObj.action.timeEnd - statusObj.action.timeStart; - - // User wanted raw (or both) output of the response? - if (["raw","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { - console.log(xhr.responseText); - } - // User wanted object (or both) output of the response? - if (["object","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { - console.log(statusObj); - } - - // Also store the statusObj - top.ICEcoder.lastFileDirCheckStatusObj = statusObj; - - // OK reponse? If error, show that, otherwise do whatever we're required to do next + // OK reponse? if (xhr.status==200) { + // Parse the response as a JSON object + statusObj = JSON.parse(xhr.responseText); + + // Set the action end time and time taken in JSON object + statusObj.action.timeEnd = new Date().getTime(); + statusObj.action.timeTaken = statusObj.action.timeEnd - statusObj.action.timeStart; + + // User wanted raw (or both) output of the response? + if (["raw","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { + console.log(xhr.responseText); + } + // User wanted object (or both) output of the response? + if (["object","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { + console.log(statusObj); + } + + // Also store the statusObj + top.ICEcoder.lastFileDirCheckStatusObj = statusObj; + + // If error, show that, otherwise do whatever we're required to do next if (statusObj.status.error) { top.ICEcoder.message(statusObj.status.errorMsg); console.log("ICEcoder error info for your request..."); @@ -2546,24 +2547,25 @@ var ICEcoder = { xhr = top.ICEcoder.xhrObj(); xhr.onreadystatechange=function() { if (xhr.readyState==4) { - // Parse the response as a JSON object - statusObj = JSON.parse(xhr.responseText); - - // Set the action end time and time taken in JSON object - statusObj.action.timeEnd = new Date().getTime(); - statusObj.action.timeTaken = statusObj.action.timeEnd - statusObj.action.timeStart; - - // User wanted raw (or both) output of the response? - if (["raw","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { - console.log(xhr.responseText); - } - // User wanted object (or both) output of the response? - if (["object","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { - console.log(statusObj); - } - - // OK reponse? If error, show that, otherwise do whatever we're required to do next + // OK reponse? if (xhr.status==200) { + // Parse the response as a JSON object + statusObj = JSON.parse(xhr.responseText); + + // Set the action end time and time taken in JSON object + statusObj.action.timeEnd = new Date().getTime(); + statusObj.action.timeTaken = statusObj.action.timeEnd - statusObj.action.timeStart; + + // User wanted raw (or both) output of the response? + if (["raw","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { + console.log(xhr.responseText); + } + // User wanted object (or both) output of the response? + if (["object","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) { + console.log(statusObj); + } + + // If error, show that, otherwise do whatever we're required to do next if (statusObj.status.error) { top.ICEcoder.message(statusObj.status.errorMsg); console.log("ICEcoder error info for your request..."); diff --git a/lib/ice-coder.min.js b/lib/ice-coder.min.js index 863b8ce..1ddef04 100644 --- a/lib/ice-coder.min.js +++ b/lib/ice-coder.min.js @@ -66,8 +66,8 @@ deleteFiles:function(a){var b;a=a?a:top.ICEcoder.selectedFiles;b=a.toString().re else top.ICEcoder.message(top.t["Nothing to paste..."])},duplicateFiles:function(a){var b;top.ICEcoder.copiedFiles&&(b=top.ICEcoder.copiedFiles);top.ICEcoder.copyFiles(a,"dontShowPaste","dontHide");a=a[0].substr(0,a[0].lastIndexOf("|"));top.ICEcoder.pasteFiles(a);"undefined"!=typeof b&&(top.ICEcoder.copiedFiles=b)},uploadFilesSelect:function(a){top.get("uploadDir").value=a;top.get("fileInput").click()},uploadFilesSubmit:function(a){""!=top.get("fileInput").value&&(top.ICEcoder.showHide("show",top.get("loadingMask")), top.get("uploadFilesForm").submit(),event.preventDefault())},showHideFileNav:function(a,b){var c=["optionsFile","optionsEdit","optionsSource","optionsHelp"];if("hide"==a)fileNavInt=setTimeout(function(){for(var a=0;ac&&(b-=b+a-c),top.get("fileMenu").style.top=b+"px");return!1},showFileMenu:function(){top.get("fileMenu").style.display="inline-block";setTimeout(function(){top.get("fileMenu").style.opacity="1"},4)},hideFileMenu:function(){top.get("fileMenu").style.display="none";top.get("fileMenu").style.opacity="0"},updateFileManagerList:function(a,b,c,d,e,f,g){var k,h,l,p,n,m,q;if("add"==a&&!top.get("filesFrame").contentWindow.document.getElementById(b.replace(top.iceRoot, @@ -108,8 +108,8 @@ top.ICEcoder.csrf);top.ICEcoder["plugTimer"+a]=-1<["_parent","_top","_self",""]. !top.ICEcoder.codeAssist;top.get("codeAssistDisplay").style.backgroundPosition=top.ICEcoder.codeAssist?"0 0":"-16px 0";top.ICEcoder.cssColorPreview();top.ICEcoder.focus(-1'+top.t["Cancelled tasks"]+"");setTimeout(function(){top.ICEcoder.serverMessage()},2E3)},setPreviousFiles:function(){var a;a=top.ICEcoder.openFiles.join(",").replace(/\//g,"|").replace(/(\|\[NEW\])|(,\|\[NEW\])/g,"").replace(/(^,)|(,$)/g,"");""==a&&(a="CLEAR");top.ICEcoder.serverQueue("add", "lib/settings.php?saveFiles="+a+"&csrf="+top.ICEcoder.csrf);top.ICEcoder.updateLast10List(a)},updateLast10List:function(a){var b,c,d;a=a.split(",");for(var e=0;e"+a[e].replace(/\|/g,"/")+"\n",c=top.ICEcoder.content.contentWindow.document.getElementById("last10Files"),-1== From 7d8b22915389879e81491fedc4e019cd75f86909 Mon Sep 17 00:00:00 2001 From: MicroVB INC Date: Wed, 16 Mar 2016 12:59:59 -0400 Subject: [PATCH 02/24] Context is now accessible inside GetVersionCount() globalized $context inside `GetVersionCount()` to eliminate `Notice: Undefined variable: context in /var/www/html/ice/lib/settings-common.php on line 203` Added check if file is readable for `.version-index`'s inside the loop within `GetVersionCount()` --- lib/settings-common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/settings-common.php b/lib/settings-common.php index 63073ad..cdd7198 100644 --- a/lib/settings-common.php +++ b/lib/settings-common.php @@ -182,6 +182,7 @@ if (!function_exists('array_replace_recursive')) { // Get number of versions total for a file function getVersionsCount($fileLoc,$fileName) { + global $context; $count = 0; $dateCounts = array(); // Establish the base, host and date dirs within... @@ -199,7 +200,7 @@ function getVersionsCount($fileLoc,$fileName) { for ($i=0; $i Date: Wed, 16 Mar 2016 18:30:21 +0000 Subject: [PATCH 03/24] LS String PHP lib added To compress and decompress strings with LZ compression --- LZCompressor/LZContext.php | 91 +++++++++ LZCompressor/LZData.php | 29 +++ LZCompressor/LZReverseDictionary.php | 33 ++++ LZCompressor/LZString.php | 286 +++++++++++++++++++++++++++ LZCompressor/LZUtil.php | 112 +++++++++++ 5 files changed, 551 insertions(+) create mode 100644 LZCompressor/LZContext.php create mode 100644 LZCompressor/LZData.php create mode 100644 LZCompressor/LZReverseDictionary.php create mode 100644 LZCompressor/LZString.php create mode 100644 LZCompressor/LZUtil.php diff --git a/LZCompressor/LZContext.php b/LZCompressor/LZContext.php new file mode 100644 index 0000000..0e41a3e --- /dev/null +++ b/LZCompressor/LZContext.php @@ -0,0 +1,91 @@ +data = new LZData; + } + + // Helper + + /** + * @param string $val + * @return bool + */ + public function dictionaryContains($val) { + return array_key_exists($val, $this->dictionary); + } + + /** + * @param $val + */ + public function addToDictionary($val) { + $this->dictionary[$val] = $this->dictSize++; + } + + /** + * @param string $val + * @return bool + */ + public function dictionaryToCreateContains($val) { + return array_key_exists($val, $this->dictionaryToCreate); + } + + /** + * decrements enlargeIn and extends numbits in case enlargeIn drops to 0 + */ + public function enlargeIn() { + $this->enlargeIn--; + if($this->enlargeIn==0) { + $this->enlargeIn = pow(2, $this->numBits); + $this->numBits++; + } + } +} diff --git a/LZCompressor/LZData.php b/LZCompressor/LZData.php new file mode 100644 index 0000000..b536ce1 --- /dev/null +++ b/LZCompressor/LZData.php @@ -0,0 +1,29 @@ +str .= $str; + } +} diff --git a/LZCompressor/LZReverseDictionary.php b/LZCompressor/LZReverseDictionary.php new file mode 100644 index 0000000..264caa4 --- /dev/null +++ b/LZCompressor/LZReverseDictionary.php @@ -0,0 +1,33 @@ +entries); + } + + public function hasEntry($index) { + return array_key_exists($index, $this->entries); + } + + public function getEntry($index) { + return $this->entries[$index]; + } + + public function addEntry($char) { + $this->entries[] = $char; + } + +} \ No newline at end of file diff --git a/LZCompressor/LZString.php b/LZCompressor/LZString.php new file mode 100644 index 0000000..75791fa --- /dev/null +++ b/LZCompressor/LZString.php @@ -0,0 +1,286 @@ +c = LZUtil::utf8_charAt($uncompressed, $ii); + if(!$context->dictionaryContains($context->c)) { + $context->addToDictionary($context->c); + $context->dictionaryToCreate[$context->c] = true; + } + $context->wc = $context->w . $context->c; + if($context->dictionaryContains($context->wc)) { + $context->w = $context->wc; + } else { + self::produceW($context, $bitsPerChar, $getCharFromInt); + } + } + if($context->w !== '') { + self::produceW($context, $bitsPerChar, $getCharFromInt); + } + + $value = 2; + for($i=0; $i<$context->numBits; $i++) { + self::writeBit($value&1, $context->data, $bitsPerChar, $getCharFromInt); + $value = $value >> 1; + } + + while (true) { + $context->data->val = $context->data->val << 1; + if ($context->data->position == ($bitsPerChar-1)) { + $context->data->append($getCharFromInt($context->data->val)); + break; + } + $context->data->position++; + } + + return $context->data->str; + } + + /** + * @param LZContext $context + * @param integer $bitsPerChar + * @param callable $getCharFromInt + * + * @return LZContext + */ + private static function produceW(LZContext $context, $bitsPerChar, $getCharFromInt) + { + if($context->dictionaryToCreateContains($context->w)) { + if(LZUtil::charCodeAt($context->w)<256) { + for ($i=0; $i<$context->numBits; $i++) { + self::writeBit(null, $context->data, $bitsPerChar, $getCharFromInt); + } + $value = LZUtil::charCodeAt($context->w); + for ($i=0; $i<8; $i++) { + self::writeBit($value&1, $context->data, $bitsPerChar, $getCharFromInt); + $value = $value >> 1; + } + } else { + $value = 1; + for ($i=0; $i<$context->numBits; $i++) { + self::writeBit($value, $context->data, $bitsPerChar, $getCharFromInt); + $value = 0; + } + $value = LZUtil::charCodeAt($context->w); + for ($i=0; $i<16; $i++) { + self::writeBit($value&1, $context->data, $bitsPerChar, $getCharFromInt); + $value = $value >> 1; + } + } + $context->enlargeIn(); + unset($context->dictionaryToCreate[$context->w]); + } else { + $value = $context->dictionary[$context->w]; + for ($i=0; $i<$context->numBits; $i++) { + self::writeBit($value&1, $context->data, $bitsPerChar, $getCharFromInt); + $value = $value >> 1; + } + } + $context->enlargeIn(); + $context->addToDictionary($context->wc); + $context->w = $context->c.''; + } + + /** + * @param string $value + * @param LZData $data + * @param integer $bitsPerChar + * @param callable $getCharFromInt + */ + private static function writeBit($value, LZData $data, $bitsPerChar, $getCharFromInt) + { + if(null !== $value) { + $data->val = ($data->val << 1) | $value; + } else { + $data->val = ($data->val << 1); + } + if ($data->position == ($bitsPerChar-1)) { + $data->position = 0; + $data->append($getCharFromInt($data->val)); + $data->val = 0; + } else { + $data->position++; + } + } + + /** + * @param LZData $data + * @param integer $resetValue + * @param callable $getNextValue + * @param integer $exponent + * @param string $feed + * @return integer + */ + private static function readBits(LZData $data, $resetValue, $getNextValue, $feed, $exponent) + { + $bits = 0; + $maxPower = pow(2, $exponent); + $power=1; + while($power != $maxPower) { + $resb = $data->val & $data->position; + $data->position >>= 1; + if ($data->position == 0) { + $data->position = $resetValue; + $data->val = $getNextValue($feed, $data->index++); + } + $bits |= (($resb>0 ? 1 : 0) * $power); + $power <<= 1; + } + return $bits; + } + + /** + * @param string $compressed + * @param integer $resetValue + * @param callable $getNextValue + * @return string + */ + private static function _decompress($compressed, $resetValue, $getNextValue) + { + if(!is_string($compressed) || strlen($compressed) === 0) { + return ''; + } + + $length = LZUtil::utf8_strlen($compressed); + $entry = null; + $enlargeIn = 4; + $numBits = 3; + $result = ''; + + $dictionary = new LZReverseDictionary(); + + $data = new LZData(); + $data->str = $compressed; + $data->val = $getNextValue($compressed, 0); + $data->position = $resetValue; + $data->index = 1; + + $next = self::readBits($data, $resetValue, $getNextValue, $compressed, 2); + + if($next < 0 || $next > 1) { + return ''; + } + + $exponent = ($next == 0) ? 8 : 16; + $bits = self::readBits($data, $resetValue, $getNextValue, $compressed, $exponent); + + $c = LZUtil::fromCharCode($bits); + $dictionary->addEntry($c); + $w = $c; + + $result .= $c; + + while(true) { + if($data->index > $length) { + return ''; + } + $bits = self::readBits($data, $resetValue, $getNextValue, $compressed, $numBits); + + $c = $bits; + + switch($c) { + case 0: + $bits = self::readBits($data, $resetValue, $getNextValue, $compressed, 8); + $c = $dictionary->size(); + $dictionary->addEntry(LZUtil::fromCharCode($bits)); + $enlargeIn--; + break; + case 1: + $bits = self::readBits($data, $resetValue, $getNextValue, $compressed, 16); + $c = $dictionary->size(); + $dictionary->addEntry(LZUtil::fromCharCode($bits)); + $enlargeIn--; + break; + case 2: + return $result; + break; + } + + if($enlargeIn == 0) { + $enlargeIn = pow(2, $numBits); + $numBits++; + } + + if($dictionary->hasEntry($c)) { + $entry = $dictionary->getEntry($c); + } + else { + if ($c == $dictionary->size()) { + $entry = $w . $w{0}; + } else { + return null; + } + } + + $result .= $entry; + $dictionary->addEntry($w . $entry{0}); + $w = $entry; + + $enlargeIn--; + if($enlargeIn == 0) { + $enlargeIn = pow(2, $numBits); + $numBits++; + } + } + } +} diff --git a/LZCompressor/LZUtil.php b/LZCompressor/LZUtil.php new file mode 100644 index 0000000..4b27a1e --- /dev/null +++ b/LZCompressor/LZUtil.php @@ -0,0 +1,112 @@ + 1) return ($h & 0x1F) << 6 | (ord($ch{1}) & 0x3F); + if ($h <= 0xEF && $len > 2) return ($h & 0x0F) << 12 | (ord($ch{1}) & 0x3F) << 6 | (ord($ch{2}) & 0x3F); + if ($h <= 0xF4 && $len > 3) + return ($h & 0x0F) << 18 | (ord($ch{1}) & 0x3F) << 12 | (ord($ch{2}) & 0x3F) << 6 | (ord($ch{3}) & 0x3F); + return -2; + } + + /** + * @param string $str + * @param integer $num + * + * @return string + */ + public static function utf8_charAt($str, $num) + { + return mb_substr($str, $num, 1, 'UTF-8'); + } + + /** + * @param string $str + * @return integer + */ + public static function utf8_strlen($str) { + return mb_strlen($str, 'UTF-8'); + } + + +} \ No newline at end of file From 4581d325514c2b6011d9edfc640caf618815d472 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 16 Mar 2016 18:32:03 +0000 Subject: [PATCH 04/24] LZ String JS lib added Compress and decompress strings with LZ compression in JS --- lib/lz-string.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 lib/lz-string.min.js diff --git a/lib/lz-string.min.js b/lib/lz-string.min.js new file mode 100644 index 0000000..b2088b1 --- /dev/null +++ b/lib/lz-string.min.js @@ -0,0 +1 @@ +var LZString=function(){function o(o,r){if(!t[o]){t[o]={};for(var n=0;ne;e++){var s=r.charCodeAt(e);n[2*e]=s>>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null===o||void 0===o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;t>e;e++)n[e]=256*o[2*e]+o[2*e+1];var s=[];return n.forEach(function(o){s.push(r(o))}),i.decompress(s.join(""))},compressToEncodedURIComponent:function(o){return null==o?"":i._compress(o,6,function(o){return e.charAt(o)})},decompressFromEncodedURIComponent:function(r){return null==r?"":""==r?null:(r=r.replace(/ /g,"+"),i._decompress(r.length,32,function(n){return o(e,r.charAt(n))}))},compress:function(o){return i._compress(o,16,function(o){return r(o)})},_compress:function(o,r,n){if(null==o)return"";var e,t,i,s={},p={},u="",c="",a="",l=2,f=3,h=2,d=[],m=0,v=0;for(i=0;ie;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++),s[c]=f++,a=String(u)}if(""!==a){if(Object.prototype.hasOwnProperty.call(p,a)){if(a.charCodeAt(0)<256){for(e=0;h>e;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==r-1){d.push(n(m));break}v++}return d.join("")},decompress:function(o){return null==o?"":""==o?null:i._decompress(o.length,32768,function(r){return o.charCodeAt(r)})},_decompress:function(o,n,e){var t,i,s,p,u,c,a,l,f=[],h=4,d=4,m=3,v="",w=[],A={val:e(0),position:n,index:1};for(i=0;3>i;i+=1)f[i]=i;for(p=0,c=Math.pow(2,2),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(t=p){case 0:for(p=0,c=Math.pow(2,8),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 1:for(p=0,c=Math.pow(2,16),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 2:return""}for(f[3]=l,s=l,w.push(l);;){if(A.index>o)return"";for(p=0,c=Math.pow(2,m),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(l=p){case 0:for(p=0,c=Math.pow(2,8),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;f[d++]=r(p),l=d-1,h--;break;case 1:for(p=0,c=Math.pow(2,16),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;f[d++]=r(p),l=d-1,h--;break;case 2:return w.join("")}if(0==h&&(h=Math.pow(2,m),m++),f[l])v=f[l];else{if(l!==d)return null;v=s+s.charAt(0)}w.push(v),f[d++]=s+v.charAt(0),h--,s=v,0==h&&(h=Math.pow(2,m),m++)}}};return i}();"function"==typeof define&&define.amd?define(function(){return LZString}):"undefined"!=typeof module&&null!=module&&(module.exports=LZString); \ No newline at end of file From 8d082120f6918054122bfc129e91e82ec0af9075 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 16 Mar 2016 18:57:00 +0000 Subject: [PATCH 05/24] Load JS LZ String lib --- index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/index.php b/index.php index 516dcf6..cbe83d0 100644 --- a/index.php +++ b/index.php @@ -80,6 +80,7 @@ $t = $text['index']; + From d8eb2b72db4975e061cf2bac0f62f09168055a4c Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 16 Mar 2016 19:51:17 +0000 Subject: [PATCH 06/24] Load LZ PHP lib, convert posted content, set on XHR --- lib/file-control-xhr.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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."'").'"); } } From cba7f06b4ead12dfe7bb3aea785dd0c75edaa7c9 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 16 Mar 2016 19:51:59 +0000 Subject: [PATCH 07/24] Load LZ PHP lib, compress and decompress contents --- lib/file-control.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/file-control.php b/lib/file-control.php index f1fcd37..9d2946b 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -3,6 +3,14 @@ include("headers.php"); 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; ?> @@ -102,7 +110,7 @@ if ($_GET['action']=="load") { $encoding=ini_get("default_charset"); if($encoding=="") $encoding="UTF-8"; - echo '