From a259f9e5eefcc211dd16342d339d51d2fe9773c6 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:00:41 +0800 Subject: [PATCH 01/22] try fix: force https in azurewebsite --- platform/Normal.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/platform/Normal.php b/platform/Normal.php index 2cb9e4c..2bc3fb2 100644 --- a/platform/Normal.php +++ b/platform/Normal.php @@ -5,12 +5,13 @@ function getpath() $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]); if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; if (isset($_SERVER['HTTP_FLY_CLIENT_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_FLY_CLIENT_IP']; + if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO']; + if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') { + $tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0]; + if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp; + } if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') { - if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') { - $tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0]; - if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp; - } - if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO']; + $_SERVER['REQUEST_SCHEME'] = 'http'; } $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2]; @@ -22,8 +23,6 @@ function getpath() else $path = $_SERVER['REQUEST_URI']; $path = path_format( substr($path, strlen($_SERVER['base_path'])) ); return $path; - //return substr($path, 1); - //return spurlencode($path, '/'); } function getGET() From 7329e5136891bc8b9c9e6c8f2f37224993c9cc70 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:05:10 +0800 Subject: [PATCH 02/22] show md when no file listing --- theme/classic.html | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/theme/classic.html b/theme/classic.html index 94273f7..d22dd42 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -483,9 +483,9 @@
- + @@ -524,8 +524,20 @@ } } + + var $head = document.getElementById('head'); + if ($head) { + //document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div')); + $head.innerHTML = marked(document.getElementById('head-md').innerText); + } + + + var $readme = document.getElementById('readme'); + if ($readme) { + $readme.innerHTML = marked(document.getElementById('readme-md').innerText); + } + - var $url = document.getElementById('url'); if ($url) { @@ -650,19 +662,6 @@ } - - var $head = document.getElementById('head'); - if ($head) { - //document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div')); - $head.innerHTML = marked(document.getElementById('head-md').innerText); - } - - - var $readme = document.getElementById('readme'); - if ($readme) { - $readme.innerHTML = marked(document.getElementById('readme-md').innerText); - } - function showthumbnails(obj) { From 4a866c8aa20ab0c16b380e7493f45f11e5f652bc Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 17 Feb 2022 18:05:13 +0800 Subject: [PATCH 03/22] load sha1.js from program --- common.php | 75 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/common.php b/common.php index 32d0a37..177c5aa 100644 --- a/common.php +++ b/common.php @@ -174,6 +174,16 @@ function main($path) $_SERVER['sitename'] = getConfig('sitename'); if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename'); + if (isset($_GET['jsFile'])) { + if (substr($_GET['jsFile'], -3)!='.js') return output('', 403); + if (!($path==''||$path=='/')) return output('', 308, [ 'Location' => path_format($_SERVER['base_path'] . '/?jsFile=' . $_GET['jsFile']) ]); + $jsFile = file_get_contents('js/' . $_GET['jsFile']); + if (!!$jsFile) { + return output( base64_encode($jsFile), 200, [ 'Content-Type' => 'text/javascript; charset=utf-8', 'Cache-Control' => 'max-age=' . 3*24*60*60 ], true ); + } else { + return output('', 404); + } + } if (isset($_GET['WaitFunction'])) { $response = WaitFunction($_GET['WaitFunction']); //var_dump($response); @@ -1146,10 +1156,26 @@ function adminform($name = '', $pass = '', $storage = '', $path = '') f.password1.value = sha1(timestamp + "" + f.password1.value); return true; } catch { - alert("sha1.js not loaded."); + //alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } } + function loadjs(url) { + var xhr = new XMLHttpRequest; + xhr.open("GET", url); + xhr.onload = function(e) { + if (xhr.status==200) { + var script = document.createElement("script"); + script.type = "text/javascript"; + script.text = xhr.responseText; + document.body.appendChild(script); + } else { + console.log(xhr.response); + } + } + xhr.send(null); + } '; $html .= ''; @@ -1950,7 +1976,7 @@ output: try { sha1(1); } catch { - alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } var timestamp = new Date().getTime(); @@ -1993,7 +2019,7 @@ output: try { sha1(1); } catch { - alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } var timestamp = new Date().getTime(); @@ -2030,7 +2056,7 @@ output: try { sha1(1); } catch { - alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } var timestamp = new Date().getTime(); @@ -2038,6 +2064,21 @@ output: f.oldPass.value = sha1(f.oldPass.value + "" + timestamp); return true; } + function loadjs(url) { + var xhr = new XMLHttpRequest; + xhr.open("GET", url); + xhr.onload = function(e) { + if (xhr.status==200) { + var script = document.createElement("script"); + script.type = "text/javascript"; + script.text = xhr.responseText; + document.body.appendChild(script); + } else { + console.log(xhr.response); + } + } + xhr.send(null); + } '; } $html .= ' @@ -2406,12 +2447,21 @@ function render_list($path = '', $files = []) } } if ($_SERVER['is_guestup_path']||( $_SERVER['admin']&&$files['type']=='folder'&&$_SERVER['ishidden']<4 )) { - while (strpos($html, '')) $html = str_replace('', '', $html); - while (strpos($html, '')) $html = str_replace('', '', $html); $now_driver = baseclassofdrive(); - unset($Driver_arr[$now_driver]); - while (strpos($html, '')) $html = str_replace('', '', $html); - while (strpos($html, '')) $html = str_replace('', '', $html); + if ($now_driver) { + while (strpos($html, '')) $html = str_replace('', '', $html); + while (strpos($html, '')) $html = str_replace('', '', $html); + unset($Driver_arr[$now_driver]); + while (strpos($html, '')) $html = str_replace('', '', $html); + while (strpos($html, '')) $html = str_replace('', '', $html); + } else { + while (strpos($html, '')) { + $tmp = splitfirst($html, ''); + $html = $tmp[0]; + $tmp = splitfirst($tmp[1], ''); + $html .= $tmp[1]; + } + } foreach ($Driver_arr as $driver) { while (strpos($html, '')) { $tmp = splitfirst($html, ''); @@ -2840,7 +2890,7 @@ function render_list($path = '', $files = []) $imgextstr = ''; foreach ($exts['img'] as $imgext) $imgextstr .= '\''.$imgext.'\', '; $html = str_replace('', $imgextstr, $html); - + $html = str_replace('', $_SERVER['sitename'], $html); @@ -2870,7 +2920,7 @@ function render_list($path = '', $files = []) if ($diskname=='') $diskname = $_SERVER['disktag']; //if (strlen($diskname)>15) $diskname = substr($diskname, 0, 12).'...'; while (strpos($html, '')) $html = str_replace('', $diskname, $html); - + $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2887,7 +2937,7 @@ function render_list($path = '', $files = []) $headomf = str_replace('', $headomfcontent, $tmp[0]); } $html .= $headomf . $tmp[1]; - + $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2989,7 +3039,6 @@ function render_list($path = '', $files = []) } $html .= $Footomf . $tmp[1]; - $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); From 0271dc5b9fe230f61f5808ecb73768e2cc167f58 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 17 Feb 2022 18:08:37 +0800 Subject: [PATCH 04/22] load sha1.js from program when login --- theme/classic.html | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/theme/classic.html b/theme/classic.html index d22dd42..01efeff 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -519,11 +519,39 @@ f.password1.value = sha1(timestamp + "" + f.password1.value); return true; } catch { - alert("sha1.js not loaded."); + //alert("sha1.js not loaded."); + if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js"); return false; } } + function loadjs(url) { + var xhr = new XMLHttpRequest; + xhr.open("GET", url); + xhr.onload = function(e) { + if (xhr.status==200) { + var script = document.createElement("script"); + script.type = "text/javascript"; + script.text = xhr.responseText; + document.body.appendChild(script); + } else { + console.log(xhr.response); + } + } + xhr.send(null); + } + + var nowtime= new Date(); + var timezone = 0-nowtime.getTimezoneOffset()/60; + var expd = new Date(); + expd.setTime(expd.getTime()+(2*60*60*1000)); + var expires = "expires="+expd.toGMTString(); + document.cookie="timezone="+timezone+"; path=/; "+expires; + if (timezone!=) { + //alert('Your timezone is '+timezone+', reload local timezone.'); + location.href=location.href; + } + var $head = document.getElementById('head'); if ($head) { @@ -792,19 +820,6 @@ return num; } - - - var nowtime= new Date(); - var timezone = 0-nowtime.getTimezoneOffset()/60; - var expd = new Date(); - expd.setTime(expd.getTime()+(2*60*60*1000)); - var expires = "expires="+expd.toGMTString(); - document.cookie="timezone="+timezone+"; path=/; "+expires; - if (timezone!=) { - alert('Your timezone is '+timezone+', reload local timezone.'); - location.href=location.href; - } - function CopyAllDownloadUrl(str) { var tmptextarea=document.createElement('textarea'); document.body.appendChild(tmptextarea); @@ -817,6 +832,7 @@ document.execCommand("copy"); alert(tmptextarea.innerHTML+""); } + function size_format(num) { if (num>1024) { From 46fb778cb53896be165bf78f92cfb474cbda0170 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 17 Feb 2022 18:14:04 +0800 Subject: [PATCH 05/22] Create sha1.min.js --- js/sha1.min.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 js/sha1.min.js diff --git a/js/sha1.min.js b/js/sha1.min.js new file mode 100644 index 0000000..3d297fd --- /dev/null +++ b/js/sha1.min.js @@ -0,0 +1,8 @@ +/** + * Minified by jsDelivr using UglifyJS v3.1.10. + * Original file: /npm/js-sha1@0.6.0/src/sha1.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +!function(){"use strict";function Sha1(t){t?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}var root="object"==typeof window?window:{},NODE_JS=!root.JS_SHA1_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS&&(root=global);var COMMON_JS=!root.JS_SHA1_NO_COMMON_JS&&"object"==typeof module&&module.exports,AMD="function"==typeof define&&define.amd,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[],createOutputMethod=function(t){return function(h){return new Sha1(!0).update(h)[t]()}},createMethod=function(){var t=createOutputMethod("hex");NODE_JS&&(t=nodeWrap(t)),t.create=function(){return new Sha1},t.update=function(h){return t.create().update(h)};for(var h=0;h>2]|=t[i]<>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(o[e>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=64?(this.block=o[16],this.start=e-64,this.hash(),this.hashed=!0):this.start=e}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,h=this.lastByteIndex;t[16]=this.block,t[h>>2]|=EXTRA[3&h],this.block=t[16],h>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var t,h,s=this.h0,e=this.h1,i=this.h2,r=this.h3,o=this.h4,H=this.blocks;for(t=16;t<80;++t)h=H[t-3]^H[t-8]^H[t-14]^H[t-16],H[t]=h<<1|h>>>31;for(t=0;t<20;t+=5)s=(h=(e=(h=(i=(h=(r=(h=(o=(h=s<<5|s>>>27)+(e&i|~e&r)+o+1518500249+H[t]<<0)<<5|o>>>27)+(s&(e=e<<30|e>>>2)|~s&i)+r+1518500249+H[t+1]<<0)<<5|r>>>27)+(o&(s=s<<30|s>>>2)|~o&e)+i+1518500249+H[t+2]<<0)<<5|i>>>27)+(r&(o=o<<30|o>>>2)|~r&s)+e+1518500249+H[t+3]<<0)<<5|e>>>27)+(i&(r=r<<30|r>>>2)|~i&o)+s+1518500249+H[t+4]<<0,i=i<<30|i>>>2;for(;t<40;t+=5)s=(h=(e=(h=(i=(h=(r=(h=(o=(h=s<<5|s>>>27)+(e^i^r)+o+1859775393+H[t]<<0)<<5|o>>>27)+(s^(e=e<<30|e>>>2)^i)+r+1859775393+H[t+1]<<0)<<5|r>>>27)+(o^(s=s<<30|s>>>2)^e)+i+1859775393+H[t+2]<<0)<<5|i>>>27)+(r^(o=o<<30|o>>>2)^s)+e+1859775393+H[t+3]<<0)<<5|e>>>27)+(i^(r=r<<30|r>>>2)^o)+s+1859775393+H[t+4]<<0,i=i<<30|i>>>2;for(;t<60;t+=5)s=(h=(e=(h=(i=(h=(r=(h=(o=(h=s<<5|s>>>27)+(e&i|e&r|i&r)+o-1894007588+H[t]<<0)<<5|o>>>27)+(s&(e=e<<30|e>>>2)|s&i|e&i)+r-1894007588+H[t+1]<<0)<<5|r>>>27)+(o&(s=s<<30|s>>>2)|o&e|s&e)+i-1894007588+H[t+2]<<0)<<5|i>>>27)+(r&(o=o<<30|o>>>2)|r&s|o&s)+e-1894007588+H[t+3]<<0)<<5|e>>>27)+(i&(r=r<<30|r>>>2)|i&o|r&o)+s-1894007588+H[t+4]<<0,i=i<<30|i>>>2;for(;t<80;t+=5)s=(h=(e=(h=(i=(h=(r=(h=(o=(h=s<<5|s>>>27)+(e^i^r)+o-899497514+H[t]<<0)<<5|o>>>27)+(s^(e=e<<30|e>>>2)^i)+r-899497514+H[t+1]<<0)<<5|r>>>27)+(o^(s=s<<30|s>>>2)^e)+i-899497514+H[t+2]<<0)<<5|i>>>27)+(r^(o=o<<30|o>>>2)^s)+e-899497514+H[t+3]<<0)<<5|e>>>27)+(i^(r=r<<30|r>>>2)^o)+s-899497514+H[t+4]<<0,i=i<<30|i>>>2;this.h0=this.h0+s<<0,this.h1=this.h1+e<<0,this.h2=this.h2+i<<0,this.h3=this.h3+r<<0,this.h4=this.h4+o<<0},Sha1.prototype.hex=function(){this.finalize();var t=this.h0,h=this.h1,s=this.h2,e=this.h3,i=this.h4;return HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[h>>28&15]+HEX_CHARS[h>>24&15]+HEX_CHARS[h>>20&15]+HEX_CHARS[h>>16&15]+HEX_CHARS[h>>12&15]+HEX_CHARS[h>>8&15]+HEX_CHARS[h>>4&15]+HEX_CHARS[15&h]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var t=this.h0,h=this.h1,s=this.h2,e=this.h3,i=this.h4;return[t>>24&255,t>>16&255,t>>8&255,255&t,h>>24&255,h>>16&255,h>>8&255,255&h,s>>24&255,s>>16&255,s>>8&255,255&s,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24&255,i>>16&255,i>>8&255,255&i]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(20),h=new DataView(t);return h.setUint32(0,this.h0),h.setUint32(4,this.h1),h.setUint32(8,this.h2),h.setUint32(12,this.h3),h.setUint32(16,this.h4),t};var exports=createMethod();COMMON_JS?module.exports=exports:(root.sha1=exports,AMD&&define(function(){return exports}))}(); +//# sourceMappingURL=/sm/dad6bd9f16f12d9db4b0e4eaae5c5f614cb87edf6808e087afac03051831773b.map From eb1319119a3ff757a1fef22d9f23c952081703eb Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 18 Feb 2022 16:11:23 +0800 Subject: [PATCH 06/22] check txtfile charset --- common.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 177c5aa..41991b6 100644 --- a/common.php +++ b/common.php @@ -727,6 +727,19 @@ function sortConfig(&$arr) return $arr; } +function chkTxtCode($str) { + $code = array( + 'ASCII', + 'GBK', + 'UTF-8', + 'UTF-16', + ); + foreach ($code as $c) { + if ($str === iconv('UTF-8', $c, iconv($c, 'UTF-8', $str))) return $c; + } + return false; +} + function getconstStr($str) { global $constStr; @@ -2555,8 +2568,9 @@ function render_list($path = '', $files = []) if (strpos($html, '')) { //$tmp_content = get_content(spurlencode(path_format(urldecode($path)), '/'))['content']['body']; $tmp_content = $files['content']['body']; - if (strlen($tmp_content)==$files['size']) $html = str_replace('', htmlspecialchars($tmp_content), $html); - else $html = str_replace('', $files['size']<1024*1024?htmlspecialchars(curl('GET', $files['url'], '', [], 0, 1)['body']):"File too large: " . $files['size'] . " B.", $html); + //if (strlen($tmp_content)==$files['size']) + $html = str_replace('', htmlspecialchars($tmp_content), $html); + //else $html = str_replace('', $files['size']<1024*1024?htmlspecialchars(curl('GET', $files['url'], '', [], 0, 1)['body']):"File too large: " . $files['size'] . " B.", $html); } $html = str_replace('', getconstStr('FileNotSupport'), $html); From e209d98ad87c26fef0e94325f71f5f9b9f1094e1 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 18 Feb 2022 16:13:38 +0800 Subject: [PATCH 07/22] check txtfile charset --- disk/Onedrive.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/disk/Onedrive.php b/disk/Onedrive.php index 949b4ea..d179bbc 100644 --- a/disk/Onedrive.php +++ b/disk/Onedrive.php @@ -57,9 +57,27 @@ class Onedrive { if (isset($parentfiles['children'][$filename][$this->DownurlStrName])) { if (in_array(splitlast($filename,'.')[1], $exts['txt'])) { if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) { - $content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]); - $parentfiles['children'][$filename]['content'] = $content1; - savecache('path_' . $parentpath, $parentfiles, $this->disktag); + //$content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]); + //$parentfiles['children'][$filename]['content'] = $content1; + //savecache('path_' . $parentpath, $parentfiles, $this->disktag); + if ($$parentfiles['children'][$filename]['size']<1024*1024) { + if (!(isset($$parentfiles['children'][$filename]['content'])&&$$parentfiles['children'][$filename]['content']['stat']==200)) { + $content1 = curl('GET', $$parentfiles['children'][$filename][$this->DownurlStrName]); + $tmp = null; + $tmp = json_decode(json_encode($content1), true); + if ($tmp['body']===null) { + $txtcode = chkTxtCode($content1['body']); + if ($txtcode!==false) $tmp['body'] = iconv($txtcode, 'UTF-8//TRANSLIT', $content1['body']); + $tmp = json_decode(json_encode($tmp), true); + if ($tmp['body']) $content1['body'] = $tmp['body']; + } + $$parentfiles['children'][$filename]['content'] = $content1; + savecache('path_' . $path, $$parentfiles['children'][$filename], $this->disktag); + } + } else { + $$parentfiles['children'][$filename]['content']['stat'] = 202; + $$parentfiles['children'][$filename]['content']['body'] = 'File too large.'; + } } } return $this->files_format($parentfiles['children'][$filename]); @@ -107,9 +125,10 @@ class Onedrive { $tmp = null; $tmp = json_decode(json_encode($content1), true); if ($tmp['body']===null) { - $tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']); + $txtcode = chkTxtCode($content1['body']); + if ($txtcode!==false) $tmp['body'] = iconv($txtcode, 'UTF-8//TRANSLIT', $content1['body']); $tmp = json_decode(json_encode($tmp), true); - if ($tmp['body']!==null) $content1['body'] = $tmp['body']; + if ($tmp['body']) $content1['body'] = $tmp['body']; } $files['content'] = $content1; savecache('path_' . $path, $files, $this->disktag); From 5433fe05220c8667c486287204066ad37c2cad9c Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 18 Feb 2022 16:15:12 +0800 Subject: [PATCH 08/22] add log in txt --- conststr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conststr.php b/conststr.php index 5b5d81c..403f5d1 100644 --- a/conststr.php +++ b/conststr.php @@ -6,7 +6,7 @@ global $constStr; $exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff', 'png', 'heic', 'webp']; $exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a']; $exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; -$exts['txt'] = ['txt', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf']; +$exts['txt'] = ['txt', 'log', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf']; $exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', '3gp', 'rmvb']; $exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar']; From 8d6864f145ff08fefd938e30692be60fb65bd4c9 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 18 Feb 2022 18:24:13 +0800 Subject: [PATCH 09/22] fix: can read js in ../ --- common.php | 1 + 1 file changed, 1 insertion(+) diff --git a/common.php b/common.php index 41991b6..38d2adc 100644 --- a/common.php +++ b/common.php @@ -177,6 +177,7 @@ function main($path) if (isset($_GET['jsFile'])) { if (substr($_GET['jsFile'], -3)!='.js') return output('', 403); if (!($path==''||$path=='/')) return output('', 308, [ 'Location' => path_format($_SERVER['base_path'] . '/?jsFile=' . $_GET['jsFile']) ]); + if (strpos($_GET['jsFile'], '/')>-1) $_GET['jsFile'] = splitlast($_GET['jsFile'], '/')[1]; $jsFile = file_get_contents('js/' . $_GET['jsFile']); if (!!$jsFile) { return output( base64_encode($jsFile), 200, [ 'Content-Type' => 'text/javascript; charset=utf-8', 'Cache-Control' => 'max-age=' . 3*24*60*60 ], true ); From c48ebba1781d8de2e76803b0c30ac71250965b77 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sat, 19 Feb 2022 13:41:00 +0800 Subject: [PATCH 10/22] fix $$ bug --- disk/Onedrive.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/disk/Onedrive.php b/disk/Onedrive.php index d179bbc..875b767 100644 --- a/disk/Onedrive.php +++ b/disk/Onedrive.php @@ -60,9 +60,9 @@ class Onedrive { //$content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]); //$parentfiles['children'][$filename]['content'] = $content1; //savecache('path_' . $parentpath, $parentfiles, $this->disktag); - if ($$parentfiles['children'][$filename]['size']<1024*1024) { - if (!(isset($$parentfiles['children'][$filename]['content'])&&$$parentfiles['children'][$filename]['content']['stat']==200)) { - $content1 = curl('GET', $$parentfiles['children'][$filename][$this->DownurlStrName]); + if ($parentfiles['children'][$filename]['size']<1024*1024) { + if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) { + $content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]); $tmp = null; $tmp = json_decode(json_encode($content1), true); if ($tmp['body']===null) { @@ -71,12 +71,12 @@ class Onedrive { $tmp = json_decode(json_encode($tmp), true); if ($tmp['body']) $content1['body'] = $tmp['body']; } - $$parentfiles['children'][$filename]['content'] = $content1; - savecache('path_' . $path, $$parentfiles['children'][$filename], $this->disktag); + $parentfiles['children'][$filename]['content'] = $content1; + savecache('path_' . $path, $parentfiles['children'][$filename], $this->disktag); } } else { - $$parentfiles['children'][$filename]['content']['stat'] = 202; - $$parentfiles['children'][$filename]['content']['body'] = 'File too large.'; + $parentfiles['children'][$filename]['content']['stat'] = 202; + $parentfiles['children'][$filename]['content']['body'] = 'File too large.'; } } } From a7acdaeb7c637a35bf8939000ea7ee12a8bf062d Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 22 Feb 2022 10:25:45 +0800 Subject: [PATCH 11/22] change sha1.js from jsdelivr to unpkg --- common.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 38d2adc..7e674f5 100644 --- a/common.php +++ b/common.php @@ -732,6 +732,7 @@ function chkTxtCode($str) { $code = array( 'ASCII', 'GBK', + 'GB18030', 'UTF-8', 'UTF-16', ); @@ -1191,7 +1192,7 @@ function adminform($name = '', $pass = '', $storage = '', $path = '') xhr.send(null); } -'; +'; $html .= ''; return output($html, $statusCode); } @@ -1949,7 +1950,7 @@ output: $frame .= getconstStr('NotNeedUpdate'); }*/ $frame .= '

- + From cfdebf35b7a4ca0c14e48cc77d21f7a3b4753bcb Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 22 Feb 2022 10:26:57 +0800 Subject: [PATCH 12/22] change sha1.js&ionicons.js from jsdelivr to unpkg --- theme/classic.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/theme/classic.html b/theme/classic.html index 01efeff..e5e8796 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -487,7 +487,7 @@ - + - - + + From 6eb6a826cf53782cff4a85fb60af182533ac2442 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 22 Feb 2022 10:38:40 +0800 Subject: [PATCH 13/22] change sortablejs to unpkg --- common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.php b/common.php index 7e674f5..67f9cc9 100644 --- a/common.php +++ b/common.php @@ -1716,7 +1716,7 @@ output: } else { if (count($disktags)>1) { $frame .= ' - +