diff --git a/common.php b/common.php
index f694199..f2bbb63 100644
--- a/common.php
+++ b/common.php
@@ -5,11 +5,14 @@ $Base64Env = [
//'Region', // used in SCF.
//'SecretId', // used in SCF.
//'SecretKey', // used in SCF.
+ //'AccessKeyID', // used in FC.
+ //'AccessKeySecret', // used in FC.
//'admin',
//'adminloginpage',
'background',
'diskname',
//'disableShowThumb',
+ //'disableChangeTheme',
//'disktag',
//'downloadencrypt',
//'function_name', // used in heroku.
@@ -33,6 +36,7 @@ $Base64Env = [
//'sharecookie',
'shareapiurl',
//'siteid',
+ 'domainforproxy',
'public_path',
//'refresh_token',
//'token_expires',
@@ -43,11 +47,14 @@ $CommonEnv = [
'Region', // used in SCF.
'SecretId', // used in SCF.
'SecretKey', // used in SCF.
+ 'AccessKeyID', // used in FC.
+ 'AccessKeySecret', // used in FC.
'admin',
'adminloginpage',
'background',
'disktag',
'disableShowThumb',
+ 'disableChangeTheme',
'function_name', // used in heroku.
'hideFunctionalityFile',
'timezone',
@@ -64,11 +71,14 @@ $ShowedCommonEnv = [
//'Region', // used in SCF.
//'SecretId', // used in SCF.
//'SecretKey', // used in SCF.
+ //'AccessKeyID', // used in FC.
+ //'AccessKeySecret', // used in FC.
//'admin',
'adminloginpage',
'background',
//'disktag',
'disableShowThumb',
+ 'disableChangeTheme',
//'function_name', // used in heroku.
'hideFunctionalityFile',
'timezone',
@@ -95,6 +105,7 @@ $InnerEnv = [
'shareurl',
//'sharecookie',
'shareapiurl',
+ 'domainforproxy',
'public_path',
'refresh_token',
'token_expires',
@@ -115,6 +126,7 @@ $ShowedInnerEnv = [
//'shareurl',
//'sharecookie',
//'shareapiurl',
+ 'domainforproxy',
'public_path',
//'refresh_token',
//'token_expires',
@@ -277,7 +289,8 @@ function main($path)
$oldname = spurlencode($_GET['filename']);
$pos = strrpos($oldname, '.');
if ($pos>0) $ext = strtolower(substr($oldname, $pos));
- $oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' );
+ //$oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' );
+ $oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname);
$data = '{"name":"' . $_GET['filemd5'] . $ext . '"}';
//echo $oldname .'
'. $data;
$tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
@@ -316,6 +329,10 @@ function main($path)
$files = list_files($path);
//echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT);
+ if ($_GET['json']) {
+ // return a json
+ return files_json($files);
+ }
if (isset($_GET['random'])&&$_GET['random']!=='') {
if ($_SERVER['ishidden']<4) {
$tmp = [];
@@ -324,14 +341,29 @@ function main($path)
}
$tmp = array_values($tmp);
if (count($tmp)>0) {
- if (isset($_GET['url'])) return output($tmp[rand(0,count($tmp)-1)], 200);
- return output('', 302, [ 'Location' => $tmp[rand(0,count($tmp)-1)] ]);
+ $url = $tmp[rand(0,count($tmp)-1)];
+ if (isset($_GET['url'])) return output($url, 200);
+ $domainforproxy = '';
+ $domainforproxy = getConfig('domainforproxy');
+ if ($domainforproxy!='') {
+ $url = proxy_replace_domain($url, $domainforproxy);
+ }
+ return output('', 302, [ 'Location' => $url ]);
} else return output('',404);
} else return output('',401);
}
if (isset($files['file']) && !isset($_GET['preview'])) {
// is file && not preview mode
- if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files[$_SERVER['DownurlStrName']] ]);
+ if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) {
+ $url = $files[$_SERVER['DownurlStrName']];
+ $domainforproxy = '';
+ $domainforproxy = getConfig('domainforproxy');
+ if ($domainforproxy!='') {
+ $url = proxy_replace_domain($url, $domainforproxy);
+ }
+ if ( strtolower(splitlast($files['name'],'.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']);
+ else return output('', 302, [ 'Location' => $url ]);
+ }
}
if ( isset($files['folder']) || isset($files['file']) ) {
return render_list($path, $files);
@@ -346,6 +378,54 @@ function main($path)
}
}
+function proxy_replace_domain($url, $domainforproxy)
+{
+ $tmp = splitfirst($url, '//');
+ $http = $tmp[0];
+ $tmp = splitfirst($tmp[1], '/');
+ $domain = $tmp[0];
+ $uri = $tmp[1];
+ if (substr($domainforproxy, 0, 7)=='http://' || substr($domainforproxy, 0, 8)=='https://') $aim = $domainforproxy;
+ else $aim = $http . '//' . $domainforproxy;
+ if (substr($aim, -1)=='/') $aim = substr($aim, 0, -1);
+ return $aim . '/' . $uri . '&Origindomain=' . $domain;
+ //$url = str_replace($tmp, $domainforproxy, $url).'&Origindomain='.$tmp;
+}
+
+function files_json($files)
+{
+ //$tmp = '';
+ if (isset($files['file'])) {
+ $tmp['file']['type'] = 0;
+ $tmp['file']['id'] = $files['id'];
+ $tmp['file']['name'] = $files['name'];
+ $tmp['file']['time'] = $files['lastModifiedDateTime'];
+ $tmp['file']['size'] = $files['size'];
+ $tmp['file']['mime'] = $files['file']['mimeType'];
+ $tmp['file']['url'] = $files[$_SERVER['DownurlStrName']];
+ $tmp['url'] = $files[$_SERVER['DownurlStrName']];
+ } elseif (isset($files['folder'])) {
+ $tmp['list'] = [];
+ foreach ($files['children'] as $file) {
+ $tmp1 = null;
+ $tmp1 = [];
+ if (isset($file['file'])) {
+ $tmp1['type'] = 0;
+ $tmp1['url'] = $file[$_SERVER['DownurlStrName']];
+ } elseif (isset($file['folder'])) {
+ $tmp1['type'] = 1;
+ }
+ $tmp1['id'] = $file['id'];
+ $tmp1['name'] = $file['name'];
+ $tmp1['time'] = $file['lastModifiedDateTime'];
+ $tmp1['size'] = $file['size'];
+ $tmp1['mime'] = $file['file']['mimeType'];
+ array_push($tmp['list'], $tmp1);
+ }
+ } else return output('', 404);
+ return output(json_encode($tmp));
+}
+
function get_access_token($refresh_token)
{
if (getConfig('Drive_ver')=='shareurl') {
@@ -801,8 +881,15 @@ function get_thumbnails_url($path = '/', $location = 0)
}
}
if ($thumb_url!='') {
- if ($location) return output('', 302, [ 'Location' => $thumb_url ]);
- else return output($thumb_url);
+ if ($location) {
+ $url = $thumb_url;
+ $domainforproxy = '';
+ $domainforproxy = getConfig('domainforproxy');
+ if ($domainforproxy!='') {
+ $url = proxy_replace_domain($url, $domainforproxy);
+ }
+ return output('', 302, [ 'Location' => $url ]);
+ } else return output($thumb_url);
}
return output('', 404);
}
@@ -830,7 +917,7 @@ function bigfileupload($path)
$getoldupinfo = json_decode($getoldupinfo_j['body'], true);
if ( json_decode( curl_request($getoldupinfo['uploadUrl'])['body'], true)['@odata.context']!='' ) return output($getoldupinfo_j['body'], $getoldupinfo_j['stat']);
}
- if (!$_SERVER['admin']) $filename = spurlencode( $fileinfo['name'] ) . '.scfupload';
+ //if (!$_SERVER['admin']) $filename = spurlencode( $fileinfo['name'] ) . '.scfupload';
$response=MSAPI('createUploadSession',path_format($path1 . '/' . $filename),'{"item": { "@microsoft.graph.conflictBehavior": "fail" }}',$_SERVER['access_token']);
$responsearry = json_decode($response['body'],true);
if (isset($responsearry['error'])) return output($response['body'], $response['stat']);
@@ -1540,11 +1627,10 @@ function EnvOpt($needUpdate = 0)
}*/
$response = setConfigResponse( setConfig($tmp, $_SERVER['disk_oprating']) );
if (api_error($response)) {
- $html = api_error_msg($response);
- $title = 'Error';
- } else {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
//WaitSCFStat();
- //sleep(3);
$html .= getconstStr('Success') . '!
';
$title = getconstStr('Setup');
@@ -1654,16 +1740,30 @@ function EnvOpt($needUpdate = 0)
}
$html .= '
'.getconstStr('AddDisk').'
';
- if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) {
+
+ $canOneKeyUpate = 0;
+ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
+ $canOneKeyUpate = 1;
+ } elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
+ $canOneKeyUpate = 1;
+ } elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
+ $canOneKeyUpate = 1;
+ } else {
+ $tmp = time();
+ if ( mkdir(''.$tmp, 0777) ) {
+ rmdir(''.$tmp);
+ $canOneKeyUpate = 1;
+ }
+ }
+ if (!$canOneKeyUpate) {
$html .= '
-'.getconstStr('VPSnotupdate').'
';
+'.getconstStr('CannotOneKeyUpate').'
';
} else {
$html .= '
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ //}
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').', '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function getfunctioninfo($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
+{
+ $fcClient = new Client([
+ "endpoint" => 'https://'.$accountId.'.'.$region.'.fc.aliyuncs.com',
+ "accessKeyID" => $AccessKeyID,
+ "accessKeySecret" => $AccessKeySecret
+ ]);
+ return $fcClient->getFunction($service_name, $function_name);
+}
+
+function updateEnvironment($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
+{
+ //print_r($Envs);
+ $fcClient = new Client([
+ "endpoint" => 'https://'.$accountId.'.'.$region.'.fc.aliyuncs.com',
+ "accessKeyID" => $AccessKeyID,
+ "accessKeySecret" => $AccessKeySecret
+ ]);
+ $tmp = $fcClient->getFunction($service_name, $function_name)['data'];
+ //$tmp = getfunctioninfo($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)['data'];
+ foreach ($tmp['environmentVariables'] as $key => $value ) {
+ $tmp_env[$key] = $value;
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmpdata['functionName'] = $tmp['functionName'];
+ $tmpdata['description'] = $tmp['description'];
+ $tmpdata['memorySize'] = $tmp['memorySize'];
+ $tmpdata['timeout'] = $tmp['timeout'];
+ $tmpdata['runtime'] = $tmp['runtime'];
+ $tmpdata['handler'] = $tmp['handler'];
+ $tmpdata['environmentVariables'] = $tmp_env;
+ $tmpdata['code']['zipFile'] = base64_encode( file_get_contents($fcClient->getFunctionCode($service_name, $function_name)['data']['url']) );
+ return $fcClient->updateFunction($service_name, $function_name, $tmpdata);
+}
+
+function SetbaseConfig($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
+{
+ //echo json_encode($Envs,JSON_PRETTY_PRINT);
+ $fcClient = new Client([
+ "endpoint" => 'https://'.$accountId.'.'.$region.'.fc.aliyuncs.com',
+ "accessKeyID" => $AccessKeyID,
+ "accessKeySecret" => $AccessKeySecret
+ ]);
+ $tmp = $fcClient->getFunction($service_name, $function_name)['data'];
+ // $tmp = getfunctioninfo($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)['data'];
+ foreach ($tmp['environmentVariables'] as $key => $value ) {
+ $tmp_env[$key] = $value;
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmpdata['functionName'] = $function_name;
+ $tmpdata['description'] = 'Onedrive index and manager in Ali FC.';
+ $tmpdata['memorySize'] = 128;
+ $tmpdata['timeout'] = 30;
+ $tmpdata['runtime'] = 'php7.2';
+ $tmpdata['handler'] = 'index.handler';
+ $tmpdata['environmentVariables'] = $tmp_env;
+ $tmpdata['code']['zipFile'] = base64_encode( file_get_contents($fcClient->getFunctionCode($service_name, $function_name)['data']['url']) );
+ return $fcClient->updateFunction($service_name, $function_name, $tmpdata);
+}
+
+function updateProgram($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret, $source)
+{
+ //WaitSCFStat();
+ $fcClient = new Client([
+ "endpoint" => 'https://'.$accountId.'.'.$region.'.fc.aliyuncs.com',
+ "accessKeyID" => $AccessKeyID,
+ "accessKeySecret" => $AccessKeySecret
+ ]);
+ $tmp = $fcClient->getFunction($service_name, $function_name)['data'];
+ //$tmp = getfunctioninfo($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)['data'];
+
+ $tmpdata['functionName'] = $tmp['functionName'];
+ $tmpdata['description'] = $tmp['description'];
+ $tmpdata['memorySize'] = $tmp['memorySize'];
+ $tmpdata['timeout'] = $tmp['timeout'];
+ $tmpdata['runtime'] = $tmp['runtime'];
+ $tmpdata['handler'] = $tmp['handler'];
+ $tmpdata['environmentVariables'] = $tmp['environmentVariables'];
+ $tmpdata['code']['zipFile'] = base64_encode( file_get_contents($source) );
+
+ return $fcClient->updateFunction($service_name, $function_name, $tmpdata);
+}
+
+function api_error($response)
+{
+ return !isset($response['data']);
+}
+
+function api_error_msg($response)
+{
+ return json_encode( $response, JSON_PRETTY_PRINT );
+ return $response['Error']['Code'] . '
+' . $response['Error']['Message'] . '
+function_name:' . $_SERVER['function_name'] . '
+Region:' . $_SERVER['Region'] . '
+namespace:' . $_SERVER['namespace'] . '
+';
+}
+
+function setConfigResponse($response)
+{
+ return $response;
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $source = '/tmp/code.zip';
+ $outPath = '/tmp/';
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . $branch . '/';
+ $tarfile = '/tmp/github.tar.gz';
+ file_put_contents($tarfile, file_get_contents($url));
+ $phar = new PharData($tarfile);
+ $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
+
+ // 获取解压出的目录名
+/*
+ @ob_start();
+ passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
+ $html.='状态:' . $stat . '
+ 结果:
+ ';
+ $archivefolder = ob_get_clean();
+ if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
+ $outPath .= $archivefolder;
+ $html.=htmlspecialchars($archivefolder);
+ //return $html;
+*/
+ $tmp = scandir($outPath);
+ $name = $auth.'-'.$project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath .= $f;
+ break;
+ }
+ }
+
+ // 将目录中文件打包成zip
+ $zip=new ZipArchive();
+ if($zip->open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ $zip->close(); //关闭处理的zip文件
+ }
+
+ return updateProgram($_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], getConfig('AccessKeyID'), getConfig('AccessKeySecret'), $source);
+}
+
+function addFileToZip($zip, $rootpath, $path = '')
+{
+ if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
+ if (substr($path,0,1)=='/') $path = substr($path, 1);
+ $handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
+ while($filename=readdir($handler)){
+ if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
+ $nowname = path_format($rootpath.'/'.$path."/".$filename);
+ if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
+ addFileToZip($zip, $rootpath, $path."/".$filename);
+ }else{ //将文件加入zip对象
+ $zip->addFile($nowname);
+ $newname = $path."/".$filename;
+ if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
+ $zip->renameName($nowname, $newname);
+ }
+ }
+ }
+ @closedir($path);
+}
diff --git a/platform/normal.php b/platform/Normal.php
similarity index 79%
rename from platform/normal.php
rename to platform/Normal.php
index c56577b..0149a95 100644
--- a/platform/normal.php
+++ b/platform/Normal.php
@@ -252,12 +252,70 @@ Can not write config to file.
';
}
-function OnekeyUpate()
-{
- return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true);
-}
-
function setConfigResponse($response)
{
return $response;
}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ // __DIR__ is xxx/platform
+ $projectPath = splitlast(__DIR__, '/')[0];
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . $branch . '/';
+ $tarfile = $projectPath.'/github.tar.gz';
+ $githubfile = file_get_contents($url);
+ if (!$githubfile) return 0;
+ file_put_contents($tarfile, $githubfile);
+ if (splitfirst(PHP_VERSION, '.')[0] == '7') {
+ $phar = new PharData($tarfile); // need php7
+ $phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
+ } else {
+ ob_start();
+ passthru('tar -xzvf '.$tarfile,$stat);
+ ob_get_clean();
+ }
+ unlink($tarfile);
+
+ $outPath = '';
+ $tmp = scandir($projectPath);
+ $name = $auth.'-'.$project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath = $projectPath . '/' . $f;
+ break;
+ }
+ }
+ //error_log($outPath);
+ if ($outPath=='') return 0;
+
+ //unlink($outPath.'/config.php');
+ rename($projectPath.'/config.php', $outPath.'/config.php');
+
+ return moveFolder($outPath, $projectPath);
+}
+
+function moveFolder($from, $to)
+{
+ if (substr($from, -1)=='/') $from = substr($from, 0, -1);
+ if (substr($to, -1)=='/') $to = substr($to, 0, -1);
+ if (!file_exists($to)) mkdir($to, 0777);
+ $handler=opendir($from);
+ while($filename=readdir($handler)) {
+ if($filename != '.' && $filename != '..'){
+ $fromfile = $from.'/'.$filename;
+ $tofile = $to.'/'.$filename;
+ if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
+ moveFolder($fromfile, $tofile);
+ }else{
+ //if (file_exists($tofile)) unlink($tofile);
+ rename($fromfile, $tofile);
+ if (file_exists($fromfile)) unlink($fromfile);
+ }
+ }
+ }
+ closedir($handler);
+ rmdir($from);
+ return 1;
+}
diff --git a/readme.md b/readme.md
index 7c4aca2..ea5d7de 100644
--- a/readme.md
+++ b/readme.md
@@ -1,14 +1,24 @@
Install program first, then add onedrive in setup after login.
先安装程序,登录后在设置中添加onedrive。
-# Deploy to heroku
+# Deploy to Heroku
Official: https://heroku.com
+Demo: https://herooneindex.herokuapp.com/
How to Install: Click the button [](https://heroku.com/deploy?template=https://github.com/qkqpttgf/OneManager-php) to Deploy a new app, or create an app then deploy via connect to your github fork.
-DEMO: https://herooneindex.herokuapp.com/
-# Deploy to VPS(Virtual Private Server) 部署到VPS或空间
+# Deploy to Tencent Serverless Cloud Function (SCF 腾讯无服务器云函数)
+Official: https://cloud.tencent.com/product/scf
+DEMO: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/
+
+~~How to Install: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/%E6%97%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%87%BD%E6%95%B0SCF%E6%90%AD%E5%BB%BAOneDrive.mp4?preview~~
+
+添加网盘时,SCF反应不过来,会添加失败,请不要删除,再添加一次相同的就可以了。
+
+
+# Deploy to Virtual Private Server (VPS 或空间)
+DEMO: 无
How to Install:
1.Start web service on your server (httpd or other), make sure you can visit it.
启动web服务器,确保你能访问到。
@@ -21,15 +31,19 @@ How to Install:
5.View the website in chrome or other.
在浏览器中访问。
-# Deploy to SCF
-Official: https://cloud.tencent.com/product/scf
-~~How to Install: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/%E6%97%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%87%BD%E6%95%B0SCF%E6%90%AD%E5%BB%BAOneDrive.mp4?preview~~
+# Deploy to Aliyun Function Compute (FC 阿里函数计算)
+Official: https://fc.console.aliyun.com/
+DEMO: 无
-先手动在环境变量添加Region,ap-hongkong或ap-guangzhou之类,具体看 https://cloud.tencent.com/document/api/583/17238 最底下,然后再安装。
-添加网盘时,SCF反应不过来,会添加失败,请不要删除,再添加一次相同的就可以了。
+How to Install:
+1,新建函数 -- HTTP函数
+2,运行环境选择php7.2
+3,触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
+4,上传代码
+5,触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
+6,访问你的域名,开始安装
-DEMO: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/
# Features 特性
When downloading files, the program produce a direct url, visitor download files from MS OFFICE via the direct url, the server expend a few bandwidth in produce.
diff --git a/theme/classic.html b/theme/classic.html
index b81e153..170850f 100644
--- a/theme/classic.html
+++ b/theme/classic.html
@@ -476,7 +476,10 @@
function changelanguage(str)
{
if (str=='Language') str = '';
- document.cookie='language='+str+'; path=/';
+ var expd = new Date();
+ expd.setTime(expd.getTime()+(2*60*60*1000));
+ var expires = "expires="+expd.toGMTString();
+ document.cookie='language='+str+'; path=/; '+expires;
location.href = location.href;
}
@@ -821,20 +824,55 @@
tr1.setAttribute('data-to',1);
var td1=document.createElement('td');
tr1.appendChild(td1);
- td1.setAttribute('style','width:30%');
+ td1.setAttribute('style','width:30%;word-break:break-word;');
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
td1.innerHTML=(file.webkitRelativePath||file.name)+'
'+size_format(file.size);
var td2=document.createElement('td');
tr1.appendChild(td2);
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
- td2.innerHTML=' ...';
if (file.size>100*1024*1024*1024) {
td2.innerHTML='';
uploadbuttonshow();
return;
}
+ upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
+
+ function getext(str) {
+ strarry=str.split('.');
+ ext=strarry[strarry.length-1].toLowerCase();
+ var reg = new RegExp(".","g");
+ var a = str.replace(reg,"");
+ if (a == ext) ext = "";
+ else ext = "." + ext;
+ return ext;
+ }
+ var ext = getext(file.webkitRelativePath||file.name);
+ var spark = new SparkMD5.ArrayBuffer();
+ var reader = new FileReader();
+ var chunksize=10*1024*1024;
+ var asize = 0;
+ function readblob(start) {
+ var end=start+chunksize;
+ var blob = file.slice(start,end);
+ reader.readAsArrayBuffer(blob);
+ }
+ readblob(asize);
+
+ reader.onload = function(e){
+ td2.innerHTML=' md5: '+(asize*100/file.size).toFixed(2)+'%';
+ var binary = this.result;
+ spark.append(binary);
+ asize += chunksize;
+ if (asize < file.size) {
+ readblob(asize);
+ } else {
+ var filemd5 = spark.end();
+ td2.innerHTML='md5: '+filemd5;
+ upbigfilename = filemd5+ext;
+
+ td2.innerHTML=' ...';
var xhr1 = new XMLHttpRequest();
- xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent((file.webkitRelativePath||file.name)) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
+ xhr1.open("GET", '?action=upbigfile&upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr1.send(null);
xhr1.onload = function(e){
@@ -847,14 +885,23 @@
uploadbuttonshow();
} else {
td2.innerHTML=' ...';
- binupfile(file,html['uploadUrl'],timea+'_'+i);
+ binupfile(file,html['uploadUrl'],timea+'_'+i, upbigfilename);
}
}
+ if (xhr1.status==409) {
+ td2.innerHTML='md5: '+filemd5;
+ tdnum = timea+'_'+i;
+ document.getElementById('upfile_td1_'+tdnum).innerHTML='';
+ }
if (i
+ }
+ }
+
}
}
function size_format(num) {
@@ -875,7 +922,7 @@
}
return num.toFixed(2) + ' GB';
}
- function binupfile(file,url,tdnum){
+ function binupfile(file,url,tdnum,filename){
var label=document.getElementById('upfile_td2_'+tdnum);
var reader = new FileReader();
var StartStr='';
@@ -896,9 +943,7 @@
var a = html['nextExpectedRanges'][0];
newstartsize = Number( a.slice(0,a.indexOf("-")) );
StartTime = new Date();
-
asize = newstartsize;
-
if (newstartsize==0) {
StartStr=':' +StartTime.toLocaleString()+'
' ;
} else {
@@ -912,19 +957,9 @@
reader.readAsArrayBuffer(blob);
}
readblob(asize);
-
- var spark = new SparkMD5.ArrayBuffer();
-
+
reader.onload = function(e){
var binary = this.result;
-
- spark.append(binary);
- if (asize < newstartsize) {
- asize += chunksize;
- readblob(asize);
- return;
- }
-
var xhr = new XMLHttpRequest();
xhr.open("PUT", url, true);
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
@@ -945,38 +980,12 @@
if (response['size']>0) {
// contain size, upload finish. 有size说明是最终返回,上传结束
var xhr3 = new XMLHttpRequest();
- xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+encodeURIComponent((file.webkitRelativePath||file.name)));
+ xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr3.send(null);
xhr3.onload = function(e){
console.log(xhr3.responseText+','+xhr3.status);
}
-
- var filemd5 = spark.end();
- var xhr4 = new XMLHttpRequest();
- xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent((file.webkitRelativePath||file.name))+'&filemd5='+filemd5);
- xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
- xhr4.send(null);
- xhr4.onload = function(e){
- console.log(xhr4.responseText+','+xhr4.status);
- var filename;
- //if (xhr4.status==200) filename = JSON.parse(xhr4.responseText)['name'];
- //if (xhr4.status==409) filename = filemd5 + (file.webkitRelativePath||file.name).substr((file.webkitRelativePath||file.name).indexOf('.'));
- filename = JSON.parse(xhr4.responseText)['name'];
- if (filename=='') {
- alert('');
- uploadbuttonshow();
- return;
- }
- var lasturl = location.href;
- if (lasturl.substr(lasturl.length-1)!='/') lasturl += '/';
- lasturl += filename + '?preview';
- //window.open(lasturl);
- document.getElementById('upfile_a_'+tdnum).href = lasturl;
- document.getElementById('upfile_a1_'+tdnum).href = filename;
- document.getElementById('upfile_cpbt_'+tdnum).style.display = "";
- }
-
EndTime=new Date();
MiddleStr = ':'+EndTime.toLocaleString()+'
';
if (newstartsize==0) {
@@ -1004,7 +1013,7 @@
xhr.send(binary);
}
} else {
- if (window.location.pathname.indexOf('%23')>0||(file.webkitRelativePath||file.name).indexOf('%23')>0) {
+ if (window.location.pathname.indexOf('%23')>0||filename.indexOf('%23')>0) {
label.innerHTML='';
} else {
label.innerHTML=''+xhr2.responseText+'';
diff --git a/theme/nchyn_grey.html b/theme/nchyn_grey.html
index 99dd479..f07b8f5 100644
--- a/theme/nchyn_grey.html
+++ b/theme/nchyn_grey.html
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/theme/nexmoe1.html b/theme/nexmoe1.html
index fd296ba..725c9c8 100644
--- a/theme/nexmoe1.html
+++ b/theme/nexmoe1.html
@@ -34,14 +34,14 @@
.mdui-list>.th{background-color:initial}
.mdui-list-item>a{width:100%;line-height:48px}
.mdui-toolbar>a:last-child{opacity:1;background-color:#1e89f2;color:#ffff}
- .more-disk{display: inline-block;}
+ .more-disk{display: inline-block;max-width: 100px;}
.more-disk div{
list-style:none;
- position:absolute;display:none;background:#ffffff;border-radius:5px;margin:-7px 0 0 0;padding:0 7px;color:#205D67;z-index:1;
+ position:absolute;display:none;background:#ffffff;border-radius:5px;margin:0 0 0 -10px;/*padding:0 7px;*/color:#205D67;z-index:1;
box-shadow: 0 0.5em 3em rgba(161,177,204,.4);
}
.more-disk:hover div{display:block}
- .more-disk div li{line-height:normal;padding: 5px 5px;}
+ .more-disk div li{line-height:normal;padding: 3px 10px;}
.more-disk div li a{text-decoration: none; color:rgba(0,0,0,.3);}
.more-disk div li a:hover{color:rgba(0,0,0,.87);}
.more-disk div li a[now]{color:rgba(0,0,0,1);}
@@ -51,8 +51,8 @@
/*.mdui-toolbar>*{display:none}*/
.mdui-toolbar>a:last-child,.mdui-toolbar>.mdui-typo-headline,.mdui-toolbar>i:first-child{display:block}
}
-
-
+
+
@@ -135,7 +135,7 @@
@@ -188,7 +188,6 @@
width:100% !important;
height:230px;
}
-
.thumb .mdui-list-item .mdui-icon{
font-size:100px;
display: block;
@@ -203,7 +202,6 @@
position: absolute;
top: 180px;
}
-
@@ -253,24 +251,23 @@
-
-
@@ -302,11 +299,9 @@
}
$ = mdui.JQ;
-
$.fn.extend({
sortElements: function (comparator, getSortable) {
getSortable = getSortable || function () { return this; };
-
var placements = this.map(function () {
var sortElement = getSortable.call(this),
parentNode = sortElement.parentNode,
@@ -314,24 +309,21 @@
document.createTextNode(''),
sortElement.nextSibling
);
-
return function () {
parentNode.insertBefore(this, nextSibling);
parentNode.removeChild(nextSibling);
};
});
-
return [].sort.call(this, comparator).each(function (i) {
placements[i].call(getSortable.call(this));
});
}
});
-
+
function downall() {
let dl_link_list = Array.from(document.querySelectorAll("li a"))
.map(x => x.href) // 所有list中的链接
.filter(x => x.slice(-1) != "/"); // 筛选出非文件夹的文件下载链接
-
let blob = new Blob([dl_link_list.join("\r\n")], {
type: 'text/plain'
}); // 构造Blog对象
@@ -360,7 +352,6 @@
}
});
}
-
}
$(function(){
@@ -373,23 +364,17 @@
return false;
});
});
-
$('.icon-sort').on('click', function () {
let sort_type = $(this).attr("data-sort"), sort_order = $(this).attr("data-order");
let sort_order_to = (sort_order === "less") ? "more" : "less";
-
$('li[data-sort]').sortElements(function (a, b) {
let data_a = $(a).attr("data-sort-" + sort_type), data_b = $(b).attr("data-sort-" + sort_type);
let rt = data_a.localeCompare(data_b, undefined, {numeric: true});
return (sort_order === "more") ? 0-rt : rt;
});
-
$(this).attr("data-order", sort_order_to).text("expand_" + sort_order_to);
});
-
});
-
-