diff --git a/common.php b/common.php index a1663b3..19613c0 100644 --- a/common.php +++ b/common.php @@ -42,6 +42,7 @@ $EnvConfigs = [ 'globalHeadMdUrl' => 0b011, 'globalReadmeMdUrl' => 0b011, 'globalFootOmfUrl' => 0b011, + 'bcmathUrl' => 0b011, 'Driver' => 0b100, 'client_id' => 0b100, @@ -56,6 +57,7 @@ $EnvConfigs = [ 'activeLimit' => 0b100, 'driveId' => 0b100, + 'diskDisplay' => 0b110, 'diskname' => 0b111, 'diskDescription' => 0b111, 'domain_path' => 0b111, @@ -272,7 +274,7 @@ function main($path) $files['type'] = 'folder'; $files['childcount'] = count($disktags); $files['showname'] = 'root'; - foreach ($disktags as $disktag) { + foreach ($disktags as $disktag) if ($_SERVER['admin']||getConfig('diskDisplay', $disktag)=='') { $files['list'][$disktag]['type'] = 'folder'; $files['list'][$disktag]['name'] = $disktag; $files['list'][$disktag]['showname'] = getConfig('diskname', $disktag); @@ -286,7 +288,7 @@ function main($path) $_SERVER['disktag'] = splitfirst( substr(path_format($path), 1), '/' )[0]; //$pos = strpos($path, '/'); //if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos); - if (!in_array($_SERVER['disktag'], $disktags)) { + if ((!$_SERVER['admin']&&getConfig('diskDisplay', $_SERVER['disktag'])=='disable')||!in_array($_SERVER['disktag'], $disktags)) { $tmp = path_format($_SERVER['base_path'] . '/' . $disktags[0] . '/' . $path); if (!!$_GET) { $tmp .= '?'; @@ -320,12 +322,13 @@ function main($path) //error_log1($_SERVER['REQUEST_METHOD']); if ($_GET['action']=='del_upload_cache') { // del '.tmp' without login. 无需登录即可删除.tmp后缀文件 - if (!driveisfine($_SERVER['disktag'], $drive)) return output('Not in drive, or disk [' . $_SERVER['disktag'] . '] error.', 403); + if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag']?'disk [ ' . $_SERVER['disktag'] . ' ] error.':'Not in drive', 403); savecache('path_' . $path1, '', $_SERVER['disktag'], 1); // clear cache. return $drive->del_upload_cache($path); } + if ($_GET['action']=='upbigfile') { - if (!driveisfine($_SERVER['disktag'], $drive)) return output('Not in drive, or disk [' . $_SERVER['disktag'] . '] error.', 403); + if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag']?'disk [ ' . $_SERVER['disktag'] . ' ] error.':'Not in drive', 403); if (!$_SERVER['admin']) { if (!$_SERVER['is_guestup_path']) return output('Not_Guest_Upload_Folder', 400); if (strpos($_GET['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); @@ -334,7 +337,20 @@ function main($path) return $drive->bigfileupload($path1); } } - + if ($_GET['action']=='upsmallfile') { + //echo json_encode($_POST, JSON_PRETTY_PRINT); + //echo json_encode($_FILES, JSON_PRETTY_PRINT); + if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag']?'disk [ ' . $_SERVER['disktag'] . ' ] error.':'Not in drive', 403); + if (!$_SERVER['admin']) { + if (!$_SERVER['is_guestup_path']) return output('Not_Guest_Upload_Folder', 400); + if (strpos($_GET['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); + if (strpos($_POST['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); + } + return smallfileupload($drive, $path); + /*if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400); + if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400); + return $drive->smallfileupload($path, $_FILES['file1']);*/ + } if ($_SERVER['admin']) { $tmp = adminoperate($path); if ($tmp['statusCode'] > 0) { @@ -385,6 +401,7 @@ function main($path) } else { $files = $drive->list_files($path1); } + //echo "
" . json_encode($files, 448) . "
"; //if ($path!=='') if ( $files['type']=='folder' && substr($path, -1)!=='/' ) { $tmp = path_format($_SERVER['base_disk_path'] . $path . '/'); @@ -446,26 +463,34 @@ function main($path) $fileConduitSize = getConfig('fileConduitSize', $_SERVER['disktag']); $fileConduitCacheTime = getConfig('fileConduitCacheTime', $_SERVER['disktag']); if (!!$fileConduitSize || !!$fileConduitCacheTime) { - if ($fileConduitSize>1) $fileConduitSize *= 1024*1024; + if ($fileConduitSize>0) $fileConduitSize *= 1024*1024; else $fileConduitSize = 1024*1024; - if ($fileConduitCacheTime>1) $fileConduitCacheTime *= 3600; + if ($fileConduitCacheTime>0) $fileConduitCacheTime *= 3600; else $fileConduitCacheTime = 3600; /*if ($_SERVER['HTTP_RANGE']!='') { $header['Range'] = $_SERVER['HTTP_RANGE']; + $response = curl('GET', $files['url'], '', $header, 1); //return output($header['Range'] . json_encode($response['returnhead'])); return output( $response['body'], $response['stat'], - //$response['returnhead'], - ['Content-Type' => $files['mime'], 'Cache-Control' => 'max-age=' . $fileConduitCacheTime], + $response['returnhead'], + //['Accept-Ranges' => 'bytes', 'Range' => $response['returnhead']['Range'], 'Content-Type' => $files['mime'], 'Cache-Control' => 'max-age=' . $fileConduitCacheTime], false ); + } else { + return output('', 206, + ['Accept-Ranges' => 'bytes', 'Content-Range' => 'bytes 0-0/' . $files['size'], 'Content-Type' => $files['mime'] ] + ); }*/ if ($files['size']<$fileConduitSize) return output( base64_encode(file_get_contents($files['url'])), 200, [ + 'Accept-Ranges' => 'bytes', + //'access-control-allow-origin' => '*', + //'access-control-expose-headers' => 'Content-Length, WWW-Authenticate, Location, Accept-Ranges', 'Content-Type' => $files['mime'], 'Cache-Control' => 'max-age=' . $fileConduitCacheTime, //'Cache-Control' => 'max-age=0', @@ -473,6 +498,7 @@ function main($path) ], true ); + //if ($files['size']<$fileConduitSize) return $drive->ConduitDown($files['url'], $files['time'], $fileConduitCacheTime); } if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE']; $header['Location'] = $url; @@ -490,12 +516,13 @@ function main($path) return render_list($path, $files); } else { if (!isset($files['error'])) { - if (is_array($files)) $files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT); - else $files['error']['message'] = $files; - $files['error']['code'] = 'unknownError'; - $files['error']['stat'] = 500; + if (is_array($files)) { + $files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT); + $files['error']['code'] = 'unknownError'; + $files['error']['stat'] = 500; + } } - return message('
' . $files['error']['message'] . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']); + return message('
' . $files.json_encode($files, JSON_PRETTY_PRINT) . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']); } } @@ -857,7 +884,7 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $loca } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); @@ -869,7 +896,9 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $loca if ($location) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //$response['body'] = curl_exec($ch); if ($returnheader) { - list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch)); + $tmpres = splitlast(curl_exec($ch), "\r\n\r\n"); + $result['body'] = $tmpres[1]; + $returnhead = $tmpres[0]; //echo "HEAD:" . $returnhead; foreach (explode("\r\n", $returnhead) as $head) { $tmp = explode(': ', $head); @@ -879,7 +908,7 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $loca } else { $response['body'] = curl_exec($ch); } - $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE); + $response['stat'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $response; } @@ -1071,7 +1100,7 @@ function needUpdate() function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/html'], $isBase64Encoded = false) { if (isset($_SERVER['Set-Cookie'])) $headers['Set-Cookie'] = $_SERVER['Set-Cookie']; - if (baseclassofdrive()=='Aliyundrive') $headers['Referrer-Policy'] = 'no-referrer'; + if (baseclassofdrive()=='Aliyundrive' || baseclassofdrive()=='BaiduDisk') $headers['Referrer-Policy'] = 'no-referrer'; //$headers['Referrer-Policy'] = 'same-origin'; //$headers['X-Frame-Options'] = 'sameorigin'; return [ @@ -1208,7 +1237,7 @@ function adminform($name = '', $pass = '', $storage = '', $path = '') function adminoperate($path) { global $drive; - if ($_SERVER['REQUEST_METHOD']=='POST') if (!driveisfine($_SERVER['disktag'], $drive)) return output('Not in drive, or disk [' . $_SERVER['disktag'] . '] error.', 403); + if ($_SERVER['REQUEST_METHOD']=='POST') if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag']?'disk [ ' . $_SERVER['disktag'] . ' ] error.':'Not in drive', 403); $path1 = path_format($_SERVER['list_path'] . '/' . $path); if (substr($path1, -1)=='/') $path1=substr($path1, 0, -1); $tmpget = $_GET; @@ -1523,7 +1552,7 @@ function EnvOpt($needUpdate = 0) $html .= ' OneManager DIR: ' . __DIR__ . '
-
+
'; if ($_POST['cmd']!='') { @@ -1670,11 +1699,26 @@ output: '; foreach ($EnvConfigs as $key => $val) if (isInnerEnv($key) && isShowedEnv($key)) { - $frame .= ' + if ($key=='diskDisplay') { + $frame .= ' + + + + + ' . getconstStr('EnvironmentsDescription')[$key] . ' + + '; + } else { + $frame .= ' '; + } } $frame .= ' @@ -2159,7 +2203,13 @@ function render_list($path = '', $files = []) $p_path=''; if ($path1 !== '/') { if ($files['type']=='file') { - $pretitle = str_replace('&','&', $files['name']); + if (isset($files['name'])) { + $pretitle = str_replace('&','&', $files['name']); + } else { + if (substr($path1, 0, 1)=='/') $pretitle = substr($path1, 1); + if (substr($path1, -1)=='/') $pretitle = substr($pretitle, 0, -1); + $pretitle = str_replace('&','&', $pretitle); + } $n_path = $pretitle; $tmp = splitlast(splitlast($path1,'/')[0],'/'); if ($tmp[1]=='') { @@ -2928,7 +2978,7 @@ function render_list($path = '', $files = []) $MultiDiskArea = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MultiDisks = $tmp[0]; - foreach ($disktags as $disk) { + foreach ($disktags as $disk) if ($_SERVER['admin']||getConfig('diskDisplay', $disk)=='') { $diskname = getConfig('diskname', $disk); if ($diskname=='') $diskname = $disk; $MultiDisksStr = str_replace('', path_format($_SERVER['base_path'].'/'.$disk.'/'), $MultiDisks); diff --git a/disk/Aliyundrive.php b/disk/Aliyundrive.php index fb92eef..4d40d38 100644 --- a/disk/Aliyundrive.php +++ b/disk/Aliyundrive.php @@ -321,7 +321,6 @@ class Aliyundrive { return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); } public function Copy($file) { - return output('NO copy', 415); if (!$file['id']) { $oldfile = $this->list_path($file['path'] . '/' . $file['name']); //error_log1('res:' . json_encode($res)); @@ -329,47 +328,60 @@ class Aliyundrive { } else { $oldfile = $this->fileGet($file['id']); } - - $url = $this->api_url . '/file/create'; - - $header["content-type"] = "application/json; charset=utf-8"; - $header['authorization'] = 'Bearer ' . $this->access_token; - - $data['check_name_mode'] = 'auto_rename'; // ignore, auto_rename, refuse. - $data['content_hash'] = $oldfile['content_hash']; - $data['content_hash_name'] = 'sha1'; - $data['content_type'] = $oldfile['content_type']; - $data['drive_id'] = $this->driveId; - $data['ignoreError'] = false; - $data['name'] = $oldfile['name']; - $data['parent_file_id'] = $oldfile['parent_file_id']; - $data['part_info_list'][0]['part_number'] = 1; - $data['size'] = $oldfile['size']; - $data['type'] = 'file'; - - $result = curl('POST', $url, json_encode($data), $header); - - if ($result['stat']==201) { - //error_log1('1,url:' . $url .' res:' . json_encode($result)); - $res = json_decode($result['body'], true); - $url = $res['part_info_list'][0]['upload_url']; - if (!$url) { // 无url,应该算秒传 - return output('no up url', 200); + if ($oldfile['type']=='folder') return output('Can not copy folder', 415); + if (!function_exists('bcadd')) { + // no php-bcmath + if ($bcmathurl = getConfig('bcmathUrl', $this->disktag)) { + if (strpos($bcmathurl, '?')) { + $bcmathurl .= '÷nd=0x' . substr(md5($this->access_token), 0, 16) . '&divisor=' . $oldfile['size']; + } else { + $bcmathurl .= '?dividend=0x' . substr(md5($this->access_token), 0, 16) . '&divisor=' . $oldfile['size']; + } + $o = curl('GET', $bcmathurl)['body']; } else { - return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); + return output('No bcmath module, can not copy', 415); } - /*$file_id = $res['file_id']; - $upload_id = $res['upload_id']; - $result = curl('PUT', $url, $content, [], 1); - if ($result['stat']==200) { // 块1传好 - $etag = $result['returnhead']['ETag']; - $result = $this->fileComplete($file_id, $upload_id, [ $etag ]); - if ($result['stat']!=200) return output($result['body'], $result['stat']); - else return output('success', 0); - }*/ + } else { + $r = bchexdec( substr(md5($this->access_token), 0, 16) ); + $o = bcmod($r, $oldfile['size']); } - //error_log1('2,url:' . $url .' res:' . json_encode($result)); - return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); + $res = curl('GET', $oldfile['download_url'], '', [ + 'Referer' => '' + , 'Range' => 'bytes=' . $o . '-' . ($o+7) + ]); + if ($res['stat']==206) { + $proof_code = base64_encode($res['body']); + $url = 'https://api.aliyundrive.com/adrive/v2/file/createWithFolders'; + $header["content-type"] = "application/json; charset=utf-8"; + $header['authorization'] = 'Bearer ' . $this->access_token; + $data['check_name_mode'] = 'auto_rename'; // ignore, auto_rename, refuse. + $data['content_hash'] = $oldfile['content_hash']; + $data['content_hash_name'] = 'sha1'; + $data['drive_id'] = $this->driveId; + $data['name'] = $oldfile['name']; + $data['parent_file_id'] = $oldfile['parent_file_id']; + $data['part_info_list'][0]['part_number'] = 1; + $data['proof_code'] = $proof_code; + $data['proof_version'] = 'v1'; + $data['size'] = $oldfile['size']; + $data['type'] = 'file'; + $result = curl('POST', $url, json_encode($data), $header); + /*if ($result['stat']==201) { + $res = json_decode($result['body'], true); + if ($res['rapid_upload']) return output('rapid upload', 200); + $url = $res['part_info_list'][0]['upload_url']; + if (!$url) { // 无url,应该算秒传 + return output('no up url', 200); + } else { + return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); + } + }*/ + //error_log1('2,url:' . $url .' res:' . json_encode($result)); + return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); + } else { + return output("Get proof error\n" . json_encode($res), 415); + } + } public function Edit($file, $content) { $tmp = splitlast($file['path'], '/'); @@ -564,6 +576,60 @@ class Aliyundrive { $thumb_url = $res['thumbnail']; return $thumb_url; } + public function smallfileupload($path, $tmpfile) { + if (!$_SERVER['admin']) { + $tmp1 = splitlast($tmpfile['name'], '.'); + if ($tmp1[0]==''||$tmp1[1]=='') $filename = sha1_file($tmpfile['tmp_name']); + else $filename = sha1_file($tmpfile['tmp_name']) . '.' . $tmp1[1]; + } else { + $filename = $tmpfile['name']; + } + //$content = file_get_contents($tmpfile['tmp_name']); + $result = $this->tmpfileCreate($this->list_path($_SERVER['list_path'] . '/' . $path . '/')['file_id'], $tmpfile['tmp_name'], $filename); + //error_log1('1,url:' . $url .' res:' . json_encode($result)); + if ($result['stat']==201) { + $res = json_decode($result['body'], true); + $url = $res['part_info_list'][0]['upload_url']; + if (!$url) { // 无url,应该算秒传 + //return output('no up url', 0); + $a = 1; + } else { + $file_id = $res['file_id']; + $upload_id = $res['upload_id']; + //$result = curl('PUT', $url, $content, [], 1); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_PUT, 1); + curl_setopt($ch, CURLOPT_HEADER, 1); + $fh_res = fopen($tmpfile['tmp_name'], 'r'); + curl_setopt($ch, CURLOPT_INFILE, $fh_res); + curl_setopt($ch, CURLOPT_INFILESIZE, filesize($tmpfile['tmp_name'])); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $tmpres = splitlast(curl_exec($ch), "\r\n\r\n"); + $result['body'] = $tmpres[1]; + $returnhead = $tmpres[0]; + foreach (explode("\r\n", $returnhead) as $head) { + $tmp = explode(': ', $head); + $heads[$tmp[0]] = $tmp[1]; + } + $result['returnhead'] = $heads; + $result['stat'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); + fclose($fh_res); + curl_close($ch); + //error_log1('2,url:' . $url .' res:' . json_encode($result)); + if ($result['stat']==200) { // 块1传好 + $result = $this->fileComplete($file_id, $upload_id, [ $result['returnhead']['ETag'] ]); + //error_log1('3, res:' . json_encode($result)); + //if ($result['stat']!=200) return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); + //else return output('success', 0); + } + } + $res = json_decode($result['body'], true); + //if (isset($res['url'])) + $res['download_url'] = $_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . $filename); + } + return output(json_encode($this->files_format($res), JSON_UNESCAPED_SLASHES), $result['stat']); + } public function bigfileupload($path) { if (isset($_POST['uploadid'])) { @@ -582,7 +648,6 @@ class Aliyundrive { $i = $_POST['filesize']; //$o = $i ? bcmod($r, $i) : 0; $o = bcmod($r, $i); - //return output(hexdec( substr(md5($this->access_token), 0, 16) ) . ' , ' . $r . ' / ' . $i . ' = ' . $o, 200); return output($o, 200); }*/ } diff --git a/disk/Onedrive.php b/disk/Onedrive.php index 875b767..52df104 100644 --- a/disk/Onedrive.php +++ b/disk/Onedrive.php @@ -973,6 +973,20 @@ class Onedrive { return $thumb_url; } + public function smallfileupload($path, $tmpfile) { + if (!$_SERVER['admin']) { + $tmp1 = splitlast($tmpfile['name'], '.'); + if ($tmp1[0]==''||$tmp1[1]=='') $filename = md5_file($tmpfile['tmp_name']); + else $filename = md5_file($tmpfile['tmp_name']) . '.' . $tmp1[1]; + } else { + $filename = $tmpfile['name']; + } + $content = file_get_contents($tmpfile['tmp_name']); + $result = $this->MSAPI('PUT', path_format($_SERVER['list_path'] . '/' . $path . '/' . $filename), $content); + $res = $this->files_format(json_decode($result['body'], true)); + if (isset($res['url'])) $res['url'] = $_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . $filename); + return output(json_encode($res, JSON_UNESCAPED_SLASHES), $result['stat']); + } public function bigfileupload($path) { if ($_POST['upbigfilename']=='') return output('error: no file name', 400); diff --git a/index.php b/index.php index 807eed4..7b83647 100644 --- a/index.php +++ b/index.php @@ -67,7 +67,9 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') { } else { include 'platform/Normal.php'; if (!function_exists('curl_init')) { - return message('Need curl, please install php-curl.', 'Error', 500); + http_response_code(500); + echo 'Need curl, please install php-curl.'; + exit(1); } $path = getpath(); //echo 'path:'. $path; diff --git a/platform/AliyunFC.php b/platform/AliyunFC.php index a32b650..65d0c91 100644 --- a/platform/AliyunFC.php +++ b/platform/AliyunFC.php @@ -546,3 +546,7 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + return output('Can not upload through FC.', 400); +} diff --git a/platform/BaiduCFC.php b/platform/BaiduCFC.php index d7e30b0..f8354cf 100644 --- a/platform/BaiduCFC.php +++ b/platform/BaiduCFC.php @@ -485,3 +485,7 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + return output('Can not upload through CFC.', 400); +} diff --git a/platform/Heroku.php b/platform/Heroku.php index b8887b3..fe0fc4e 100644 --- a/platform/Heroku.php +++ b/platform/Heroku.php @@ -415,3 +415,9 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400); + if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400); + return $drive->smallfileupload($path, $_FILES['file1']); +} diff --git a/platform/HuaweiFG_env.php b/platform/HuaweiFG_env.php index 1ea9f51..f3c76c7 100644 --- a/platform/HuaweiFG_env.php +++ b/platform/HuaweiFG_env.php @@ -536,3 +536,7 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + return output('Can not upload through FG.', 400); +} diff --git a/platform/HuaweiFG_file.php b/platform/HuaweiFG_file.php index ca34546..3fbecb0 100644 --- a/platform/HuaweiFG_file.php +++ b/platform/HuaweiFG_file.php @@ -902,3 +902,7 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + return output('Can not upload through FG.', 400); +} diff --git a/platform/Normal.php b/platform/Normal.php index 2bc3fb2..454eb89 100644 --- a/platform/Normal.php +++ b/platform/Normal.php @@ -391,3 +391,9 @@ function WaitFunction() { function changeAuthKey() { return message("Not need.", 'Change platform Auth token or key', 404); } + +function smallfileupload($drive, $path) { + if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400); + if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400); + return $drive->smallfileupload($path, $_FILES['file1']); +} diff --git a/platform/Replit.php b/platform/Replit.php index a682197..a611805 100644 --- a/platform/Replit.php +++ b/platform/Replit.php @@ -355,3 +355,9 @@ function WaitFunction() { function changeAuthKey() { return message("Not need.", 'Change platform Auth token or key', 404); } + +function smallfileupload($drive, $path) { + if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400); + if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400); + return $drive->smallfileupload($path, $_FILES['file1']); +} diff --git a/platform/TencentSCF_env.php b/platform/TencentSCF_env.php index ff5fd4f..7ba565d 100644 --- a/platform/TencentSCF_env.php +++ b/platform/TencentSCF_env.php @@ -662,3 +662,7 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + return output('Can not upload through SCF.', 400); +} diff --git a/platform/TencentSCF_file.php b/platform/TencentSCF_file.php index 606481f..8db3f4c 100644 --- a/platform/TencentSCF_file.php +++ b/platform/TencentSCF_file.php @@ -705,3 +705,7 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + return output('Can not upload through SCF.', 400); +} diff --git a/platform/Vercel.php b/platform/Vercel.php index aa4a4f8..9b9c66b 100644 --- a/platform/Vercel.php +++ b/platform/Vercel.php @@ -316,7 +316,7 @@ function VercelUpdate($appId, $token, $sourcePath = "") $data["target"] = "production"; $data["routes"][0]["src"] = "/(.*)"; $data["routes"][0]["dest"] = "/api/index.php"; - $data["functions"]["api/index.php"]["runtime"] = "vercel-php@0.4.0"; + $data["functions"]["api/index.php"]["runtime"] = "vercel-php@0.5.1"; if ($sourcePath=="") $sourcePath = splitlast(splitlast(__DIR__, "/")[0], "/")[0]; //echo $sourcePath . "
"; getEachFiles($file, $sourcePath); @@ -432,7 +432,7 @@ function WaitFunction($deployid = '') { } $header["Authorization"] = "Bearer " . getConfig('APIKey'); $header["Content-Type"] = "application/json"; - $url = "https://api.vercel.com/v11/deployments/" . $deployid; + $url = "https://api.vercel.com/v13/deployments/" . $deployid; $response = curl("GET", $url, "", $header); if ($response['stat']==200) { $result = json_decode($response['body'], true); @@ -489,3 +489,9 @@ function changeAuthKey() { '; return message($html, 'Change platform Auth token or key', 200); } + +function smallfileupload($drive, $path) { + if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400); + if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400); + return $drive->smallfileupload($path, $_FILES['file1']); +} diff --git a/theme/classic.html b/theme/classic.html index fe2ff16..a4b19bb 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -665,6 +665,21 @@ disableAutoFetch: true, rangeChunkSize: 65535 }); + /*loadingTask.onProgress = (e) => { + //console.log(e); + var p = document.getElementById('p'); + if (p==null) { + p = document.createElement('div'); + p.id = 'p'; + p.setAttribute('onclick', "this.style.display = 'none';"); + p.style = 'left: 10px; top: 30%; position: fixed;'; + document.body.appendChild(p); + } + p.innerHTML = 'Loaded: ' + ((e.loaded/e.total)*100).toFixed(2) + '%
(' + size_format(e.loaded) + ' / ' + size_format(e.total) + ')'; + p.style.display = ''; + if (e.loaded==e.total) p.style.display = 'none'; + + }*/ loadingTask.promise.then(function(pdf) { var pagenum = pdf.numPages; var pdfContainer = document.getElementById('pdf-d'); @@ -678,7 +693,6 @@ pdfContainer.appendChild(pdfnextpagebutton); var pdfWaitNextPage = setInterval(function(){ //console.log(document.documentElement.scrollTop + ", " + document.body.scrollHeight); - console.log("next page: " + pagepos + " / " + pagenum); if (pdfnextpagebutton.style.display=='none') { for (var i=pagepos;i<=(pagepos+41024) { + num=num/1024; + } else { + return num.toFixed(2) + ' B'; + } + if (num>1024) { + num=num/1024; + } else { + return num.toFixed(2) + ' KB'; + } + if (num>1024) { + num=num/1024; + } else { + return num.toFixed(2) + ' MB'; + } + return num.toFixed(2) + ' GB'; + } diff --git a/theme/renexmoe.html b/theme/renexmoe.html index 804ec53..f1bdb32 100644 --- a/theme/renexmoe.html +++ b/theme/renexmoe.html @@ -1,7 +1,7 @@ - + @@ -15,8 +15,13 @@ content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no" /> <!--Title--> +<<<<<<< HEAD +======= + + +>>>>>>> 94f780963b612b2f91ec8f92939e9382b1271823