Compare commits

..

No commits in common. "master" and "v3.1" have entirely different histories.
master ... v3.1

39 changed files with 2969 additions and 13057 deletions

View File

@ -9,11 +9,6 @@ RewriteRule ^(.*) index.php?/$1 [L]
### nginx ### nginx
# rewrite ^/(?!.well-known)(.*)$ /index.php?/$1 last; # rewrite ^/(?!.well-known)(.*)$ /index.php?/$1 last;
# #
### nginx Subdirectory 在子目录中使用
# location /OneManager2/ {
# rewrite ^/(.*)$ /OneManager2/index.php?/$1 last;
# }
#
### caddy ### caddy
# rewrite { # rewrite {
# to index.php?/$1 # to index.php?/$1

View File

@ -1,7 +0,0 @@
run = "php -S 0.0.0.0:8000 index.php"
entrypoint = "index.php"
[nix]
channel = "stable-22_11"
[deployment]
run = ["sh", "-c", "php -S 0.0.0.0:8000 index.php"]
deploymentTarget = "cloudrun"

View File

@ -1,113 +0,0 @@
// Hosts Array
// 服务器数组
const H = [
'https://herooneindex.herokuapp.com/',
'https://onemanager.glitch.me/',
'https://onemanager-php.vercel.app/'
]
// View Type
// 1 , only first host,
// 只第一条Host记录有用
// 2 , view top 2 host as odd/even days,
// 只有前两条记录有效,分别单双日运行
// 3 , view random host
// 所有记录随机访问
const T = 1
// CF proxy all, true/false
// 一切给CF代理true或false
const CFproxy = true
// Used in cloudflare workers
// // // // // //
addEventListener('fetch', event => {
let url=new URL(event.request.url);
if (url.protocol == 'http:') {
// force HTTPS
url.protocol = 'https:'
event.respondWith( Response.redirect(url.href) )
} else {
let host = null;
if (T===1) {
host = H[0];
}
if (T===2) {
host = H[new Date().getDate()%2];
}
if (T===3) {
let n = H.length;
host = H[Math.round(Math.random()*n*10)%n];
}
//console.log(host)
if (host.substr(0, 7)!='http://'&&host.substr(0, 8)!='https://') host = 'http://' + host;
let response = fetchAndApply(host, event.request);
event.respondWith( response );
}
})
async function fetchAndApply(host, request) {
let f_url = new URL(request.url);
let a_url = new URL(host);
let replace_path = a_url.pathname;
if (replace_path.substr(replace_path.length-1)!='/') replace_path += '/';
let replaced_path = '/';
let query = f_url.search;
let path = f_url.pathname;
if (host.substr(host.length-1)=='/') path = path.substr(1);
f_url.href = host + path + query;
let response = null;
if (!CFproxy) {
response = await fetch(f_url, request);
} else {
let method = request.method;
let body = request.body;
let request_headers = request.headers;
let new_request_headers = new Headers(request_headers);
new_request_headers.set('Host', f_url.host);
new_request_headers.set('Referer', request.url);
response = await fetch(f_url.href, {
/*cf: {
cacheEverything: true,
cacheTtl: 1000,
mirage: true,
polish: "on",
minify: {
javascript: true,
css: true,
html: true,
}
},*/
method: method,
body: body,
headers: new_request_headers
});
}
let out_headers = new Headers(response.headers);
if (out_headers.get('Content-Disposition')=='attachment') out_headers.delete('Content-Disposition');
let out_body = null;
let contentType = out_headers.get('Content-Type');
if (contentType.includes("application/text")) {
out_body = await response.text();
while (replace_path!='/'&&out_body.includes(replace_path)) out_body = out_body.replace(replace_path, replaced_path);
} else if (contentType.includes("text/html")) {
//f_url.href +
out_body = await response.text();
while (replace_path!='/'&&out_body.includes(replace_path)) out_body = out_body.replace(replace_path, replaced_path);
} else {
out_body = await response.body;
}
let out_response = new Response(out_body, {
status: response.status,
headers: out_headers
})
return out_response;
}

1477
common.php

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,8 @@ global $constStr;
$exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff', 'png', 'heic', 'webp']; $exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff', 'png', 'heic', 'webp'];
$exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a']; $exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a'];
$exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; $exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
$exts['txt'] = ['txt', 'log', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf']; $exts['txt'] = ['txt', '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['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', 'rmvb'];
$exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar']; $exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar'];
$constStr = [ $constStr = [
@ -88,8 +88,8 @@ $constStr = [
'EnvironmentsDescription' => [ 'EnvironmentsDescription' => [
'en-us' => [ 'en-us' => [
'admin' => 'The admin password, Login button will not show when empty', 'admin' => 'The admin password, Login button will not show when empty',
'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?login=admin\', it is \'?login={this value}\'.', 'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.',
'autoJumpFirstDisk' => 'a switch used in multy disks, if 1, auto jump to first disk', 'autoJumpFirstDisk' => 'used in multy disks, if 1, auto jump to first disk',
'customScript' => '<script> in all pages, e.g. http turn to https', 'customScript' => '<script> in all pages, e.g. http turn to https',
'customCss' => '<style> in <head>', 'customCss' => '<style> in <head>',
'customTheme' => 'an url of html', 'customTheme' => 'an url of html',
@ -98,71 +98,59 @@ $constStr = [
'diskname' => 'The disk name you want show.', 'diskname' => 'The disk name you want show.',
'diskDescription' => ' Some tips of this disk, not used in code.', 'diskDescription' => ' Some tips of this disk, not used in code.',
'disktag' => 'A tag used in store config and url.', 'disktag' => 'A tag used in store config and url.',
'disableShowThumb' => 'a switch, if 1, the ShowThumbnail button will not display', 'disableShowThumb' => 'if 1, the ShowThumbnail button will not display',
'disableChangeTheme' => 'a switch, if 1, the Theme selection button will not display', 'disableChangeTheme' => 'if 1, the Theme selection button will not display',
'downloadencrypt' => 'a switch, 0 or 1. if 1, the files in encrypt folder can be downloaded without password', 'downloadencrypt' => '0 or 1. if 1, the files in encrypt folder can be downloaded without password',
'globalHeadOmfUrl' => 'get txt from url, show it as head.omf in every page.', 'dontBasicAuth' => 'if 1, will not popup user/pass windows in encrypted folder, but show the page in theme.',
'globalHeadMdUrl' => 'get txt from url, show it as head.md in every page.',
'globalReadmeMdUrl' => 'get txt from url, show it as readme.md in every page.',
'globalFootOmfUrl' => 'get txt from url, show it as foot.omf in every page.',
'useBasicAuth' => 'a switch, if 1, will popup user/pass windows in encrypted folder.',
'background' => 'Set an url as background photo.', 'background' => 'Set an url as background photo.',
'backgroundm' => 'Set an url as background in mobile phone.', 'backgroundm' => 'Set an url as background in mobile phone.',
'forceHttps' => 'a switch, if 1, force to redirect to https when visit via http.', 'theme' => 'Select theme.',
'fileConduitCacheTime' => 'Input number, unit is hour, if set this, little file<1M(or fileConduitSize) will through program and cache in explorer, otherwise, default 302 to Microsoft',
'fileConduitSize' => 'Input number, unit is M(suggest less than 4M), if set this, little file<this value will through program and cache in explorer, otherwise, default 302 to Microsoft',
'theme' => 'Select theme for guest.',
'timezone' => 'Set default timezone.', 'timezone' => 'Set default timezone.',
'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.', 'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.',
'hideFunctionalityFile' => 'a switch, 0 or 1. if 1, some file will not show in list to guest, like readme.md', 'hideFunctionalityFile' => '0 or 1. if 1, some file will not show in list to guest, like readme.md',
'passfile' => 'The password of folder(& its childrens) will save in this file.', 'passfile' => 'The password of folder(& its childrens) will save in this file.',
'domainforproxy' => 'Will replace the https://xxxxx-my.sharepoint.com with this value.Add &Origindomain=xxxxx-my.sharepoint.com at last', 'domainforproxy' => 'Will replace the https://xxxxx-my.sharepoint.com with this value.Add &Origindomain=xxxxx-my.sharepoint.com at last',
'public_path' => 'Show this Onedrive dir when through the long url of API Gateway.', 'public_path' => 'Show this Onedrive dir when through the long url of API Gateway; public show files less than private.',
'sitename' => 'sitename', 'sitename' => 'sitename',
'Onedrive_ver' => 'Onedrive version',
], ],
'zh-cn' => [ 'zh-cn' => [
'admin' => '管理密码,不添加时不显示登录页面且无法登录。', 'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?login=admin\',而是\'?login=此设置的值\'。', 'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
'autoJumpFirstDisk' => '一个开关,用于多个磁盘如果为1则自动跳转到第一个磁盘', 'autoJumpFirstDisk' => '用于多个磁盘如果为1则自动跳转到第一个磁盘',
'customScript' => '<script>,在所有页都会存在,例如放一个http跳转https', 'customScript' => '<script>,在所有页都会存在,例如放一个http跳转https',
'customCss' => '<style>,在<head>最后面', 'customCss' => '<style>,在<head>最后面',
'customTheme' => 'html格式的主题的url', 'customTheme' => 'html格式的主题的url',
'referrer' => '只有这些域名能引用本站资源。格式为a1.com|b1.com', 'referrer' => '只有这些域名能引用本站资源。格式为a1.com|b1.com',
'domain_path' => '使用多个自定义域名时指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2。', 'domain_path' => '使用多个自定义域名时指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2比private_path优先。',
'diskname' => '这个盘你想显示什么名称。', 'diskname' => '这个盘你想显示什么名称。',
'diskDescription' => '对这个盘的一些描述,随便写,代码不引用这个。', 'diskDescription' => '对这个盘的一些描述,随便写,代码不引用这个。',
'disktag' => '一个标签用于保存配置多盘时会显示在url中。', 'disktag' => '一个标签用于保存配置多盘时会显示在url中。',
'disableShowThumb' => '一个开关,如果填 1, ‘显示缩略’按钮将被隐藏。', 'disableShowThumb' => '如果填 1, ‘显示缩略’按钮将被隐藏。',
'disableChangeTheme' => '一个开关,如果为 1则不会显示主题选择按钮', 'disableChangeTheme' => '如果为 1则不会显示主题选择按钮',
'downloadencrypt' => '一个开关0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。', 'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
'globalHeadOmfUrl' => '从url获取文本当成head.omf显示在每一页。', 'dontBasicAuth' => '如果为 1加密目录不再弹出用户名密码窗口只会显示主题自带的页面。',
'globalHeadMdUrl' => '从url获取文本当成head.md显示在每一页。',
'globalReadmeMdUrl' => '从url获取文本当成readme.md显示在每一页。',
'globalFootOmfUrl' => '从url获取文本当成foot.omf显示在每一页。',
'useBasicAuth' => '一个开关,如果为 1加密目录将弹出用户名密码窗口不会显示主题自带的输入密码页面。',
'background' => '设置一个url作为背景。', 'background' => '设置一个url作为背景。',
'backgroundm' => '设置一个url作为手机端用的背景。', 'backgroundm' => '设置一个url作为手机端用的背景。',
'forceHttps' => '一个开关0或1。如果设置为1会强制跳https', 'theme' => '选择一个主题。',
'fileConduitCacheTime' => '填数字单位是小时如果设置小于1M(或fileConduitSize)的小文件会从程序通过然后缓存在浏览器不然默认302跳微软',
'fileConduitSize' => '填数字单位是M(建议4M以下)如果设置小于这个值的小文件会从程序通过然后缓存在浏览器不然默认302跳微软',
'theme' => '为游客选择一个主题。',
'timezone' => '设置默认时区。', 'timezone' => '设置默认时区。',
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。', 'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
'hideFunctionalityFile' => '一个开关0 或 1。如果 1, 功能文件不列表给游客看但它的功能正常比如readme.md', 'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表给游客看但它的功能正常比如readme.md',
'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;', 'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;',
'domainforproxy' => '会将https://xxxxx-my.sharepoint.com替换成这个值在目标需要自己设置反代。会加上&Origindomain=原域名', 'domainforproxy' => '会将https://xxxxx-my.sharepoint.com替换成这个值在目标需要自己设置反代。会加上&Origindomain=原域名',
'public_path' => '使用API长链接访问时显示网盘文件的路径不设置时默认为根目录。', 'public_path' => '使用API长链接访问时显示网盘文件的路径不设置时默认为根目录不能是private_path的上级public看到的不能比private多要么看到的就不一样。',
'sitename' => '网站的名称', 'sitename' => '网站的名称',
'Onedrive_ver' => 'Onedrive版本',
], ],
'zh-tw' => [ 'zh-tw' => [
'admin' => '管理密碼,不設定密碼將不顯示登入頁面且無法登入。', 'admin' => '管理密碼,不設定密碼將不顯示登入頁面且無法登入。',
'adminloginpage' => '如果設定,登入按鈕及頁面隱藏。管理登入的頁面不再是\'?login=admin\',而是\'?login=此設置的值\'。', 'adminloginpage' => '如果設定,登入按鈕及頁面隱藏。管理登入的頁面不再是\'?admin\',而是\'?此設置的值\'。',
'autoJumpFirstDisk' => '用於多盤如果設1將會自動跳到第一個盤。', 'autoJumpFirstDisk' => '用於多盤如果設1將會自動跳到第一個盤。',
'customScript' => '<script>,在所有頁都會存在,例如放一個http跳轉https', 'customScript' => '<script>,在所有頁都會存在,例如放一個http跳轉https',
'customCss' => '<style>,在<head>最後面', 'customCss' => '<style>,在<head>最後面',
'customTheme' => 'html格式的主題的url', 'customTheme' => 'html格式的主題的url',
'referrer' => '', 'referrer' => '',
'domain_path' => '使用多個自訂域名時指定每個域名看到的目錄。格式為a1.com:/dirto/path1|b1.com:/path2。', 'domain_path' => '使用多個自訂域名時指定每個域名看到的目錄。格式為a1.com:/dirto/path1|b1.com:/path2比private_path優先。',
'diskname' => '這個盤你想顯示什麼名稱。', 'diskname' => '這個盤你想顯示什麼名稱。',
'disktag' => '一個標籤用於儲存配置多盤時會顯示在url中。', 'disktag' => '一個標籤用於儲存配置多盤時會顯示在url中。',
'disableShowThumb' => '如果填 1, ‘顯示縮略’按鈕將被隱藏。', 'disableShowThumb' => '如果填 1, ‘顯示縮略’按鈕將被隱藏。',
@ -170,24 +158,25 @@ $constStr = [
'downloadencrypt' => '0 或 1。如果 1, 那加密目錄內的文件可以不需要密碼就能下載。', 'downloadencrypt' => '0 或 1。如果 1, 那加密目錄內的文件可以不需要密碼就能下載。',
'background' => '設定一個url作為背景。', 'background' => '設定一個url作為背景。',
'backgroundm' => '設定一個url作為手機用的背景。', 'backgroundm' => '設定一個url作為手機用的背景。',
'theme' => '为遊客選擇一個主題。', 'theme' => '選擇一個主題。',
'timezone' => '設定預設時區。', 'timezone' => '設定預設時區。',
'guestup_path' => '設定遊客上傳路徑(圖床路徑),不設定這個值時該目錄內容會正常列文件出來,設定後只有上傳介面,不顯示其中文件(登入後顯示)。', 'guestup_path' => '設定遊客上傳路徑(圖床路徑),不設定這個值時該目錄內容會正常列文件出來,設定後只有上傳介面,不顯示其中文件(登入後顯示)。',
'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表給遊客看但它的功能正常比如readme.md', 'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表給遊客看但它的功能正常比如readme.md',
'passfile' => '自訂密碼文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目錄時不會顯示,只有知道密碼才能查看或下載此文件。密碼是這個文件的內容,可以空格、可以中文;', 'passfile' => '自訂密碼文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目錄時不會顯示,只有知道密碼才能查看或下載此文件。密碼是這個文件的內容,可以空格、可以中文;',
'domainforproxy' => '會將https://xxxxx-my.sharepoint.com取代成這個值在目標需要自己設定反代。會加上&Origindomain=原域名', 'domainforproxy' => '會將https://xxxxx-my.sharepoint.com取代成這個值在目標需要自己設定反代。會加上&Origindomain=原域名',
'public_path' => '使用API長連結訪問時顯示網路硬碟檔案的路徑不設定時預設為根目錄。', 'public_path' => '使用API長連結訪問時顯示網路硬碟檔案的路徑不設定時預設為根目錄不能是private_path的上級public看到的不能比private多要麼看到的就不一樣。',
'sitename' => '網站的名稱', 'sitename' => '網站的名稱',
'Onedrive_ver' => 'Onedrive版本',
], ],
'ja' => [ 'ja' => [
'admin' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。', 'admin' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。',
'adminloginpage' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?login=admin \'ではなく、\'?login=この設定の値\'。', 'adminloginpage' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?admin \'ではなく、\'?この設定の値\'。',
'autoJumpFirstDisk' => '複数のディスクを使って、1を設定すると、自動的に最初のディスクにジャンプします。', 'autoJumpFirstDisk' => '複数のディスクを使って、1を設定すると、自動的に最初のディスクにジャンプします。',
'customScript' => 'scriptは、すべてのページに存在します。例えば、httpを置いてhttpsをジャンプします。', 'customScript' => 'scriptは、すべてのページに存在します。例えば、httpを置いてhttpsをジャンプします。',
'customCss' => 'styleは、headの一番後ろにあります。', 'customCss' => 'styleは、headの一番後ろにあります。',
'customTheme' => 'htmlフォーマットのテーマのurl', 'customTheme' => 'htmlフォーマットのテーマのurl',
'referrer' => '', 'referrer' => '',
'domain_path' => '複数のドメイン名を使用する場合、ドメイン名ごとに見られるディレクトリを指定します。フォーマットはa1.com:/dirto/path1|b1.com:/path2。', 'domain_path' => '複数のドメイン名を使用する場合、ドメイン名ごとに見られるディレクトリを指定します。フォーマットはa 1.com:/dirto/path 1.com:/path 2で、prvate_path優先。',
'diskname' => 'このディスクの名前を表示したいですか?', 'diskname' => 'このディスクの名前を表示したいですか?',
'disktag' => '一つのラベルは保存配置に使い、複数のディスクはurlに表示されます。', 'disktag' => '一つのラベルは保存配置に使い、複数のディスクはurlに表示されます。',
'disableShowThumb' => '1を記入すると、「表示サムネイル」ボタンが隠れます。', 'disableShowThumb' => '1を記入すると、「表示サムネイル」ボタンが隠れます。',
@ -201,18 +190,19 @@ $constStr = [
'hideFunctionalityFile' => '0または1です。もし1ならば、いくつかの書類はリストで観光客に見せませんが、その機能は正常です。readme.md', 'hideFunctionalityFile' => '0または1です。もし1ならば、いくつかの書類はリストで観光客に見せませんが、その機能は正常です。readme.md',
'passfile' => 'カスタムパスワードファイルの名前は、\'pppppp \'、\'aaaa.txt \'などの場合があります。ディレクトリをリストするときには表示されません。パスワードを知っている場合にのみ、このファイルを表示またはダウンロードできます。 パスワードはこのファイルの内容であり、スペースまたは漢字を使用できます。', 'passfile' => 'カスタムパスワードファイルの名前は、\'pppppp \'、\'aaaa.txt \'などの場合があります。ディレクトリをリストするときには表示されません。パスワードを知っている場合にのみ、このファイルを表示またはダウンロードできます。 パスワードはこのファイルの内容であり、スペースまたは漢字を使用できます。',
'domainforproxy' => '会将https://xxxy-my.sharepoint.comこの値に代えて、目標には自分で反世代を設定する必要があります。に加えて&amp;Originndomain=元のドメイン名', 'domainforproxy' => '会将https://xxxy-my.sharepoint.comこの値に代えて、目標には自分で反世代を設定する必要があります。に加えて&amp;Originndomain=元のドメイン名',
'public_path' => 'APIのロングリンクアクセスを使用する場合、ネットワークディスクファイルのパスが表示されますが、設定されていない場合はデフォルトでルートディレクトリになり。', 'public_path' => 'APIのロングリンクアクセスを使用する場合、ネットワークディスクファイルのパスが表示されますが、設定されていない場合はデフォルトでルートディレクトリになり、private_pathの上位にはなりませんpublicはprivate以上のものを見ることができません。それ以外は異なります。。',
'sitename' => 'ウェブサイト名', 'sitename' => 'ウェブサイト名',
'Onedrive_ver' => 'Onedriveバージョン',
], ],
'ko-kr' => [ 'ko-kr' => [
'admin' => '비밀번호를 관리하고 로그인 페이지를 표시하지 않으며 추가하지 않으면 로그인 할 수 없습니다.', 'admin' => '비밀번호를 관리하고 로그인 페이지를 표시하지 않으며 추가하지 않으면 로그인 할 수 없습니다.',
'adminloginpage' => '설정하면 로그인 버튼과 페이지가 숨겨집니다. 로그인 관리 페이지는 더 이상 \ ?login=admin\'이 아니라 \ ?login=이 설정의 값 \'입니다.', 'adminloginpage' => '설정하면 로그인 버튼과 페이지가 숨겨집니다. 로그인 관리 페이지는 더 이상 \ ?Admin\'이 아니라 \ ?이 설정의 값 \'입니다.',
'autoJumpFirstDisk' => '여러 개의 디스크 에 사용 되 며, 1 이 되면 첫 번 째 디스크 로 자동 으로 이동 합 니 다.', 'autoJumpFirstDisk' => '여러 개의 디스크 에 사용 되 며, 1 이 되면 첫 번 째 디스크 로 자동 으로 이동 합 니 다.',
'customScript' => '< script > 은 모든 페이지 에 존재 합 니 다. 예 를 들 어 http 을 하나 넣 고 https 로 이동 합 니 다.', 'customScript' => '< script > 은 모든 페이지 에 존재 합 니 다. 예 를 들 어 http 을 하나 넣 고 https 로 이동 합 니 다.',
'customCss' => '< 스타일 >, < 헤드 > 맨 뒤에', 'customCss' => '< 스타일 >, < 헤드 > 맨 뒤에',
'customTheme' => 'html 형식의 테마 url', 'customTheme' => 'html 형식의 테마 url',
'referrer' => '', 'referrer' => '',
'domain_path' => '도 메 인 이름 을 여러 개 사용자 정의 할 때 도 메 인 이름 마다 보 이 는 디 렉 터 리 를 지정 합 니 다.형식 은 a1.com:/dirto/path1|b1.com:/path2.', 'domain_path' => '도 메 인 이름 을 여러 개 사용자 정의 할 때 도 메 인 이름 마다 보 이 는 디 렉 터 리 를 지정 합 니 다.형식 은 a1. com: / dirto / path 1 | b1. com: / path 2, privatepath 우선.',
'diskname' => '이 접시 에 당신 은 어떤 명칭 을 표시 하고 싶 습 니까?', 'diskname' => '이 접시 에 당신 은 어떤 명칭 을 표시 하고 싶 습 니까?',
'disktag' => '디스크가 여러 개인 경우 구성을 저장하는 데 사용되는 레이블이 url에 표시됩니다.', 'disktag' => '디스크가 여러 개인 경우 구성을 저장하는 데 사용되는 레이블이 url에 표시됩니다.',
'disableShowThumb' => '1을 입력하면 “썸네일 표시”버튼이 숨겨집니다.', 'disableShowThumb' => '1을 입력하면 “썸네일 표시”버튼이 숨겨집니다.',
@ -228,10 +218,11 @@ $constStr = [
'domainforproxy' => 'https://xxxxx-my.sharepoint.com을이 값으로 바꾸고 대상에서 안티 생성을 설정해야합니다. & Origindomain = Original domain name 을 추가합니다.', 'domainforproxy' => 'https://xxxxx-my.sharepoint.com을이 값으로 바꾸고 대상에서 안티 생성을 설정해야합니다. & Origindomain = Original domain name 을 추가합니다.',
'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.', 'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.',
'sitename' => '웹 사이트 이름', 'sitename' => '웹 사이트 이름',
'Onedrive_ver' => 'Onedrive 버전',
], ],
'fa' => [ 'fa' => [
'admin' => 'رمز عبور ادمین، در صورت خالی بودن دکمه لاگین به نمایش در نمی‌آید', 'admin' => 'رمز عبور ادمین، در صورت خالی بودن دکمه لاگین به نمایش در نمی‌آید',
'adminloginpage' => 'در صورت تنظیم ، دکمه ورود نمایش داده نمی شود و صفحه ورود دیگر \?login=admin\ نیست بلکه \?login={مقدار ورودی شما}\ است.', 'adminloginpage' => 'در صورت تنظیم ، دکمه ورود نمایش داده نمی شود و صفحه ورود دیگر \?admin\ نیست بلکه \?{مقدار ورودی شما}\ است.',
'referrer' => '', 'referrer' => '',
'domain_path' => 'تنظیم دامنه سفارشی، به صورت a1.com:/dirto/path1|b2.com:/path2', 'domain_path' => 'تنظیم دامنه سفارشی، به صورت a1.com:/dirto/path1|b2.com:/path2',
'diskname' => 'نام دیسک که می‌خواهید نشان دهید.', 'diskname' => 'نام دیسک که می‌خواهید نشان دهید.',
@ -242,6 +233,7 @@ $constStr = [
'passfile' => 'رمز عبور dir در این فایل ذخیره می شود.', 'passfile' => 'رمز عبور dir در این فایل ذخیره می شود.',
'public_path' => 'این مسیر Onedrive را هنگامی که از طریق آدرس طولانی API Gateway استفاده می کنید ، نشان دهید. فایل های نمایش عمومی کمتر از خصوصی.', 'public_path' => 'این مسیر Onedrive را هنگامی که از طریق آدرس طولانی API Gateway استفاده می کنید ، نشان دهید. فایل های نمایش عمومی کمتر از خصوصی.',
'sitename' => 'نام سایت', 'sitename' => 'نام سایت',
'Onedrive_ver' => 'ورژن Onedrive',
], ],
'ar-sa' => [ 'ar-sa' => [
'admin' => ' إدارة كلمة السر ، لا يمكنك عرض صفحة تسجيل الدخول دون إضافة', 'admin' => ' إدارة كلمة السر ، لا يمكنك عرض صفحة تسجيل الدخول دون إضافة',
@ -267,6 +259,7 @@ $constStr = [
'domainforproxy' => 'سوف لا شيء استبدال هذه القيمة ، تحتاج إلى تعيين جيل معاكس في الهدف الخاص بك إضافة اسم النطاق الأصلي', 'domainforproxy' => 'سوف لا شيء استبدال هذه القيمة ، تحتاج إلى تعيين جيل معاكس في الهدف الخاص بك إضافة اسم النطاق الأصلي',
'public_path' => 'عند استخدام API وصلة طويلة للوصول إلى عرض مسار الملف على القرص ، إذا لم يتم تعيين الافتراضي هو الجذر ، لا يمكن أن يكون private ش لا يمكن أن نرى أكثر من private publics ، أو لا', 'public_path' => 'عند استخدام API وصلة طويلة للوصول إلى عرض مسار الملف على القرص ، إذا لم يتم تعيين الافتراضي هو الجذر ، لا يمكن أن يكون private ش لا يمكن أن نرى أكثر من private publics ، أو لا',
'sitename' => 'اسم الموقع', 'sitename' => 'اسم الموقع',
'Onedrive_ver' => 'أوندريف',
], ],
], ],
'SetSecretsFirst' => [ 'SetSecretsFirst' => [
@ -1084,11 +1077,11 @@ $constStr = [
'ar-sa' => 'أكد بي إتش بي قابل للكتابة', 'ar-sa' => 'أكد بي إتش بي قابل للكتابة',
], ],
'MakesuerRewriteOn' => [ 'MakesuerRewriteOn' => [
'en-us' => 'Plase make sure the RewriteEngine is On', 'en-us' => 'Plase make sure the RewriteEngine is On.',
'zh-cn' => '确认重写(伪静态)功能启用', 'zh-cn' => '确认重写(伪静态)功能启用',
'zh-tw' => '確認重寫(偽靜態)功能啟用', 'zh-tw' => '確認重寫(偽靜態)功能啟用',
'ja' => '書き換え(擬似静的)機能が有効になっていることを確認します', 'ja' => '書き換え(擬似静的)機能が有効になっていることを確認します',
'ko-kr' => '다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오', 'ko-kr' => '다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오.',
'fa' => 'لطفاً مطمئن شوید که RewriteEngine روشن است.', 'fa' => 'لطفاً مطمئن شوید که RewriteEngine روشن است.',
'ar-sa' => 'يؤكد أن الكتابة يمكن أن تكون وظيفة شبه استاتي', 'ar-sa' => 'يؤكد أن الكتابة يمكن أن تكون وظيفة شبه استاتي',
], ],
@ -1134,9 +1127,9 @@ $constStr = [
'ar-sa' => 'اختيار اللغة', 'ar-sa' => 'اختيار اللغة',
], ],
'RefreshCache' => [ 'RefreshCache' => [
'en-us' => 'Refresh Cache of Current Folder', 'en-us' => 'RefreshCache',
'zh-cn' => '刷新当前目录的缓存', 'zh-cn' => '刷新缓存',
'zh-tw' => '重新整理当前資料夾快取', 'zh-tw' => '重新整理快取',
'ja' => 'キャッシュを再構築', 'ja' => 'キャッシュを再構築',
'ko-kr' => '캐시 플러시', 'ko-kr' => '캐시 플러시',
'fa' => 'رفرش cache', 'fa' => 'رفرش cache',
@ -1152,46 +1145,6 @@ $constStr = [
'zh-cn' => '查询分支', 'zh-cn' => '查询分支',
'zh-tw' => '查詢分支', 'zh-tw' => '查詢分支',
], ],
'OldPassword' => [
'en-us' => 'Old Password',
'zh-cn' => '旧密码',
'zh-tw' => '旧密碼',
],
'NewPassword' => [
'en-us' => 'New Password',
'zh-cn' => '新密码',
'zh-tw' => '新密碼',
],
'ReInput' => [
'en-us' => 'ReInput',
'zh-cn' => '再输入一次',
'zh-tw' => '再输入一次',
],
'ChangAdminPassword' => [
'en-us' => 'Chang Admin Password',
'zh-cn' => '修改管理密码',
'zh-tw' => '修改管理密碼',
],
'AdminPassword' => [
'en-us' => 'Admin Password',
'zh-cn' => '管理密码',
'zh-tw' => '管理密碼',
],
'export' => [
'en-us' => 'export',
'zh-cn' => '导出',
'zh-tw' => '导出',
],
'config' => [
'en-us' => 'config',
'zh-cn' => '配置',
'zh-tw' => '配置',
],
'import' => [
'en-us' => 'import',
'zh-cn' => '导入',
'zh-tw' => '导入',
],
'ONEMANAGER_CONFIG_SAVE_ENV' => [ 'ONEMANAGER_CONFIG_SAVE_ENV' => [
'en-us' => 'Config save in Environments', 'en-us' => 'Config save in Environments',
'zh-cn' => '配置保存在环境变量', 'zh-cn' => '配置保存在环境变量',

View File

@ -9,10 +9,7 @@ class Aliyundrive {
//$this->auth_url = 'https://websv.aliyundrive.com/token/refresh'; //$this->auth_url = 'https://websv.aliyundrive.com/token/refresh';
$this->auth_url = 'https://auth.aliyundrive.com/v2/account/token'; $this->auth_url = 'https://auth.aliyundrive.com/v2/account/token';
$this->api_url = 'https://api.aliyundrive.com/v2'; $this->api_url = 'https://api.aliyundrive.com/v2';
$this->api_url_v3 = 'https://api.aliyundrive.com/adrive/v3';
$this->driveId = getConfig('driveId', $tag); $this->driveId = getConfig('driveId', $tag);
//$this->DownurlStrName = 'download_url';
$this->DownurlStrName = 'url';
$res = $this->get_access_token(getConfig('refresh_token', $tag)); $res = $this->get_access_token(getConfig('refresh_token', $tag));
} }
@ -53,7 +50,7 @@ class Aliyundrive {
$tmp['time'] = $files['updated_at']; $tmp['time'] = $files['updated_at'];
$tmp['size'] = $files['size']; $tmp['size'] = $files['size'];
$tmp['mime'] = $files['file']['mimeType']; $tmp['mime'] = $files['file']['mimeType'];
$tmp['url'] = $files[$this->DownurlStrName]; $tmp['url'] = $files['download_url'];
$tmp['content'] = $files['content']; $tmp['content'] = $files['content'];
if (isset($files['exist'])) $tmp['exist'] = $files['exist']; if (isset($files['exist'])) $tmp['exist'] = $files['exist'];
if (isset($files['rapid_upload'])) $tmp['rapid_upload'] = $files['rapid_upload']; if (isset($files['rapid_upload'])) $tmp['rapid_upload'] = $files['rapid_upload'];
@ -69,7 +66,7 @@ class Aliyundrive {
$filename = strtolower($file['name']); $filename = strtolower($file['name']);
if ($file['type']=='file') { if ($file['type']=='file') {
$tmp['list'][$filename]['type'] = 'file'; $tmp['list'][$filename]['type'] = 'file';
$tmp['list'][$filename]['url'] = $file[$this->DownurlStrName]; $tmp['list'][$filename]['url'] = $file['download_url'];
$tmp['list'][$filename]['mime'] = $file['file']['content_type']; $tmp['list'][$filename]['mime'] = $file['file']['content_type'];
} elseif ($file['type']=='folder') { } elseif ($file['type']=='folder') {
$tmp['list'][$filename]['type'] = 'folder'; $tmp['list'][$filename]['type'] = 'folder';
@ -79,7 +76,7 @@ class Aliyundrive {
$tmp['list'][$filename]['name'] = $file['name']; $tmp['list'][$filename]['name'] = $file['name'];
$tmp['list'][$filename]['time'] = $file['updated_at']; $tmp['list'][$filename]['time'] = $file['updated_at'];
$tmp['list'][$filename]['size'] = $file['size']; $tmp['list'][$filename]['size'] = $file['size'];
//$tmp['childcount']++; $tmp['childcount']++;
} }
} elseif (isset($files['code'])||isset($files['error'])) { } elseif (isset($files['code'])||isset($files['error'])) {
return $files; return $files;
@ -93,13 +90,14 @@ class Aliyundrive {
global $exts; global $exts;
while (substr($path, -1)=='/') $path = substr($path, 0, -1); while (substr($path, -1)=='/') $path = substr($path, 0, -1);
if ($path == '') $path = '/'; if ($path == '') $path = '/';
//$files = getcache('path_' . $path, $this->disktag);
//if (!$files) {
if (!($files = getcache('path_' . $path, $this->disktag))) { if (!($files = getcache('path_' . $path, $this->disktag))) {
if ($path == '/' || $path == '') { if ($path == '/' || $path == '') {
$files = $this->fileList('root'); $files = $this->fileList('root');
//error_log1('root_id' . $files['file_id']); //error_log1('root_id' . $files['id']);
$files['file_id'] = 'root'; $files['file_id'] = 'root';
$files['type'] = 'folder'; $files['type'] = 'folder';
//error_log1(json_encode($files, JSON_PRETTY_PRINT));
} else { } else {
$tmp = splitlast($path, '/'); $tmp = splitlast($path, '/');
$parent_path = $tmp[0]; $parent_path = $tmp[0];
@ -115,33 +113,22 @@ class Aliyundrive {
$files['time'] = $item['updated_at']; $files['time'] = $item['updated_at'];
$files['size'] = $item['size']; $files['size'] = $item['size'];
} else $files = $item; } else $files = $item;
} }
} }
//echo $files['name']; //echo $files['name'];
} }
if ($files['type']=='file') { if ($files['type']=='file') {
if (in_array(strtolower(splitlast($files['name'],'.')[1]), $exts['txt'])) { if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) {
if ($files['size']<1024*1024) {
if (!(isset($files['content'])&&$files['content']['stat']==200)) { if (!(isset($files['content'])&&$files['content']['stat']==200)) {
$header['Referer'] = 'https://www.aliyundrive.com/'; $header['Referer'] = 'https://www.aliyundrive.com/';
$header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'; $header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36';
$content1 = curl('GET', $files[$this->DownurlStrName], '', $header); $content1 = curl('GET', $files['download_url'], '', $header);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
}
//error_log1('body : ' . $content1['body'] . PHP_EOL);
$files['content'] = $content1; $files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag); savecache('path_' . $path, $files, $this->disktag);
} }
} else { error_log1($files['name'] . ' : ' . json_encode($files['content']) . PHP_EOL);
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
//error_log1($files['name'] . ' : ' . json_encode($files['content']) . PHP_EOL);
} }
} }
if (!$files) { if (!$files) {
@ -185,37 +172,25 @@ class Aliyundrive {
} }
protected function fileList($parent_file_id) protected function fileList($parent_file_id)
{ {
$url = $this->api_url_v3 . '/file/list'; $url = $this->api_url . '/file/list';
$header["content-type"] = "application/json; charset=utf-8"; $header["content-type"] = "application/json; charset=utf-8";
$header['authorization'] = 'Bearer ' . $this->access_token; $header['authorization'] = 'Bearer ' . $this->access_token;
$data['limit'] = 200; $data['limit'] = 50;
$data['marker'] = null; $data['marker'] = NULL;
$data['drive_id'] = $this->driveId; $data['drive_id'] = $this->driveId;
$data['parent_file_id'] = $parent_file_id; $data['parent_file_id'] = $parent_file_id;
$data['image_thumbnail_process'] = 'image/resize,w_160/format,jpeg'; $data['image_thumbnail_process'] = 'image/resize,w_160/format,jpeg';
$data['image_url_process'] = 'image/resize,w_1920/format,jpeg'; $data['image_url_process'] = 'image/resize,w_1920/format,jpeg';
$data['video_thumbnail_process'] = 'video/snapshot,t_0,f_jpg,w_300'; $data['video_thumbnail_process'] = 'video/snapshot,t_0,f_jpg,w_300';
$data['fields'] = '*'; $data['fields'] = '*';
$data['order_by'] = 'name'; //updated_at $data['order_by'] = 'updated_at';
$data['order_direction'] = 'ASC'; //DESC $data['order_direction'] = 'DESC';
$res = curl('POST', $url, json_encode($data), $header); $res = curl('POST', $url, json_encode($data), $header);
//error_log1($res['stat'] . $res['body']); //error_log1($res['stat'] . $res['body']);
if ($res['stat']==200) { if ($res['stat']==200) return json_decode($res['body'], true);
$body = json_decode($res['body'], true);
$body1 = $body;
while ($body1['next_marker']!='') {
$data['marker'] = $body1['next_marker'];
$res1 = null;
$res1 = curl('POST', $url, json_encode($data), $header);
$body1 = json_decode($res1['body'], true);
$body['items'] = array_merge($body['items'], $body1['items']);
}
return $body;
//return json_decode($res['body'], true);
}
else return $res; else return $res;
} }
@ -331,60 +306,47 @@ class Aliyundrive {
} else { } else {
$oldfile = $this->fileGet($file['id']); $oldfile = $this->fileGet($file['id']);
} }
if ($oldfile['type']=='folder') return output('Can not copy folder', 415);
if (!function_exists('bcadd')) { $url = $this->api_url . '/file/create';
// no php-bcmath
if ($bcmathurl = getConfig('bcmathUrl', $this->disktag)) {
if (strpos($bcmathurl, '?')) {
$bcmathurl .= '&dividend=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('No bcmath module, can not copy', 415);
}
} else {
$r = bchexdec( substr(md5($this->access_token), 0, 16) );
$o = bcmod($r, $oldfile['size']);
}
$res = curl('GET', $oldfile[$this->DownurlStrName], '', [
'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["content-type"] = "application/json; charset=utf-8";
$header['authorization'] = 'Bearer ' . $this->access_token; $header['authorization'] = 'Bearer ' . $this->access_token;
$data['check_name_mode'] = 'auto_rename'; // ignore, auto_rename, refuse. $data['check_name_mode'] = 'auto_rename'; // ignore, auto_rename, refuse.
$data['content_hash'] = $oldfile['content_hash']; $data['content_hash'] = $oldfile['content_hash'];
$data['content_hash_name'] = 'sha1'; $data['content_hash_name'] = 'sha1';
$data['content_type'] = $oldfile['content_type'];
$data['drive_id'] = $this->driveId; $data['drive_id'] = $this->driveId;
$data['ignoreError'] = false;
$data['name'] = $oldfile['name']; $data['name'] = $oldfile['name'];
$data['parent_file_id'] = $oldfile['parent_file_id']; $data['parent_file_id'] = $oldfile['parent_file_id'];
$data['part_info_list'][0]['part_number'] = 1; $data['part_info_list'][0]['part_number'] = 1;
$data['proof_code'] = $proof_code;
$data['proof_version'] = 'v1';
$data['size'] = $oldfile['size']; $data['size'] = $oldfile['size'];
$data['type'] = 'file'; $data['type'] = 'file';
$result = curl('POST', $url, json_encode($data), $header); $result = curl('POST', $url, json_encode($data), $header);
/*if ($result['stat']==201) {
if ($result['stat']==201) {
//error_log1('1,url:' . $url .' res:' . json_encode($result));
$res = json_decode($result['body'], true); $res = json_decode($result['body'], true);
if ($res['rapid_upload']) return output('rapid upload', 200);
$url = $res['part_info_list'][0]['upload_url']; $url = $res['part_info_list'][0]['upload_url'];
if (!$url) { // 无url应该算秒传 if (!$url) { // 无url应该算秒传
return output('no up url', 200); return output('no up url', 200);
} else { } else {
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
} }
/*$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);
}*/ }*/
}
//error_log1('2,url:' . $url .' res:' . json_encode($result)); //error_log1('2,url:' . $url .' res:' . json_encode($result));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); 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) { public function Edit($file, $content) {
$tmp = splitlast($file['path'], '/'); $tmp = splitlast($file['path'], '/');
@ -506,31 +468,6 @@ class Aliyundrive {
return curl('POST', $url, json_encode($data), $header); return curl('POST', $url, json_encode($data), $header);
} }
protected function fileCreate1($parentId, $fileName, $sha1, $proof_code, $size, $part_number) {
//$url = $this->api_url . '/file/create';
$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'] = 'refuse'; // ignore, auto_rename, refuse.
$data['content_hash'] = $sha1;
$data['content_hash_name'] = 'sha1';
//$data['content_type'] = '';
$data['drive_id'] = $this->driveId;
//$data['ignoreError'] = false;
$data['name'] = $fileName;
$data['parent_file_id'] = $parentId;
for ($i=0;$i<$part_number;$i++) {
$data['part_info_list'][$i]['part_number'] = $i+1;
}
$data['proof_code'] = $proof_code;
$data['proof_version'] = 'v1';
$data['size'] = (int)$size;
$data['type'] = 'file';
return curl('POST', $url, json_encode($data), $header);
}
protected function tmpfileCreate($parentId, $tmpFilePath, $tofileName = '') { protected function tmpfileCreate($parentId, $tmpFilePath, $tofileName = '') {
$sha1 = sha1_file($tmpFilePath); $sha1 = sha1_file($tmpFilePath);
if ($tofileName == '') $tofileName = splitlast($tmpFilePath, '/')[1]; if ($tofileName == '') $tofileName = splitlast($tmpFilePath, '/')[1];
@ -579,60 +516,6 @@ class Aliyundrive {
$thumb_url = $res['thumbnail']; $thumb_url = $res['thumbnail'];
return $thumb_url; 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[$this->DownurlStrName] = $_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) public function bigfileupload($path)
{ {
if (isset($_POST['uploadid'])) { if (isset($_POST['uploadid'])) {
@ -640,20 +523,6 @@ class Aliyundrive {
$result = $this->fileComplete($_POST['fileid'], $_POST['uploadid'], json_decode($_POST['etag'], true)); $result = $this->fileComplete($_POST['fileid'], $_POST['uploadid'], json_decode($_POST['etag'], true));
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
} else { } else {
if (isset($_POST['CalcProof'])) {
return output(substr(md5($this->access_token), 0, 16), 200);
// Calc proof code
/*if (!function_exists('bcadd')) {
// no php-bcmath
return output(0, 200);
} else {
$r = bchexdec( substr(md5($this->access_token), 0, 16) );
$i = $_POST['filesize'];
//$o = $i ? bcmod($r, $i) : 0;
$o = bcmod($r, $i);
return output($o, 200);
}*/
}
if ($_POST['upbigfilename']=='') return output('error: no file name', 400); if ($_POST['upbigfilename']=='') return output('error: no file name', 400);
if (!is_numeric($_POST['filesize'])) return output('error: no file size', 400); if (!is_numeric($_POST['filesize'])) return output('error: no file size', 400);
if (!isset($_POST['filesha1'])) return output('error: no file sha1', 400); if (!isset($_POST['filesha1'])) return output('error: no file sha1', 400);
@ -683,11 +552,7 @@ class Aliyundrive {
//error_log1($res['body']); //error_log1($res['body']);
$parent_file_id = json_decode($res['body'], true)['file_id']; $parent_file_id = json_decode($res['body'], true)['file_id'];
} }
//if (!function_exists('bcadd')) { $response = $this->fileCreate($parent_file_id, $filename, $_POST['filesha1'], $fileinfo['size'], ceil($fileinfo['size']/$_POST['chunksize']));
// $response = $this->fileCreate($parent_file_id, $filename, $_POST['filesha1'], $fileinfo['size'], ceil($fileinfo['size']/$_POST['chunksize']));
//} else {
$response = $this->fileCreate1($parent_file_id, $filename, $_POST['filesha1'], $_POST['proof_code'], $fileinfo['size'], ceil($fileinfo['size']/$_POST['chunksize']));
//}
$res = json_decode($response['body'], true); $res = json_decode($response['body'], true);
if (isset($res['exist'])) { if (isset($res['exist'])) {
// 已经有 // 已经有
@ -743,19 +608,8 @@ class Aliyundrive {
$title = 'Error'; $title = 'Error';
return message($html, $title, 201); return message($html, $title, 201);
} else { } else {
$str .= ' $str .= '<meta http-equiv="refresh" content="5;URL=' . $url . '">';
<script> return message($str, getconstStr('WaitJumpIndex'), 201);
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(min++);
} else {
clearInterval(uploadList);
location.href = "' . $url . '";
}
}, 1000);
</script>';
return message($str, getconstStr('WaitJumpIndex'), 201, 1);
} }
} }
if (isset($_GET['SelectDrive'])) { if (isset($_GET['SelectDrive'])) {
@ -816,7 +670,6 @@ class Aliyundrive {
</form> </form>
</div> </div>
<script> <script>
var status = "' . $response['DplStatus'] . '";
function notnull(t) function notnull(t)
{ {
if (t.driveId.value==\'\') { if (t.driveId.value==\'\') {
@ -827,7 +680,7 @@ class Aliyundrive {
} }
</script> </script>
'; ';
return message($html, $title, 201, 1); return message($html, $title, 201);
} }
if (isset($_GET['install0']) && $_POST['disktag_add']!='') { if (isset($_GET['install0']) && $_POST['disktag_add']!='') {
$_POST['disktag_add'] = preg_replace('/[^0-9a-zA-Z|_]/i', '', $_POST['disktag_add']); $_POST['disktag_add'] = preg_replace('/[^0-9a-zA-Z|_]/i', '', $_POST['disktag_add']);
@ -863,7 +716,7 @@ class Aliyundrive {
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
$title = 'Error'; $title = 'Error';
return message($html, $title, 400); return message($html, $title, 201);
} else { } else {
$title = 'Refresh token'; $title = 'Refresh token';
$html = ' $html = '
@ -882,10 +735,9 @@ class Aliyundrive {
} }
return true; return true;
} }
var status = "' . $response['DplStatus'] . '";
</script> </script>
'; ';
return message($html, $title, 201, 1); return message($html, $title, 201);
} }
} }
@ -913,7 +765,7 @@ class Aliyundrive {
alert("Do not input ' . $envs . '"); alert("Do not input ' . $envs . '");
return false; return false;
} }
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,})$/; var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
if (!reg.test(t.disktag_add.value)) { if (!reg.test(t.disktag_add.value)) {
alert(\'' . getconstStr('TagFormatAlert') . '\'); alert(\'' . getconstStr('TagFormatAlert') . '\');
return false; return false;

File diff suppressed because it is too large Load Diff

View File

@ -128,8 +128,7 @@ class Googledrive {
//$this->permission('delete', $files['id']); //$this->permission('delete', $files['id']);
//if (isset($item['mimeType']) && $item['mimeType']!='application/vnd.google-apps.folder') { //if (isset($item['mimeType']) && $item['mimeType']!='application/vnd.google-apps.folder') {
if (in_array(strtolower(splitlast($item['name'],'.')[1]), $exts['txt'])) { if (in_array(splitlast($item['name'],'.')[1], $exts['txt'])) {
if ($files['size']<1024*1024) {
if (!(isset($item['content'])&&$item['content']['stat']==200)) { if (!(isset($item['content'])&&$item['content']['stat']==200)) {
//if (!isset($item['downUrl'])) { //if (!isset($item['downUrl'])) {
$res = curl('GET', $item['webContentLink'], '', [], 1); $res = curl('GET', $item['webContentLink'], '', [], 1);
@ -139,23 +138,12 @@ class Googledrive {
//} //}
if ($res['stat']==302) { if ($res['stat']==302) {
$content1 = curl('GET', $weblink, '', ["User-Agent"=>"qkqpttgf/OneManager 3.0.0", "Accept"=>"*/*"]); $content1 = curl('GET', $weblink, '', ["User-Agent"=>"qkqpttgf/OneManager 3.0.0", "Accept"=>"*/*"]);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
}
$item['content'] = $content1; $item['content'] = $content1;
}// else $content1 = $res; }// else $content1 = $res;
//error_log1($item['name'] . '~' . json_encode($content1, JSON_PRETTY_PRINT) . PHP_EOL); //error_log1($item['name'] . '~' . json_encode($content1, JSON_PRETTY_PRINT) . PHP_EOL);
$parent_folder['files'][$i] = $item; $parent_folder['files'][$i] = $item;
savecache('path_' . $path, $parent_folder, $this->disktag); savecache('path_' . $path, $parent_folder, $this->disktag);
} }
} else {
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
} }
//} //}
@ -718,7 +706,7 @@ class Googledrive {
alert("Do not input ' . $envs . '"); alert("Do not input ' . $envs . '");
return false; return false;
} }
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,})$/; var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
if (!reg.test(t.disktag_add.value)) { if (!reg.test(t.disktag_add.value)) {
alert(\'' . getconstStr('TagFormatAlert') . '\'); alert(\'' . getconstStr('TagFormatAlert') . '\');
return false; return false;

View File

@ -1,7 +1,4 @@
<?php <?php
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
class Onedrive { class Onedrive {
protected $access_token; protected $access_token;
@ -49,35 +46,20 @@ class Onedrive {
{ {
global $exts; global $exts;
if (!($files = getcache('path_' . $path, $this->disktag))) { if (!($files = getcache('path_' . $path, $this->disktag))) {
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
$pos = splitlast($path, '/'); $pos = splitlast($path, '/');
$parentpath = $pos[0]; $parentpath = $pos[0];
if ($parentpath=='') $parentpath = '/'; if ($parentpath=='') $parentpath = '/';
$filename = strtolower($pos[1]); $filename = $pos[1];
if ($parentfiles = getcache('path_' . $parentpath, $this->disktag)) { if ($parentfiles = getcache('path_' . $parentpath, $this->disktag)) {
if (isset($parentfiles['children'][$filename][$this->DownurlStrName])) { if (isset($parentfiles['children'][$filename][$this->DownurlStrName])) {
if (in_array(splitlast($filename,'.')[1], $exts['txt'])) { 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);
if ($parentfiles['children'][$filename]['size']<1024*1024) {
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) { if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
$content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]); $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; $parentfiles['children'][$filename]['content'] = $content1;
savecache('path_' . $path, $parentfiles['children'][$filename], $this->disktag); savecache('path_' . $parentpath, $parentfiles, $this->disktag);
}
} else {
$parentfiles['children'][$filename]['content']['stat'] = 202;
$parentfiles['children'][$filename]['content']['body'] = 'File too large.';
}
} }
} }
return $this->files_format($parentfiles['children'][$filename]); return $this->files_format($parentfiles['children'][$filename]);
@ -111,32 +93,19 @@ class Onedrive {
} }
} else { } else {
// files num < 200 , then cache // files num < 200 , then cache
if (isset($files['children'])) { //if (isset($files['children'])) {
$files['children'] = children_name($files['children']); //$files['children'] = children_name($files['children']);
} //}
savecache('path_' . $path, $files, $this->disktag); savecache('path_' . $path, $files, $this->disktag);
} }
} }
if (isset($files['file'])) { if (isset($files['file'])) {
if (in_array(strtolower(splitlast($files['name'],'.')[1]), $exts['txt'])) { if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) {
if ($files['size']<1024*1024) {
if (!(isset($files['content'])&&$files['content']['stat']==200)) { if (!(isset($files['content'])&&$files['content']['stat']==200)) {
$content1 = curl('GET', $files[$this->DownurlStrName]); $content1 = curl('GET', $files[$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'];
}
$files['content'] = $content1; $files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag); savecache('path_' . $path, $files, $this->disktag);
} }
} else {
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
} }
} }
if (isset($files['error'])) { if (isset($files['error'])) {
@ -150,7 +119,7 @@ class Onedrive {
} else { } else {
$files['error']['stat'] = 503; $files['error']['stat'] = 503;
$files['error']['code'] = 'unknownError'; $files['error']['code'] = 'unknownError';
$files['error']['message'] = 'unknownError ' . $arr['body'] . " ~"; $files['error']['message'] = 'unknownError';
} }
//$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true); //$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
//error_log1(json_encode($files, JSON_PRETTY_PRINT)); //error_log1(json_encode($files, JSON_PRETTY_PRINT));
@ -199,7 +168,6 @@ class Onedrive {
return $files; return $files;
} }
//error_log1(json_encode($tmp)); //error_log1(json_encode($tmp));
//echo '<pre>' . json_encode($tmp, JSON_PRETTY_PRINT) . '</pre>';
return $tmp; return $tmp;
} }
@ -362,24 +330,21 @@ class Onedrive {
$oldname = path_format($file['path'] . '/' . $oldname); $oldname = path_format($file['path'] . '/' . $oldname);
$data = '{"name":"' . $newname . '"}'; $data = '{"name":"' . $newname . '"}';
//echo $oldname; //echo $oldname;
if ($file['id']) $result = $this->MSAPI('PATCH', "/items/" . $file['id'], $data); $result = $this->MSAPI('PATCH', $oldname, $data);
else $result = $this->MSAPI('PATCH', $oldname, $data);
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
} }
public function Delete($file) { public function Delete($file) {
$filename = spurlencode($file['name']); $filename = spurlencode($file['name']);
$filename = path_format($file['path'] . '/' . $filename); $filename = path_format($file['path'] . '/' . $filename);
//echo $filename; //echo $filename;
if ($file['id']) $result = $this->MSAPI('DELETE', "/items/" . $file['id']); $result = $this->MSAPI('DELETE', $filename);
else $result = $this->MSAPI('DELETE', $filename); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
if ($result['stat']!=204) $r_body = json_encode($this->files_format(json_decode($result['body'], true))); return output($result['body'], $result['stat']);
return output($r_body, $result['stat']);
//return output($result['body'], $result['stat']);
} }
public function Encrypt($folder, $passfilename, $pass) { public function Encrypt($folder, $passfilename, $pass) {
$filename = '/items/' . $folder['id'] . ':/' . urlencode($passfilename); $filename = path_format($folder['path'] . '/' . urlencode($passfilename));
if ($pass==='') { if ($pass==='') {
$result = $this->MSAPI('DELETE', $filename); $result = $this->MSAPI('DELETE', $filename, '');
} else { } else {
$result = $this->MSAPI('PUT', $filename, $pass); $result = $this->MSAPI('PUT', $filename, $pass);
} }
@ -387,19 +352,18 @@ class Onedrive {
if ($path1!='/'&&substr($path1, -1)=='/') $path1 = substr($path1, 0, -1); if ($path1!='/'&&substr($path1, -1)=='/') $path1 = substr($path1, 0, -1);
savecache('path_' . $path1 . '/?password', '', $this->disktag, 1); savecache('path_' . $path1 . '/?password', '', $this->disktag, 1);
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
//return output($result['body'], $result['stat']); return output($result['body'], $result['stat']);
} }
public function Move($file, $folder) { public function Move($file, $folder) {
$filename = spurlencode($file['name']); $filename = spurlencode($file['name']);
$filename = path_format($file['path'] . '/' . $filename); $filename = path_format($file['path'] . '/' . $filename);
$data = '{"parentReference":{"path": "/drive/root:' . $folder['path'] . '"}}'; $data = '{"parentReference":{"path": "/drive/root:' . $folder['path'] . '"}}';
if ($file['id']) $result = $this->MSAPI('PATCH', "/items/" . $file['id'], $data); $result = $this->MSAPI('PATCH', $filename, $data);
else $result = $this->MSAPI('PATCH', $filename, $data);
$path2 = spurlencode($folder['path'], '/'); $path2 = spurlencode($folder['path'], '/');
if ($path2!='/'&&substr($path2, -1)=='/') $path2 = substr($path2, 0, -1); if ($path2!='/'&&substr($path2, -1)=='/') $path2 = substr($path2, 0, -1);
savecache('path_' . $path2, json_decode('{}', true), $this->disktag, 1); savecache('path_' . $path2, json_decode('{}', true), $this->disktag, 1);
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
//return output($result['body'], $result['stat']); return output($result['body'], $result['stat']);
} }
public function Copy($file) { public function Copy($file) {
$filename = spurlencode($file['name']); $filename = spurlencode($file['name']);
@ -413,8 +377,7 @@ class Onedrive {
$newname = '.' . $namearr[1] . ' (' . date("Ymd\THis\Z") . ')'; $newname = '.' . $namearr[1] . ' (' . date("Ymd\THis\Z") . ')';
} }
$data = '{ "name": "' . $newname . '" }'; $data = '{ "name": "' . $newname . '" }';
if ($file['id']) $result = $this->MSAPI('copy', "/items/" . $file['id'], $data); $result = $this->MSAPI('copy', $filename, $data);
else $result = $this->MSAPI('copy', $filename, $data);
/*$num = 0; /*$num = 0;
while ($result['stat']==409 && json_decode($result['body'], true)['error']['code']=='nameAlreadyExists') { while ($result['stat']==409 && json_decode($result['body'], true)['error']['code']=='nameAlreadyExists') {
$num++; $num++;
@ -429,7 +392,7 @@ class Onedrive {
$result = $this->MSAPI('copy', $filename, $data); $result = $this->MSAPI('copy', $filename, $data);
}*/ }*/
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
//return output($result['body'], $result['stat']); return output($result['body'], $result['stat']);
} }
public function Edit($file, $content) { public function Edit($file, $content) {
/*TXT一般不会超过4M不用二段上传 /*TXT一般不会超过4M不用二段上传
@ -456,7 +419,7 @@ class Onedrive {
} }
//savecache('path_' . $path1, json_decode('{}',true), $_SERVER['disktag'], 1); //savecache('path_' . $path1, json_decode('{}',true), $_SERVER['disktag'], 1);
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']); return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
//return output($result['body'], $result['stat']); return output($result['body'], $result['stat']);
} }
public function AddDisk() { public function AddDisk() {
@ -465,7 +428,7 @@ class Onedrive {
$envs = ''; $envs = '';
foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', '; foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
$url = $_SERVER['PHP_SELF']; $url = path_format($_SERVER['PHP_SELF'] . '/');
//$this->api_url = splitfirst($_SERVER['api_url'], '/v1.0')[0] . '/v1.0'; //$this->api_url = splitfirst($_SERVER['api_url'], '/v1.0')[0] . '/v1.0';
if (isset($_GET['Finish'])) { if (isset($_GET['Finish'])) {
@ -481,7 +444,6 @@ class Onedrive {
} }
$tmp = null; $tmp = null;
$tmp['Driver'] = get_class($this);
if ($_POST['DriveType']=='Onedrive') { if ($_POST['DriveType']=='Onedrive') {
/*$api = $this->api_url . '/me'; /*$api = $this->api_url . '/me';
$arr = curl('GET', $api, '', [ 'Authorization' => 'Bearer ' . $this->access_token ], 1); $arr = curl('GET', $api, '', [ 'Authorization' => 'Bearer ' . $this->access_token ], 1);
@ -497,8 +459,8 @@ class Onedrive {
} else { } else {
return message($arr['stat'] . $arr['body'], 'Get User ID', $arr['stat']); return message($arr['stat'] . $arr['body'], 'Get User ID', $arr['stat']);
}*/ }*/
if ($tmp['Driver']=='Sharepoint') $tmp['Driver'] = 'Onedrive'; if (get_class($this)=='Sharepoint') $tmp['Driver'] = 'Onedrive';
elseif ($tmp['Driver']=='SharepointCN') $tmp['Driver'] = 'OnedriveCN'; elseif (get_class($this)=='SharepointCN') $tmp['Driver'] = 'OnedriveCN';
$tmp['sharepointSite'] = ''; $tmp['sharepointSite'] = '';
$tmp['siteid'] = ''; $tmp['siteid'] = '';
} elseif ($_POST['DriveType']=='Custom') { } elseif ($_POST['DriveType']=='Custom') {
@ -511,14 +473,14 @@ class Onedrive {
//if ($arr['stat']!=200) return message($arr['stat'] . $arr['body'], 'Get Sharepoint Drive ID ' . $_POST['DriveType'], $arr['stat']); //if ($arr['stat']!=200) return message($arr['stat'] . $arr['body'], 'Get Sharepoint Drive ID ' . $_POST['DriveType'], $arr['stat']);
$tmp['siteid'] = $siteid; $tmp['siteid'] = $siteid;
$tmp['sharepointSite'] = $_POST['sharepointSite']; $tmp['sharepointSite'] = $_POST['sharepointSite'];
if ($tmp['Driver']=='Onedrive') $tmp['Driver'] = 'Sharepoint'; if (get_class($this)=='Onedrive') $tmp['Driver'] = 'Sharepoint';
elseif ($tmp['Driver']=='OnedriveCN') $tmp['Driver'] = 'SharepointCN'; elseif (get_class($this)=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
} else { } else {
// 直接是siteid // 直接是siteid
$tmp['siteid'] = $_POST['DriveType']; $tmp['siteid'] = $_POST['DriveType'];
$tmp['sharepointSite'] = $_POST['sharepointSiteUrl']; $tmp['sharepointSite'] = $_POST['sharepointSiteUrl'];
if ($tmp['Driver']=='Onedrive') $tmp['Driver'] = 'Sharepoint'; if (get_class($this)=='Onedrive') $tmp['Driver'] = 'Sharepoint';
elseif ($tmp['Driver']=='OnedriveCN') $tmp['Driver'] = 'SharepointCN'; elseif (get_class($this)=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
} }
$response = setConfigResponse( setConfig($tmp, $this->disktag) ); $response = setConfigResponse( setConfig($tmp, $this->disktag) );
@ -527,23 +489,14 @@ class Onedrive {
$title = 'Error'; $title = 'Error';
return message($html, $title, 201); return message($html, $title, 201);
} else { } else {
$html .= '<script> $str .= '<meta http-equiv="refresh" content="5;URL=' . $url . '">
<script>
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1); expd.setTime(expd.getTime()+1);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'disktag=; path=/; \'+expires; document.cookie=\'disktag=; path=/; \'+expires;
var i = 0;
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . $url . '?setup&disktag=' . $_GET['disktag'] . '";
}
}, 1000);
</script>'; </script>';
return message($html, getconstStr('Wait'), 201, 1); return message($str, getconstStr('WaitJumpIndex'), 201);
} }
} }
@ -573,13 +526,12 @@ class Onedrive {
$title = 'Select Driver'; $title = 'Select Driver';
$html = ' $html = '
<div> <div>
<form name="form1" action="?Finish&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);"> <form action="?Finish&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);">
<label><input type="radio" name="DriveType" value="Onedrive">' . 'Use Onedrive ' . getconstStr(' ') . '</label><br>'; <label><input type="radio" name="DriveType" value="Onedrive" checked>' . 'Use Onedrive ' . getconstStr(' ') . '</label><br>';
if ($sites[0]!='') foreach ($sites as $k => $v) { if ($sites[0]!='') foreach ($sites as $k => $v) {
$html .= ' $html .= '
<label> <label>
<input type="radio" name="DriveType" value="' . $v['id'] . '" onclick="document.getElementById(\'sharepointSiteUrl\').value=\'' . $v['webUrl'] . '\';">' . 'Use Sharepoint: <br><div style="width:100%;margin:0px 35px">webUrl: ' . $v['webUrl'] . '<br>siteid: ' . $v['id'] . '</div> <input type="radio" name="DriveType" value="' . $v['id'] . '" onclick="document.getElementById(\'sharepointSiteUrl\').value=\'' . $v['webUrl'] . '\';">' . 'Use Sharepoint: <br><div style="width:100%;margin:0px 35px">webUrl: ' . $v['webUrl'] . '<br>siteid: ' . $v['id'] . '</div>
<input type="hidden" id="' . $v['id'] . '" name="' . $v['id'] . '" value="' . $v['webUrl'] . '">
</label>'; </label>';
} }
$html .= ' $html .= '
@ -596,26 +548,6 @@ class Onedrive {
</form> </form>
</div> </div>
<script> <script>
var driver = "' . $_GET['AddDisk'] . '";
if (driver=="Onedrive"||driver=="OnedriveCN") {
document.form1.DriveType[0].checked = true;
} else {
var siteid = "' . getConfig('siteid', $this->disktag) . '";
if (siteid==="") {
document.form1.DriveType[document.form1.DriveType.length-1].checked = true;
} else {
for (i=0; i<document.form1.DriveType.length; i++) {
if (document.form1.DriveType[i].value==siteid) {
document.form1.DriveType[i].checked = true;
document.getElementById(\'sharepointSiteUrl\').value = document.getElementById(siteid).value;
}
}
if (document.getElementById(\'sharepointSiteUrl\').value=="") {
document.form1.DriveType[document.form1.DriveType.length-1].checked = true;
document.getElementById(\'sharepointSite\').value = "' . getConfig('sharepointSite', $this->disktag) . '";
}
}
}
function notnull(t) function notnull(t)
{ {
if (t.DriveType.value==\'\') { if (t.DriveType.value==\'\') {
@ -651,7 +583,6 @@ class Onedrive {
texta[i].style.height = texta[i].scrollHeight + \'px\'; texta[i].style.height = texta[i].scrollHeight + \'px\';
} }
</script>'; </script>';
$tmptoken['Driver'] = $_GET['AddDisk'];
$tmptoken['refresh_token'] = $refresh_token; $tmptoken['refresh_token'] = $refresh_token;
$tmptoken['token_expires'] = time()+7*24*60*60; $tmptoken['token_expires'] = time()+7*24*60*60;
$response = setConfigResponse( setConfig($tmptoken, $this->disktag) ); $response = setConfigResponse( setConfig($tmptoken, $this->disktag) );
@ -661,19 +592,9 @@ class Onedrive {
return message($html, $title, 201); return message($html, $title, 201);
} else { } else {
savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60); savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60);
$html .= '<script> $str .= '
var i = 0; <meta http-equiv="refresh" content="3;URL=' . $url . '?AddDisk=' . get_class($this) . '&disktag=' . $_GET['disktag'] . '&SelectDrive">';
var status = "' . $response['DplStatus'] . '"; return message($str, getconstStr('Wait') . ' 3s', 201);
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . $url . '?AddDisk=' . $_GET['AddDisk'] . '&disktag=' . $_GET['disktag'] . '&SelectDrive";
}
}, 1000);
</script>';
return message($html, getconstStr('Wait') . ' 3s', 201, 1);
} }
} }
return message('<pre>' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . '</pre>', $tmp['stat']); return message('<pre>' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . '</pre>', $tmp['stat']);
@ -681,7 +602,7 @@ class Onedrive {
} }
if (isset($_GET['install1'])) { if (isset($_GET['install1'])) {
//if (get_class($this)=='Onedrive' || get_class($this)=='OnedriveCN') { if (get_class($this)=='Onedrive' || get_class($this)=='OnedriveCN') {
return message(' return message('
<a href="" id="a1">' . getconstStr('JumptoOffice') . '</a> <a href="" id="a1">' . getconstStr('JumptoOffice') . '</a>
<script> <script>
@ -692,9 +613,9 @@ class Onedrive {
location.href = url; location.href = url;
</script> </script>
', getconstStr('Wait') . ' 1s', 201); ', getconstStr('Wait') . ' 1s', 201);
//} else { } else {
// return message('Something error, retry after a few seconds.', 'Retry', 201); return message('Something error, retry after a few seconds.', 'Retry', 201);
//} }
} }
if (isset($_GET['install0'])) { if (isset($_GET['install0'])) {
@ -703,7 +624,7 @@ class Onedrive {
$f = substr($_POST['disktag_add'], 0, 1); $f = substr($_POST['disktag_add'], 0, 1);
if (strlen($_POST['disktag_add'])==1) $_POST['disktag_add'] .= '_'; if (strlen($_POST['disktag_add'])==1) $_POST['disktag_add'] .= '_';
if (isCommonEnv($_POST['disktag_add'])) { if (isCommonEnv($_POST['disktag_add'])) {
return message('Do not input ' . $envs . '<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>', 'Error', 400); return message('Do not input ' . $envs . '<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>', 'Error', 201);
} elseif (!(('a'<=$f && $f<='z') || ('A'<=$f && $f<='Z'))) { } elseif (!(('a'<=$f && $f<='z') || ('A'<=$f && $f<='Z'))) {
return message('Please start with letters<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button> return message('Please start with letters<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>
<script> <script>
@ -711,7 +632,7 @@ class Onedrive {
expd.setTime(expd.getTime()+1); expd.setTime(expd.getTime()+1);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'disktag=; path=/; \'+expires; document.cookie=\'disktag=; path=/; \'+expires;
</script>', 'Error', 400); </script>', 'Error', 201);
} }
$tmp = null; $tmp = null;
@ -721,8 +642,7 @@ class Onedrive {
//$this->disktag = $_POST['disktag_add']; //$this->disktag = $_POST['disktag_add'];
$tmp['disktag_add'] = $_POST['disktag_add']; $tmp['disktag_add'] = $_POST['disktag_add'];
$tmp['diskname'] = $_POST['diskname']; $tmp['diskname'] = $_POST['diskname'];
//$tmp['Driver'] = $_POST['Drive_ver']; $tmp['Driver'] = $_POST['Drive_ver'];
$tmp['Driver'] = $_GET['AddDisk'];
if ($_POST['Drive_ver']=='Sharelink') { if ($_POST['Drive_ver']=='Sharelink') {
$tmp['shareurl'] = $_POST['shareurl']; $tmp['shareurl'] = $_POST['shareurl'];
} else { } else {
@ -738,32 +658,18 @@ class Onedrive {
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
$title = 'Error'; $title = 'Error';
return message($html, $title, 400);
} else { } else {
$title = getconstStr('MayinEnv'); $title = getconstStr('MayinEnv');
$html = getconstStr('Wait'); $html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_POST['Drive_ver'] . '">';
if ($_POST['Drive_ver']!='Sharelink') $url .= '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_GET['AddDisk']; if ($_POST['Drive_ver']=='Sharelink') $html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '">';
$html .= '<script>
var i = 0;
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . $url . '";
} }
}, 1000); return message($html, $title, 201);
</script>';
return message($html, $title, 201, 1);
}
} }
} }
$html = ' $html = '
<div> <div>
<form id="form1" name="form1" action="" method="post" onsubmit="return notnull(this);"> <form id="form1" action="" method="post" onsubmit="return notnull(this);">
' . getconstStr('DiskTag') . ': (' . getConfig('disktag') . ') ' . getconstStr('DiskTag') . ': (' . getConfig('disktag') . ')
<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br> <input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
' . getconstStr('DiskName') . ': ' . getconstStr('DiskName') . ':
@ -775,7 +681,7 @@ class Onedrive {
<label><input type="checkbox" name="NT_Drive_custom" onclick="document.getElementById(\'NT_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br> <label><input type="checkbox" name="NT_Drive_custom" onclick="document.getElementById(\'NT_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br>
<div id="NT_secret" style="display:none;margin:10px 35px"> <div id="NT_secret" style="display:none;margin:10px 35px">
<a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br> <a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br>
return_uri(Reply URL):<br>' . $this->redirect_uri . '<br> return_uri(Reply URL):<br>https://scfonedrive.github.io/<br>
client_id:<input type="text" name="NT_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br> client_id:<input type="text" name="NT_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br>
client_secret:<input type="text" name="NT_client_secret" style="width:100%"><br> client_secret:<input type="text" name="NT_client_secret" style="width:100%"><br>
</div> </div>
@ -785,7 +691,7 @@ class Onedrive {
<label><input type="checkbox" name="CN_Drive_custom" onclick="document.getElementById(\'CN_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br> <label><input type="checkbox" name="CN_Drive_custom" onclick="document.getElementById(\'CN_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br>
<div id="CN_secret" style="display:none;margin:10px 35px"> <div id="CN_secret" style="display:none;margin:10px 35px">
<a href="https://portal.azure.cn/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br> <a href="https://portal.azure.cn/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br>
return_uri(Reply URL):<br>' . $this->redirect_uri . '<br> return_uri(Reply URL):<br>https://scfonedrive.github.io/<br>
client_id:<input type="text" name="CN_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br> client_id:<input type="text" name="CN_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br>
client_secret:<input type="text" name="CN_client_secret" style="width:100%"><br> client_secret:<input type="text" name="CN_client_secret" style="width:100%"><br>
</div> </div>
@ -803,21 +709,6 @@ class Onedrive {
</form> </form>
</div> </div>
<script> <script>
var driver = "' . get_class($this) . '";
if (driver=="Onedrive" || driver=="Sharepoint") {
document.form1.Drive_ver[0].checked = true;
document.getElementById(\'NT_custom\').style.display=\'\';
//document.getElementById(\'CN_custom\').style.display=\'\';
//document.getElementById(\'inputshareurl\').style.display=\'none\';
}
if (driver=="OnedriveCN" || driver=="SharepointCN") {
document.form1.Drive_ver[1].checked = true;
document.getElementById(\'CN_custom\').style.display=\'\';
}
if (driver=="Sharelink") {
document.form1.Drive_ver[2].checked = true;
document.getElementById(\'inputshareurl\').style.display=\'\';
}
function notnull(t) function notnull(t)
{ {
if (t.disktag_add.value==\'\') { if (t.disktag_add.value==\'\') {
@ -826,10 +717,10 @@ class Onedrive {
} }
envs = [' . $envs . ']; envs = [' . $envs . '];
if (envs.indexOf(t.disktag_add.value)>-1) { if (envs.indexOf(t.disktag_add.value)>-1) {
alert("Do not input \"" + t.disktag_add.value + "\" in ' . getconstStr('DiskTag') . '"); alert("Do not input ' . $envs . '");
return false; return false;
} }
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,})$/; var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
if (!reg.test(t.disktag_add.value)) { if (!reg.test(t.disktag_add.value)) {
alert(\'' . getconstStr('TagFormatAlert') . '\'); alert(\'' . getconstStr('TagFormatAlert') . '\');
return false; return false;
@ -843,28 +734,25 @@ class Onedrive {
alert(\'shareurl\'); alert(\'shareurl\');
return false; return false;
} }
driver = \'Sharelink\';
} else { } else {
if (t.Drive_ver.value==\'Onedrive\') { if ((t.Drive_ver.value==\'Onedrive\') && t.NT_Drive_custom.checked==true) {
if (t.NT_Drive_custom.checked==true) {
if (t.NT_client_secret.value==\'\'||t.NT_client_id.value==\'\') { if (t.NT_client_secret.value==\'\'||t.NT_client_id.value==\'\') {
alert(\'client_id & client_secret\'); alert(\'client_id & client_secret\');
return false; return false;
} }
} }
if (driver!="Onedrive" && driver!="Sharepoint") driver = "Onedrive"; if ((t.Drive_ver.value==\'OnedriveCN\') && t.CN_Drive_custom.checked==true) {
}
if (t.Drive_ver.value==\'OnedriveCN\') {
if (t.CN_Drive_custom.checked==true) {
if (t.CN_client_secret.value==\'\'||t.CN_client_id.value==\'\') { if (t.CN_client_secret.value==\'\'||t.CN_client_id.value==\'\') {
alert(\'client_id & client_secret\'); alert(\'client_id & client_secret\');
return false; return false;
} }
} }
if (driver!="OnedriveCN" && driver!="SharepointCN") driver = "OnedriveCN";
} }
} document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=" + t.Drive_ver.value;
document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=" + driver; //var expd = new Date();
//expd.setTime(expd.getTime()+(2*60*60*1000));
//var expires = "expires="+expd.toGMTString();
//document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/; \'+expires;
return true; return true;
} }
</script>'; </script>';
@ -918,9 +806,8 @@ class Onedrive {
$sharepointname = $tmp[1]; $sharepointname = $tmp[1];
} }
$tmp = splitlast($tmp[0], '/'); $tmp = splitlast($tmp[0], '/');
//if (getConfig('Driver', $this->disktag)=='Onedrive') $url = 'https://graph.microsoft.com/v1.0/sites/root:/' . $tmp[1] . '/' . $sharepointname; if (getConfig('Driver', $this->disktag)=='Onedrive') $url = 'https://graph.microsoft.com/v1.0/sites/root:/' . $tmp[1] . '/' . $sharepointname;
//if (getConfig('Driver', $this->disktag)=='OnedriveCN') $url = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/root:/' . $tmp[1] . '/' . $sharepointname; if (getConfig('Driver', $this->disktag)=='OnedriveCN') $url = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/root:/' . $tmp[1] . '/' . $sharepointname;
$url = $this->api_url . '/sites/root:/' . $tmp[1] . '/' . $sharepointname;
$i=0; $i=0;
$response = []; $response = [];
@ -973,20 +860,6 @@ class Onedrive {
return $thumb_url; 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) public function bigfileupload($path)
{ {
if ($_POST['upbigfilename']=='') return output('error: no file name', 400); if ($_POST['upbigfilename']=='') return output('error: no file name', 400);
@ -1012,8 +885,8 @@ class Onedrive {
if ($fileinfo['size']>10*1024*1024) { if ($fileinfo['size']>10*1024*1024) {
$cachefilename = spurlencode( $fileinfo['path'] . '/.' . $fileinfo['filelastModified'] . '_' . $fileinfo['size'] . '_' . $fileinfo['name'] . '.tmp', '/'); $cachefilename = spurlencode( $fileinfo['path'] . '/.' . $fileinfo['filelastModified'] . '_' . $fileinfo['size'] . '_' . $fileinfo['name'] . '.tmp', '/');
$getoldupinfo=$this->list_files(path_format($path . '/' . $cachefilename)); $getoldupinfo=$this->list_files(path_format($path . '/' . $cachefilename));
//error_log1(json_encode($getoldupinfo, JSON_PRETTY_PRINT)); //echo json_encode($getoldupinfo, JSON_PRETTY_PRINT);
if (isset($getoldupinfo['url'])&&$getoldupinfo['size']<5120) { if (isset($getoldupinfo['file'])&&$getoldupinfo['size']<5120) {
$getoldupinfo_j = curl('GET', $getoldupinfo['url']); $getoldupinfo_j = curl('GET', $getoldupinfo['url']);
$getoldupinfo = json_decode($getoldupinfo_j['body'], true); $getoldupinfo = json_decode($getoldupinfo_j['body'], true);
if ( json_decode( curl('GET', $getoldupinfo['uploadUrl'])['body'], true)['@odata.context']!='' ) return output($getoldupinfo_j['body'], $getoldupinfo_j['stat']); if ( json_decode( curl('GET', $getoldupinfo['uploadUrl'])['body'], true)['@odata.context']!='' ) return output($getoldupinfo_j['body'], $getoldupinfo_j['stat']);
@ -1042,7 +915,7 @@ class Onedrive {
return $diskSpace; return $diskSpace;
} }
protected function MSAPI($method, $path, $data = '', $headers = []) protected function MSAPI($method, $path, $data = '')
{ {
$activeLimit = getConfig('activeLimit', $this->disktag); $activeLimit = getConfig('activeLimit', $this->disktag);
if ($activeLimit!='') { if ($activeLimit!='') {
@ -1060,16 +933,11 @@ class Onedrive {
$url = $this->api_url . $this->ext_api_url; $url = $this->api_url . $this->ext_api_url;
if ($path=='' or $path=='/') { if ($path=='' or $path=='/') {
$url .= '/'; $url .= '/';
} elseif (substr($path, 0, 6)=="/items") {
$url = substr($url, 0, -5);
$url .= $path;
} else { } else {
$url .= ':' . $path; $url .= ':' . $path;
if (substr($url,-1)=='/') $url=substr($url,0,-1); if (substr($url,-1)=='/') $url=substr($url,0,-1);
} }
if ($method=='GET') { if ($method=='PUT') {
$method = 'GET'; // do nothing
} elseif ($method=='PUT') {
if ($path=='' or $path=='/') { if ($path=='' or $path=='/') {
$url .= 'content'; $url .= 'content';
} else { } else {
@ -1085,8 +953,6 @@ class Onedrive {
} else { } else {
if ($path=='' or $path=='/') { if ($path=='' or $path=='/') {
$url .= $method; $url .= $method;
} elseif (substr($path, 0, 6)=="/items") {
$url .= '/' . $method;
} else { } else {
$url .= ':/' . $method; $url .= ':/' . $method;
} }
@ -1131,10 +997,10 @@ class Onedrive {
} }
} }
curl_close($ch); curl_close($ch);
/*error_log1($response['stat'].' error_log1($response['stat'].'
'.$response['body'].' '.$response['body'].'
'.$url.' '.$url.'
');*/ ');
return $response; return $response;
} }

102
index.php
View File

@ -1,54 +1,23 @@
<?php <?php
//error_reporting(E_ALL & ~E_NOTICE); //error_reporting(E_ALL & ~E_NOTICE);
error_reporting(0); error_reporting(0);
include 'vendor/autoload.php'; include 'vendor/autoload.php';
include 'conststr.php'; include 'conststr.php';
include 'common.php'; include 'common.php';
date_default_timezone_set('UTC');
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>'; //echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
//echo '<pre>'. json_encode($_ENV, JSON_PRETTY_PRINT).'</pre>'; if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
global $platform;
$platform = checkPlatform();
function checkPlatform() {
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')
return 'SCF';
if (isset($_SERVER['FC_FUNC_CODE_PATH']))
return 'FC';
if (isset($_SERVER['RUNTIME_LOG_PATH']) && $_SERVER['RUNTIME_LOG_PATH']=='/home/snuser/log')
return 'FG';
if (isset($_SERVER['BCE_CFC_RUNTIME_NAME']) && $_SERVER['BCE_CFC_RUNTIME_NAME']=='php7')
return 'CFC';
if (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app')
return 'Heroku';
if (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/var/task/user')
return 'Vercel';
if (isset($_SERVER['DOCUMENT_ROOT'])&&substr($_SERVER['DOCUMENT_ROOT'], 0, 13)==='/home/runner/')
return 'Replit';
return 'Normal';
}
function writebackPlatform($p) {
if ('SCF'==$p) $_SERVER['USER']='qcloud';
if ('FC'==$p) $_SERVER['FC_FUNC_CODE_PATH']=getenv('FC_FUNC_CODE_PATH');
if ('FG'==$p) $_SERVER['RUNTIME_LOG_PATH']='/home/snuser/log';
if ('CFC'==$p) $_SERVER['BCE_CFC_RUNTIME_NAME']='php7';
//if ('Heroku'==$p) $_SERVER['HEROKU_APP_DIR']='/app';
if ('Vercel'==$p) $_SERVER['DOCUMENT_ROOT']='/var/task/user';
//if ('Replit'==$p) $_SERVER['DOCUMENT_ROOT']='/home/runner/';
}
if ('SCF'==$platform) {
if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/TencentSCF_file.php'; if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/TencentSCF_file.php';
else include 'platform/TencentSCF_env.php'; else include 'platform/TencentSCF_env.php';
} elseif ('FC'==$platform) { } elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
include 'platform/AliyunFC.php'; include 'platform/AliyunFC.php';
} elseif ('FG'==$platform) { } elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
//if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/HuaweiFG_file.php'; //if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/HuaweiFG_file.php';
//else include 'platform/HuaweiFG_env.php'; //else include 'platform/HuaweiFG_env.php';
echo 'FG' . PHP_EOL; echo 'FG' . PHP_EOL;
} elseif ('CFC'==$platform) { } elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
include 'platform/BaiduCFC.php'; include 'platform/BaiduCFC.php';
} elseif ('Heroku'==$platform) { } elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
include 'platform/Heroku.php'; include 'platform/Heroku.php';
$path = getpath(); $path = getpath();
//echo 'path:'. $path; //echo 'path:'. $path;
@ -60,60 +29,21 @@ if ('SCF'==$platform) {
header($headerName . ': ' . $headerVal, true); header($headerName . ': ' . $headerVal, true);
} }
http_response_code($re['statusCode']); http_response_code($re['statusCode']);
if ($re['isBase64Encoded']) echo base64_decode($re['body']); echo $re['body'];
else echo $re['body'];
} elseif ('Vercel'==$platform) {
if (getenv('ONEMANAGER_CONFIG_SAVE')=='env') include 'platform/Vercel_env.php';
else include 'platform/Vercel.php';
writebackPlatform('Vercel');
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
$re = main($path);
$sendHeaders = array();
foreach ($re['headers'] as $headerName => $headerVal) {
header($headerName . ': ' . $headerVal, true);
}
http_response_code($re['statusCode']);
if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} elseif ('Replit'==$platform) {
include 'platform/Replit.php';
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
$re = main($path);
$sendHeaders = array();
foreach ($re['headers'] as $headerName => $headerVal) {
header($headerName . ': ' . $headerVal, true);
}
http_response_code($re['statusCode']);
if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} else { } else {
include 'platform/Normal.php'; include 'platform/Normal.php';
if (!function_exists('curl_init')) {
http_response_code(500);
echo '<font color="red">Need curl</font>, please install php-curl.';
exit(1);
}
$path = getpath(); $path = getpath();
//echo 'path:'. $path; //echo 'path:'. $path;
$_GET = getGET(); $_GET = getGET();
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>'; //echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
$re = main($path); $re = main($path);
$sendHeaders = array(); $sendHeaders = array();
foreach ($re['headers'] as $headerName => $headerVal) { foreach ($re['headers'] as $headerName => $headerVal) {
header($headerName . ': ' . $headerVal, true); header($headerName . ': ' . $headerVal, true);
} }
http_response_code($re['statusCode']); http_response_code($re['statusCode']);
if ($re['isBase64Encoded']) echo base64_decode($re['body']); echo $re['body'];
else echo $re['body'];
} }
// Tencent SCF // Tencent SCF
@ -122,14 +52,10 @@ function main_handler($event, $context)
$event = json_decode(json_encode($event), true); $event = json_decode(json_encode($event), true);
$context = json_decode(json_encode($context), true); $context = json_decode(json_encode($context), true);
printInput($event, $context); printInput($event, $context);
if ( $event['requestContext']['serviceId'] === substr($event['headers']['host'], 0, strlen($event['requestContext']['serviceId'])) ) {
if ($event['path']==='/' . $context['function_name']) return output('add / at last.', 308, ['Location'=>'/'.$event['requestContext']['stage'].'/'.$context['function_name'].'/']);
}
unset($_POST); unset($_POST);
unset($_GET); unset($_GET);
unset($_COOKIE); unset($_COOKIE);
unset($_SERVER); unset($_SERVER);
writebackPlatform('SCF');
GetGlobalVariable($event); GetGlobalVariable($event);
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>'; //echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
$path = GetPathSetting($event, $context); $path = GetPathSetting($event, $context);
@ -140,8 +66,7 @@ function main_handler($event, $context)
// Aliyun FC & Huawei FG & Baidu CFC // Aliyun FC & Huawei FG & Baidu CFC
function handler($event, $context) function handler($event, $context)
{ {
global $platform; if (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
if ('FC'==$platform) {
// Aliyun FC // Aliyun FC
set_error_handler("myErrorHandler"); set_error_handler("myErrorHandler");
$tmp = array( $tmp = array(
@ -160,15 +85,14 @@ function handler($event, $context)
unset($_GET); unset($_GET);
unset($_COOKIE); unset($_COOKIE);
unset($_SERVER); unset($_SERVER);
writebackPlatform('FC');
GetGlobalVariable($event); GetGlobalVariable($event);
$path = GetPathSetting($event, $context); $path = GetPathSetting($event, $context);
$re = main($path); $re = main($path);
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], ($re['isBase64Encoded']?base64_decode($re['body']):$re['body'])); return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['body']);
} elseif ('FG'==$platform) { } elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
// Huawei FG // Huawei FG
global $contextUserData; global $contextUserData;
$contextUserData = $context; $contextUserData = $context;
@ -183,14 +107,13 @@ function handler($event, $context)
unset($_GET); unset($_GET);
unset($_COOKIE); unset($_COOKIE);
unset($_SERVER); unset($_SERVER);
writebackPlatform('FG');
GetGlobalVariable($event); GetGlobalVariable($event);
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>'; //echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
$path = GetPathSetting($event, $context); $path = GetPathSetting($event, $context);
return main($path); return main($path);
} elseif ('CFC'==$platform) { } elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
// Baidu CFC // Baidu CFC
//$html = '<pre>'. json_encode($event, JSON_PRETTY_PRINT).'</pre>'; //$html = '<pre>'. json_encode($event, JSON_PRETTY_PRINT).'</pre>';
//$html .= '<pre>'. json_encode($context, JSON_PRETTY_PRINT).'</pre>'; //$html .= '<pre>'. json_encode($context, JSON_PRETTY_PRINT).'</pre>';
@ -204,7 +127,6 @@ function handler($event, $context)
unset($_GET); unset($_GET);
unset($_COOKIE); unset($_COOKIE);
unset($_SERVER); unset($_SERVER);
writebackPlatform('CFC');
GetGlobalVariable($event); GetGlobalVariable($event);
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>'; //echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
$path = GetPathSetting($event, $context); $path = GetPathSetting($event, $context);

File diff suppressed because it is too large Load Diff

8
js/sha1.min.js vendored

File diff suppressed because one or more lines are too long

1
js/spark-md5.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -37,24 +37,18 @@ function GetPathSetting($event, $context)
$_SERVER['region'] = $context['region']; $_SERVER['region'] = $context['region'];
$_SERVER['service_name'] = $context['service']['name']; $_SERVER['service_name'] = $context['service']['name'];
$_SERVER['function_name'] = $context['function']['name']; $_SERVER['function_name'] = $context['function']['name'];
//$path = str_replace('%5D', ']', str_replace('%5B', '[', $event['path']));//%5B $path = $event['path'];
//$path = $event['path']; $tmp = $event['requestURI'];
$path = $event['requestURI'];
if (strpos($path, '?')) $path = substr($path, 0, strpos($path, '?'));
$tmp = urldecode($event['requestURI']);
if (strpos($tmp, '?')) $tmp = substr($tmp, 0, strpos($tmp, '?')); if (strpos($tmp, '?')) $tmp = substr($tmp, 0, strpos($tmp, '?'));
if ($path=='/'||$path=='') { if ($path=='/'||$path=='') {
$_SERVER['base_path'] = $tmp; $_SERVER['base_path'] = $tmp;
} else { } else {
$tmp = str_replace('&amp;', '&', $tmp); $_SERVER['base_path'] = substr($tmp, 0, -strlen($path)+1);
while ($tmp!=urldecode($tmp)) $tmp = urldecode($tmp);
$tmp1 = urldecode($event['path']);
while ($tmp1!=urldecode($tmp1)) $tmp1 = urldecode($tmp1);
$_SERVER['base_path'] = substr($tmp, 0, strlen($tmp)-strlen($tmp1)+1);
//$_SERVER['base_path'] = substr($tmp, 0, strlen(urldecode($event['path'])));
} }
$_SERVER['base_path'] = spurlencode($_SERVER['base_path'], '/');
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['clientIP']; $_SERVER['REMOTE_ADDR'] = $event['clientIP'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'][0]; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'][0];
if (isset($event['headers']['Authorization'])) { if (isset($event['headers']['Authorization'])) {
@ -65,11 +59,10 @@ function GetPathSetting($event, $context)
$_SERVER['HTTP_HOST'] = $event['headers']['Host'][0]; $_SERVER['HTTP_HOST'] = $event['headers']['Host'][0];
$_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto'][0]; $_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto'][0];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
//if ($_SERVER['HTTP_REFERER']!='')
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2];
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'][0]; $_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
$_SERVER['REQUEST_METHOD'] = $event['method'];
return $path; return $path;
//return spurlencode($path, '/');
} }
function getConfig($str, $disktag = '') function getConfig($str, $disktag = '')
@ -185,16 +178,16 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
//$AccessKeyID = getConfig('AccessKeyID'); $AccessKeyID = getConfig('AccessKeyID');
//if ($AccessKeyID=='') { if ($AccessKeyID=='') {
$AccessKeyID = $_POST['AccessKeyID']; $AccessKeyID = $_POST['AccessKeyID'];
$tmp['AccessKeyID'] = $AccessKeyID; $tmp['AccessKeyID'] = $AccessKeyID;
//} }
//$AccessKeySecret = getConfig('AccessKeySecret'); $AccessKeySecret = getConfig('AccessKeySecret');
//if ($AccessKeySecret=='') { if ($AccessKeySecret=='') {
$AccessKeySecret = $_POST['AccessKeySecret']; $AccessKeySecret = $_POST['AccessKeySecret'];
$tmp['AccessKeySecret'] = $AccessKeySecret; $tmp['AccessKeySecret'] = $AccessKeySecret;
//} }
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) ); $response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) );
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
@ -229,11 +222,10 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
//if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
$html .= '
<a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">'.getconstStr('Create').' AccessKeyID & AccessKeySecret</a><br> <a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">'.getconstStr('Create').' AccessKeyID & AccessKeySecret</a><br>
<label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br> <label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br>
<label>AccessKeySecret:<input name="AccessKeySecret" type="password" placeholder="" size=""></label><br>'; <label>AccessKeySecret:<input name="AccessKeySecret" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<input type="submit" value="'.getconstStr('Submit').'"> <input type="submit" value="'.getconstStr('Submit').'">
</form> </form>
@ -254,8 +246,7 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
//if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
$html .= '
if (t.AccessKeyID.value==\'\') { if (t.AccessKeyID.value==\'\') {
alert(\'input AccessKeyID\'); alert(\'input AccessKeyID\');
return false; return false;
@ -421,24 +412,39 @@ function setConfigResponse($response)
return json_decode($response, true); return json_decode($response, true);
} }
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{ {
$source = '/tmp/code.zip'; $source = '/tmp/code.zip';
$outPath = '/tmp/'; $outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压 // 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/'; $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['ErrorMessage'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz'; $tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url)); file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile); $phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖 $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名 // 获取解压出的目录名
$outPath = findIndexPath($outPath); /*
@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
$zip=new ZipArchive(); $zip=new ZipArchive();
@ -468,7 +474,7 @@ function addFileToZip($zip, $rootpath, $path = '')
} }
} }
} }
@closedir($handler); @closedir($path);
} }
function myErrorHandler($errno, $errstr, $errfile, $errline) { function myErrorHandler($errno, $errstr, $errfile, $errline) {
@ -492,60 +498,3 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) {
} }
return true; return true;
} }
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['AccessKeyID']!=''&&$_POST['AccessKeySecret']!='') {
$tmp['AccessKeyID'] = $_POST['AccessKeyID'];
$tmp['AccessKeySecret'] = $_POST['AccessKeySecret'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $tmp['AccessKeyID'], $tmp['AccessKeySecret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">' . getconstStr('Create') . ' AccessKeyID & AccessKeySecret</a><br>
<label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br>
<label>AccessKeySecret:<input name="AccessKeySecret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.AccessKeyID.value==\'\') {
alert(\'input AccessKeyID\');
return false;
}
if (t.AccessKeySecret.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through FC.', 400);
}

View File

@ -1,6 +1,4 @@
<?php <?php
// https://cloud.baidu.com/doc/CFC/s/jjwvz45ex
// https://cloud.baidu.com/doc/CFC/s/2jwvz44ns
function printInput($event, $context) function printInput($event, $context)
{ {
@ -36,7 +34,9 @@ function GetPathSetting($event, $context)
$_SERVER['functionBrn'] = $context['functionBrn']; $_SERVER['functionBrn'] = $context['functionBrn'];
$_SERVER['base_path'] = '/'; $_SERVER['base_path'] = '/';
$path = $event['path']; $path = $event['path'];
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp']; $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'];
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['User-Agent']; $_SERVER['HTTP_USER_AGENT'] = $event['headers']['User-Agent'];
@ -48,10 +48,9 @@ function GetPathSetting($event, $context)
$_SERVER['HTTP_HOST'] = $event['headers']['Host']; $_SERVER['HTTP_HOST'] = $event['headers']['Host'];
$_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto']; $_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
//if ($_SERVER['HTTP_REFERER']!='')
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['Referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'];
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
$_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7'; $_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
return $path; return $path;
} }
@ -167,16 +166,16 @@ function install()
} }
if ($_GET['install1']) { if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
//$SecretId = getConfig('SecretId'); $SecretId = getConfig('SecretId');
//if ($SecretId=='') { if ($SecretId=='') {
$SecretId = $_POST['SecretId']; $SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId; $tmp['SecretId'] = $SecretId;
//} }
//$SecretKey = getConfig('SecretKey'); $SecretKey = getConfig('SecretKey');
//if ($SecretKey=='') { if ($SecretKey=='') {
$SecretKey = $_POST['SecretKey']; $SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey; $tmp['SecretKey'] = $SecretKey;
//} }
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey)); $response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
@ -210,11 +209,10 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='') if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
$html .= '
<a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">'.getconstStr('Create').' Access Key & Secret Key</a><br> <a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">'.getconstStr('Create').' Access Key & Secret Key</a><br>
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br> <label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>Secret Key:<input name="SecretKey" type="password" placeholder="" size=""></label><br>'; <label>Secret Key:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<input type="submit" value="'.getconstStr('Submit').'"> <input type="submit" value="'.getconstStr('Submit').'">
</form> </form>
@ -235,8 +233,7 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='') if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
$html .= '
if (t.SecretId.value==\'\') { if (t.SecretId.value==\'\') {
alert(\'input Access Key\'); alert(\'input Access Key\');
return false; return false;
@ -367,7 +364,7 @@ function api_error_msg($response)
{ {
if (isset($response['code'])) $html = $response['code'] . '<br> if (isset($response['code'])) $html = $response['code'] . '<br>
' . $response['message']; ' . $response['message'];
else $html = json_encode($response, JSON_PRETTY_PRINT); else $html = var_dump($response);
return $html . '<br><br> return $html . '<br><br>
BRN: ' . $_SERVER['functionBrn'] . '<br> BRN: ' . $_SERVER['functionBrn'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
@ -379,24 +376,29 @@ function setConfigResponse($response)
return json_decode( $response, true ); return json_decode( $response, true );
} }
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{ {
$source = '/tmp/code.zip'; $source = '/tmp/code.zip';
$outPath = '/tmp/'; $outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压 // 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/'; $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['FunctionBrn'=>$_SERVER['functionBrn'], 'code'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz'; $tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url)); file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile); $phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖 $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名 // 获取包中目录名
$outPath = findIndexPath($outPath); $tmp = scandir('phar://'.$tarfile);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
// 放入配置文件
//file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
// 将目录中文件打包成zip // 将目录中文件打包成zip
//$zip=new ZipArchive(); //$zip=new ZipArchive();
@ -428,64 +430,5 @@ function addFileToZip($zip, $rootpath, $path = '')
} }
} }
} }
@closedir($handler); @closedir($path);
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretKey']!='') {
$SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId;
$SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey;
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">' . getconstStr('Create') . ' Access Key & Secret Key</a><br>
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>Secret Key:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input Access Key\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input Secret Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through CFC.', 400);
} }

View File

@ -1,5 +1,4 @@
<?php <?php
// https://devcenter.heroku.com/articles/platform-api-reference#build-create
function getpath() function getpath()
{ {
@ -104,7 +103,7 @@ function setConfig($arr, $disktag = '')
{ {
if ($disktag=='') $disktag = $_SERVER['disktag']; if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|",getConfig('disktag')); $disktags = explode("|",getConfig('disktag'));
if ($disktag!='') $diskconfig = json_decode(getenv($disktag), true); $diskconfig = json_decode(getenv($disktag), true);
$tmp = []; $tmp = [];
$indisk = 0; $indisk = 0;
$operatedisk = 0; $operatedisk = 0;
@ -170,8 +169,11 @@ function install()
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language']; //$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = getConfig('APIKey');
if ($APIKey=='') {
$APIKey = $_POST['APIKey']; $APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey; $tmp['APIKey'] = $APIKey;
}
$HerokuappId = getConfig('HerokuappId'); $HerokuappId = getConfig('HerokuappId');
if ($HerokuappId=='') { if ($HerokuappId=='') {
$function_name = getConfig('function_name'); $function_name = getConfig('function_name');
@ -194,27 +196,17 @@ function install()
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
$title = 'Error'; $title = 'Error';
return message($html, $title, 400);
} else { } else {
$html = getconstStr('Success') . ' return output('Jump
<script> <script>
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1000); expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
var status = "' . $response['DplStatus'] . '"; </script>
var i = 0; <meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
} }
return message($html, $title, 201);
} }
} }
if ($_GET['install0']) { if ($_GET['install0']) {
@ -225,9 +217,9 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
$html .= ' if (getConfig('APIKey')=='') $html .= '
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br> <a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br>
<label>API Key:<input name="APIKey" type="password" placeholder="" size=""></label><br>'; <label>API Key:<input name="APIKey" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>'; <label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= ' $html .= '
@ -254,7 +246,7 @@ language:<br>';
alert(\'input admin\'); alert(\'input admin\');
return false; return false;
}'; }';
$html .= ' if (getConfig('APIKey')=='') $html .= '
if (t.APIKey.value==\'\') { if (t.APIKey.value==\'\') {
alert(\'input API Key\'); alert(\'input API Key\');
return false; return false;
@ -320,11 +312,7 @@ function updateHerokuapp($HerokuappId, $apikey, $source)
{ {
$tmp['source_blob']['url'] = $source; $tmp['source_blob']['url'] = $source;
$data = json_encode($tmp); $data = json_encode($tmp);
$response = HerokuAPI('POST', 'https://api.heroku.com/apps/' . $HerokuappId . '/builds', $data, $apikey); return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $HerokuappId . '/builds', $data, $apikey);
$result = json_decode( $response['body'], true );
$result['DplStatus'] = $result['id'];
$response['body'] = json_encode($result);
return $response;
} }
function api_error($response) function api_error($response)
@ -340,15 +328,10 @@ function_name:' . $_SERVER['function_name'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
} }
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{ {
if ($GitSource=='Github') {
//'https://github.com/qkqpttgf/OneManager-php/tarball/master/'; //'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
$source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/'; $source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$source = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return ['stat'=>403, 'body'=>json_encode(['id'=>'Error', 'message'=>'Git Source input Error!'])];
return updateHerokuapp(getConfig('HerokuappId'), getConfig('APIKey'), $source); return updateHerokuapp(getConfig('HerokuappId'), getConfig('APIKey'), $source);
} }
@ -356,68 +339,3 @@ function setConfigResponse($response)
{ {
return json_decode( $response['body'], true ); return json_decode( $response['body'], true );
} }
function WaitFunction($buildId = '') {
// GET /apps/{app_id_or_name}/builds/{build_id}
if ($buildId=='1') return true;
$response = HerokuAPI('GET', 'https://api.heroku.com/apps/' . getConfig('HerokuappId') . '/builds/' . $buildId, '', getConfig('APIKey'));
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['status']=="succeeded") return true;
else return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = setConfigResponse( setHerokuConfig($tmp, getConfig('HerokuappId'), $APIKey) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br>
<label>API Key:<input name="APIKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'input API Key\');
return false;
}
return true;
}
</script>';
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']);
}

View File

@ -1,12 +1,9 @@
<?php <?php
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0110.html
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0111.html
global $contextUserData; global $contextUserData;
function printInput($event, $context) function printInput($event, $context)
{ {
$tmp['RequestID'] = $context->getRequestID(); $tmp['eventID'] = $context->geteventID();
$tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds(); $tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
$tmp['AccessKey'] = $context->getAccessKey(); $tmp['AccessKey'] = $context->getAccessKey();
$tmp['SecretKey'] = $context->getSecretKey(); $tmp['SecretKey'] = $context->getSecretKey();
@ -17,7 +14,7 @@ function printInput($event, $context)
$tmp['MemorySize'] = $context->getMemorySize(); $tmp['MemorySize'] = $context->getMemorySize();
$tmp['CPUNumber'] = $context->getCPUNumber(); $tmp['CPUNumber'] = $context->getCPUNumber();
$tmp['ProjectID'] = $context->getProjectID(); $tmp['ProjectID'] = $context->getProjectID();
$tmp['Package'] = $context->getPackage(); $tmp['Package'] = $context->Package();
$tmp['Token'] = $context->getToken(); $tmp['Token'] = $context->getToken();
$tmp['Logger'] = $context->getLogger(); $tmp['Logger'] = $context->getLogger();
@ -51,16 +48,17 @@ function GetPathSetting($event, $context)
$_SERVER['ProjectID'] = $context->getProjectID(); $_SERVER['ProjectID'] = $context->getProjectID();
$host_name = $event['headers']['host']; $host_name = $event['headers']['host'];
$_SERVER['HTTP_HOST'] = $host_name; $_SERVER['HTTP_HOST'] = $host_name;
$path = path_format('/' . $event['pathParameters']['']); $path = path_format($event['pathParameters'][''].'/');
$path = str_replace('+', '%2B', $path); $_SERVER['base_path'] = path_format($event['path'].'/');
$_SERVER['base_path'] = path_format($event['path']);
if ( $_SERVER['base_path'] == $path ) { if ( $_SERVER['base_path'] == $path ) {
$_SERVER['base_path'] = '/'; $_SERVER['base_path'] = '/';
} else { } else {
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, strlen($_SERVER['base_path'])-strlen($path)); $_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/'; if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
} }
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip']; $_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent']; $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
@ -71,10 +69,10 @@ function GetPathSetting($event, $context)
} }
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto']; $_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
//if ($_SERVER['HTTP_REFERER']!='')
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since']; $_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
return $path; return $path;
} }
@ -193,9 +191,18 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = getConfig('HW_urn');
if ($tmp['HW_urn']=='') {
$tmp['HW_urn'] = $_POST['HW_urn']; $tmp['HW_urn'] = $_POST['HW_urn'];
}
$tmp['HW_key'] = getConfig('HW_key');
if ($tmp['HW_key']=='') {
$tmp['HW_key'] = $_POST['HW_key']; $tmp['HW_key'] = $_POST['HW_key'];
}
$tmp['HW_secret'] = getConfig('HW_secret');
if ($tmp['HW_secret']=='') {
$tmp['HW_secret'] = $_POST['HW_secret']; $tmp['HW_secret'] = $_POST['HW_secret'];
}
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE']; $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response']; //$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response'];
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) ); $response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
@ -237,14 +244,13 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
$html .= '
在函数代码操作页上方找到URN鼠标放上去后显示URN复制填入<br> 在函数代码操作页上方找到URN鼠标放上去后显示URN复制填入<br>
<label>URN:<input name="HW_urn" type="text" placeholder="" size=""></label><br> <label>URN:<input name="HW_urn" type="text" placeholder="" size=""></label><br>
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥, <a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息填入<br> 在下载的credentials.csv文件中找到对应信息填入<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br> <label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>'; <label>Secret Access Key:<input name="HW_secret" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br> <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@ -268,8 +274,7 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
$html .= '
if (t.HW_urn.value==\'\') { if (t.HW_urn.value==\'\') {
alert(\'input URN\'); alert(\'input URN\');
return false; return false;
@ -429,24 +434,27 @@ function setConfigResponse($response)
return json_decode( $response, true ); return json_decode( $response, true );
} }
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{ {
$source = '/tmp/code.zip'; $source = '/tmp/code.zip';
$outPath = '/tmp/'; $outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压 // 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/'; $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error_code'=>'Error', 'error_msg'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz'; $tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url)); file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile); $phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖 $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名 // 获取解压出的目录名
$outPath = findIndexPath($outPath); $tmp = scandir($outPath);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
// 将目录中文件打包成zip // 将目录中文件打包成zip
//$zip=new ZipArchive(); //$zip=new ZipArchive();
@ -478,64 +486,5 @@ function addFileToZip($zip, $rootpath, $path = '')
} }
} }
} }
@closedir($handler); @closedir($path);
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息填入<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through FG.', 400);
} }

View File

@ -1,12 +1,9 @@
<?php <?php
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0110.html
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0111.html
global $contextUserData; global $contextUserData;
function printInput($event, $context) function printInput($event, $context)
{ {
$tmp['RequestID'] = $context->getRequestID(); $tmp['eventID'] = $context->geteventID();
$tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds(); $tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
$tmp['AccessKey'] = $context->getAccessKey(); $tmp['AccessKey'] = $context->getAccessKey();
$tmp['SecretKey'] = $context->getSecretKey(); $tmp['SecretKey'] = $context->getSecretKey();
@ -17,7 +14,7 @@ function printInput($event, $context)
$tmp['MemorySize'] = $context->getMemorySize(); $tmp['MemorySize'] = $context->getMemorySize();
$tmp['CPUNumber'] = $context->getCPUNumber(); $tmp['CPUNumber'] = $context->getCPUNumber();
$tmp['ProjectID'] = $context->getProjectID(); $tmp['ProjectID'] = $context->getProjectID();
$tmp['Package'] = $context->getPackage(); $tmp['Package'] = $context->Package();
$tmp['Token'] = $context->getToken(); $tmp['Token'] = $context->getToken();
$tmp['Logger'] = $context->getLogger(); $tmp['Logger'] = $context->getLogger();
@ -51,16 +48,17 @@ function GetPathSetting($event, $context)
$_SERVER['ProjectID'] = $context->getProjectID(); $_SERVER['ProjectID'] = $context->getProjectID();
$host_name = $event['headers']['host']; $host_name = $event['headers']['host'];
$_SERVER['HTTP_HOST'] = $host_name; $_SERVER['HTTP_HOST'] = $host_name;
$path = path_format('/' . $event['pathParameters']['']); $path = path_format($event['pathParameters'][''].'/');
$path = str_replace('+', '%2B', $path); $_SERVER['base_path'] = path_format($event['path'].'/');
$_SERVER['base_path'] = path_format($event['path']);
if ( $_SERVER['base_path'] == $path ) { if ( $_SERVER['base_path'] == $path ) {
$_SERVER['base_path'] = '/'; $_SERVER['base_path'] = '/';
} else { } else {
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, strlen($_SERVER['base_path'])-strlen($path)); $_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/'; if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
} }
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip']; $_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent']; $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
@ -71,17 +69,19 @@ function GetPathSetting($event, $context)
} }
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto']; $_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
//if ($_SERVER['HTTP_REFERER']!='')
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since']; $_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
return $path; return $path;
} }
function getConfig($str, $disktag = '') function getConfig($str, $disktag = '')
{ {
$projectPath = splitlast(__DIR__, '/')[0];
$configPath = $projectPath . '/.data/config.php'; global $slash;
$projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$s = file_get_contents($configPath); $s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}'; $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') { if ($configs!='') {
@ -106,8 +106,9 @@ function setConfig($arr, $disktag = '')
{ {
if ($disktag=='') $disktag = $_SERVER['disktag']; if ($disktag=='') $disktag = $_SERVER['disktag'];
$projectPath = splitlast(__DIR__, '/')[0]; global $slash;
$configPath = $projectPath . '/.data/config.php'; $projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$s = file_get_contents($configPath); $s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}'; $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') $envs = json_decode($configs, true); if ($configs!='') $envs = json_decode($configs, true);
@ -204,9 +205,18 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = getConfig('HW_urn');
if ($tmp['HW_urn']=='') {
$tmp['HW_urn'] = $_POST['HW_urn']; $tmp['HW_urn'] = $_POST['HW_urn'];
}
$tmp['HW_key'] = getConfig('HW_key');
if ($tmp['HW_key']=='') {
$tmp['HW_key'] = $_POST['HW_key']; $tmp['HW_key'] = $_POST['HW_key'];
}
$tmp['HW_secret'] = getConfig('HW_secret');
if ($tmp['HW_secret']=='') {
$tmp['HW_secret'] = $_POST['HW_secret']; $tmp['HW_secret'] = $_POST['HW_secret'];
}
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE']; $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//return message($html, $title, 201); //return message($html, $title, 201);
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) ); $response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
@ -248,14 +258,13 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
$html .= '
在函数代码操作页上方找到URN鼠标放上去后显示URN复制填入<br> 在函数代码操作页上方找到URN鼠标放上去后显示URN复制填入<br>
<label>URN:<input name="HW_urn" type="text" placeholder="urn:fss:ap-XXXXXXXX:XXXXXXXXXXXXXXXXXXXXc01a1e9caXXX:function:default:XXXXX:latest" size=""></label><br> <label>URN:<input name="HW_urn" type="text" placeholder="urn:fss:ap-XXXXXXXX:XXXXXXXXXXXXXXXXXXXXc01a1e9caXXX:function:default:XXXXX:latest" size=""></label><br>
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥, <a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息填入<br> 在下载的credentials.csv文件中找到对应信息填入<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br> <label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>'; <label>Secret Access Key:<input name="HW_secret" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br> <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@ -279,18 +288,17 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
$html .= '
if (t.HW_urn.value==\'\') { if (t.HW_urn.value==\'\') {
alert(\'input URN\'); alert(\'input URN\');
return false; return false;
} }
if (t.HW_key.value==\'\') { if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\'); alert(\'input name\');
return false; return false;
} }
if (t.HW_secret.value==\'\') { if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\'); alert(\'input pwd\');
return false; return false;
}'; }';
$html .= ' $html .= '
@ -419,6 +427,7 @@ function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret) function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
{ {
global $slash;
//echo json_encode($Envs,JSON_PRETTY_PRINT); //echo json_encode($Envs,JSON_PRETTY_PRINT);
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' ); if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
else { else {
@ -461,8 +470,8 @@ function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
return $response; return $response;
} }
$projectPath = splitlast(__DIR__, '/')[0]; $projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . '/.data/config.php'; $configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$s = file_get_contents($configPath); $s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}'; $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') $tmp_env = json_decode($configs, true); if ($configs!='') $tmp_env = json_decode($configs, true);
@ -517,24 +526,39 @@ function setConfigResponse($response)
return json_decode( $response, true ); return json_decode( $response, true );
} }
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{ {
$source = '/tmp/code.zip'; $source = '/tmp/code.zip';
$outPath = '/tmp/'; $outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压 // 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/'; $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error_code'=>'Error', 'error_msg'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz'; $tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url)); file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile); $phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖 $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名 // 获取解压出的目录名
$outPath = findIndexPath($outPath); /*
@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;
}
}
// 放入配置文件 // 放入配置文件
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php')); file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
@ -569,7 +593,7 @@ function addFileToZip($zip, $rootpath, $path = '')
} }
} }
} }
@closedir($handler); @closedir($path);
} }
@ -579,7 +603,6 @@ function addFileToZip($zip, $rootpath, $path = '')
define("BasicDateFormat", "Ymd\THis\Z"); define("BasicDateFormat", "Ymd\THis\Z");
define("Algorithm", "SDK-HMAC-SHA256"); define("Algorithm", "SDK-HMAC-SHA256");
define("HeaderXDate", "X-Sdk-Date"); define("HeaderXDate", "X-Sdk-Date");
@ -846,62 +869,3 @@ class Signer
return $curl; return $curl;
} }
} }
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息填入<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through FG.', 400);
}

View File

@ -4,16 +4,8 @@ function getpath()
{ {
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]); $_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_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']; // Glitch
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') {
$_SERVER['REQUEST_SCHEME'] = 'http';
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
//if ($_SERVER['HTTP_REFERER']!='')
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2]; $_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
if (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/app') $_SERVER['base_path'] = '/'; if (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/app') $_SERVER['base_path'] = '/';
else $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/'); else $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
@ -23,6 +15,8 @@ function getpath()
else $path = $_SERVER['REQUEST_URI']; else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) ); $path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path; return $path;
//return substr($path, 1);
//return spurlencode($path, '/');
} }
function getGET() function getGET()
@ -233,7 +227,7 @@ function install()
url += location.pathname; url += location.pathname;
if (url.substr(-1)!="/") url += "/"; if (url.substr(-1)!="/") url += "/";
url += "app.json"; url += "app.json";
url += "?" + Date.now(); //alert(url);
var xhr4 = new XMLHttpRequest(); var xhr4 = new XMLHttpRequest();
xhr4.open("GET", url); xhr4.open("GET", url);
xhr4.setRequestHeader("x-requested-with","XMLHttpRequest"); xhr4.setRequestHeader("x-requested-with","XMLHttpRequest");
@ -245,7 +239,7 @@ function install()
document.getElementById("submitbtn").disabled = false; document.getElementById("submitbtn").disabled = false;
document.getElementById("formdiv").style.display = ""; document.getElementById("formdiv").style.display = "";
} else { } else {
alert("' . getconstStr('MakesuerRewriteOn') . '?\nfalse\n\nUrl: " + url + "\nExpect http code 201, but received " + xhr4.status); alert("Url: " + url + "\nExpect http code 201, but received " + xhr4.status);
} }
} }
} }
@ -277,9 +271,8 @@ language:<br>';
$title = getconstStr('SelectLanguage'); $title = getconstStr('SelectLanguage');
return message($html, $title, 201); return message($html, $title, 201);
} }
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
$title = 'Install'; $title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201); return message($html, $title, 201);
} }
@ -311,23 +304,19 @@ function setConfigResponse($response)
return json_decode($response, true); return json_decode($response, true);
} }
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{ {
global $slash; $slash = '/';
if (strpos(__DIR__, ':')) $slash = '\\';
// __DIR__ is xxx/platform // __DIR__ is xxx/platform
$projectPath = splitlast(__DIR__, $slash)[0]; $projectPath = splitlast(__DIR__, $slash)[0];
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压 // 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/'; $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return 0;
$tarfile = $projectPath . $slash .'github.tar.gz'; $tarfile = $projectPath . $slash .'github.tar.gz';
$githubfile = file_get_contents($url); $githubfile = file_get_contents($url);
if (!$githubfile) return 0; if (!$githubfile) return 0;
file_put_contents($tarfile, $githubfile); file_put_contents($tarfile, $githubfile);
if (splitfirst(PHP_VERSION, '.')[0] > '5') { if (splitfirst(PHP_VERSION, '.')[0] > '5') {
$phar = new PharData($tarfile); // need php5.3, 7, 8 $phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖 $phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
@ -339,7 +328,14 @@ function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneM
unlink($tarfile); unlink($tarfile);
$outPath = ''; $outPath = '';
$outPath = findIndexPath($projectPath); $tmp = scandir($projectPath);
$name = $auth . '-' . $project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath = $projectPath . $slash . $f;
break;
}
}
//error_log1($outPath); //error_log1($outPath);
if ($outPath=='') return 0; if ($outPath=='') return 0;
@ -350,12 +346,11 @@ function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneM
$tmp1['message'] = "Can not move " . $projectPath . $slash . '.data' . $slash . 'config.php' . " to " . $outPath . $slash . '.data' . $slash . 'config.php'; $tmp1['message'] = "Can not move " . $projectPath . $slash . '.data' . $slash . 'config.php' . " to " . $outPath . $slash . '.data' . $slash . 'config.php';
return json_encode($tmp1); return json_encode($tmp1);
} }
return moveFolder($outPath, $projectPath); return moveFolder($outPath, $projectPath, $slash);
} }
function moveFolder($from, $to) function moveFolder($from, $to, $slash)
{ {
global $slash;
if (substr($from, -1)==$slash) $from = substr($from, 0, -1); if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
if (substr($to, -1)==$slash) $to = substr($to, 0, -1); if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
if (!file_exists($to)) mkdir($to, 0777); if (!file_exists($to)) mkdir($to, 0777);
@ -365,7 +360,7 @@ function moveFolder($from, $to)
$fromfile = $from . $slash . $filename; $fromfile = $from . $slash . $filename;
$tofile = $to . $slash . $filename; $tofile = $to . $slash . $filename;
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归 if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = moveFolder($fromfile, $tofile); $response = moveFolder($fromfile, $tofile, $slash);
if (api_error(setConfigResponse($response))) return $response; if (api_error(setConfigResponse($response))) return $response;
}else{ }else{
//if (file_exists($tofile)) unlink($tofile); //if (file_exists($tofile)) unlink($tofile);
@ -383,17 +378,3 @@ function moveFolder($from, $to)
rmdir($from); rmdir($from);
return json_encode( [ 'response' => 'success' ] ); return json_encode( [ 'response' => 'success' ] );
} }
function WaitFunction() {
return true;
}
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']);
}

View File

@ -1,363 +0,0 @@
<?php
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 ($_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['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = '/';
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path;
}
function getGET()
{
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
$getstrarr = explode("&",$getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function ReplitAPI($op, $key, $value = '') {
//error_log1($op . '_' . $key . '_' . $value);
$apiurl = getenv('REPLIT_DB_URL');
//foreach (explode("\n", curl('GET', $apiurl . '?prefix')['body']) as $a) curl('DELETE', $apiurl . '/' . $a);
if ($op === 'r') {
if (!($config = getcache('REPLIT_CONFIG'))) {
$config = json_decode(curl('GET', $apiurl . '/REPLIT_CONFIG')['body'], true);
savecache('REPLIT_CONFIG', $config);
}
return ['stat'=>200, 'body'=>(is_array($config[$key])?json_encode($config[$key]):$config[$key])];
} elseif ($op === 'w') {
return curl('POST', $apiurl, 'REPLIT_CONFIG=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]);
} elseif ($op === 'd') {
// not use
return curl('DELETE', $apiurl . '/' . $key);
} else {
return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().'];
}
}
function getConfig($str, $disktag = '')
{
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$env = json_decode(ReplitAPI('r', $disktag)['body'], true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']);
else return ReplitAPI('r', $str)['body'];
}
return '';
}
function setConfig($arr, $disktag = '')
{
if (!($envs = getcache('REPLIT_CONFIG'))) {
$envs = json_decode(curl('GET', getenv('REPLIT_DB_URL') . '/REPLIT_CONFIG')['body'], true);
savecache('REPLIT_CONFIG', $envs);
}
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getConfig('disktag'));
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
else $envs[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
else $envs[$disktag][$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$envs[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$envs[$newtag] = $envs[$v];
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$envs[$k] = $v;
}
}
if ($indisk) {
$diskconfig = $envs[$disktag];
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$envs[$disktag] = $diskconfig;
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$envs['disktag'] = implode('|', $tags);
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
unset($envs[$arr['disktag_rename']]);
} else {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
else $envs['disktag'] = '';
}
}
$envs = array_filter($envs, 'array_value_isnot_null');
sortConfig($envs);
$response = ReplitAPI('w', 'REPLIT_CONFIG', json_encode($envs));
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT));
savecache('REPLIT_CONFIG', null, '', 0);
if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "<br>\nError in writting " . $key . "=" . $val];
return $response;
}
function install()
{
global $constStr;
if ($_GET['install2']) {
if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_COOKIE['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$response = setConfigResponse( setConfig($tmp) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 201);
} else {
return output('Jump
<script>
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
}
}
}
if ($_GET['install1']) {
/*if (!ConfigWriteable()) {
$html .= getconstStr('MakesuerWriteable');
$title = 'Error';
return message($html, $title, 201);
}
if (!RewriteEngineOn()) {
$html .= getconstStr('MakesuerRewriteOn');
$title = 'Error';
return message($html, $title, 201);
}*/
$html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);">
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
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;
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\''.getconstStr('SetAdminPassword').'\');
return false;
}
return true;
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
}
if ($_GET['install0']) {
$html .= '
<form action="?install1" method="post">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
function changelanguage(str)
{
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;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
$title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201);
}
function ConfigWriteable()
{
$t = md5( md5(time()).rand(1000,9999) );
$r = setConfig([ 'tmp' => $t ]);
$tmp = getConfig('tmp');
setConfig([ 'tmp' => '' ]);
if ($tmp == $t) return true;
if ($r) return true;
return false;
}
function api_error($response)
{
return !($response['stat']==200||$response['stat']==204||$response['stat']==404);
//return isset($response['message']);
}
function api_error_msg($response)
{
return '<pre>'. json_encode($response, JSON_PRETTY_PRINT).'</pre>' . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function setConfigResponse($response)
{
return $response;
//return json_decode($response, true);
}
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
// __DIR__ is xxx/platform
$projectPath = splitlast(__DIR__, '/')[0];
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return ['stat'=>500, 'body'=>'Git Source input Error!'];
$tarfile = $projectPath . '/github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return ['stat'=>500, 'body'=>'download error from github.'];
file_put_contents($tarfile, $githubfile);
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
$phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
} else {
ob_start();
passthru('tar -xzvf ' . $tarfile, $stat);
ob_get_clean();
}
unlink($tarfile);
$outPath = '';
$outPath = findIndexPath($projectPath);
//error_log1($outPath);
if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.'];
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)){// 如果读取的某个对象是文件夹,则递归
$response = moveFolder($fromfile, $tofile);
if (api_error(setConfigResponse($response))) return $response;
}else{
if (file_exists($tofile)) unlink($tofile);
$response = rename($fromfile, $tofile);
if (!$response) {
$tmp['code'] = "Move Failed";
$tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
return ['stat'=>500, 'body'=>json_encode($tmp)];
}
if (file_exists($fromfile)) unlink($fromfile);
}
}
}
closedir($handler);
rmdir($from);
return ['stat'=>200, 'body'=>'success.'];
}
function WaitFunction() {
return true;
}
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']);
}

View File

@ -1,379 +0,0 @@
<?php
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 ($_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['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = '/';
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path;
}
function getGET()
{
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
$getstrarr = explode("&",$getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function ReplitAPI($op, $key, $value = '') {
//error_log1($op . '_' . $key . '_' . $value);
$apiurl = getenv('REPLIT_DB_URL');
if ($op === 'r') {
return curl('GET', $apiurl . '/' . $key);
} elseif ($op === 'w') {
return curl('POST', $apiurl, $key . '=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]);
} elseif ($op === 'd') {
return curl('DELETE', $apiurl . '/' . $key);
} else {
return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().'];
}
}
function getConfig($str, $disktag = '')
{
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$env = json_decode(ReplitAPI('r', $disktag)['body'], true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']);
else return ReplitAPI('r', $str)['body'];
}
return '';
}
function setConfig($arr, $disktag = '')
{
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getConfig('disktag'));
if ($disktag!='') $diskconfig = json_decode(ReplitAPI('r', $disktag)['body'], true);
$tmp = [];
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
else $tmp[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
else $diskconfig[$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$tmp[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$tmp[$newtag] = getConfig($v);
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$tmp[$k] = json_encode($v);
}
}
if ($indisk) {
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig);
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$tmp['disktag'] = implode('|', $tags);
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
$tmp[$arr['disktag_rename']] = null;
} else {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = null;
}
}
$response = null;
foreach ($tmp as $key => $val) {
if (!!$val) $response = ReplitAPI('w', $key, $val);
else $response = ReplitAPI('d', $key);
if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "<br>\nError in writting " . $key . "=" . $val];
}
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT));
return $response;
}
function install()
{
global $constStr;
if ($_GET['install2']) {
if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_COOKIE['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$response = setConfigResponse( setConfig($tmp) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 201);
} else {
return output('Jump
<script>
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
}
}
}
if ($_GET['install1']) {
if (!ConfigWriteable()) {
$html .= getconstStr('MakesuerWriteable');
$title = 'Error';
return message($html, $title, 201);
}
/*if (!RewriteEngineOn()) {
$html .= getconstStr('MakesuerRewriteOn');
$title = 'Error';
return message($html, $title, 201);
}*/
$html .= '<button id="checkrewritebtn" onclick="checkrewrite();">'.getconstStr('MakesuerRewriteOn').'</button>
<div id="formdiv" style="display: none">
<form action="?install2" method="post" onsubmit="return notnull(this);">
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'" disabled>
</form>
</div>
<script>
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;
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\''.getconstStr('SetAdminPassword').'\');
return false;
}
return true;
}
function checkrewrite()
{
url=location.protocol + "//" + location.host;
//if (location.port!="") url += ":" + location.port;
url += location.pathname;
if (url.substr(-1)!="/") url += "/";
url += "app.json";
url += "?" + Date.now();
var xhr4 = new XMLHttpRequest();
xhr4.open("GET", url);
xhr4.setRequestHeader("x-requested-with","XMLHttpRequest");
xhr4.send(null);
xhr4.onload = function(e){
console.log(xhr4.responseText+","+xhr4.status);
if (xhr4.status==201) {
document.getElementById("checkrewritebtn").style.display = "none";
document.getElementById("submitbtn").disabled = false;
document.getElementById("formdiv").style.display = "";
} else {
alert("' . getconstStr('MakesuerRewriteOn') . '?\nfalse\n\nUrl: " + url + "\nExpect http code 201, but received " + xhr4.status);
}
}
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
}
if ($_GET['install0']) {
$html .= '
<form action="?install1" method="post">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
function changelanguage(str)
{
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;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
$title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201);
}
function ConfigWriteable()
{
$t = md5( md5(time()).rand(1000,9999) );
$r = setConfig([ 'tmp' => $t ]);
$tmp = getConfig('tmp');
setConfig([ 'tmp' => '' ]);
if ($tmp == $t) return true;
if ($r) return true;
return false;
}
function api_error($response)
{
return !($response['stat']==200||$response['stat']==204||$response['stat']==404);
//return isset($response['message']);
}
function api_error_msg($response)
{
return '<pre>'. json_encode($response, JSON_PRETTY_PRINT).'</pre>' . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function setConfigResponse($response)
{
return $response;
//return json_decode($response, true);
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$slash = '/';
if (strpos(__DIR__, ':')) $slash = '\\';
// __DIR__ is xxx/platform
$projectPath = splitlast(__DIR__, $slash)[0];
// 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
$tarfile = $projectPath . $slash .'github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return ['stat'=>500, 'body'=>'download error from github.'];
file_put_contents($tarfile, $githubfile);
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
$phar = new PharData($tarfile); // need php5.3, 7, 8
$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 . $slash . $f;
break;
}
}
//error_log1($outPath);
if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.'];
return moveFolder($outPath, $projectPath, $slash);
}
function moveFolder($from, $to, $slash)
{
if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
if (!file_exists($to)) mkdir($to, 0777);
$handler=opendir($from);
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..'){
$fromfile = $from . $slash . $filename;
$tofile = $to . $slash . $filename;
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = moveFolder($fromfile, $tofile, $slash);
if (api_error(setConfigResponse($response))) return $response;
}else{
if (file_exists($tofile)) unlink($tofile);
$response = rename($fromfile, $tofile);
if (!$response) {
$tmp['code'] = "Move Failed";
$tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
return ['stat'=>500, 'body'=>json_encode($tmp)];
}
if (file_exists($fromfile)) unlink($fromfile);
}
}
}
closedir($handler);
rmdir($from);
return ['stat'=>200, 'body'=>'success.'];
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
return message("Not need.", 'Change platform Auth token or key', 404);
}

View File

@ -1,7 +1,4 @@
<?php <?php
// https://cloud.tencent.com/document/product/583/33846
// https://cloud.tencent.com/document/product/583/18581
// https://cloud.tencent.com/document/product/583/18580
function printInput($event, $context) function printInput($event, $context)
{ {
@ -44,7 +41,9 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = $event['requestContext']['path']; $_SERVER['base_path'] = $event['requestContext']['path'];
$path = substr($event['path'], strlen($event['requestContext']['path'])); $path = substr($event['path'], strlen($event['requestContext']['path']));
} }
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp']; $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent']; $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
@ -53,13 +52,11 @@ function GetPathSetting($event, $context)
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0]; $_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1]; $_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
} }
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-api-scheme']; $_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
//$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since']; $_SERVER['USER'] = 'qcloud';
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
return $path; return $path;
} }
@ -169,24 +166,16 @@ function install()
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script> </script>
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201, 1); <meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
} }
return message(getconstStr('Success') . ' return output('Jump
<script> <script>
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000)); expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
var i = 0; </script>
var uploadList = setInterval(function(){ <meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>', 201, 1);
} }
if ($_GET['install1']) { if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
@ -210,7 +199,7 @@ function install()
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') { if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>'; $html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
$title = 'Reinstall'; $title = 'Reinstall';
return message($html, $title, 201, 1); return message($html, $title, 201);
} }
$html .= ' $html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);"> <form action="?install2" method="post" onsubmit="return notnull(this);">
@ -228,7 +217,7 @@ function install()
} }
</script>'; </script>';
$title = getconstStr('SetAdminPassword'); $title = getconstStr('SetAdminPassword');
return message($html, $title, 201, 1); return message($html, $title, 201);
} }
} }
if ($_GET['install0']) { if ($_GET['install0']) {
@ -239,11 +228,10 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='') if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
$html .= '
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br> <a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br> <label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>'; <label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br> <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@ -267,8 +255,7 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='') if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
$html .= '
if (t.SecretId.value==\'\') { if (t.SecretId.value==\'\') {
alert(\'input SecretId\'); alert(\'input SecretId\');
return false; return false;
@ -383,6 +370,9 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
{ {
//echo json_encode($Envs,JSON_PRETTY_PRINT); //echo json_encode($Envs,JSON_PRETTY_PRINT);
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' ); if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
/*$trynum = 0;
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;*/
//json_decode($a,true)['Response']['Environment']['Variables'][0]['Key'] //json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables']; $tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
foreach ($tmp as $tmp1) { foreach ($tmp as $tmp1) {
@ -422,7 +412,7 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr)); return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
} }
function updateProgram_OLD($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source) function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
{ {
WaitSCFStat(); WaitSCFStat();
$meth = 'POST'; $meth = 'POST';
@ -461,207 +451,14 @@ namespace:' . $_SERVER['namespace'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
} }
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source['url'] = 'https://github.com/' . $auth . '/' . $project;
$source['branch'] = $branch;
return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source);
}
function setConfigResponse($response) function setConfigResponse($response)
{ {
return json_decode( $response, true )['Response']; return json_decode( $response, true )['Response'];
} }
function WaitFunction() {
//$trynum = 0;
//while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
//'.++$trynum;
if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true;
else return false;
}
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
{
$secretId = $SecretId;
$secretKey = $SecretKey;
$host = 'scf.tencentcloudapi.com';
$service = "scf";
$version = "2018-04-16";
$action = "UpdateFunctionCode";
$region = $Region;
$timestamp = time();
$algorithm = "TC3-HMAC-SHA256";
// step 1: build canonical request string
$httpRequestMethod = "POST";
$canonicalUri = "/";
$canonicalQueryString = "";
$canonicalHeaders = "content-type:application/json; charset=utf-8\n"."host:".$host."\n";
$signedHeaders = "content-type;host";
//$tmpdata['Action'] = 'UpdateFunctionCode';
$tmpdata['Code']['ZipFile'] = base64_encode( file_get_contents($source) );
$tmpdata['CodeSource'] = 'ZipFile';
$tmpdata['FunctionName'] = $function_name;
$tmpdata['Handler'] = 'index.main_handler';
//$tmpdata['Namespace'] = $Namespace;
//$tmpdata['Nonce'] = time();
//$tmpdata['Region'] = $Region;
//$tmpdata['SecretId'] = $SecretId;
//$tmpdata['Timestamp'] = time();
//$tmpdata['Token'] = '';
//$tmpdata['Version'] = '2018-04-16';
$payload = json_encode($tmpdata);
//$payload = '{"Limit": 1, "Filters": [{"Values": ["\u672a\u547d\u540d"], "Name": "instance-name"}]}';
$hashedRequestPayload = hash("SHA256", $payload);
$canonicalRequest = $httpRequestMethod."\n"
.$canonicalUri."\n"
.$canonicalQueryString."\n"
.$canonicalHeaders."\n"
.$signedHeaders."\n"
.$hashedRequestPayload;
//echo $canonicalRequest.PHP_EOL;
// step 2: build string to sign
$date = gmdate("Y-m-d", $timestamp);
$credentialScope = $date."/".$service."/tc3_request";
$hashedCanonicalRequest = hash("SHA256", $canonicalRequest);
$stringToSign = $algorithm."\n"
.$timestamp."\n"
.$credentialScope."\n"
.$hashedCanonicalRequest;
//echo $stringToSign.PHP_EOL;
// step 3: sign string
$secretDate = hash_hmac("SHA256", $date, "TC3".$secretKey, true);
$secretService = hash_hmac("SHA256", $service, $secretDate, true);
$secretSigning = hash_hmac("SHA256", "tc3_request", $secretService, true);
$signature = hash_hmac("SHA256", $stringToSign, $secretSigning);
//echo $signature.PHP_EOL;
// step 4: build authorization
$authorization = $algorithm
." Credential=".$secretId."/".$credentialScope
.", SignedHeaders=content-type;host, Signature=".$signature;
//echo $authorization.PHP_EOL;
//$curl = "curl -X POST https://".$host
// .' -H "Authorization: '.$authorization.'"'
// .' -H "Content-Type: application/json; charset=utf-8"'
// .' -H "Host: '.$host.'"'
// .' -H "X-TC-Action: '.$action.'"'
// .' -H "X-TC-Timestamp: '.$timestamp.'"'
// .' -H "X-TC-Version: '.$version.'"'
// .' -H "X-TC-Region: '.$region.'"'
// ." -d '".$payload."'";
//error_log1( $curl.PHP_EOL );
//return '{"response": {"Error": {"Message":"' . $curl . '"}}}';
$headers['Authorization'] = $authorization;
$headers['Content-Type'] = 'application/json; charset=utf-8';
$headers['Host'] = $host;
$headers['X-TC-Action'] = $action;
$headers['X-TC-Timestamp'] = $timestamp;
$headers['X-TC-Version'] = $version;
$headers['X-TC-Region'] = $region;
return curl('POST', 'https://'.$host, $payload, $headers)['body'];
}
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['Response'=>['Error'=>['code'=>'Git Source input Error!']]]);
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名
$outPath = findIndexPath($outPath);
// 将目录中文件打包成zip
//$zip=new ZipArchive();
$zip=new PharData($source);
//if($zip->open($source, ZipArchive::CREATE)){
addFileToZip($zip, $outPath); //调用方法对要打包的根目录进行操作并将ZipArchive的对象传递给方法
// $zip->close(); //关闭处理的zip文件
//}
return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $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)){// 如果读取的某个对象是文件夹,则递归
$zip->addEmptyDir($path."/".$filename);
addFileToZip($zip, $rootpath, $path."/".$filename);
}else{ //将文件加入zip对象
$newname = $path."/".$filename;
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
$zip->addFile($nowname, $newname);
//$zip->renameName($nowname, $newname);
}
}
}
@closedir($handler);
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through SCF.', 400);
}

View File

@ -1,7 +1,4 @@
<?php <?php
// https://cloud.tencent.com/document/product/583/33846
// https://cloud.tencent.com/document/product/583/18581
// https://cloud.tencent.com/document/product/583/18580
function printInput($event, $context) function printInput($event, $context)
{ {
@ -44,7 +41,9 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = $event['requestContext']['path']; $_SERVER['base_path'] = $event['requestContext']['path'];
$path = substr($event['path'], strlen($event['requestContext']['path'])); $path = substr($event['path'], strlen($event['requestContext']['path']));
} }
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp']; $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent']; $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
@ -53,13 +52,11 @@ function GetPathSetting($event, $context)
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0]; $_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1]; $_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
} }
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-api-scheme']; $_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
//$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since']; $_SERVER['USER'] = 'qcloud';
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
return $path; return $path;
} }
@ -181,31 +178,29 @@ function install()
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script> </script>
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201, 1); <meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
} }
return message(getconstStr('Success') . ' return output('Jump
<script> <script>
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000)); expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
var i = 0; </script>
var uploadList = setInterval(function(){ <meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>', 201, 1);
} }
if ($_GET['install1']) { if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$SecretId = getConfig('SecretId');
if ($SecretId=='') {
$SecretId = $_POST['SecretId']; $SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId; $tmp['SecretId'] = $SecretId;
}
$SecretKey = getConfig('SecretKey');
if ($SecretKey=='') {
$SecretKey = $_POST['SecretKey']; $SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey; $tmp['SecretKey'] = $SecretKey;
}
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE']; $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
$response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
if (api_error($response)) { if (api_error($response)) {
@ -216,7 +211,7 @@ function install()
if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') { if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>'; $html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
$title = 'Reinstall'; $title = 'Reinstall';
return message($html, $title, 201, 1); return message($html, $title, 201);
} }
$html .= ' $html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);"> <form action="?install2" method="post" onsubmit="return notnull(this);">
@ -234,7 +229,7 @@ function install()
} }
</script>'; </script>';
$title = getconstStr('SetAdminPassword'); $title = getconstStr('SetAdminPassword');
return message($html, $title, 201, 1); return message($html, $title, 201);
} }
} }
if ($_GET['install0']) { if ($_GET['install0']) {
@ -245,11 +240,10 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='') if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
$html .= '
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">'.getconstStr('Create').' SecretId & SecretKey</a><br> <a href="https://console.cloud.tencent.com/cam/capi" target="_blank">'.getconstStr('Create').' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br> <label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>'; <label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br> <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@ -273,8 +267,7 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='') if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
$html .= '
if (t.SecretId.value==\'\') { if (t.SecretId.value==\'\') {
alert(\'input SecretId\'); alert(\'input SecretId\');
return false; return false;
@ -595,25 +588,27 @@ function setConfigResponse($response)
return json_decode( $response, true )['Response']; return json_decode( $response, true )['Response'];
} }
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{ {
$source = '/tmp/code.zip'; $source = '/tmp/code.zip';
$outPath = '/tmp/'; $outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压 // 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/'; $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['Response'=>['Error'=>['code'=>'Git Source input Error!']]]);
$tarfile = '/tmp/github.tar.gz'; $tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url)); file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile); $phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖 $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名 // 获取包中目录名
$outPath = findIndexPath($outPath); $tmp = scandir('phar://'.$tarfile);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
// 放入配置文件 // 放入配置文件
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php')); file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
@ -647,64 +642,5 @@ function addFileToZip($zip, $rootpath, $path = '')
} }
} }
} }
@closedir($handler); @closedir($path);
}
function WaitFunction() {
if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true;
else return false;
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through SCF.', 400);
} }

View File

@ -1,496 +0,0 @@
<?php
// https://vercel.com/docs/api#endpoints/deployments/create-a-new-deployment
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['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['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = "/";
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'], '?');
if ($p > 0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format(substr($path, strlen($_SERVER['base_path'])));
return $path;
}
function getGET() {
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues, "=");
$_POST[urldecode(substr($postvalues, 0, $pos))] = urldecode(substr($postvalues, $pos + 1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'], '?');
if ($p > 0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p + 1);
$getstrarr = explode("&", $getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function getConfig($str, $disktag = '') {
$projectPath = splitlast(__DIR__, '/')[0];
$configPath = $projectPath . '/.data/config.php';
$s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs != '') {
$envs = json_decode($configs, true);
if (isInnerEnv($str)) {
if ($disktag == '') $disktag = $_SERVER['disktag'];
if (isset($envs[$disktag][$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$disktag][$str]);
else return $envs[$disktag][$str];
}
} else {
if (isset($envs[$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$str]);
else return $envs[$str];
}
}
}
return '';
}
function setConfig($arr, $disktag = '') {
if ($disktag == '') $disktag = $_SERVER['disktag'];
$projectPath = splitlast(__DIR__, '/')[0];
$configPath = $projectPath . '/.data/config.php';
$s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs != '') $envs = json_decode($configs, true);
$disktags = explode("|", getConfig('disktag'));
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
else $envs[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
else $envs[$disktag][$k] = $v;
$indisk = 1;
} elseif ($k == 'disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k == 'disktag_del') {
$disktags = array_diff($disktags, [$v]);
$envs[$v] = '';
$operatedisk = 1;
} elseif ($k == 'disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$envs[$newtag] = $envs[$v];
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k == 'disktag_rename' || $k == 'disktag_newname') {
if ($arr['disktag_rename'] != $arr['disktag_newname']) $operatedisk = 1;
} else {
$envs[$k] = $v;
}
}
if ($indisk) {
$diskconfig = $envs[$disktag];
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$envs[$disktag] = $diskconfig;
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname'] != '') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag == $arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$envs['disktag'] = implode('|', $tags);
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
$envs[$arr['disktag_rename']] = '';
} else {
$disktags = array_unique($disktags);
$disktag_s = "";
foreach ($disktags as $disktag) if ($disktag != '') $disktag_s .= $disktag . '|';
if ($disktag_s != '') $envs['disktag'] = substr($disktag_s, 0, -1);
else $envs['disktag'] = '';
}
}
$envs = array_filter($envs, 'array_value_isnot_null');
//ksort($envs);
//sortConfig($envs);
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT));
//echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT);
return setVercelConfig($envs, getConfig('HerokuappId'), getConfig('APIKey'));
}
function install() {
global $constStr;
if ($_GET['install1']) {
if ($_POST['admin'] != '') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = $_POST['APIKey'];
//if ($APIKey=='') {
// $APIKey = getConfig('APIKey');
//}
$tmp['APIKey'] = $APIKey;
$token = $APIKey;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$aliases = json_decode(curl("GET", "https://api.vercel.com/v3/now/aliases", "", $header)['body'], true);
$host = splitfirst($_SERVER["host"], "//")[1];
$aliases1 = [];
foreach ($aliases["aliases"] as $key => $aliase) {
$aliases1[] = $aliase["alias"];
if ($host == $aliase["alias"]) $projectId = $aliase["projectId"];
}
if (!$projectId) {
$html = 'Please visit from one of: ' . json_encode($aliases1, JSON_PRETTY_PRINT);
return message($html, 'Error', 400);
}
$tmp['HerokuappId'] = $projectId;
$response = json_decode(setVercelConfig($tmp, $projectId, $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var expd = new Date();
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
$title = "Success";
return message($html, $title, 201, 1);
}
}
}
if ($_GET['install0']) {
$html = '
<form action="?install1" method="post" onsubmit="return notnull(this);">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="' . $key1 . '" ' . ($key1 == $constStr['language'] ? 'checked' : '') . ' onclick="changelanguage(\'' . $key1 . '\')">' . $value1 . '</label><br>';
}
$html .= '<br>
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>';
$html .= '<br>
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<div id="showerror"></div>
<script>
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;
var errordiv = document.getElementById("showerror");
function changelanguage(str)
{
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;
}
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\'input admin\');
return false;
}
if (t.APIKey.value==\'\') {
alert(\'input Token\');
return false;
}
return true;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
//if (substr($_SERVER["host"], -10)=="vercel.app") {
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
$html .= "<br>Remember: you MUST wait 30-60s after each operate / do some change, that make sure Vercel has done the building<br>";
//} else {
// $html.= "Please visit form *.vercel.app";
//}
$title = 'Install';
return message($html, $title, 201);
}
function copyFolder($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, 1);
$handler = opendir($from);
while ($filename = readdir($handler)) {
if ($filename != '.' && $filename != '..') {
$fromfile = $from . '/' . $filename;
$tofile = $to . '/' . $filename;
if (is_dir($fromfile)) { // 如果读取的某个对象是文件夹,则递归
copyFolder($fromfile, $tofile);
} else {
copy($fromfile, $tofile);
}
}
}
closedir($handler);
return 1;
}
function setVercelConfig($envs, $appId, $token) {
sortConfig($envs);
$outPath = '/tmp/code/';
$outPath_Api = $outPath . 'api/';
$coderoot = __DIR__;
$coderoot = splitlast($coderoot, '/')[0] . '/';
//echo $outPath_Api . '<br>' . $coderoot . '<br>';
copyFolder($coderoot, $outPath_Api);
$prestr = '<?php $configs = \'' . PHP_EOL;
$aftstr = PHP_EOL . '\';';
file_put_contents($outPath_Api . '.data/config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
return VercelUpdate($appId, $token, $outPath);
}
function VercelUpdate($appId, $token, $sourcePath = "") {
if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}';
$url = "https://api.vercel.com/v13/deployments";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$data["name"] = "OneManager";
$data["project"] = $appId;
$data["target"] = "production";
$data["routes"][0]["src"] = "/(.*)";
$data["routes"][0]["dest"] = "/api/index.php";
$data["functions"]["api/index.php"]["runtime"] = "vercel-php@0.6.0";
if ($sourcePath == "") $sourcePath = splitlast(splitlast(__DIR__, "/")[0], "/")[0];
//echo $sourcePath . "<br>";
getEachFiles($file, $sourcePath);
$data["files"] = $file;
//echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>";
$response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
$result['DplStatus'] = $result['id'];
return json_encode($result);
}
function checkBuilding($projectId, $token) {
$r = 0;
$url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, '', $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
foreach ($result['deployments'] as $deployment) {
if ($deployment['state'] !== "READY" && $deployment['state'] !== "ERROR") $r++;
}
return $r;
//if ($r===0) return true;
//else return false;
}
function getEachFiles(&$file, $base, $path = "") {
//if (substr($base, -1)=="/") $base = substr($base, 0, -1);
//if (substr($path, -1)=="/") $path = substr($path, 0, -1);
$handler = opendir(path_format($base . "/" . $path));
while ($filename = readdir($handler)) {
if ($filename != '.' && $filename != '..' && $filename != '.git') {
$fromfile = path_format($base . "/" . $path . "/" . $filename);
//echo $fromfile . "<br>";
if (is_dir($fromfile)) { // 如果读取的某个对象是文件夹,则递归
$response = getEachFiles($file, $base, path_format($path . "/" . $filename));
if (api_error(setConfigResponse($response))) return $response;
} else {
$tmp['file'] = path_format($path . "/" . $filename);
$tmp['data'] = file_get_contents($fromfile);
$file[] = $tmp;
}
}
}
closedir($handler);
return json_encode(['response' => 'success']);
}
function api_error($response) {
return isset($response['error']);
}
function api_error_msg($response) {
return $response['error']['code'] . '<br>
' . $response['error']['message'] . '<br>
<button onclick="location.href = location.href;">' . getconstStr('Refresh') . '</button>';
}
function setConfigResponse($response) {
return json_decode($response, true);
}
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master') {
$tmppath = '/tmp';
if ($GitSource == 'Github') {
// 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource == 'HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error' => ['code' => 'Git Source input Error!']]);
$tarfile = $tmppath . '/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($tmppath, null, true); //路径 要解压的文件 是否覆盖
unlink($tarfile);
// 获取解压出的目录名
$outPath = findIndexPath($tmppath);
if ($outPath == '') return '{"error":{"message":"no outpath"}}';
$name = $project . 'CODE';
mkdir($tmppath . "/" . $name, 0777, 1);
rename($outPath, $tmppath . "/" . $name . '/api');
$outPath = $tmppath . "/" . $name;
//echo $outPath . "<br>";
//error_log1($outPath);
// put in config
$coderoot = __DIR__;
$coderoot = splitlast($coderoot, '/')[0] . '/';
copy($coderoot . '.data/config.php', $outPath . '/api/.data/config.php');
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
}
function WaitFunction($deployid = '') {
if ($deployid == '1') {
$tmp['stat'] = 400;
$tmp['body'] = 'id must provided.';
return $tmp;
}
$token = getConfig('APIKey');
if ($token != '') {
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v13/deployments/" . $deployid;
$response = curl("GET", $url, "", $header);
if ($response['stat'] == 200) {
$result = json_decode($response['body'], true);
if ($result['readyState'] == "READY") return true;
if ($result['readyState'] == "ERROR") return $response;
return false;
} else {
$response['body'] .= $url;
return $response;
}
} else {
return false;
}
}
function changeAuthKey() {
if ($_POST['APIKey'] != '') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = setConfigResponse(setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey));
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
$title = "Success";
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'Input Token\');
return false;
}
return true;
}
</script>';
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']);
}

View File

@ -1,472 +0,0 @@
<?php
// https://vercel.com/docs/api#endpoints/deployments/create-a-new-deployment
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['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['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = "/";
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path;
}
function getGET()
{
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
$getstrarr = explode("&",$getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function getConfig($str, $disktag = '')
{
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$tmp = getenv($disktag);
if (is_array($tmp)) $env = $tmp;
else $env = json_decode($tmp, true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(getenv($str));
else return getenv($str);
}
return '';
}
function setConfig($arr, $disktag = '')
{
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getenv('disktag'));
if ($disktag!='') {
$tmp = getenv($disktag);
if (is_array($tmp)) $diskconfig = $tmp;
else $diskconfig = json_decode($tmp, true);
}
$tmp = [];
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
else $tmp[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
else $diskconfig[$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$tmp[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$tagvalue = getenv($v);
if (is_array($tagvalue)) $tmp[$newtag] = json_encode($tagvalue);
else $tmp[$newtag] = $tagvalue;
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$tmp[$k] = json_encode($v);
}
}
if ($indisk) {
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig);
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$tmp['disktag'] = implode('|', $tags);
$tagvalue = getenv($arr['disktag_rename']);
if (is_array($tagvalue)) $tmp[$arr['disktag_newname']] = json_encode($tagvalue);
else $tmp[$arr['disktag_newname']] = $tagvalue;
$tmp[$arr['disktag_rename']] = null;
} else {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = null;
}
}
foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT));
//echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT);
return setVercelConfig($tmp, getConfig('HerokuappId'), getConfig('APIKey'));
}
function install()
{
global $constStr;
if ($_GET['install1']) {
if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$token = $APIKey;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$aliases = json_decode(curl("GET", "https://api.vercel.com/v3/now/aliases", "", $header)['body'], true);
$host = splitfirst($_SERVER["host"], "//")[1];
foreach ($aliases["aliases"] as $key => $aliase) {
if ($host==$aliase["alias"]) $projectId = $aliase["projectId"];
}
$tmp['HerokuappId'] = $projectId;
$response = json_decode(setVercelConfig($tmp, $projectId, $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var expd = new Date();
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
}
if ($_GET['install0']) {
$html .= '
<form action="?install1" method="post" onsubmit="return notnull(this);">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
$html .= '<br>
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>';
$html .= '<br>
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<div id="showerror"></div>
<script>
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;
var errordiv = document.getElementById("showerror");
function changelanguage(str)
{
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;
}
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\'input admin\');
return false;
}
if (t.APIKey.value==\'\') {
alert(\'input Token\');
return false;
}
return true;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
if (substr($_SERVER["host"], -10)=="vercel.app") {
$html .= '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
$html .= "<br>Remember: you MUST wait 30-60s after each operate / do some change, that make sure Vercel has done the building<br>" ;
} else {
$html.= "Please visit form *.vercel.app";
}
$title = 'Install';
return message($html, $title, 201);
}
// POST /v8/projects/:id/env
function setVercelConfig($envs, $appId, $token)
{
$url = "https://api.vercel.com/v8/projects/" . $appId . "/env";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, "", $header);
$result = json_decode($response['body'], true);
foreach ($result["envs"] as $key => $value) {
$existEnvs[$value["key"]] = $value["id"];
}
foreach ($envs as $key => $value) {
$response = null;
$tmp = null;
$tmp["type"] = "encrypted";
$tmp["key"] = $key;
$tmp["value"] = $value;
$tmp["target"] = [ "development", "production", "preview" ];
if (isset($existEnvs[$key])) {
if ($value) $response = curl("PATCH", $url . "/" . $existEnvs[$key], json_encode($tmp), $header);
else $response = curl("DELETE", $url . "/" . $existEnvs[$key], "", $header);
} else {
if ($value) $response = curl("POST", $url, json_encode($tmp), $header);
}
//echo $key . " = " . $value . ", <br>" . $response . json_encode($response, JSON_PRETTY_PRINT) . "<br>";
if (!!$response && $response['stat']!=200) return $response['body'];
}
return VercelUpdate($appId, $token);
}
function VercelUpdate($appId, $token, $sourcePath = "")
{
if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}';
$url = "https://api.vercel.com/v13/deployments";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$data["name"] = "OneManager";
$data["project"] = $appId;
$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";
if ($sourcePath=="") $sourcePath = splitlast(splitlast(__DIR__, "/")[0], "/")[0];
//echo $sourcePath . "<br>";
getEachFiles($file, $sourcePath);
$data["files"] = $file;
//echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>";
$response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
$result['DplStatus'] = $result['id'];
return json_encode($result);
}
function checkBuilding($projectId, $token)
{
$r = 0;
$url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, '', $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
foreach ( $result['deployments'] as $deployment ) {
if ($deployment['state']!=="READY") $r++;
}
return $r;
//if ($r===0) return true;
//else return false;
}
function getEachFiles(&$file, $base, $path = "")
{
//if (substr($base, -1)=="/") $base = substr($base, 0, -1);
//if (substr($path, -1)=="/") $path = substr($path, 0, -1);
$handler=opendir(path_format($base . "/" . $path));
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..' && $filename != '.git'){
$fromfile = path_format($base . "/" . $path . "/" . $filename);
//echo $fromfile . "<br>";
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = getEachFiles($file, $base, path_format($path . "/" . $filename));
if (api_error(setConfigResponse($response))) return $response;
}else{
$tmp['file'] = path_format($path . "/" . $filename);
$tmp['data'] = file_get_contents($fromfile);
$file[] = $tmp;
}
}
}
closedir($handler);
return json_encode( [ 'response' => 'success' ] );
}
function api_error($response)
{
return isset($response['error']);
}
function api_error_msg($response)
{
return $response['error']['code'] . '<br>
' . $response['error']['message'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function setConfigResponse($response)
{
return json_decode($response, true);
}
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$tmppath = '/tmp';
if ($GitSource=='Github') {
// 从github下载对应tar.gz并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error'=>['code'=>'Git Source input Error!']]);
$tarfile = $tmppath . '/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
unlink($tarfile);
// 获取解压出的目录名
$outPath = findIndexPath($tmppath);
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
$name = $project . 'CODE';
mkdir($tmppath . "/" . $name, 0777, 1);
rename($outPath, $tmppath . "/" . $name . '/api');
$outPath = $tmppath . "/" . $name;
//echo $outPath . "<br>";
//error_log1($outPath);
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
}
function WaitFunction($deployid) {
if ($buildId=='1') {
$tmp['stat'] = 400;
$tmp['body'] = 'id must provided.';
return $tmp;
}
$header["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/deployments/" . $deployid;
$response = curl("GET", $url, "", $header);
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['readyState']=="READY") return true;
if ($result['readyState']=="ERROR") return $response;
return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = json_decode(setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'Input Token\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}

287
readme.md
View File

@ -1,234 +1,117 @@
[中文readme](readme_cn.md) Install program first, then add onedrive in setup after login.
先安装程序登录后在设置中添加onedrive。
# NOTICE: # Deploy to Heroku
Official: https://heroku.com
Demo: https://herooneindex.herokuapp.com/
The Releases is used as archive, not newest code. How to Install: Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](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.
Please read the descriptions of settings before raising an issue.
---
# Deploy to Vercel
### Official
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### Notice
> 1. you must wait 30-50s to make sure deploy READY after change config;
>
> 2. Vercel limit 100 deploy every day.
### How to Install
> https://scfonedrive.github.io/Vercel/Deploy.html .
---
# Deploy to Replit
### Official
https://repl.it/
https://replit.com/
### Demo
https://onemanager.qkqpttgf.repl.co/
### How to Install
A:
> 1. Click the "+" or "Create Repl", click the `Import from Github`;
> 2. Input `https://github.com/qkqpttgf/OneManager-php` in "GitHub URL", then it will auto show "Language" - "PHP Web Server", Click the "Import from Github";
> 3. After done, click the green button "Run", it will show the web page on the right, you MUST open it in a new tab or window.
B:
> 1. Click the "+" or "Create Repl", find template "PHP Web Server" (via input "php"), input a name for your project in "Title" or left it default, Click the "+ Create Repl".
> 2. After done, input `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` to Console or Shell on the right, press "Enter" to run it.
> 3. Click the green button "Run", it will show the web page on the right, you MUST open it in a new tab or window.
---
# ~~Deploy to Heroku~~
## Dyno will no longer free
### Official
https://heroku.com
### Demo
https://herooneindex.herokuapp.com/
### How to Install
> ~~Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
>
> Star this project, then Fork, create an app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork.
---
# Deploy to Glitch # Deploy to Glitch
Official: https://glitch.com/
Demo: https://onemanager.glitch.me/
### Official How to Install: New Project -> Import form Github -> paste "https://github.com/qkqpttgf/OneManager-php", after done, Show -> In a New Window.
https://glitch.com/
### Demo
https://onemanager.glitch.me/
### How to Install
[New Project] -> [Import form Github] -> paste "https://github.com/qkqpttgf/OneManager-php" , after done, [Show] -> [In a New Window].
---
# ~~Deploy to Tencent Serverless Cloud Function (SCF)~~
## SCF no longer free
### Official
https://cloud.tencent.com/product/scf
### DEMO
null
### How to Install
see CN readme.
----
# Deploy to Huawei cloud Function Graph (FG) # Deploy to Tencent Serverless Cloud Function (SCF 腾讯无服务器云函数)
Official: https://cloud.tencent.com/product/scf
DEMO: 无
注意SCF新增限制环境变量整体最大4KB所以最多添加4个盘。
### Official How to Install:
1进入函数服务上方选择地区然后点击新建。
2输入函数名称选择模板函数在模糊搜索中输入onedrive大小写随意选择那个【获取onedrive信息.....】,点下一步,在代码界面不用动,直接点完成。
3点击触发管理创建触发器触发方式改成API网关触发底下勾选启用集成响应提交。
4在触发管理中可以看到一个 访问路径,访问它,开始安装。
https://console.huaweicloud.com/functiongraph/ (重点:勾选集成响应)
### DEMO 添加网盘时SCF可能会反应不过来不跳转到微软导致添加失败请不要删除这个盘再添加一次相同标签的盘就可以了。
null
### How to Install
see CN readme.
----
# Deploy to Aliyun Function Compute (FC)
### Official:
https://fc.console.aliyun.com/
### DEMO
null
### How to Install
see CN readme.
---
# Deploy to Baidu Cloud Function Compute (CFC)
### Official
https://console.bce.baidu.com/cfc/#/cfc/functions
### DEMO
null
### How to Install
see CN readme.
---
# Deploy to Virtual Private Server (VPS) or php host
### DEMO
null
### How to Install
# 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. 1.Start web service on your server (httpd or other), make sure you can visit it.
启动web服务器确保你能访问到。
2.Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php. 2.Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php.
开启伪静态(重写)功能,规则在.htaccess文件中ngnix从里面复制我们的目的是不管访问什么都让index.php来处理。
3.Upload code. 3.Upload code.
上传好代码。
4.Change the file .data/config.php can be read&write (666 is suggested). 4.Change the file .data/config.php can be read&write (666 is suggested).
使web身份可读写代码中的.data/config.php文件推荐chmod 666 .data/config.php。
5.View the website in chrome or other. 5.View the website in chrome or other.
在浏览器中访问。
----
# Features # Deploy to Huawei cloud Function Graph (FG 华为云函数工作流)
Official: https://console.huaweicloud.com/functiongraph/
DEMO: 无
注意FG中环境变量整体大小为2KB所以最多添加2个盘。
How to Install:
1在函数列表点右边创建函数
2输入名称选择运行时语言为PHP7.3点上传ZIP文件选择文件然后点右边的创建函数这里的ZIP文件不能直接用从Github上下载的ZIP文件要将它解压后去掉外层文件夹后再压缩为ZIP。
3创建触发器选API网关安全认证选None后端超时毫秒将5000改成30000上面创建分组一下其它的点点点
4访问触发器给的url开始安装
5在触发器界面点触发器名称跳到API网关管理右边更多URL可以添加自定义域名自定义域名后发现还是要 xxxx.com/函数名 来访问点上方的编辑第1页不用改点下一步请求Path改成/注意匹配模式是前缀匹配Method为ANY然后不用点下一步了点立即完成然后去发布生效
# Deploy to Aliyun Function Compute (FC 阿里云函数计算)
Official: https://fc.console.aliyun.com/
DEMO: 无
How to Install:
1新建函数 -- HTTP函数
2运行环境选择php7.2
3触发器认证方式选择anonymous请求方式里面点一下GET再点一下POST最终框框里面有这2个
4上传代码
5触发器中点进去找到配置自定义域名点击前往创建路径中填 /* ,其它下拉选择。
6访问你的域名开始安装
# Deploy to Baidu Cloud Function Compute (CFC 百度云函数计算)
Official: https://console.bce.baidu.com/cfc/#/cfc/functions
DEMO: 无
自定义域名需要另外使用API网关并备案。
How to Install:
1在函数列表点创建函数
2创建方式改为空白函数点下一步
3输入名称选择运行时为PHP7.2,点下一步
4触发器下拉选择HTTP触发器URL路径填 /{filepath+} HTTP方法全选身份验证不验证点提交
5进入代码编辑页编辑类型改上传函数ZIP包选择文件这里的ZIP文件不能直接用从Github上下载的ZIP文件要将它解压后去掉外层文件夹后再压缩为ZIP。开始上传
6点击右边触发器复制并访问提供的url开始安装
# 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. 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.
下载时由程序解析出直链浏览器直接从微软Onedrive服务器下载文件服务器只消耗与微软通信的少量流量。
When uploading files, the program produce a direct url, visitor upload files to MS OFFICE via the direct url, the server expend a few bandwidth in produce. When uploading files, the program produce a direct url, visitor upload files to MS OFFICE via the direct url, the server expend a few bandwidth in produce.
上传时由程序生成上传url浏览器直接向微软Onedrive的这个url上传文件服务器只消耗与微软通信的少量流量。
The XXX_path in setting is the path in Onedrive, not in url, program will find the path in Onedrive. The XXX_path in setting is the path in Onedrive, not in url, program will find the path in Onedrive.
设置中的 XXX_path 是Onedrive里面的路径并不是你url里面的程序会去你Onedrive里面找这个路径。
LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited. LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited.
网站图标将favicon.ico文件放在你要展示的目录中确保 xxxxx.com/favicon.ico 可以访问到。
Program will show content of 'readme.md' & 'head.md'. Program will show content of 'readme.md' & 'head.md'.
可以在文件列表显示head.md跟readme.md文件的内容。
guest upload path, is a folder that the guest can upload files, but can not be list (exclude admin). guest up path, is a folder that the guest can upload files, but can not be list (exclude admin).
游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。
If there is 'index.html' file, program will only show the content of 'index.html', not list the files. If there is 'index.html' file, program will only show the content of 'index.html', not list the files.
如果目录中有index.html文件只会输出显示html文件不显示程序框架。
Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort. Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
---- # Functional files 功能性文件
# Functional files
### favicon.ico ### favicon.ico
put it in the showing home folder of FIRST disk (maybe not root of onedrive). 放在第一个盘的显示目录不一定是onedrive根目录
put it in the showing home folder of FIRST disk (maybe not root of onedrive).
### index.html ### index.html
show content of index.html as html. 将index.html以静态网页显示出来。
### head.md readme.md
it will showed at top or bottom as markdown. 以MD语法显示在顶部或底部。
### head.omf foot.omf
it will showed at top or bottom as html (javascript works!). 以html显示在顶部或底部可以跑js
show content of index.html as html. Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
### head.md
### readme.md
it will showed at top or bottom as markdown.
### head.omf
### foot.omf
it will showed at top or bottom as html (javascript works!).
----
# A cup of coffee
https://paypal.me/qkqpttgf
-----
# Chat
### Telegram Group
https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw

View File

@ -1,276 +0,0 @@
[Readme EN](readme.md)
# 注意:
请关掉浏览器的翻译。
Releases只是当存档在用的并不是最新代码。
请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。
---
# 部署到 Vercel
### 官网
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### 注意
> 1. 每次更改配置后都要等 30-50s 来确保部署成功;
>
> 2. Vercel 每天限制 100 次部署。
### 安装(英文)
https://scfonedrive.github.io/Vercel/Deploy.html
---
# 部署到 Replit
### 官网
https://repl.it/
https://replit.com/
### Demo
https://onemanager.qkqpttgf.repl.co/
### 安装
A:
> 1. 点右上的 "+" 或左上的 "+ Create Repl",点击`Import from Github`
> 2. 在"GitHub URL"中输入`https://github.com/qkqpttgf/OneManager-php`,会自动弹出显示"Language"与"PHP Web Server",点下面的"Import from Github"。
> 3. 结束后,点上方的绿色 "Run" 按钮,右边会显示一个网页,你要在新窗口打开它来安装,不然不能登录。
B:
> 1. 点右上的 "+" 或左上的 "+ Create Repl"template中输入php点选"PHP Web Server",在"Title"里输入你想要的名称或者让它默认, 点下面的"+ Create Repl"。
> 2. 结束后在右边的Console或Shell里输入 `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` 敲回车运行。
> 3. 点上方的绿色 "Run" 按钮,右边会显示一个网页,你要在新窗口打开它来安装,不然不能登录。
---
# ~~部署到 Heroku~~
## Dyno套餐不再免费
### 官网
https://heroku.com
### Demo
https://herooneindex.herokuapp.com/
### 安装
> 给这个项目点star然后fork在Heroku创建一个app然后点进Deploy页在"Deployment method"处点"Connect GitHub"选择你的fork。
---
# 部署到 Glitch
### 官网
https://glitch.com/
### Demo
https://onemanager.glitch.me/
### 安装
点 [New Project] -> 点 [Import form Github] -> 粘贴 "https://github.com/qkqpttgf/OneManager-php" ,结束后,左上角点 [Show] -> [In a New Window]。
---
# ~~部署到腾讯无服务器云函数 Serverless Cloud Function (SCF)~~
## SCF要收套餐费用了
### 官网
https://cloud.tencent.com/product/scf
### DEMO
暂无
### 注意事项
SCF新增限制环境变量整体最大4KB所以最多添加4个盘可以在安装时选择将配置保存在文件来避开限制
### 安装
1. 进入函数服务,上方选择地区,然后点击新建。
2. 输入函数名称选择模板函数在模糊搜索中输入onedrive大小写随意选择那个【获取onedrive信息.....】,点下一步,在代码界面不用动,直接点完成。
3. 点击触发管理创建触发器触发方式改成API网关触发底下勾选启用集成响应提交。
4. 在触发管理中可以看到一个 访问路径,访问它,开始安装。
(重点:**勾选集成响应**
> **添加网盘时SCF可能会反应不过来不跳转到微软导致添加失败请不要删除这个盘再添加一次相同标签的盘就可以了。**
----
# 部署到华为云函数工作流 Function Graph (FG)
### 官网
https://console.huaweicloud.com/functiongraph/
### DEMO
暂无
### 注意事项
FG中环境变量整体大小为2KB所以最多添加2个盘一个onedrive一个aliyundrive可以在安装时选择将配置保存在文件来避开限制
### 安装
1. 在函数列表,点右边创建函数
2. 输入名称选择运行时语言为PHP7.3点上传ZIP文件选择文件然后点右边的创建函数这里的ZIP文件不能直接用从Github上下载的ZIP文件要将它解压后去掉外层文件夹后再压缩为ZIP。
3. 创建触发器选API网关安全认证选None后端超时毫秒将5000改成30000上面创建分组一下其它的点点点
4. 访问触发器给的url开始安装
5. 在【触发器界面】点【触发器名称】跳到API网关管理右边【更多URL】可以添加自定义域名自定义域名后发现还是要 xxxx.com/函数名 来访问点上方的【编辑】第1页不用改点【下一步】**请求Path改成/**注意匹配模式是前缀匹配Method为ANY然后不用点下一步了点【立即完成】然后去【发布】生效
----
# 部署到阿里云函数计算 Function Compute (FC)
### 官网
https://fc.console.aliyun.com/
### DEMO
### 安装
1. 新建函数 -- HTTP函数
2. 运行环境选择php7.2
3. 触发器认证方式选择anonymous请求方式里面点一下GET再点一下POST最终框框里面有这2个
4. 上传代码这里的ZIP文件不能直接用从Github上下载的ZIP文件要将它解压后去掉外层文件夹后再压缩为ZIP。
5. 触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
6. 访问你的域名,开始安装
---
# 部署到百度云函数计算 Cloud Function Compute (CFC)
### 官网
https://console.bce.baidu.com/cfc/#/cfc/functions
### DEMO
暂无
### 注意事项
**自定义域名需要另外使用API网关并备案。**
### 安装
1. 在函数列表,点创建函数
2. 创建方式改为空白函数,点下一步
3. 输入名称选择运行时为PHP7.2,点下一步
4. 触发器下拉选择HTTP触发器URL路径填 /{filepath+} HTTP方法全选身份验证不验证点提交
5. 进入代码编辑页编辑类型改上传函数ZIP包选择文件这里的ZIP文件不能直接用从Github上下载的ZIP文件要将它解压后去掉外层文件夹后再压缩为ZIP。开始上传
6. 点击右边触发器复制并访问提供的url开始安装
---
# 部署到VPS (Virtual Private Server) 或 空间
### DEMO
暂无
### 安装
1. 启动web服务器确保你能访问到。
2. 开启伪静态(重写)功能,规则在.htaccess文件中ngnix从里面复制我们的目的是不管访问什么都让index.php来处理。
3. 上传好代码。
4. 使web身份可读写代码中的.data/config.php文件推荐chmod 666 .data/config.php。
5. 在浏览器中访问。
----
# 特性
下载时由程序解析出直链浏览器直接从微软Onedrive服务器下载文件服务器只消耗与微软通信的少量流量。
上传时由程序生成上传url浏览器直接向微软Onedrive的这个url上传文件服务器只消耗与微软通信的少量流量。
设置中的 XXX_path 是Onedrive里面的路径并不是你url里面的程序会去你Onedrive里面找这个路径。
网站图标将favicon.ico文件放在你要展示的目录中确保 xxxxx.com/favicon.ico 可以访问到。
可以在文件列表显示head.md跟readme.md文件的内容。
游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。
如果目录中有index.html文件只会输出显示html文件不显示程序框架。
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
----
# 功能性文件
### favicon.ico
放在第一个盘的显示目录不一定是onedrive根目录
### index.html
将index.html以静态网页显示出来。
### head.md
### readme.md
以MD语法显示在顶部或底部。
### head.omf
### foot.omf
以html显示在顶部或底部可以跑js
----
# 捐赠
https://paypal.me/qkqpttgf
-----
# 群聊
**请看完上面的中英双语再加群,谢谢!**
### QQ 群:
212088653
### Telegram Group
https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw

View File

@ -254,14 +254,14 @@
<div class="title pull-left"> <div class="title pull-left">
<a href="<!--base_path-->"><!--Sitename--></a> <a href="<!--base_path-->"><!--Sitename--></a>
</div> </div>
<div class="pull-right"><!-- <div class="pull-right">
<!--LoginStart--> <!--LoginStart-->
<a class="pull-left" onclick="/*login();*/"><!--constStr@Login--></a> <a class="pull-left" onclick="/*login();*/"><!--constStr@Login--></a>
<!--LoginEnd--> <!--LoginEnd-->
<!--AdminStart--> <!--AdminStart-->
<a class="pull-left" onclick="logout();"><!--constStr@Logout--></a> <a class="pull-left" onclick="logout();"><!--constStr@Logout--></a>
<!--AdminEnd--> <!--AdminEnd-->
&nbsp;| --> &nbsp;|
<div class="pull-right lang"> <div class="pull-right lang">
<select name="language" id="language" class="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)"> <select name="language" id="language" class="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
<option value="">Language</option> <option value="">Language</option>
@ -305,7 +305,7 @@
<div> <div>
<div style="margin: 24px"> <div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea> <textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a> <a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
</div> </div>
</div> </div>
<div> <div>
@ -386,7 +386,7 @@
<div style="margin:50px"> <div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a> <a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center> <center>
<form action="<!--IsPreview?-->login=admin" method="post"> <form action="<!--IsPreview?-->admin" method="post">
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->"> <input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input type="submit" value="<!--constStr@Login-->"> <input type="submit" value="<!--constStr@Login-->">
</form> </form>
@ -396,7 +396,6 @@
<!--LoginEnd--> <!--LoginEnd-->
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script> <script>
<!--AdminStart-->
window.onload = function () window.onload = function ()
{ {
// 获取所有radios元素 // 获取所有radios元素
@ -449,7 +448,6 @@
radios[i].setAttribute("currStatus", false); radios[i].setAttribute("currStatus", false);
} }
} }
<!--AdminEnd-->
function changelanguage(str) function changelanguage(str)
{ {
if (str=='Language') str = ''; if (str=='Language') str = '';
@ -481,10 +479,7 @@
<!--IsFileStart--> <!--IsFileStart-->
var $url = document.getElementById('url'); var $url = document.getElementById('url');
if ($url) { if ($url) {
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML; $url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px'; $url.style.height = $url.scrollHeight + 'px';
} }
<!--IsvideoFileStart--> <!--IsvideoFileStart-->

View File

@ -3,9 +3,9 @@
"music":"musical-notes", "music":"musical-notes",
"video":"logo-youtube", "video":"logo-youtube",
"img":"image", "img":"image",
"office":"newspaper", "office":"paper",
"txt":"clipboard", "txt":"clipboard",
"zip":"file-tray-full", "zip":"filing",
"iso":"disc", "iso":"disc",
"apk":"logo-android", "apk":"logo-android",
"exe":"logo-windows", "exe":"logo-windows",
@ -31,18 +31,18 @@
.title{text-align:center;margin-top:1rem;letter-spacing:2px;margin-bottom:2rem} .title{text-align:center;margin-top:1rem;letter-spacing:2px;margin-bottom:2rem}
.title a{color:#333;text-decoration:none} .title a{color:#333;text-decoration:none}
.list-wrapper{width:80%;margin:0 auto 30px;position:relative;box-shadow:0 0 32px 0 rgb(128,128,128);border-radius:15px;} .list-wrapper{width:80%;margin:0 auto 30px;position:relative;box-shadow:0 0 32px 0 rgb(128,128,128);border-radius:15px;}
.list-container{position:relative;/*overflow:hidden;*/border-radius:15px;background-color:rgba(245,245,245,0.5);} .list-container{position:relative;overflow:hidden;border-radius:15px;}
.list-container,.list-header-container,.list-wrapper,a.back-link:hover,body{color:#24292e}
.list-header-container{position:relative} .list-header-container{position:relative}
.list-header-container a.back-link{color:#000;display:inline-block;position:absolute;font-size:16px;margin:20px 10px;padding:10px 10px;vertical-align:middle;text-decoration:none} .list-header-container a.back-link{color:#000;display:inline-block;position:absolute;font-size:16px;margin:20px 10px;padding:10px 10px;vertical-align:middle;text-decoration:none}
.table-header{margin:0;border:0 none;padding:30px 30px;text-align:left;font-weight:400;color:#000;word-break: break-all;word-wrap: break-word;} .list-container,.list-header-container,.list-wrapper,a.back-link:hover,body{color:#24292e}
.list-body-container{position:relative;left:0;box-sizing:border-box;/*overflow-x:hidden;overflow-y:auto;background:rgba(245,245,245,0.5)*/} .table-header{margin:0;border:0 none;padding:30px 30px;text-align:left;font-weight:400;color:#000;background-color:rgba(245,245,245,0.5);word-break: break-all;word-wrap: break-word;}
.more-disk{margin:0;border:0 none;padding:30px 30px;text-align:left;font-weight:400;color:#000;white-space:nowrap;overflow:auto;} .list-body-container{position:relative;left:0;overflow-x:hidden;overflow-y:auto;box-sizing:border-box;background:rgba(245,245,245,0.5)}
.more-disk{margin:0;border:0 none;padding:30px 30px;text-align:left;font-weight:400;color:#000;background-color:rgba(245,245,245,0.5);white-space:nowrap;overflow:auto;}
.more-disk a{margin:0 10px;padding:5px;transition-duration: 0.4s;border-radius: 12px; background-color: white; color: black; border: 2px solid rgba(85,85,85,0.7); } .more-disk a{margin:0 10px;padding:5px;transition-duration: 0.4s;border-radius: 12px; background-color: white; color: black; border: 2px solid rgba(85,85,85,0.7); }
.more-disk a:hover, .more-disk a[now]{ background-color: rgba(85,85,85,0.7); color: white; } .more-disk a:hover, .more-disk a[now]{ background-color: rgba(85,85,85,0.7); color: white; }
.list-table{width:100%;padding:0 20px 20px 20px;border-spacing:0} .list-table{width:100%;padding:0 20px 20px 20px;border-spacing:0}
.list-table tr{height:40px} .list-table tr{height:40px}
.list-table tr[data-to]:hover{background:rgba(85,85,85,0.7) !important;color:white;} .list-table tr[data-to]:hover{background:rgba(85,85,85,0.7);color:white;}
.list-table tr[data-to]:hover a{color:white} .list-table tr[data-to]:hover a{color:white}
.list-table tr:first-child{background:rgba(245,245,245,0)} .list-table tr:first-child{background:rgba(245,245,245,0)}
.list-table td,.list-table th{padding:0 10px;text-align:left} .list-table td,.list-table th{padding:0 10px;text-align:left}
@ -54,16 +54,15 @@
.operate{display:inline-table;margin:0;margin-right:5px;list-style:none} .operate{display:inline-table;margin:0;margin-right:5px;list-style:none}
.operate ul{position:absolute;display:none;background:#fffaaa;border:0px #f7f7f7 solid;border-radius:5px;margin:-7px 0 0 0;padding:0 7px;color:#205D67;z-index:1;} .operate ul{position:absolute;display:none;background:#fffaaa;border:0px #f7f7f7 solid;border-radius:5px;margin:-7px 0 0 0;padding:0 7px;color:#205D67;z-index:1;}
.operate:hover ul{position:absolute;display:inline-table;} .operate:hover ul{position:absolute;display:inline-table;}
body .active ul{position:absolute;display:inline-table;} /*for some mobile browser */
.operate ul li{padding:7px;list-style:none;display:block;} .operate ul li{padding:7px;list-style:none;display:block;}
.list-table tr[data-to]:hover .operate ul li a{color:black} .list-table tr[data-to]:hover .operate ul li a{color:black}
<!--AdminEnd--> <!--AdminEnd-->
.operatediv{position:absolute;border:1px #CCCCCC;background-color:#FFFFCC;z-index:2;} .operatediv{position:absolute;border:1px #CCCCCC;background-color:#FFFFCC;z-index:2;}
.operatediv div{margin:16px} .operatediv div{margin:16px}
.operatediv_close{position:absolute;right:3px;top:3px;} .operatediv_close{position:absolute;right:3px;top:3px;}
.readme{padding:8px;} .readme{padding:8px;background-color:rgba(245,245,245,0.5);}
.markdown-body, .customfile{padding:20px;text-align:left} .markdown-body, .customfile{padding:20px;text-align:left}
@media only screen and (orientation: portrait){ @media only screen and (max-width:480px){
<!--BackgroundMStart--> <!--BackgroundMStart-->
body{background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-image:url("<!--BackgroundMUrl-->");} body{background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-image:url("<!--BackgroundMUrl-->");}
<!--BackgroundMEnd--> <!--BackgroundMEnd-->
@ -86,7 +85,7 @@
<li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul> <li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul>
<!--IsFolderStart--> <!--IsFolderStart-->
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li> <li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li> <li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li> <li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li>
<!--IsFolderEnd--> <!--IsFolderEnd-->
<li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li> <li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li>
@ -94,12 +93,12 @@
</ul></li> </ul></li>
<!--AdminEnd--> <!--AdminEnd-->
&nbsp; &nbsp;
<!--<select class="changelanguage" name="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)"> <select class="changelanguage" name="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
<option value="">Language</option> <option value="">Language</option>
<!--SelectLanguageStart--> <!--SelectLanguageStart-->
<option value="<!--SelectLanguageKey-->" <!--SelectLanguageSelected-->><!--SelectLanguageValue--></option> <option value="<!--SelectLanguageKey-->" <!--SelectLanguageSelected-->><!--SelectLanguageValue--></option>
<!--SelectLanguageEnd--> <!--SelectLanguageEnd-->
</select>--> </select>
</div> </div>
<!--NeedUpdateStart--> <!--NeedUpdateStart-->
<div style='position:absolute;'><font color='red'><!--constStr@NeedUpdate--></font></div> <div style='position:absolute;'><font color='red'><!--constStr@NeedUpdate--></font></div>
@ -164,7 +163,7 @@
</div> </div>
<!--EncryptedEnd--> <!--EncryptedEnd-->
<!--GuestUploadStart--> <!--GuestUploadStart-->
<div id="upload_div" style="padding:0 0 16px 0"> <div id="upload_div" style="margin:0 0 16px 0">
<div id="upload_btns" align="center"> <div id="upload_btns" align="center">
<select onchange="document.getElementById('upload_file').webkitdirectory=this.value;"> <select onchange="document.getElementById('upload_file').webkitdirectory=this.value;">
<option value=""><!--constStr@UploadFile--></option> <option value=""><!--constStr@UploadFile--></option>
@ -177,14 +176,14 @@
<!--GuestUploadEnd--> <!--GuestUploadEnd-->
<!--IsFileStart--> <!--IsFileStart-->
<div style="padding: 12px 4px 4px; text-align: center"> <div style="margin: 12px 4px 4px; text-align: center">
<div style="margin: 24px"> <div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea> <textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a> <a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
</div> </div>
<div style="margin: 24px"> <div style="margin: 24px">
<!--IsimgFileStart--> <!--IsimgFileStart-->
<img src="<!--FileEncodeUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';if (this.offsetHeight>document.documentElement.clientHeight) this.style.height=document.documentElement.clientHeight + 'px';" /> <img src="<!--FileEncodeUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';" />
<!--IsimgFileEnd--> <!--IsimgFileEnd-->
<!--IsvideoFileStart--> <!--IsvideoFileStart-->
<div id="video-a0"></div> <div id="video-a0"></div>
@ -202,7 +201,6 @@
<div id="txt"> <div id="txt">
<!--AdminStart--> <!--AdminStart-->
<form id="txt-form" action="" method="POST"> <form id="txt-form" action="" method="POST">
<input name="_admin" type="hidden" value="">
<a onclick="document.getElementById('txt-a').readOnly='';document.getElementById('txt-save').style.display='';document.getElementById('txt-editbutton').style.display='none';document.getElementById('txt-cancelbutton').style.display='';" id="txt-editbutton"><ion-icon name="create"></ion-icon><!--constStr@ClicktoEdit--></a> <a onclick="document.getElementById('txt-a').readOnly='';document.getElementById('txt-save').style.display='';document.getElementById('txt-editbutton').style.display='none';document.getElementById('txt-cancelbutton').style.display='';" id="txt-editbutton"><ion-icon name="create"></ion-icon><!--constStr@ClicktoEdit--></a>
<a onclick="document.getElementById('txt-a').readOnly='readonly';document.getElementById('txt-save').style.display='none';document.getElementById('txt-editbutton').style.display='';document.getElementById('txt-cancelbutton').style.display='none';" id="txt-cancelbutton" style="display:none"><ion-icon name="close"></ion-icon><!--constStr@CancelEdit--></a>&nbsp;&nbsp;&nbsp; <a onclick="document.getElementById('txt-a').readOnly='readonly';document.getElementById('txt-save').style.display='none';document.getElementById('txt-editbutton').style.display='';document.getElementById('txt-cancelbutton').style.display='none';" id="txt-cancelbutton" style="display:none"><ion-icon name="close"></ion-icon><!--constStr@CancelEdit--></a>&nbsp;&nbsp;&nbsp;
<a id="txt-save" style="display:none"><ion-icon name="save"></ion-icon><!--constStr@Save--></a> <a id="txt-save" style="display:none"><ion-icon name="save"></ion-icon><!--constStr@Save--></a>
@ -210,12 +208,6 @@
<textarea id="txt-a" name="editfile" readonly style="width: 100%; margin-top: 2px;" <!--AdminStart-->onchange="document.getElementById('txt-save').onclick=function(){document.getElementById('txt-form').submit();}"<!--AdminEnd--> ><!--TxtContent--></textarea> <textarea id="txt-a" name="editfile" readonly style="width: 100%; margin-top: 2px;" <!--AdminStart-->onchange="document.getElementById('txt-save').onclick=function(){document.getElementById('txt-form').submit();}"<!--AdminEnd--> ><!--TxtContent--></textarea>
<!--AdminStart--> <!--AdminStart-->
</form> </form>
<script>
var inputAdminStorage = document.getElementsByName("_admin");
for (i=0;i<inputAdminStorage.length;i++) {
inputAdminStorage[i].value = localStorage.getItem("admin");
}
</script>
<!--AdminEnd--> <!--AdminEnd-->
</div> </div>
<!--IstxtFileEnd--> <!--IstxtFileEnd-->
@ -229,7 +221,7 @@
<table class="list-table" id="list-table"> <table class="list-table" id="list-table">
<tr id="tr0"> <tr id="tr0">
<th class="file"> <th class="file">
<a id="file_a0" fileid="<!--FolderId-->" onclick="sortby('a');"><!--constStr@File--></a> <a onclick="sortby('a');"><!--constStr@File--></a>
<!--ShowThumbnailsStart--> <!--ShowThumbnailsStart-->
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<label><input type="checkbox" id="originalpic"><!--constStr@OriginalPic--></label> <label><input type="checkbox" id="originalpic"><!--constStr@OriginalPic--></label>
@ -248,7 +240,7 @@
<!--AdminStart--> <!--AdminStart-->
<li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a> <li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a>
<ul> <ul>
<li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li> <li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li> <li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li>
<li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li> <li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li>
<li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li> <li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li>
@ -313,7 +305,7 @@
</form> </form>
<!--MorePageEnd--> <!--MorePageEnd-->
<!--AdminStart--> <!--AdminStart-->
<div id="upload_div" style="padding:0 0 16px 0"> <div id="upload_div" style="margin:0 0 16px 0">
<div id="upload_btns" align="center"> <div id="upload_btns" align="center">
<select onchange="document.getElementById('upload_file').webkitdirectory=this.value;"> <select onchange="document.getElementById('upload_file').webkitdirectory=this.value;">
<option value=""><!--constStr@UploadFile--></option> <option value=""><!--constStr@UploadFile--></option>
@ -471,7 +463,7 @@
<div style="margin:50px"> <div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a> <a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center> <center>
<form action="<!--IsPreview?-->login=admin" method="post" onsubmit="return sha1loginpass(this);"> <form action="<!--IsPreview?-->admin" method="post" onsubmit="return sha1loginpass(this);">
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->"> <input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input name="timestamp" type="hidden" value=""> <input name="timestamp" type="hidden" value="">
<input type="submit" value="<!--constStr@Login-->"> <input type="submit" value="<!--constStr@Login-->">
@ -483,13 +475,12 @@
<div style="color: rgba(247,247,249,0);"><!--FootStr--></div> <div style="color: rgba(247,247,249,0);"><!--FootStr--></div>
</body> </body>
<!--MdRequireStart--><link rel="stylesheet" href="https://unpkg.com/github-markdown-css@3.0.1/github-markdown.css">
<script type="text/javascript" src="?jsFile=marked.js"></script><!--MdRequireEnd-->
<!--ListStart--> <!--ListStart-->
<!--GuestUploadStart--><script type="text/javascript" src="?jsFile=spark-md5.min.js"></script><!--GuestUploadEnd--> <!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
<!--AliyundriveUploadJsStart--><script src="https://unpkg.com/bignumber.js@9.0.2/bignumber.js"></script> <script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
<script src="?jsFile=sha1.min.js"></script><!--AliyundriveUploadJsEnd--> <!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
<!--IsFileStart--><!--IspdfFileStart--><script src="https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd--> <!--AliyundriveUploadJsStart--><script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
<!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--ListEnd--> <!--ListEnd-->
<script type="text/javascript"> <script type="text/javascript">
function changelanguage(str) function changelanguage(str)
@ -520,60 +511,17 @@
f.password1.value = sha1(timestamp + "" + f.password1.value); f.password1.value = sha1(timestamp + "" + f.password1.value);
return true; return true;
} catch { } 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; 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);
}
<!--LoginEnd--> <!--LoginEnd-->
<!--WriteTimezoneStart-->
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!=<!--timezone-->) {
//alert('Your timezone is '+timezone+', reload local timezone.');
location.href=location.href;
}
<!--WriteTimezoneEnd-->
<!--HeadmdStart-->
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);
}
<!--HeadmdEnd-->
<!--ReadmemdStart-->
var $readme = document.getElementById('readme');
if ($readme) {
$readme.innerHTML = marked(document.getElementById('readme-md').innerText);
}
<!--ReadmemdEnd-->
<!--ListStart--> <!--ListStart-->
<!--IsFileStart--> <!--IsFileStart-->
var $url = document.getElementById('url'); var $url = document.getElementById('url');
if ($url) { if ($url) {
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML; $url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px'; $url.style.height = $url.scrollHeight + 'px';
} }
<!--IsofficeFileStart--> <!--IsofficeFileStart-->
@ -652,67 +600,29 @@
}); });
} }
} }
addVideos(["<!--FileEncodeUrl-->"]); addVideos(['<!--FileEncodeUrl-->']);
<!--IsvideoFileEnd--> <!--IsvideoFileEnd-->
<!--IspdfFileStart--> <!--IspdfFileStart-->
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.worker.min.js'; pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
var loadingTask = pdfjsLib.getDocument({ var loadingTask = pdfjsLib.getDocument({
url: "<!--FileDownUrl-->", url: '<!--FileDownUrl-->',
cMapUrl: "https://unpkg.com/pdfjs-dist@2.4.456/cmaps/", cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/",
cMapPacked: true, cMapPacked: true,
disableStream: true,
disableAutoFetch: true,
rangeChunkSize: 65535 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) + '%<br>(' + 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) { loadingTask.promise.then(function(pdf) {
var pagenum = pdf.numPages; var pagenum = pdf.numPages;
var pdfContainer = document.getElementById('pdf-d'); var pdfContainer = document.getElementById('pdf-d');
pdfContainer.innerHTML = ''; pdfContainer.innerHTML = '';
var pagepos = 1; for (var i=1;i<=pagenum;i++) {
var pdfnextpagebutton = document.createElement('button');
pdfnextpagebutton.id = 'pdfnextpagebutton';
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
pdfnextpagebutton.setAttribute('onclick', "this.style.display = 'none';");
pdfnextpagebutton.style.display = 'none';
pdfContainer.appendChild(pdfnextpagebutton);
var pdfWaitNextPage = setInterval(function(){
//console.log(document.documentElement.scrollTop + ", " + document.body.scrollHeight);
if (pdfnextpagebutton.style.display=='none') {
for (var i=pagepos;i<=(pagepos+4<pagenum?pagepos+4:pagenum);i++) {
var canvasNew = document.createElement('canvas'); var canvasNew = document.createElement('canvas');
canvasNew.id = 'pdf-c'+i; canvasNew.id = 'pdf-c'+i;
pdfContainer.appendChild(canvasNew); pdfContainer.appendChild(canvasNew);
renderpage(pdf,i); renderpage(pdf,i);
} }
pagepos = i;
if (pagepos<pagenum) {
console.log("next page: " + pagepos + " / " + pagenum);
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
pdfnextpagebutton.style.display ='';
pdfContainer.appendChild(pdfnextpagebutton);
} else {
console.log("end of pdf");
clearInterval(pdfWaitNextPage);
}
}
}, 1000);
}); });
function renderpage(pdf,i) { function renderpage(pdf,i)
{
pdf.getPage(i).then(function(page) { pdf.getPage(i).then(function(page) {
var scale = 1.5; var scale = 1.5;
var viewport = page.getViewport({ scale: scale, }); var viewport = page.getViewport({ scale: scale, });
@ -727,27 +637,22 @@
page.render(renderContext); page.render(renderContext);
}); });
} }
function size_format(num) {
if (num>1024) {
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';
}
<!--IspdfFileEnd--> <!--IspdfFileEnd-->
<!--IsFileEnd--> <!--IsFileEnd-->
<!--IsFolderStart--> <!--IsFolderStart-->
<!--HeadmdStart-->
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);
}
<!--HeadmdEnd-->
<!--ReadmemdStart-->
var $readme = document.getElementById('readme');
if ($readme) {
$readme.innerHTML = marked(document.getElementById('readme-md').innerText);
}
<!--ReadmemdEnd-->
<!--ShowThumbnailsStart--> <!--ShowThumbnailsStart-->
function showthumbnails(obj) { function showthumbnails(obj) {
images = [<!--ImgExts-->]; images = [<!--ImgExts-->];
@ -869,7 +774,6 @@
} }
function size_reformat(str) { function size_reformat(str) {
if (str.substr(-1)==' ') str=str.substr(0,str.length-1); if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
if (str.substr(-2)=='TB') num=str.substr(0,str.length-3)*1024*1024*1024*1024;
if (str.substr(-2)=='GB') num=str.substr(0,str.length-3)*1024*1024*1024; if (str.substr(-2)=='GB') num=str.substr(0,str.length-3)*1024*1024*1024;
if (str.substr(-2)=='MB') num=str.substr(0,str.length-3)*1024*1024; if (str.substr(-2)=='MB') num=str.substr(0,str.length-3)*1024*1024;
if (str.substr(-2)=='KB') num=str.substr(0,str.length-3)*1024; if (str.substr(-2)=='KB') num=str.substr(0,str.length-3)*1024;
@ -878,6 +782,18 @@
} }
<!--IsNotHiddenEnd--> <!--IsNotHiddenEnd-->
<!--IsFolderEnd--> <!--IsFolderEnd-->
<!--WriteTimezoneStart-->
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!=<!--timezone-->) {
alert('Your timezone is '+timezone+', reload local timezone.');
location.href=location.href;
}
<!--WriteTimezoneEnd-->
function CopyAllDownloadUrl(str) { function CopyAllDownloadUrl(str) {
var tmptextarea=document.createElement('textarea'); var tmptextarea=document.createElement('textarea');
document.body.appendChild(tmptextarea); document.body.appendChild(tmptextarea);
@ -1024,9 +940,7 @@
} else { } else {
filemd5 = spark.end(); filemd5 = spark.end();
td2.innerHTML='md5: '+filemd5; td2.innerHTML='md5: '+filemd5;
delete uploading[upbigfilename];
upbigfilename = filemd5+ext; upbigfilename = filemd5+ext;
uploading[upbigfilename] = i;
<!--GuestEnd--> <!--GuestEnd-->
td2.innerHTML='<!--constStr@GetUploadLink--> ...'; td2.innerHTML='<!--constStr@GetUploadLink--> ...';
var xhr1 = new XMLHttpRequest(); var xhr1 = new XMLHttpRequest();
@ -1071,7 +985,7 @@
delete uploading[upbigfilename]; delete uploading[upbigfilename];
} }
} }
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5 + '&_admin=' + localStorage.getItem("admin")); xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5);
<!--GuestStart--> <!--GuestStart-->
} }
} }
@ -1090,7 +1004,6 @@
var newstartsize = 0; var newstartsize = 0;
if(!!file){ if(!!file){
var asize=0; var asize=0;
var chunksize=10*1024*1024; // chunk size, max 60M. 每小块上传大小最大60M微软建议10M
var totalsize=file.size; var totalsize=file.size;
var xhr2 = new XMLHttpRequest(); var xhr2 = new XMLHttpRequest();
xhr2.open("GET", url); xhr2.open("GET", url);
@ -1108,6 +1021,8 @@
} else { } else {
StartStr='<!--constStr@LastUpload-->'+size_format(newstartsize)+ '<br><!--constStr@ThisTime--><!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ; StartStr='<!--constStr@LastUpload-->'+size_format(newstartsize)+ '<br><!--constStr@ThisTime--><!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
} }
var chunksize=5*1024*1024; // chunk size, max 60M. 每小块上传大小最大60M微软建议10M
if (totalsize>200*1024*1024) chunksize=10*1024*1024;
function readblob(start) { function readblob(start) {
var end=start+chunksize; var end=start+chunksize;
var blob = file.slice(start,end); var blob = file.slice(start,end);
@ -1117,7 +1032,6 @@
reader.onload = function(e){ reader.onload = function(e){
var binary = this.result; var binary = this.result;
var lastCurrentSpeed;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("PUT", url, true); xhr.open("PUT", url, true);
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest'); //xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
@ -1125,13 +1039,10 @@
xhr.setRequestHeader('Content-Range', 'bytes ' + asize + '-' + bsize +'/'+ totalsize); xhr.setRequestHeader('Content-Range', 'bytes ' + asize + '-' + bsize +'/'+ totalsize);
xhr.upload.onprogress = function(e){ xhr.upload.onprogress = function(e){
if (e.lengthComputable) { if (e.lengthComputable) {
let tmptime = new Date(); var tmptime = new Date();
let tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime()); var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
lastCurrentSpeed = tmpspeed; var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
let remaintime = (totalsize-asize-e.loaded)/tmpspeed; label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
let percent = ((asize+e.loaded)*100/totalsize).toFixed(2);
label.parentNode.style.background = "linear-gradient(to right, rgba(0,0,0,25%) " + percent + "%, rgba(0,0,0,0%) 0%)";
label.innerHTML = StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + percent + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
} }
} }
var C_starttime = new Date(); var C_starttime = new Date();
@ -1160,7 +1071,7 @@
while (filename.indexOf('%2F')>0) filename = filename.replace('%2F', '/'); while (filename.indexOf('%2F')>0) filename = filename.replace('%2F', '/');
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>'; document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr; label.innerHTML=StartStr+MiddleStr;
label.parentNode.style.background = 'rgba(0,80,0,25%)'; label.style.color='green';
// uploadbuttonshow(); // uploadbuttonshow();
<!--AdminStart--> <!--AdminStart-->
@ -1174,9 +1085,6 @@
} else { } else {
var a=response['nextExpectedRanges'][0]; var a=response['nextExpectedRanges'][0];
asize=Number( a.slice(0,a.indexOf("-")) ); asize=Number( a.slice(0,a.indexOf("-")) );
chunksize = 10*1024*1024;
if (lastCurrentSpeed>5*1024*1024) chunksize = 20*1024*1024;
if (lastCurrentSpeed>10*1024*1024) chunksize = 50*1024*1024;
readblob(asize); readblob(asize);
} }
} } else readblob(asize); } } else readblob(asize);
@ -1217,39 +1125,7 @@
}// else console.log(Object.keys(uploading).length); }// else console.log(Object.keys(uploading).length);
} else clearInterval(uploadList); } else clearInterval(uploadList);
}, 1000); }, 1000);
function CalcProof(file) { //getuplink(i);
return new Promise(function(resolve, reject){
var xhr = new XMLHttpRequest();
xhr.open("POST", '?action=upbigfile');
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
xhr.setRequestHeader('x-requested-with', 'XMLHttpRequest');
xhr.onload = function(e){
var html;
if (xhr.status==200) {
//console.log(xhr.responseText);
var r = new BigNumber("0x".concat(xhr.responseText));
var i = new BigNumber(file.size);
var o = i ? r.mod(i) : 0;
var reader1 = new FileReader();
var start = o.toNumber();
var end = start + 8;
//if (file.size<end) end = file.size;
console.log(start + " ~ " + end);
//reader1.readAsBinaryString(file.slice(start,end));
reader1.readAsDataURL(file.slice(start,end));
reader1.onload = function(e) {
var proof = this.result;
proof = proof.substr(proof.indexOf('base64,')+7);
resolve(proof);
}
} else {
//console.log(xhr.status+'calc proof code\n'+xhr.responseText);
reject(xhr.status+"\ncalc proof code\n"+xhr.responseText);
}
}
xhr.send('CalcProof=1');
});
}
function getuplink(i, r=0) { function getuplink(i, r=0) {
var file=files[i]; var file=files[i];
var td1; var td1;
@ -1277,11 +1153,11 @@
uploadbuttonshow(); uploadbuttonshow();
return; return;
}*/ }*/
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name)); var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
uploading[upbigfilename] = [i]; uploading[upbigfilename] = [i];
var spark = sha1.create(); var spark = sha1.create();
var reader = new FileReader(); var reader = new FileReader();
var chunksize=10*1024*1024;
var asize = 0; var asize = 0;
var filesha1; var filesha1;
function readblob(start) { function readblob(start) {
@ -1289,14 +1165,7 @@
var blob = file.slice(start,end); var blob = file.slice(start,end);
reader.readAsArrayBuffer(blob); reader.readAsArrayBuffer(blob);
} }
var proof_code = '';
CalcProof(file).then(a => {
proof_code = a;
console.log('proof: ' + proof_code);
readblob(asize); readblob(asize);
}, e => {
td2.innerHTML = e;
});
reader.onload = function(e){ reader.onload = function(e){
td2.innerHTML='<!--constStr@Calculate--> SHA1: '+(asize*100/file.size).toFixed(2)+'%'; td2.innerHTML='<!--constStr@Calculate--> SHA1: '+(asize*100/file.size).toFixed(2)+'%';
@ -1364,7 +1233,7 @@
getuplink(i); getuplink(i);
}*/ }*/
} }
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&proof_code=' + proof_code + '&filesha1=' + filesha1 + '&chunksize=' + chunksize + '&_admin=' + localStorage.getItem("admin")); xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&filesha1=' + filesha1 + '&chunksize=' + chunksize);
} }
} }
} }
@ -1443,14 +1312,14 @@
} }
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>'; document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr; label.innerHTML=StartStr+MiddleStr;
label.parentNode.style.background = 'rgba(0,80,0,25%)'; label.style.color='green';
} else { } else {
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>'; label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
localStorage.removeItem(filesha1); localStorage.removeItem(filesha1);
} }
delete uploading[filename]; delete uploading[filename];
} }
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']) + '&_admin=' + localStorage.getItem("admin")); xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
} else { } else {
var binary = this.result; var binary = this.result;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
@ -1463,9 +1332,7 @@
var tmptime = new Date(); var tmptime = new Date();
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime()); var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
var remaintime = (totalsize-asize-e.loaded)/tmpspeed; var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
let percent = ((asize+e.loaded)*100/totalsize).toFixed(2); label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
label.parentNode.style.background = "linear-gradient(to right, rgba(0,0,0,25%) " + percent + "%, rgba(0,0,0,0%) 0%)";
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + percent + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
} }
} }
var C_starttime = new Date(); var C_starttime = new Date();
@ -1516,14 +1383,14 @@
} }
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>'; document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr; label.innerHTML=StartStr+MiddleStr;
label.parentNode.style.background = 'rgba(0,80,0,25%)'; label.style.color='green';
} else { } else {
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>'; label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
localStorage.removeItem(filesha1); localStorage.removeItem(filesha1);
} }
delete uploading[filename]; delete uploading[filename];
} }
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']) + '&_admin=' + localStorage.getItem("admin")); xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
// uploadbuttonshow(); // uploadbuttonshow();
} else { } else {
readblob(asize); readblob(asize);
@ -1566,25 +1433,9 @@
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1000); expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie = "admin=; path=<!--base_path-->; "+expires; document.cookie = "admin=; path=/; "+expires;
location.href = location.href; location.href = location.href;
} }
/*for some mobile browser*/
function menu_click(e){
var ee=document.getElementsByClassName("active");
for(var i=0;i<ee.length;i++){
ee[i].classList.remove("active");
}
if(e.type!="mouseout")this.classList.add("active");
}
(function(){
var e=document.getElementsByClassName("operate");
document.body.addEventListener("touchstart", menu_click);
for(var i=0;i<e.length;i++){
e[i].addEventListener("touchstart", menu_click);
e[i].addEventListener("mouseout", menu_click);
}
})();
<!--IsFolderStart--> <!--IsFolderStart-->
function showdiv(event,action,num) { function showdiv(event,action,num) {
var $operatediv=document.getElementsByName('operatediv'); var $operatediv=document.getElementsByName('operatediv');
@ -1594,33 +1445,32 @@
document.getElementById('mask').style.display=''; document.getElementById('mask').style.display='';
//document.getElementById('mask').style.width=document.documentElement.scrollWidth+'px'; //document.getElementById('mask').style.width=document.documentElement.scrollWidth+'px';
document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px'; document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px';
var str;
if (num=='') { if (num=='') {
str = ''; var str='';
num = 0; var fileid='';
} else { } else {
str = decodeURIComponent(document.getElementById('file_a'+num).href); var str=decodeURIComponent(document.getElementById('file_a'+num).href);
if (str.substr(-1)==' ') str=str.substr(0, str.length-1); if (str.substr(-1)==' ') str=str.substr(0, str.length-1);
if (str.substr(-1)=='/') str=str.substr(0, str.length-1); if (str.substr(-1)=='/') str=str.substr(0, str.length-1);
if (str.substr(-8)=='?preview') str=str.substr(0, str.length-8); if (str.substr(-8)=='?preview') str=str.substr(0, str.length-8);
if (str.lastIndexOf('/')>-1) str=str.substr(str.lastIndexOf('/')+1); if (str.lastIndexOf('/')>-1) str=str.substr(str.lastIndexOf('/')+1);
}
var fileid=document.getElementById('file_a'+num).attributes['fileid'].nodeValue; var fileid=document.getElementById('file_a'+num).attributes['fileid'].nodeValue;
}
document.getElementById(action + '_div').style.display=''; document.getElementById(action + '_div').style.display='';
document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&amp;'); document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&amp;');
document.getElementById(action + '_sid').value=num; document.getElementById(action + '_sid').value=num;
document.getElementById(action + '_fileid').value=fileid; document.getElementById(action + '_fileid').value=fileid;
document.getElementById(action + '_hidden').value=str; document.getElementById(action + '_hidden').value=str;
if (action=='rename') document.getElementById(action + '_input').value=str; if (action=='rename') document.getElementById(action + '_input').value=str;
/*var $e = event || window.event; var $e = event || window.event;
var $scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;*/ var $scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var $scrollY = document.documentElement.scrollTop || document.body.scrollTop; var $scrollY = document.documentElement.scrollTop || document.body.scrollTop;
/*var $x = $e.pageX || $e.clientX + $scrollX; var $x = $e.pageX || $e.clientX + $scrollX;
var $y = $e.pageY || $e.clientY + $scrollY; var $y = $e.pageY || $e.clientY + $scrollY;
if (action=='create') {*/ if (action=='create') {
document.getElementById(action + '_div').style.left=(document.body.clientWidth-document.getElementById(action + '_div').offsetWidth)/2 +'px'; document.getElementById(action + '_div').style.left=(document.body.clientWidth-document.getElementById(action + '_div').offsetWidth)/2 +'px';
document.getElementById(action + '_div').style.top=(window.innerHeight-document.getElementById(action + '_div').offsetHeight)/2+$scrollY +'px'; document.getElementById(action + '_div').style.top=(window.innerHeight-document.getElementById(action + '_div').offsetHeight)/2+$scrollY +'px';
/*} else { } else {
if ($x + document.getElementById(action + '_div').offsetWidth > document.body.clientWidth) { if ($x + document.getElementById(action + '_div').offsetWidth > document.body.clientWidth) {
if (document.getElementById(action + '_div').offsetWidth > document.body.clientWidth) { if (document.getElementById(action + '_div').offsetWidth > document.body.clientWidth) {
document.getElementById(action + '_div').offsetWidth=document.body.clientWidth+'px'; document.getElementById(action + '_div').offsetWidth=document.body.clientWidth+'px';
@ -1632,7 +1482,7 @@
document.getElementById(action + '_div').style.left=$x+'px'; document.getElementById(action + '_div').style.left=$x+'px';
} }
document.getElementById(action + '_div').style.top=$y+'px'; document.getElementById(action + '_div').style.top=$y+'px';
}*/ }
document.getElementById(action + '_input').focus(); document.getElementById(action + '_input').focus();
} }
function submit_operate(str) { function submit_operate(str) {
@ -1661,7 +1511,7 @@
document.getElementById(str+'_div').style.display='none'; document.getElementById(str+'_div').style.display='none';
document.getElementById('mask').style.display='none'; document.getElementById('mask').style.display='none';
} }
xhr.send(serializeForm(str+'_form') + '&_admin=' + localStorage.getItem("admin")); xhr.send(serializeForm(str+'_form'));
return false; return false;
} }
function addelement(html) { function addelement(html) {
@ -1762,7 +1612,7 @@
document.getElementById('password1').focus(); document.getElementById('password1').focus();
<!--EncryptedEnd--> <!--EncryptedEnd-->
</script> </script>
<script src="https://www.unpkg.com/ionicons@6.0.1/dist/ionicons.js"></script> <script src="//unpkg.zhimg.com/ionicons@4.4.4/dist/ionicons.js"></script>
<!--LoginStart--><script src="?jsFile=sha1.min.js"></script><!--LoginEnd--> <!--LoginStart--><script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script><!--LoginEnd-->
<!--customScript--> <!--customScript-->
</html> </html>

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@
"music":"musical-notes", "music":"musical-notes",
"video":"logo-youtube", "video":"logo-youtube",
"img":"image", "img":"image",
"office":"newspaper", "office":"paper",
"txt":"clipboard", "txt":"clipboard",
"zip":"file-tray-full", "zip":"filing",
"iso":"disc", "iso":"disc",
"apk":"logo-android", "apk":"logo-android",
"exe":"logo-windows", "exe":"logo-windows",
@ -89,10 +89,9 @@
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<form action="<!--IsPreview?-->login=admin" method="post" onsubmit="return sha1loginpass(this);"> <form action="?admin" method="post">
<div class="modal-body"> <div class="modal-body">
<input class="form-control" id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->"> <input class="form-control" id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input name="timestamp" type="hidden">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<input class="btn btn-primary" type="submit" value="<!--constStr@Login-->"></button> <input class="btn btn-primary" type="submit" value="<!--constStr@Login-->"></button>
@ -110,7 +109,7 @@
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<!--IsFolderStart--> <!--IsFolderStart-->
<a class="dropdown-item" data-toggle="modal" data-target="#NewFileModal"><ion-icon name="create"></ion-icon><!--constStr@Create--></a> <a class="dropdown-item" data-toggle="modal" data-target="#NewFileModal"><ion-icon name="create"></ion-icon><!--constStr@Create--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value=''"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a> <a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value=''"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a>
<a class="dropdown-item" href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a> <a class="dropdown-item" href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a>
<!--IsFolderEnd--> <!--IsFolderEnd-->
<a class="dropdown-item" href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a> <a class="dropdown-item" href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a>
@ -178,7 +177,7 @@
<div style="padding:20px"> <div style="padding:20px">
<center> <center>
<form action="" method="post"> <form action="" method="post">
<input id="password1" name="password1" type="password" placeholder="<!--constStr@InputPassword-->"> <input name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input type="submit" value="<!--constStr@Submit-->"> <input type="submit" value="<!--constStr@Submit-->">
</form> </form>
</center> </center>
@ -223,7 +222,7 @@
<div style="margin: 12px 4px 4px; text-align: center"> <div style="margin: 12px 4px 4px; text-align: center">
<div style="margin: 24px"> <div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea> <textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a> <a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
</div> </div>
<div style="margin: 24px"> <div style="margin: 24px">
<!--IsimgFileStart--> <!--IsimgFileStart-->
@ -288,7 +287,7 @@
<ion-icon name="construct"></ion-icon> <ion-icon name="construct"></ion-icon>
</a> </a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value='<!--FileEncodeReplaceName-->'"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a> <a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value='<!--FileEncodeReplaceName-->'"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#renameModal" onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a> <a class="dropdown-item" data-toggle="modal" data-target="#renameModal" onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#MoveModal" onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a> <a class="dropdown-item" data-toggle="modal" data-target="#MoveModal" onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#CopyModal" onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a> <a class="dropdown-item" data-toggle="modal" data-target="#CopyModal" onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a>
@ -669,7 +668,7 @@ return false;
<!--IsFolderEnd--> <!--IsFolderEnd-->
<!--AdminEnd--> <!--AdminEnd-->
<!--LoginStart--> <!--LoginStart-->
<script src="?jsFile=sha1.min.js"></script>
<!--LoginEnd--> <!--LoginEnd-->
<p class="text-center text-muted"><a href="https://github.com/qkqpttgf/OneManager-php" class="text-muted">OneManager</a> By 逸笙 Theme By Nchyn</p> <p class="text-center text-muted"><a href="https://github.com/qkqpttgf/OneManager-php" class="text-muted">OneManager</a> By 逸笙 Theme By Nchyn</p>
<p class="text-center" style="color: rgba(247,247,249,0);"><!--FootStr--></p> <p class="text-center" style="color: rgba(247,247,249,0);"><!--FootStr--></p>
@ -677,11 +676,11 @@ return false;
</body> </body>
<!--ListStart--> <!--ListStart-->
<!--MdRequireStart--><link rel="stylesheet" href="https://unpkg.com/github-markdown-css@3.0.1/github-markdown.css"> <!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
<script type="text/javascript" src="?jsFile=marked.js"></script><!--MdRequireEnd--> <script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
<!--GuestUploadStart--><script type="text/javascript" src="?jsFile=spark-md5.min.js"></script><!--GuestUploadEnd--> <!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
<!--AliyundriveUploadJsStart--><script src="?jsFile=sha1.min.js"></script><!--AliyundriveUploadJsEnd--> <!--AliyundriveUploadJsStart--><script src="//cdn.bootcdn.net/ajax/libs/js-sha1/0.6.0/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
<!--IsFileStart--><!--IspdfFileStart--><script src="https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd--> <!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--ListEnd--> <!--ListEnd-->
<script type="text/javascript"> <script type="text/javascript">
function changelanguage(str) function changelanguage(str)
@ -718,10 +717,7 @@ return false;
<!--IsFileStart--> <!--IsFileStart-->
var $url = document.getElementById('url'); var $url = document.getElementById('url');
if ($url) { if ($url) {
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML; $url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px'; $url.style.height = $url.scrollHeight + 'px';
} }
<!--IsofficeFileStart--> <!--IsofficeFileStart-->
@ -803,10 +799,10 @@ return false;
addVideos(['<!--FileEncodeUrl-->']); addVideos(['<!--FileEncodeUrl-->']);
<!--IsvideoFileEnd--> <!--IsvideoFileEnd-->
<!--IspdfFileStart--> <!--IspdfFileStart-->
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.worker.min.js'; pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
var loadingTask = pdfjsLib.getDocument({ var loadingTask = pdfjsLib.getDocument({
url: '<!--FileDownUrl-->', url: '<!--FileDownUrl-->',
cMapUrl: "https://unpkg.com/pdfjs-dist@2.4.456/cmaps/", cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/",
cMapPacked: true, cMapPacked: true,
rangeChunkSize: 65535 rangeChunkSize: 65535
}); });
@ -1746,41 +1742,12 @@ return false;
document.getElementById('login_div').style.top=(window.innerHeight-document.getElementById('login_div').offsetHeight)/2+document.body.scrollTop +'px'; document.getElementById('login_div').style.top=(window.innerHeight-document.getElementById('login_div').offsetHeight)/2+document.body.scrollTop +'px';
document.getElementById('login_input').focus(); document.getElementById('login_input').focus();
} }
function sha1loginpass(f) {
if (f.password1.value=="") return false;
try {
timestamp = new Date().getTime() + "";
timestamp = timestamp.substr(0, timestamp.length-3);
f.timestamp.value = timestamp;
f.password1.value = sha1(timestamp + "" + f.password1.value);
return true;
} catch {
//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);
}
<!--LoginEnd--> <!--LoginEnd-->
<!--EncryptedStart--> <!--EncryptedStart-->
document.getElementById('password1').focus(); document.getElementById('password1').focus();
<!--EncryptedEnd--> <!--EncryptedEnd-->
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script> <script src="//unpkg.zhimg.com/ionicons@4.4.4/dist/ionicons.js"></script>
<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="//cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="//cdn.bootcdn.net/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> <script src="//cdn.bootcdn.net/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="//cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script> <script src="//cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>

View File

@ -145,8 +145,8 @@
</div> </div>
<!--IsofficeFileEnd--> <!--IsofficeFileEnd-->
<!--IsvideoFileStart--> <!--IsvideoFileStart-->
<link class="dplayer-css" rel="stylesheet" href="https://fastly.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css"> <link class="dplayer-css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/dplayer/1.27.0/DPlayer.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
<div class="nexmoe-item"> <div class="nexmoe-item">
<div class="mdui-center" id="dplayer"></div> <div class="mdui-center" id="dplayer"></div>
</div> </div>
@ -283,8 +283,8 @@
<!--ShowThumbnailsEnd--> <!--ShowThumbnailsEnd-->
<!--IsFolderEnd--> <!--IsFolderEnd-->
<!--ListEnd--> <!--ListEnd-->
<!--MdRequireStart--><link rel="stylesheet" href="https://unpkg.com/github-markdown-css@3.0.1/github-markdown.css"> <!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
<script type="text/javascript" src="?jsFile=marked.js"></script><!--MdRequireEnd--> <script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
<script> <script>
<!--MorePageStart--> <!--MorePageStart-->
function nextpage(num) { function nextpage(num) {

View File

@ -374,8 +374,8 @@
<!--ListEnd--> <!--ListEnd-->
<script src="//cdn.jsdelivr.net/gh/mcstudios/glightbox/dist/js/glightbox.min.js"></script> <script src="//cdn.jsdelivr.net/gh/mcstudios/glightbox/dist/js/glightbox.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script> <script src="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<!--MdRequireStart--><link rel="stylesheet" href="https://unpkg.com/github-markdown-css@3.0.1/github-markdown.css"> <!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
<script type="text/javascript" src="?jsFile=marked.js"></script><!--MdRequireEnd--> <script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
<script> <script>
<!--MorePageStart--> <!--MorePageStart-->
function nextpage(num) { function nextpage(num) {

View File

@ -3,9 +3,9 @@
"music":"musical-notes", "music":"musical-notes",
"video":"logo-youtube", "video":"logo-youtube",
"img":"image", "img":"image",
"office":"newspaper", "office":"paper",
"txt":"clipboard", "txt":"clipboard",
"zip":"file-tray-full", "zip":"filing",
"iso":"disc", "iso":"disc",
"apk":"logo-android", "apk":"logo-android",
"exe":"logo-windows", "exe":"logo-windows",
@ -27,9 +27,6 @@
<!--BackgroundStart--> <!--BackgroundStart-->
<style>body{background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-position-x:center;background-image:url("<!--BackgroundUrl-->")}</style> <style>body{background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-position-x:center;background-image:url("<!--BackgroundUrl-->")}</style>
<!--BackgroundEnd--> <!--BackgroundEnd-->
<!--BackgroundMStart-->
<style>@media screen and (orientation:portrait){body{background-image:url("<!--BackgroundMUrl-->");}}</style>
<!--BackgroundMEnd-->
<script type="text/javascript">if(window.console&&window.console.log){console.log("%c Onemoe Theme %c https://github.com/kizx/onemoe-theme ","color: #fff; margin: 1em 0; padding: 5px 0; background: #673ab7;","margin: 1em 0; padding: 5px 0; background: #efefef;")}</script> <script type="text/javascript">if(window.console&&window.console.log){console.log("%c Onemoe Theme %c https://github.com/kizx/onemoe-theme ","color: #fff; margin: 1em 0; padding: 5px 0; background: #673ab7;","margin: 1em 0; padding: 5px 0; background: #efefef;")}</script>
<!--customCss--> <!--customCss-->
</head> </head>
@ -43,7 +40,7 @@
<li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul> <li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul>
<!--IsFolderStart--> <!--IsFolderStart-->
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li> <li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li> <li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li> <li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li>
<!--IsFolderEnd--> <!--IsFolderEnd-->
<li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li> <li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li>
@ -107,41 +104,42 @@
<div class="list-wrapper" id="list-div"> <div class="list-wrapper" id="list-div">
<div class="list-container"> <div class="list-container">
<div class="list-header-container"> <div class="list-header-container">
<h3 class="table-header"><a href="<!--base_path-->"><!--constStr@Home--></a><!--DiskPathArrayStart--> / <a href="<!--PathArrayLink-->"><!--PathArrayName--></a><!--DiskPathArrayEnd--></h3> <!--BackArrowStart-->
<a href="<!--BackArrowUrl-->" class="back-link">
<ion-icon name="arrow-back"></ion-icon>
</a>
<!--BackArrowEnd-->
<h3 class="table-header"><!--PathArrayStart--> / <a href="<!--PathArrayLink-->"><!--PathArrayName--></a><!--PathArrayEnd--></h3>
</div> </div>
<div class="list-body-container"> <div class="list-body-container">
<!--EncryptedStart--> <!--EncryptedStart-->
<div style="padding:20px"> <div style="padding:20px">
<center> <center>
<form action="" method="post"> <form action="" method="post">
<input id="password1" name="password1" type="password" placeholder="<!--constStr@InputPassword-->"> <input name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input type="submit" value="<!--constStr@Submit-->"> <input type="submit" value="<!--constStr@Submit-->">
</form> </form>
</center> </center>
</div> </div>
<!--EncryptedEnd--> <!--EncryptedEnd-->
<!--GuestUploadStart--> <!--GuestUploadStart-->
<div id="upload_div" style="padding:0 0 16px 0"> <div id="upload_div" style="margin:10px">
<div id="upload_btns" align="center"> <div id="upload_btns" align="center">
<select onchange="document.getElementById('upload_file').webkitdirectory=this.value;"> <input id="upload_file" type="file" name="upload_filename">
<option value=""><!--constStr@UploadFile--></option>
<option value="1"><!--constStr@UploadFolder--></option>
</select>
<input id="upload_file" type="file" name="upload_filename" multiple="multiple">
<input id="upload_submit" onclick="preup();" value="<!--constStr@Upload-->" type="button"> <input id="upload_submit" onclick="preup();" value="<!--constStr@Upload-->" type="button">
</div> </div>
</div> </div>
<!--GuestUploadEnd--> <!--GuestUploadEnd-->
<!--IsFileStart--> <!--IsFileStart-->
<div style="padding: 12px 4px 4px; text-align: center"> <div style="margin: 12px 4px 4px; text-align: center">
<div style="margin: 24px"> <div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea> <textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a> <a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
</div> </div>
<div style="margin: 24px"> <div style="margin: 24px">
<!--IsimgFileStart--> <!--IsimgFileStart-->
<img src="<!--FileEncodeUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';" /> <img src="<!--FileDownUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';" />
<!--IsimgFileEnd--> <!--IsimgFileEnd-->
<!--IsvideoFileStart--> <!--IsvideoFileStart-->
<div id="video-a0"></div> <div id="video-a0"></div>
@ -198,7 +196,7 @@
<!--AdminStart--> <!--AdminStart-->
<li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a> <li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a>
<ul> <ul>
<li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li> <li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li> <li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li>
<li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li> <li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li>
<li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li> <li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li>
@ -207,7 +205,7 @@
</li> </li>
<!--AdminEnd--> <!--AdminEnd-->
<ion-icon name="folder"></ion-icon> <ion-icon name="folder"></ion-icon>
<a id="file_a<!--filenum-->" name="folderlist" href="<!--FileEncodeReplaceUrl-->/" fileid="<!--FileId-->"><!--FileEncodeReplaceName--></a> <a id="file_a<!--filenum-->" name="folderlist" href="<!--FileEncodeReplaceUrl-->/"><!--FileEncodeReplaceName--></a>
</td> </td>
<td class="updated_at" id="folder_time<!--filenum-->"><!--lastModifiedDateTime--></td> <td class="updated_at" id="folder_time<!--filenum-->"><!--lastModifiedDateTime--></td>
<td class="size" id="folder_size<!--filenum-->"><!--size--></td> <td class="size" id="folder_size<!--filenum-->"><!--size--></td>
@ -227,7 +225,7 @@
</li> </li>
<!--AdminEnd--> <!--AdminEnd-->
<ion-icon name="<!--IconValue-->"></ion-icon> <ion-icon name="<!--IconValue-->"></ion-icon>
<a id="file_a<!--filenum-->" name="filelist" href="<!--FileEncodeReplaceUrl-->?preview" fileid="<!--FileId-->" target=_blank><!--FileEncodeReplaceName--></a> <a id="file_a<!--filenum-->" name="filelist" href="<!--FileEncodeReplaceUrl-->?preview" target=_blank><!--FileEncodeReplaceName--></a>
<a class="download" href="<!--FileEncodeReplaceUrl-->"><ion-icon name="download"></ion-icon></a> <a class="download" href="<!--FileEncodeReplaceUrl-->"><ion-icon name="download"></ion-icon></a>
</td> </td>
<td class="updated_at" id="file_time<!--filenum-->"><!--lastModifiedDateTime--></td> <td class="updated_at" id="file_time<!--filenum-->"><!--lastModifiedDateTime--></td>
@ -263,7 +261,7 @@
</form> </form>
<!--MorePageEnd--> <!--MorePageEnd-->
<!--AdminStart--> <!--AdminStart-->
<div id="upload_div" style="padding:0 0 16px 0"> <div id="upload_div" style="margin:0 0 16px 0">
<div id="upload_btns" align="center"> <div id="upload_btns" align="center">
<select onchange="document.getElementById('upload_file').webkitdirectory=this.value;"> <select onchange="document.getElementById('upload_file').webkitdirectory=this.value;">
<option value=""><!--constStr@UploadFile--></option> <option value=""><!--constStr@UploadFile--></option>
@ -275,10 +273,10 @@
</div> </div>
<!--AdminEnd--> <!--AdminEnd-->
<!--IsFolderEnd--> <!--IsFolderEnd-->
</div>
</div>
</div>
<!--ListEnd--> <!--ListEnd-->
</div>
</div>
</div>
<!--ReadmemdStart--> <!--ReadmemdStart-->
<div class="list-wrapper" id="readme-div"> <div class="list-wrapper" id="readme-div">
<div class="list-container"> <div class="list-container">
@ -315,7 +313,6 @@
<label id="rename_label"></label><br><br><a onclick="operatediv_close('rename')" class="operatediv_close"><!--constStr@Close--></a> <label id="rename_label"></label><br><br><a onclick="operatediv_close('rename')" class="operatediv_close"><!--constStr@Close--></a>
<form id="rename_form" onsubmit="return submit_operate('rename');"> <form id="rename_form" onsubmit="return submit_operate('rename');">
<input id="rename_sid" name="rename_sid" type="hidden" value=""> <input id="rename_sid" name="rename_sid" type="hidden" value="">
<input id="rename_fileid" name="rename_fileid" type="hidden" value="">
<input id="rename_hidden" name="rename_oldname" type="hidden" value=""> <input id="rename_hidden" name="rename_oldname" type="hidden" value="">
<input id="rename_input" name="rename_newname" type="text" value=""> <input id="rename_input" name="rename_newname" type="text" value="">
<input name="operate_action" type="submit" value="<!--constStr@Rename-->"> <input name="operate_action" type="submit" value="<!--constStr@Rename-->">
@ -329,7 +326,6 @@
<form id="delete_form" onsubmit="return submit_operate('delete');"> <form id="delete_form" onsubmit="return submit_operate('delete');">
<label id="delete_input"><!--constStr@Delete-->?</label> <label id="delete_input"><!--constStr@Delete-->?</label>
<input id="delete_sid" name="delete_sid" type="hidden" value=""> <input id="delete_sid" name="delete_sid" type="hidden" value="">
<input id="delete_fileid" name="delete_fileid" type="hidden" value="">
<input id="delete_hidden" name="delete_name" type="hidden" value=""> <input id="delete_hidden" name="delete_name" type="hidden" value="">
<input name="operate_action" type="submit" value="<!--constStr@Submit-->"> <input name="operate_action" type="submit" value="<!--constStr@Submit-->">
</form> </form>
@ -340,7 +336,6 @@
<label id="encrypt_label"></label><br><br><a onclick="operatediv_close('encrypt')" class="operatediv_close"><!--constStr@Close--></a> <label id="encrypt_label"></label><br><br><a onclick="operatediv_close('encrypt')" class="operatediv_close"><!--constStr@Close--></a>
<form id="encrypt_form" onsubmit="return submit_operate('encrypt');"> <form id="encrypt_form" onsubmit="return submit_operate('encrypt');">
<input id="encrypt_sid" name="encrypt_sid" type="hidden" value=""> <input id="encrypt_sid" name="encrypt_sid" type="hidden" value="">
<input id="encrypt_fileid" name="encrypt_fileid" type="hidden" value="">
<input id="encrypt_hidden" name="encrypt_folder" type="hidden" value=""> <input id="encrypt_hidden" name="encrypt_folder" type="hidden" value="">
<input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<!--constStr@InputPasswordUWant-->"> <input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<!--constStr@InputPasswordUWant-->">
<!--EncryptBtnStart--><input name="operate_action" type="submit" value="<!--constStr@Encrypt-->"><!--EncryptBtnEnd--><!--EncryptAlertStart--><br><label><!--constStr@SetpassfileBfEncrypt--></label><!--EncryptAlertEnd--> <!--EncryptBtnStart--><input name="operate_action" type="submit" value="<!--constStr@Encrypt-->"><!--EncryptBtnEnd--><!--EncryptAlertStart--><br><label><!--constStr@SetpassfileBfEncrypt--></label><!--EncryptAlertEnd-->
@ -352,7 +347,6 @@
<label id="copy_label"></label><br><br><a onclick="operatediv_close('copy')" class="operatediv_close"><!--constStr@Close--></a> <label id="copy_label"></label><br><br><a onclick="operatediv_close('copy')" class="operatediv_close"><!--constStr@Close--></a>
<form id="copy_form" onsubmit="return submit_operate('copy');"> <form id="copy_form" onsubmit="return submit_operate('copy');">
<input id="copy_sid" name="copy_sid" type="hidden" value=""> <input id="copy_sid" name="copy_sid" type="hidden" value="">
<input id="copy_fileid" name="copy_fileid" type="hidden" value="">
<input id="copy_hidden" name="copy_name" type="hidden" value=""> <input id="copy_hidden" name="copy_name" type="hidden" value="">
<input id="copy_input" name="copy_input" type="hidden" value=""> <input id="copy_input" name="copy_input" type="hidden" value="">
<input name="operate_action" type="submit" value="<!--constStr@Copy-->"> <input name="operate_action" type="submit" value="<!--constStr@Copy-->">
@ -364,7 +358,6 @@
<label id="move_label"></label><br><br><a onclick="operatediv_close('move')" class="operatediv_close"><!--constStr@Close--></a> <label id="move_label"></label><br><br><a onclick="operatediv_close('move')" class="operatediv_close"><!--constStr@Close--></a>
<form id="move_form" onsubmit="return submit_operate('move');"> <form id="move_form" onsubmit="return submit_operate('move');">
<input id="move_sid" name="move_sid" type="hidden" value=""> <input id="move_sid" name="move_sid" type="hidden" value="">
<input id="move_fileid" name="move_fileid" type="hidden" value="">
<input id="move_hidden" name="move_name" type="hidden" value=""> <input id="move_hidden" name="move_name" type="hidden" value="">
<select id="move_input" name="move_folder"> <select id="move_input" name="move_folder">
<!--MoveRootStart--> <!--MoveRootStart-->
@ -383,7 +376,6 @@
<a onclick="operatediv_close('create')" class="operatediv_close"><!--constStr@Close--></a> <a onclick="operatediv_close('create')" class="operatediv_close"><!--constStr@Close--></a>
<form id="create_form" onsubmit="return submit_operate('create');"> <form id="create_form" onsubmit="return submit_operate('create');">
<input id="create_sid" name="create_sid" type="hidden" value=""> <input id="create_sid" name="create_sid" type="hidden" value="">
<input id="create_fileid" name="create_fileid" type="hidden" value="">
<input id="create_hidden" type="hidden" value=""> <input id="create_hidden" type="hidden" value="">
<table> <table>
<tr> <tr>
@ -421,9 +413,8 @@
<div style="margin:50px"> <div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a> <a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center> <center>
<form action="<!--IsPreview?-->login=admin" method="post" onsubmit="return sha1loginpass(this);"> <form action="<!--IsPreview?-->admin" method="post">
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->"> <input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input name="timestamp" type="hidden" value="">
<input type="submit" value="<!--constStr@Login-->"> <input type="submit" value="<!--constStr@Login-->">
</form> </form>
</center> </center>
@ -434,11 +425,10 @@
</body> </body>
<!--ListStart--> <!--ListStart-->
<!--MdRequireStart--><link rel="stylesheet" href="https://unpkg.com/github-markdown-css@3.0.1/github-markdown.css"> <!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
<script type="text/javascript" src="?jsFile=marked.js"></script><!--MdRequireEnd--> <script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
<!--GuestUploadStart--><script type="text/javascript" src="?jsFile=spark-md5.min.js"></script><!--GuestUploadEnd--> <!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
<!--AliyundriveUploadJsStart--><script src="?jsFile=sha1.min.js"></script><!--AliyundriveUploadJsEnd--> <!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--IsFileStart--><!--IspdfFileStart--><script src="https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--ListEnd--> <!--ListEnd-->
<script type="text/javascript"> <script type="text/javascript">
function changelanguage(str) function changelanguage(str)
@ -450,39 +440,32 @@
document.cookie='language='+str+'; path=/; '+expires; document.cookie='language='+str+'; path=/; '+expires;
location.href = location.href; location.href = location.href;
} }
<!--LoginStart-->
function login() {
document.getElementById('mask').style.display='';
//document.getElementById('mask').style.width=document.documentElement.scrollWidth+'px';
document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px';
document.getElementById('login_div').style.display='';
document.getElementById('login_div').style.left=(document.body.clientWidth-document.getElementById('login_div').offsetWidth)/2 +'px';
document.getElementById('login_div').style.top=(window.innerHeight-document.getElementById('login_div').offsetHeight)/2+document.body.scrollTop +'px';
document.getElementById('login_input').focus();
}
function sha1loginpass(f) {
if (f.password1.value=="") return false;
try {
timestamp = new Date().getTime() + "";
timestamp = timestamp.substr(0, timestamp.length-3);
f.timestamp.value = timestamp;
f.password1.value = sha1(timestamp + "" + f.password1.value);
return true;
} catch {
alert("sha1.js not loaded.");
return false;
}
}
<!--LoginEnd-->
<!--ListStart--> <!--ListStart-->
/*var root = '<!--base_disk_path-->';
function path_format(path) {
path = '/' + path + '/';
while (path.indexOf('//') !== -1) {
path = path.replace('//', '/')
}
return path
}
document.querySelectorAll('.table-header').forEach(function (e) {
var path = e.innerText;
if (path.substr(path.length-1)=='/') path = path.substr(0, path.length-1);
var paths = path.split('/');
e.innerHTML = '/ ';
if (paths <= 2) return;
for (var i = 1; i < paths.length - 1; i++) {
var to = path_format(root + paths.slice(0, i + 1).join('/'));
e.innerHTML += '<a href="' + to + '">' + paths[i] + '</a> / '
}
e.innerHTML += paths[paths.length - 1];
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
});*/
<!--IsFileStart--> <!--IsFileStart-->
var $url = document.getElementById('url'); var $url = document.getElementById('url');
if ($url) { if ($url) {
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML; $url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px'; $url.style.height = $url.scrollHeight + 'px';
} }
<!--IsofficeFileStart--> <!--IsofficeFileStart-->
@ -561,13 +544,13 @@
}); });
} }
} }
addVideos(['<!--FileEncodeUrl-->']); addVideos(['<!--FileDownUrl-->']);
<!--IsvideoFileEnd--> <!--IsvideoFileEnd-->
<!--IspdfFileStart--> <!--IspdfFileStart-->
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.worker.min.js'; pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
var loadingTask = pdfjsLib.getDocument({ var loadingTask = pdfjsLib.getDocument({
url: '<!--FileDownUrl-->', url: '<!--FileDownUrl-->',
cMapUrl: "https://unpkg.com/pdfjs-dist@2.4.456/cmaps/", cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/",
cMapPacked: true, cMapPacked: true,
rangeChunkSize: 65535 rangeChunkSize: 65535
}); });
@ -606,6 +589,7 @@
if ($head) { if ($head) {
//document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div')); //document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div'));
$head.innerHTML = marked(document.getElementById('head-md').innerText); $head.innerHTML = marked(document.getElementById('head-md').innerText);
} }
<!--HeadmdEnd--> <!--HeadmdEnd-->
<!--ReadmemdStart--> <!--ReadmemdStart-->
@ -625,13 +609,15 @@
strarry=str.split('.'); strarry=str.split('.');
ext=strarry[strarry.length-1].toLowerCase(); ext=strarry[strarry.length-1].toLowerCase();
if (images.indexOf(ext)>-1) { if (images.indexOf(ext)>-1) {
if (document.getElementById('originalpic').checked==true) {
var url=files[$i].href; var url=files[$i].href;
url=url.substr(0,url.length-8); url=url.substr(0,url.length-8);
if (document.getElementById('originalpic').checked==true) {
files[$i].parentNode.parentNode.innerHTML='<td colspan="3"><img src="'+url+'" alt="'+str+'" onload="if (this.offsetWidth>document.getElementById(\'list-div\').offsetWidth) this.style.width=\'100%\';"></td>'; files[$i].parentNode.parentNode.innerHTML='<td colspan="3"><img src="'+url+'" alt="'+str+'" onload="if (this.offsetWidth>document.getElementById(\'list-div\').offsetWidth) this.style.width=\'100%\';"></td>';
$i--; $i--;
} else { } else {
url+='?thumbnails'; var nurl=window.location.href;
if (nurl.substr(-1)!="/") nurl+="/";
var url=nurl+str+'?thumbnails';
get_thumbnails_url(url, str, files[$i]); get_thumbnails_url(url, str, files[$i]);
} }
} }
@ -768,40 +754,6 @@
alert(tmptextarea.innerHTML+"<!--constStr@Success-->"); alert(tmptextarea.innerHTML+"<!--constStr@Success-->");
} }
<!--UploadJsStart--> <!--UploadJsStart-->
function size_format(num) {
if (num>1024) {
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';
}
function seconds2hour(seconds) {
let h, m, s;
if (parseFloat(seconds)<60) {
return seconds + 's';
} else {
s = (seconds % 60).toFixed(0);
m = parseInt(seconds / 60);
if (parseInt(m)<60) {
return m + 'm' + s + 's';
} else {
h = parseInt(m / 60);
m = m % 60;
return h + 'h' + m + 'm' + s + 's';
}
}
}
function uploadbuttonhide() { function uploadbuttonhide() {
document.getElementById('upload_btns').style.display='none'; document.getElementById('upload_btns').style.display='none';
/*document.getElementById('upload_submit').disabled='disabled'; /*document.getElementById('upload_submit').disabled='disabled';
@ -816,9 +768,6 @@
document.getElementById('upload_submit').style.display=''; document.getElementById('upload_submit').style.display='';
document.getElementById('upload_file').style.display='';*/ document.getElementById('upload_file').style.display='';*/
} }
var uploading = new Object();
<!--UploadJsEnd-->
<!--OnedriveUploadJsStart-->
function preup() { function preup() {
uploadbuttonhide(); uploadbuttonhide();
var files=document.getElementById('upload_file').files; var files=document.getElementById('upload_file').files;
@ -831,15 +780,7 @@
table1.setAttribute('class','list-table'); table1.setAttribute('class','list-table');
var timea=new Date().getTime(); var timea=new Date().getTime();
var i=0; var i=0;
var uploadList = setInterval(function(){
if (i<files.length) {
if (Object.keys(uploading).length<5) {
getuplink(i); getuplink(i);
i++;
}// else console.log(Object.keys(uploading).length);
} else clearInterval(uploadList);
}, 1000);
//getuplink(i);
function getuplink(i, r=0) { function getuplink(i, r=0) {
var file=files[i]; var file=files[i];
var td1; var td1;
@ -852,7 +793,7 @@
tr1.appendChild(td1); tr1.appendChild(td1);
td1.setAttribute('style','width:30%;word-break:break-word;'); td1.setAttribute('style','width:30%;word-break:break-word;');
td1.setAttribute('id','upfile_td1_'+timea+'_'+i); td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size)+' ('+(i+1)+'/'+files.length+')'; td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size);
td2=document.createElement('td'); td2=document.createElement('td');
tr1.appendChild(td2); tr1.appendChild(td2);
td2.setAttribute('id','upfile_td2_'+timea+'_'+i); td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
@ -865,13 +806,11 @@
uploadbuttonshow(); uploadbuttonshow();
return; return;
} }
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name)); upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
uploading[upbigfilename] = i;
var filemd5=''; var filemd5='';
<!--GuestStart--> <!--GuestStart-->
function getext(str) { function getext(str) {
strarry=str.split('.'); strarry=str.split('.');
if (strarry.length==1) return '';
ext=strarry[strarry.length-1].toLowerCase(); ext=strarry[strarry.length-1].toLowerCase();
var reg = new RegExp(".","g"); var reg = new RegExp(".","g");
var a = str.replace(reg,""); var a = str.replace(reg,"");
@ -899,21 +838,29 @@
if (asize < file.size) { if (asize < file.size) {
readblob(asize); readblob(asize);
} else { } else {
filemd5 = spark.end(); var filemd5 = spark.end();
td2.innerHTML='md5: '+filemd5; td2.innerHTML='md5: '+filemd5;
upbigfilename = filemd5+ext; upbigfilename = filemd5+ext;
<!--GuestEnd--> <!--GuestEnd-->
td2.innerHTML='<!--constStr@GetUploadLink--> ...'; td2.innerHTML='<!--constStr@GetUploadLink--> ...';
var xhr1 = new XMLHttpRequest(); var xhr1 = new XMLHttpRequest();
xhr1.open("POST", '?action=upbigfile'); xhr1.open("POST", '?action=upbigfile');
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest'); xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr1.onprogress = function(e){ xhr1.onprogress = function(e){
td2.innerHTML+='.'; td2.innerHTML+='.';
} }
xhr1.onload = function(e){ xhr1.onload = function(e){
//console.log(xhr1.status+xhr1.responseText); console.log(xhr1.status+xhr1.responseText);
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>'; td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>';
if (xhr1.status==409) {
// td2.innerHTML='nameAlreadyExists';
var html=JSON.parse(xhr1.responseText);
td2.innerHTML=html['error']['code']+': '+html['error']['message'];
<!--GuestStart-->
td2.innerHTML='md5: '+filemd5;
<!--GuestEnd-->
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
}
if (xhr1.status==200) { if (xhr1.status==200) {
if (xhr1.responseText=='') { if (xhr1.responseText=='') {
getuplink(i,1); getuplink(i,1);
@ -926,24 +873,10 @@
td2.innerHTML='<!--constStr@UploadStart--> ...'; td2.innerHTML='<!--constStr@UploadStart--> ...';
binupfile(file,html['uploadUrl'],timea+'_'+i, upbigfilename); binupfile(file,html['uploadUrl'],timea+'_'+i, upbigfilename);
} }
} else {
if (xhr1.status==409) {
// td2.innerHTML='nameAlreadyExists';
var html=JSON.parse(xhr1.responseText);
td2.innerHTML=html['error']['code']+': '+html['error']['message'];
<!--GuestStart-->
td2.innerHTML='md5: '+filemd5;
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'"><!--constStr@CopyUrl--></button></div>';
<!--GuestEnd-->
<!--AdminStart-->
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" style="display:none"><!--constStr@CopyUrl--></button></div>';
<!--AdminEnd-->
} }
/*if (i<files.length-1) { if (i<files.length-1) {
i++; i++;
getuplink(i); getuplink(i);
}*/
delete uploading[upbigfilename];
} }
} }
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5); xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5);
@ -954,7 +887,24 @@
} }
uploadbuttonshow(); uploadbuttonshow();
} }
function size_format(num) {
if (num>1024) {
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';
}
function binupfile(file,url,tdnum,filename){ function binupfile(file,url,tdnum,filename){
var label=document.getElementById('upfile_td2_'+tdnum); var label=document.getElementById('upfile_td2_'+tdnum);
var reader = new FileReader(); var reader = new FileReader();
@ -1003,7 +953,7 @@
var tmptime = new Date(); var tmptime = new Date();
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime()); var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
var remaintime = (totalsize-asize-e.loaded)/tmpspeed; var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1)); label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+remaintime.toFixed(1)+'s';
} }
} }
var C_starttime = new Date(); var C_starttime = new Date();
@ -1012,7 +962,6 @@
var response=JSON.parse(xhr.responseText); var response=JSON.parse(xhr.responseText);
if (response['size']>0) { if (response['size']>0) {
// contain size, upload finish. 有size说明是最终返回上传结束 // contain size, upload finish. 有size说明是最终返回上传结束
if (totalsize>10*1024*1024) {
var xhr3 = new XMLHttpRequest(); var xhr3 = new XMLHttpRequest();
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename); xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest'); xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
@ -1020,7 +969,6 @@
xhr3.onload = function(e){ xhr3.onload = function(e){
console.log(xhr3.responseText+','+xhr3.status); console.log(xhr3.responseText+','+xhr3.status);
} }
}
EndTime=new Date(); EndTime=new Date();
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>'; MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
if (newstartsize==0) { if (newstartsize==0) {
@ -1028,12 +976,8 @@
} else { } else {
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>'; MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
} }
delete uploading[filename]; document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||response.name)+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||response.name)+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
while (filename.indexOf('%2F')>0) filename = filename.replace('%2F', '/');
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr; label.innerHTML=StartStr+MiddleStr;
label.style.color='green';
// uploadbuttonshow(); // uploadbuttonshow();
<!--AdminStart--> <!--AdminStart-->
response.name=file.webkitRelativePath||response.name; response.name=file.webkitRelativePath||response.name;
@ -1042,7 +986,6 @@
} else { } else {
if (!response['nextExpectedRanges']) { if (!response['nextExpectedRanges']) {
label.innerHTML='<font color="red">'+xhr.responseText+'</font><br>'; label.innerHTML='<font color="red">'+xhr.responseText+'</font><br>';
delete uploading[filename];
} else { } else {
var a=response['nextExpectedRanges'][0]; var a=response['nextExpectedRanges'][0];
asize=Number( a.slice(0,a.indexOf("-")) ); asize=Number( a.slice(0,a.indexOf("-")) );
@ -1058,332 +1001,12 @@
} else { } else {
label.innerHTML='<font color="red">'+xhr2.responseText+'</font>'; label.innerHTML='<font color="red">'+xhr2.responseText+'</font>';
} }
delete uploading[filename];
// uploadbuttonshow(); // uploadbuttonshow();
} }
} }
} }
} }
<!--OnedriveUploadJsEnd--> <!--UploadJsEnd-->
<!--AliyundriveUploadJsStart-->
function preup() {
uploadbuttonhide();
var files=document.getElementById('upload_file').files;
if (files.length<1) {
uploadbuttonshow();
return;
};
var table1=document.createElement('table');
document.getElementById('upload_div').appendChild(table1);
table1.setAttribute('class','list-table');
var timea=new Date().getTime();
var i=0;
var uploadList = setInterval(function(){
if (i<files.length) {
if (Object.keys(uploading).length<5) {
getuplink(i);
i++;
}// else console.log(Object.keys(uploading).length);
} else clearInterval(uploadList);
}, 1000);
//getuplink(i);
function getuplink(i, r=0) {
var file=files[i];
var td1;
var td2;
if (r==0) {
var tr1=document.createElement('tr');
table1.appendChild(tr1);
tr1.setAttribute('data-to',1);
td1=document.createElement('td');
tr1.appendChild(td1);
td1.setAttribute('style','width:30%;word-break:break-word;');
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size)+' ('+(i+1)+'/'+files.length+')';
td2=document.createElement('td');
tr1.appendChild(td2);
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
}
var tdnum = timea+'_'+i;
td1=document.getElementById('upfile_td1_'+tdnum);
td2=document.getElementById('upfile_td2_'+tdnum);
var chunksize=10*1024*1024; // 分块大小
//var chunksize=100*1024; // 测试小块
/*if (file.size>100*1024*1024*1024) {
td2.innerHTML='<font color="red"><!--constStr@UpFileTooLarge--></font>';
uploadbuttonshow();
return;
}*/
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
uploading[upbigfilename] = [i];
var spark = sha1.create();
var reader = new FileReader();
var chunksize=10*1024*1024;
var asize = 0;
var filesha1;
function readblob(start) {
var end=start+chunksize;
var blob = file.slice(start,end);
reader.readAsArrayBuffer(blob);
}
readblob(asize);
reader.onload = function(e){
td2.innerHTML='<!--constStr@Calculate--> SHA1: '+(asize*100/file.size).toFixed(2)+'%';
var binary = this.result;
spark.update(binary);
asize += chunksize;
if (asize < file.size) {
readblob(asize);
} else {
filesha1 = spark.hex();
td2.innerHTML='SHA1: ' + filesha1;
<!--GuestStart-->
function getext(str) {
let p = str.lastIndexOf('.');
if (p===-1) return '';
if (p===0) return '';
return str.substr(p);
}
var ext = getext(file.webkitRelativePath||file.name);
upbigfilename = filesha1 + ext;
<!--GuestEnd-->
//while (upbigfilename.indexOf('%2F')>0) upbigfilename = upbigfilename.replace('%2F', '/');
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
var html = JSON.parse(localStorage.getItem(filesha1));
//console.log(html);
if (html!==null && ('part_info_list' in html)) {
td2.innerHTML='<!--constStr@UploadStart--> ...';
binupfile(file, html, timea+'_'+i, upbigfilename, filesha1, chunksize);
} else {
var xhr1 = new XMLHttpRequest();
xhr1.open("POST", '?action=upbigfile');
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr1.onload = function(e){
//console.log(xhr1.status+xhr1.responseText);
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>';
if (xhr1.status==201) {
if (xhr1.responseText=='') {
getuplink(i,1);
return;
}
var html=JSON.parse(xhr1.responseText);
//console.log(html);
if (!html['part_info_list']) {
if (html.name!='') {
if (html.exist==true) td2.innerHTML=html.name+' 文件名已有';
else if (html.rapid_upload==true) td2.innerHTML=html.name+' 秒传';
else td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
} else {
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
}
delete uploading[upbigfilename];
} else {
td2.innerHTML='<!--constStr@UploadStart--> ...';
//console.log(html);
localStorage.setItem(filesha1, JSON.stringify(html));
binupfile(file, html, timea+'_'+i, upbigfilename, filesha1, chunksize);
}
} else {
delete uploading[upbigfilename];
}
/*if (i<files.length-1) {
i++;
getuplink(i);
}*/
}
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&filesha1=' + filesha1 + '&chunksize=' + chunksize);
}
}
}
}
uploadbuttonshow();
}
function binupfile(file, res, tdnum, filename, filesha1, chunksize) {
// xhr.getResponseHeader
if (!('ETag' in res)) res['ETag'] = new Array();
var fileid = res['file_id'];
var uploadid = res['upload_id'];
var label=document.getElementById('upfile_td2_'+tdnum);
var reader = new FileReader();
var StartStr='';
var MiddleStr='';
var StartTime;
var EndTime;
var newstartsize = 0;
if(!!file){
var chunknum = 0;
var chunknumtotal = res['part_info_list'].length;
var asize=0;
var totalsize=file.size;
var newstartsize=0;
while (res['ETag'][chunknum]!=null) {
chunknum++;
newstartsize += chunksize;
}
StartTime = new Date();
asize = newstartsize;
if (newstartsize==0) {
StartStr='<!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
} else {
StartStr='<!--constStr@LastUpload-->'+size_format(newstartsize)+ '<br><!--constStr@ThisTime--><!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
}
//var chunksize=5*1024*1024; // chunk size, max 60M. 每小块上传大小
//if (totalsize>200*1024*1024) chunksize=10*1024*1024;
function readblob(start) {
var end=start+chunksize;
var blob = file.slice(start,end);
reader.readAsArrayBuffer(blob);
//reader.readAsArrayBuffer(file);
}
readblob(asize);
reader.onload = function(e){
if (asize>totalsize) {
var xhr1 = new XMLHttpRequest();
xhr1.open("POST", '?action=upbigfile');
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr1.onload = function(e){
console.log(xhr1.responseText+','+xhr1.status);
if (xhr1.status==200) {
localStorage.removeItem(filesha1);
<!--AdminStart-->
var html=JSON.parse(xhr1.responseText);
//response.name=file.webkitRelativePath||response.name;
addelement(html);
<!--AdminEnd-->
/*if (totalsize>10*1024*1024) {
var xhr3 = new XMLHttpRequest();
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);
}
}*/
EndTime=new Date();
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
if (newstartsize==0) {
MiddleStr += '<!--constStr@AverageSpeed-->:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
} else {
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
}
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr;
label.style.color='green';
} else {
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
localStorage.removeItem(filesha1);
}
delete uploading[filename];
}
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
} else {
var binary = this.result;
var xhr = new XMLHttpRequest();
xhr.open("PUT", res['part_info_list'][chunknum]['upload_url'], true);
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
bsize=asize+e.loaded-1;
xhr.setRequestHeader('Content-Range', 'bytes ' + asize + '-' + bsize +'/'+ totalsize);
xhr.upload.onprogress = function(e){
if (e.lengthComputable) {
var tmptime = new Date();
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
}
}
var C_starttime = new Date();
xhr.onload = function(e){
if (xhr.status<500) {
//console.log(xhr.responseText);
//console.log(xhr.getResponseHeader('ETag'));
//var response=JSON.parse(xhr.responseText);
if (xhr.responseText==''&&xhr.getResponseHeader('ETag')!='') {
// 有ETag说明本段上传成功
let etag = xhr.getResponseHeader('ETag');
//if (etag.substr(0,1)=='"') etag = etag.substr(1);还就要引号!
//if (etag.substr(-1)=='"') etag = etag.substr(0, etag.length-1);
res['ETag'][chunknum] = etag;
localStorage.setItem(filesha1, JSON.stringify(res));
chunknum++;
asize = bsize + 1;
if (chunknum==chunknumtotal) {
// 上传结束
var xhr1 = new XMLHttpRequest();
xhr1.open("POST", '?action=upbigfile');
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr1.onload = function(e){
console.log(xhr1.responseText+','+xhr1.status);
if (xhr1.status==200) {
localStorage.removeItem(filesha1);
<!--AdminStart-->
var html=JSON.parse(xhr1.responseText);
//response.name=file.webkitRelativePath||response.name;
addelement(html);
<!--AdminEnd-->
/*if (totalsize>10*1024*1024) {
var xhr3 = new XMLHttpRequest();
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);
}
}*/
EndTime=new Date();
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
if (newstartsize==0) {
MiddleStr += '<!--constStr@AverageSpeed-->:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
} else {
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
}
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr;
label.style.color='green';
} else {
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
localStorage.removeItem(filesha1);
}
delete uploading[filename];
}
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
// uploadbuttonshow();
} else {
readblob(asize);
}
} else {
console.log(xhr.status+xhr.responseText);//<PartEtag>
if (xhr.status==409) {
let str = xhr.responseText;
str = str.substr(str.indexOf('<PartEtag>')+10);
str = str.substr(0, str.indexOf('</PartEtag>'));
res['ETag'][chunknum] = str;
localStorage.setItem(filesha1, JSON.stringify(res));
chunknum++;
asize += chunksize;
readblob(asize);
} else {
delete uploading[filename];
}
//label.innerHTML='<font color="red">'+xhr.responseText+'</font><br>';
} } else readblob(asize);
}
xhr.send(binary);
}
}
}
}
<!--AliyundriveUploadJsEnd-->
<!--GoogledriveUploadJsStart-->
function preup() {
alert("Stop!\nCan not upload form explorer without token.");
}
<!--GoogledriveUploadJsEnd-->
<!--ListEnd--> <!--ListEnd-->
function operatediv_close(operate) { function operatediv_close(operate) {
document.getElementById(operate+'_div').style.display='none'; document.getElementById(operate+'_div').style.display='none';
@ -1391,28 +1014,9 @@
} }
<!--AdminStart--> <!--AdminStart-->
function logout() { function logout() {
var expd = new Date(); document.cookie = "admin=; path=/";
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie = "admin=; path=/; "+expires;
location.href = location.href; location.href = location.href;
} }
/*for some mobile browser*/
function menu_click(e){
var ee=document.getElementsByClassName("active");
for(var i=0;i<ee.length;i++){
ee[i].classList.remove("active");
}
if(e.type!="mouseout")this.classList.add("active");
}
(function(){
var e=document.getElementsByClassName("operate");
document.body.addEventListener("touchstart", menu_click);
for(var i=0;i<e.length;i++){
e[i].addEventListener("touchstart", menu_click);
e[i].addEventListener("mouseout", menu_click);
}
})();
<!--IsFolderStart--> <!--IsFolderStart-->
function showdiv(event,action,num) { function showdiv(event,action,num) {
var $operatediv=document.getElementsByName('operatediv'); var $operatediv=document.getElementsByName('operatediv');
@ -1424,19 +1028,21 @@
document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px'; document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px';
if (num=='') { if (num=='') {
var str=''; var str='';
var fileid='';
} else { } else {
var str=decodeURIComponent(document.getElementById('file_a'+num).href); var str=document.getElementById('file_a'+num).innerText;
if (str=='') {
str=document.getElementById('file_a'+num).getElementsByTagName("img")[0].alt;
if (str=='') {
alert('<!--constStr@GetFileNameFail-->');
operatediv_close(action);
return;
}
}
if (str.substr(-1)==' ') str=str.substr(0,str.length-1); if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
if (str.substr(-1)=='/') str=str.substr(0, str.length-1);
if (str.substr(-8)=='?preview') str=str.substr(0, str.length-8);
if (str.lastIndexOf('/')>-1) str=str.substr(str.lastIndexOf('/')+1);
var fileid=document.getElementById('file_a'+num).attributes['fileid'].nodeValue;
} }
document.getElementById(action + '_div').style.display=''; document.getElementById(action + '_div').style.display='';
document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&amp;'); document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&amp;');
document.getElementById(action + '_sid').value=num; document.getElementById(action + '_sid').value=num;
document.getElementById(action + '_fileid').value=fileid;
document.getElementById(action + '_hidden').value=str; document.getElementById(action + '_hidden').value=str;
if (action=='rename') document.getElementById(action + '_input').value=str; if (action=='rename') document.getElementById(action + '_input').value=str;
var $e = event || window.event; var $e = event || window.event;
@ -1465,9 +1071,9 @@
function submit_operate(str) { function submit_operate(str) {
var num=document.getElementById(str+'_sid').value; var num=document.getElementById(str+'_sid').value;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("POST", ''); xhr.open("GET", '?'+serializeForm(str+'_form'));
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
xhr.setRequestHeader('x-requested-with','XMLHttpRequest'); xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr.send(null);
xhr.onload = function(e){ xhr.onload = function(e){
var html; var html;
if (xhr.status<300) { if (xhr.status<300) {
@ -1483,12 +1089,10 @@
html=JSON.parse(xhr.responseText); html=JSON.parse(xhr.responseText);
addelement(html); addelement(html);
} }
//alert('success');
} else alert(xhr.status+'\n'+xhr.responseText); } else alert(xhr.status+'\n'+xhr.responseText);
document.getElementById(str+'_div').style.display='none'; document.getElementById(str+'_div').style.display='none';
document.getElementById('mask').style.display='none'; document.getElementById('mask').style.display='none';
} }
xhr.send(serializeForm(str+'_form'));
return false; return false;
} }
function addelement(html) { function addelement(html) {
@ -1502,16 +1106,15 @@
a1.target='_blank'; a1.target='_blank';
var td2=document.createElement('td'); var td2=document.createElement('td');
td2.setAttribute('class','updated_at'); td2.setAttribute('class','updated_at');
if (!!html.time) td2.innerText=html.time.replace(/T/,' ').replace(/Z/,''); td2.innerText=html.lastModifiedDateTime.replace(/T/,' ').replace(/Z/,'');
var td3=document.createElement('td'); var td3=document.createElement('td');
td3.setAttribute('class','size'); td3.setAttribute('class','size');
if (!!html.size) td3.innerText=size_format(html.size); td3.innerText=size_format(html.size);
else td3.innerText='0 B'; if (!!html.folder) {
if (html.type=='folder') {
a1.href+='/'; a1.href+='/';
document.getElementById('tr0').parentNode.insertBefore(tr1,document.getElementById('tr0').nextSibling); document.getElementById('tr0').parentNode.insertBefore(tr1,document.getElementById('tr0').nextSibling);
} }
if (html.type=='file') { if (!!html.file) {
a1.href+='?preview'; a1.href+='?preview';
a1.name='filelist'; a1.name='filelist';
document.getElementById('tr0').parentNode.appendChild(tr1); document.getElementById('tr0').parentNode.appendChild(tr1);
@ -1585,11 +1188,18 @@
} }
<!--IsFolderEnd--> <!--IsFolderEnd-->
<!--AdminEnd--> <!--AdminEnd-->
<!--EncryptedStart--> <!--LoginStart-->
document.getElementById('password1').focus(); function login() {
<!--EncryptedEnd--> document.getElementById('mask').style.display='';
//document.getElementById('mask').style.width=document.documentElement.scrollWidth+'px';
document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px';
document.getElementById('login_div').style.display='';
document.getElementById('login_div').style.left=(document.body.clientWidth-document.getElementById('login_div').offsetWidth)/2 +'px';
document.getElementById('login_div').style.top=(window.innerHeight-document.getElementById('login_div').offsetHeight)/2+document.body.scrollTop +'px';
document.getElementById('login_input').focus();
}
<!--LoginEnd-->
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script> <script src="//unpkg.zhimg.com/ionicons@4.4.4/dist/ionicons.js"></script>
<!--LoginStart--><script src="?jsFile=sha1.min.js"></script><!--LoginEnd-->
<!--customScript--> <!--customScript-->
</html> </html>

View File

@ -3,9 +3,9 @@
"music":"musical-notes", "music":"musical-notes",
"video":"logo-youtube", "video":"logo-youtube",
"img":"image", "img":"image",
"office":"newspaper", "office":"paper",
"txt":"clipboard", "txt":"clipboard",
"zip":"file-tray-full", "zip":"filing",
"iso":"disc", "iso":"disc",
"apk":"logo-android", "apk":"logo-android",
"exe":"logo-windows", "exe":"logo-windows",
@ -89,7 +89,7 @@
<li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul> <li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul>
<!--IsFolderStart--> <!--IsFolderStart-->
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li> <li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li> <li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li> <li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li>
<!--IsFolderEnd--> <!--IsFolderEnd-->
<li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li> <li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li>
@ -179,7 +179,7 @@
<div style="margin: 12px 4px 4px; text-align: center"> <div style="margin: 12px 4px 4px; text-align: center">
<div style="margin: 24px"> <div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea> <textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a> <a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
</div> </div>
<div style="margin: 24px"> <div style="margin: 24px">
<!--IsimgFileStart--> <!--IsimgFileStart-->
@ -240,7 +240,7 @@
<!--AdminStart--> <!--AdminStart-->
<li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a> <li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a>
<ul> <ul>
<li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li> <li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li> <li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li>
<li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li> <li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li>
<li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li> <li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li>
@ -457,9 +457,8 @@
<div style="margin:50px"> <div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a> <a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center> <center>
<form action="<!--IsPreview?-->login=admin" method="post" onsubmit="return sha1loginpass(this);"> <form action="<!--IsPreview?-->admin" method="post">
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->"> <input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input name="timestamp" type="hidden" value="">
<input type="submit" value="<!--constStr@Login-->"> <input type="submit" value="<!--constStr@Login-->">
</form> </form>
</center> </center>
@ -470,10 +469,10 @@
</body> </body>
<!--ListStart--> <!--ListStart-->
<!--MdRequireStart--><link rel="stylesheet" href="https://unpkg.com/github-markdown-css@3.0.1/github-markdown.css"> <!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
<script type="text/javascript" src="?jsFile=marked.js"></script><!--MdRequireEnd--> <script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
<!--GuestUploadStart--><script type="text/javascript" src="?jsFile=spark-md5.min.js"></script><!--GuestUploadEnd--> <!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
<!--IsFileStart--><!--IspdfFileStart--><script src="https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd--> <!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--ListEnd--> <!--ListEnd-->
<script type="text/javascript"> <script type="text/javascript">
function changelanguage(str) function changelanguage(str)
@ -510,10 +509,7 @@
<!--IsFileStart--> <!--IsFileStart-->
var $url = document.getElementById('url'); var $url = document.getElementById('url');
if ($url) { if ($url) {
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML; $url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px'; $url.style.height = $url.scrollHeight + 'px';
} }
<!--IsofficeFileStart--> <!--IsofficeFileStart-->
@ -595,10 +591,10 @@
addVideos(['<!--FileDownUrl-->']); addVideos(['<!--FileDownUrl-->']);
<!--IsvideoFileEnd--> <!--IsvideoFileEnd-->
<!--IspdfFileStart--> <!--IspdfFileStart-->
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.worker.min.js'; pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
var loadingTask = pdfjsLib.getDocument({ var loadingTask = pdfjsLib.getDocument({
url: '<!--FileDownUrl-->', url: '<!--FileDownUrl-->',
cMapUrl: "https://unpkg.com/pdfjs-dist@2.4.456/cmaps/", cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/",
cMapPacked: true, cMapPacked: true,
rangeChunkSize: 65535 rangeChunkSize: 65535
}); });
@ -1247,43 +1243,11 @@
document.getElementById('login_div').style.top=(window.innerHeight-document.getElementById('login_div').offsetHeight)/2+document.body.scrollTop +'px'; document.getElementById('login_div').style.top=(window.innerHeight-document.getElementById('login_div').offsetHeight)/2+document.body.scrollTop +'px';
document.getElementById('login_input').focus(); document.getElementById('login_input').focus();
} }
function sha1loginpass(f) {
if (f.password1.value == "") return false;
try {
timestamp = new Date().getTime() + "";
timestamp = timestamp.substr(0, timestamp.length - 3);
f.timestamp.value = timestamp;
f.password1.value = sha1(timestamp + "" + f.password1.value);
return true;
} catch {
//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);
}
<!--LoginEnd--> <!--LoginEnd-->
<!--EncryptedStart--> <!--EncryptedStart-->
document.getElementById('password1').focus(); document.getElementById('password1').focus();
<!--EncryptedEnd--> <!--EncryptedEnd-->
</script> </script>
<!--LoginStart--> <script src="//unpkg.zhimg.com/ionicons@4.4.4/dist/ionicons.js"></script>
<script src="?jsFile=sha1.min.js"></script>
<!--LoginEnd-->
<script src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<!--customScript--> <!--customScript-->
</html> </html>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
<link rel="preconnect" href="https://fastly.jsdelivr.net" /> <link rel="preconnect" href="https://cdn.jsdelivr.net" />
<link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" />
<meta charset="utf-8" /> <meta charset="utf-8" />
@ -16,7 +16,7 @@
/> />
<title><!--Title--></title> <title><!--Title--></title>
<meta name="description" content="A Onemanager-PHP site with Theme-renexmoe" /> <meta name="description" content="A Onemanager-PHP site with Theme-renexmoe" />
<link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/css/app.css"><meta name="theme-color" content="#fff" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/css/app.css"><meta name="theme-color" content="#fff" />
<!--BackgroundStart--> <!--BackgroundStart-->
<style> <style>
body { body {
@ -98,9 +98,13 @@
<div class="mdui-drawer mdui-drawer-close" id="main-drawer"> <div class="mdui-drawer mdui-drawer-close" id="main-drawer">
<div class="mdui-list" mdui-collapse="{accordion: true}"> <div class="mdui-list" mdui-collapse="{accordion: true}">
<!--LoginStart--> <!--LoginStart-->
<li class="mdui-list-item mdui-ripple" href="?login=admin" > <li
<a class="mdui-list-item-icon mdui-icon material-icons">account_circle</a> class="mdui-list-item mdui-ripple"
<a class="mdui-list-item-content" href="?login=admin">登录</a> href="javascript:void(0);"
mdui-dialog="{target: '#login_input'}"
>
<a class="mdui-list-item-icon mdui-icon material-icons">account_circle</a
><a class="mdui-list-item-content">登录</a>
</li> </li>
<!--LoginEnd--> <!--LoginEnd-->
<!--AdminStart--> <!--AdminStart-->
@ -511,5 +515,5 @@
{ "music":"audiotrack", "video":"ondemand_video", "img":"image", { "music":"audiotrack", "video":"ondemand_video", "img":"image",
"pdf":"picture_as_pdf", "default":"insert_drive_file"} "pdf":"picture_as_pdf", "default":"insert_drive_file"}
<!--IconValuesEnd--> <!--IconValuesEnd-->
<script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@1b381f3c.a4f2dc4618121eac37e2.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@28a13772.98a11cc0c1cf2495c3d8.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@34e3d95a.2f8dbf552095a86a7f1b.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@798ab416.9ed46bb752b71a3c13a4.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@9c50beac.30955a99f08c9574cd14.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@f0256996.956ea71aa357ba3fdc28.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/webpack-runtime.93708ab3e9cb84dcc01a.js"></script> <script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@1b381f3c.a4f2dc4618121eac37e2.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@28a13772.98a11cc0c1cf2495c3d8.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@34e3d95a.2f8dbf552095a86a7f1b.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@798ab416.9ed46bb752b71a3c13a4.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@9c50beac.30955a99f08c9574cd14.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@f0256996.956ea71aa357ba3fdc28.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/webpack-runtime.93708ab3e9cb84dcc01a.js"></script>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
#!/bin/bash #!bash
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo " echo "

41
version
View File

@ -1,46 +1,7 @@
20220127-1234.43
<font color="red">change login page, default not '?admin' but '?login=admin' now! and if set adminloginpage, it will be '?login=[value]'.</font> rm JumpFirstDisk, 403 in operating root, change sorting disk, remake disktags tab, add global md config. Allow Preview when enable downloadencrypt. some change in adding Onedrive disk. show upload progress in table background. fix some bugs.
<font color="red">更改登录地址,默认不再是'?admin'而是'?login=admin'如果设置了adminloginpage那登录地址会是'?login=值'。</font>移除 JumpFirstDisk在root操作时返回403更改盘排序重做盘符排列添加全局md配置。在开启downloadencrypt后可以网页预览了。添加onedrive盘时稍做修改。上传时以背景做进度条。修复其它bug。
20211220-1100.42
Add new platform Replit. Add a git source for update. sha1.js use jsdelivr cdn. fix some bugs.
新增Replit平台。新增国内git源以后国内可以选择从HIT源更新。sha1.js换成jsdelivr CDN。修复bug。
20211201-1602.41
add a latent function, you can edit platform token(or API key) via '?setup=auth' when the token invalid, not need edit it in Environment(or Config Var) manually, (even in Vercel, config saved in file, and can't modiy it manually).
新增隐藏功能在平台操作代码的token或API key失效时可以在 '?setup=auth' 修改它不用去环境变量修改了特别地Vercel保存在代码中时都改不到
20211129
check if there is another deployment building when start deploy.
Vercel部署时检测是否有另一个部署。
20211104
check if exist php-curl or not in php host and VPS.
在VPS中检测是否有php-curl。
20211021
specialchars, fix: list folder, encrypt folder, preview files, rename, show in title, error on back link after login at specialchars folder, etc.
针对特殊字符,解决目录的列表,目录的加密,文件的预览,目录与文件重命名,在网页标题的显示,在特殊字符处登录后跳转出错等问题。
20211006
oprate files by fileID, write a localStorage when login to anti CSRF.
管理时对文件id操作管理登录时写入一个localStorage预防CSRF。
20210908
add fileConduitSize&fileConduitCacheTime, little files can stream from program, better to show html/js as local file.
增加fileConduitSizefileConduitCacheTime小文件可以从服务器中转以对html/js本地化更好的支持。
20210903
add a latent function, you can run some command by '?setup=cmd', be care, please dont try "top", and set times by "ping -c 4".
新增隐藏功能,你可以通过'?setup=cmd'来跑一些命令注意不要试图跑top另外ping请-c设置次数。
20210820-1810.40
because Vercel must redeploy after change Environment Variables, and it must <4k, so decide that, save config in code file. <font color=red>in Vercel, after update, please install again. if you want continue use Environment, please add a ( name: "ONEMANAGER_CONFIG_SAVE", value: "env" ) in Environment Variables in Project Settings before update.</font>
因为Vercel修改环境变量也必须重新部署才生效而且环境变量只能小于4k所以决定将配置保存在代码文件中。<font color=red>升级更新后用Vercel的请重新安装。如果还想继续使用环境变量请在更新前在Project Settings的Environment Variables中新增一个( name: "ONEMANAGER_CONFIG_SAVE", value: "env" )的环境变量。</font>
20210817-2030.39
fix bugs in Vercel. add wait function in operating. change update method in SCF. add payme in readme.
修复一些Vercel上的bug。在操作完后添加等待功能确认平台已经准备好。SCF的更新方式改变。在readme中添加讨饭链接。
20210804-1535.38
try fix "&"/"&amp;" in filename. try show an img too height. change upload chunk size when upload speed>10M/s. fix forceHttps when custom domain in Glitch. fix ionicons svg lost.try use file id when rename. background (or other) based on width/height not only width. fix some bugs. Pre-Add platform Vercel, just wait bugs fixed.
尝试修复文件名含 "&"/"&amp;"。尝试在一屏内显示过长的图片。上传时分割的块大小随着上传速度改变。修复Glitch中使用自定义域名时forceHttps问题。修复ionicons图标失踪。尝试在重命名时使用file id来操作。背景或其它基于长宽来看是竖屏还是横屏不再只看宽度。修复其它bug。预加入Vercel平台等修复bugs。
20210512-1648.37
add setting "forceHttps", can force 302 jump to https. fix preview office files. fix manage in safari.fix disktag can be "home". fix some bugs.
新增一个设置可以强制跳转https。修复office文档预览。修复safari上点不了管理。盘的标签可以是home了随便命名了。修复一些其它问题。
20210331-1530.36 20210331-1530.36
admin can only use classic theme after admin login, and guest can not change theme now. fix: Sharelink can not work in php8. show disk space. limit 5 files in uploading. do with activityLimitReached. fix some bugs. admin can only use classic theme after admin login, and guest can not change theme now. fix: Sharelink can not work in php8. show disk space. limit 5 files in uploading. do with activityLimitReached. fix some bugs.
暂时解决昨天阿里云盘最新防盗链。管理登录后只能用classic主题游客不能再切换主题了。修复Sharelink在php8下不能正常工作。显示盘空间。同时上传文件数限制5个。对activityLimitReached稍微处理。修复一些bug。 暂时解决昨天阿里云盘最新防盗链。管理登录后只能用classic主题游客不能再切换主题了。修复Sharelink在php8下不能正常工作。显示盘空间。同时上传文件数限制5个。对activityLimitReached稍微处理。修复一些bug。
20210313-1352.35 20210313-1352.35
use driveId, after update, <font color="red">Aliyundrive and Googledrive please click the Change link after Driver type</font>. try fix: php8 will run error 500. change layout in settup. fix: uploading non-englist file name. try fix: sha1 a big file. use driveId, after update, <font color="red">Aliyundrive and Googledrive please click the Change link after Driver type</font>. try fix: php8 will run error 500. change layout in settup. fix: uploading non-englist file name. try fix: sha1 a big file.
换用driveId更新后<font color="red">Aliyundrive与Googledrive请点一下那个切换链接</font>。尝试修复php8的500 ERROR。改变设置页面的布局。修复上传中文名文件时最终文件以url代码命名。阿里云盘上传时可以sha1大文件了。 换用driveId更新后<font color="red">Aliyundrive与Googledrive请点一下那个切换链接</font>。尝试修复php8的500 ERROR。改变设置页面的布局。修复上传中文名文件时最终文件以url代码命名。阿里云盘上传时可以sha1大文件了。