Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d48854791f | ||
|
|
6bf9e7e843 | ||
|
|
86a083e196 | ||
|
|
f4d7c354ea | ||
|
|
00d61d6118 | ||
|
|
f4a11d5312 | ||
|
|
56fe3f3c5f | ||
|
|
53c122937d | ||
|
|
1b2c468d7e | ||
|
|
187a43e073 | ||
|
|
2f01d6c3f7 | ||
|
|
6b0e5bf8d5 | ||
|
|
f86f713679 | ||
|
|
473769c693 | ||
|
|
179fa24c4a | ||
|
|
d479ac6662 | ||
|
|
1b04aafd95 | ||
|
|
3939317b1b | ||
|
|
739f42e24f | ||
|
|
6abedbafd5 | ||
|
|
05bbb1b861 | ||
|
|
3842fb7952 | ||
|
|
4ef20bdf50 | ||
|
|
7a86da6764 | ||
|
|
378a59eda6 | ||
|
|
3571c47671 | ||
|
|
1bee94cf43 | ||
|
|
f57ddf02db | ||
|
|
bc12e82c74 | ||
|
|
e67ff8736b | ||
|
|
fe765192e1 | ||
|
|
36df71a77c | ||
|
|
a1381e7fcc | ||
|
|
93b713b508 | ||
|
|
3a95027a06 | ||
|
|
cfda210fdc | ||
|
|
0a7887409c | ||
|
|
ce4fc41443 | ||
|
|
8cc9efa43c | ||
|
|
267b17102c | ||
|
|
127febb75d | ||
|
|
b0bee473ff | ||
|
|
91c6583d70 | ||
|
|
02745e7742 | ||
|
|
92d17d389d | ||
|
|
85741cae27 | ||
|
|
f926b37ae5 | ||
|
|
96cad800b7 | ||
|
|
55f267092d | ||
|
|
52a47fbd05 | ||
|
|
f6a8243a83 | ||
|
|
43ce495d76 | ||
|
|
eb12b784d3 | ||
|
|
1f4552bb73 | ||
|
|
d83bdcbf94 | ||
|
|
4e806bb8bd | ||
|
|
f10a5d3c1a | ||
|
|
6c4d20083f | ||
|
|
4cdc02ec7f | ||
|
|
0f9cc9451e | ||
|
|
2e94fb6502 | ||
|
|
e9ceedbd50 | ||
|
|
268c6e8be7 | ||
|
|
3619a611a7 | ||
|
|
2887a7026e | ||
|
|
08c790690d | ||
|
|
c653abf457 | ||
|
|
87654f35ce | ||
|
|
fe4f4e50d7 | ||
|
|
0dac337037 | ||
|
|
a18eb9f9f6 | ||
|
|
4962a90795 | ||
|
|
5e0626e469 | ||
|
|
9b88ee17cc | ||
|
|
ab538a0d2f | ||
|
|
cd4f2efc42 | ||
|
|
9fc6c02ca4 | ||
|
|
eac15d83f8 | ||
|
|
2e8e29a35e | ||
|
|
e3e0f7f27d | ||
|
|
a3b1430041 | ||
|
|
097254f084 | ||
|
|
b5f6032e2b | ||
|
|
c016841216 | ||
|
|
7ddd30036d | ||
|
|
fe293a6254 | ||
|
|
f90fbf4d58 | ||
|
|
d2e68b3ce3 | ||
|
|
10ba4218af | ||
|
|
9bf62b0af8 | ||
|
|
50d78ee6df | ||
|
|
acdb4640bd | ||
|
|
f018448441 | ||
|
|
dee127ef64 | ||
|
|
d4d4c4e739 | ||
|
|
8f4c5d2d30 | ||
|
|
e8ea8dfb93 | ||
|
|
e8280db8c3 | ||
|
|
d2cdce4277 | ||
|
|
243f08f0fa | ||
|
|
e0fc287a45 | ||
|
|
d5e9ee6103 | ||
|
|
56b4ab43d9 | ||
|
|
34829639f8 | ||
|
|
f8bc8f5ee8 | ||
|
|
f7cd9e8483 | ||
|
|
3bab14d3ea | ||
|
|
d5ea792034 | ||
|
|
7a7342201f | ||
|
|
28e2f7b564 | ||
|
|
ac2a9910b0 | ||
|
|
23729cc564 | ||
|
|
562ee87eef | ||
|
|
79c0b002c0 | ||
|
|
e4693b29ed | ||
|
|
a1268da0fe | ||
|
|
4b816fb206 | ||
|
|
bb8c1afc58 | ||
|
|
e439ed8e68 | ||
|
|
44bedf16a7 | ||
|
|
53f88aa506 | ||
|
|
7f07ab1b38 | ||
|
|
1e437f8864 | ||
|
|
f50949dae6 | ||
|
|
27091d5085 | ||
|
|
d31aad16e9 | ||
|
|
185824353e | ||
|
|
0e907d4873 | ||
|
|
388b8f33a9 | ||
|
|
c69bbe3eca | ||
|
|
bddd6e91f2 | ||
|
|
64dd0f238c | ||
|
|
6a616eca6b | ||
|
|
0cea4dee5e | ||
|
|
8912bf7c30 | ||
|
|
3edd92f168 | ||
|
|
f5c7e1e2b5 | ||
|
|
1e987c8504 | ||
|
|
06a077085b | ||
|
|
ac2012df31 | ||
|
|
d344fa2245 | ||
|
|
65fa8c290f | ||
|
|
64265e4185 | ||
|
|
0da8412119 | ||
|
|
ad14918cd7 | ||
|
|
8d961d72de | ||
|
|
b3c61d22d3 | ||
|
|
1929c65011 | ||
|
|
5edd249144 | ||
|
|
baa884ab07 | ||
|
|
47014d73e3 | ||
|
|
c8a9540d03 | ||
|
|
ca75c22de1 | ||
|
|
133990ceff | ||
|
|
23fa448a2f | ||
|
|
e85c6eab0d | ||
|
|
cd45927eaa | ||
|
|
40053a64c5 | ||
|
|
adfe133522 | ||
|
|
08f177bca5 | ||
|
|
b273bdf961 | ||
|
|
bd568a5630 | ||
|
|
45205ff347 | ||
|
|
72bcd304bf | ||
|
|
2f41e4f7b3 | ||
|
|
c5cf5b7fae | ||
|
|
f986460bba | ||
|
|
c57b8606be | ||
|
|
9a101d78c7 | ||
|
|
44caac5cec | ||
|
|
902488ebd0 | ||
|
|
3b8c0d82ad | ||
|
|
938d7cfda1 | ||
|
|
788df4b518 | ||
|
|
dfb5255511 | ||
|
|
8836da8432 | ||
|
|
8075c3d2d8 | ||
|
|
f5eaea3917 | ||
|
|
cb0cf8f8e4 | ||
|
|
fb64194010 | ||
|
|
fdf37489e4 | ||
|
|
1d062e0fc5 | ||
|
|
4fb6007e55 | ||
|
|
d0f7eefe2e | ||
|
|
166573b0cc | ||
|
|
0e5320dd93 | ||
|
|
ca9fc485b5 | ||
|
|
46786637bc | ||
|
|
a9f3629748 | ||
|
|
855a805f29 | ||
|
|
e3843c7060 | ||
|
|
88dfcd00dc | ||
|
|
94ab3fec4c | ||
|
|
73e952bb5c | ||
|
|
78fb66fb24 | ||
|
|
e75fa0eaab | ||
|
|
b82daa3f36 | ||
|
|
040305aa10 | ||
|
|
9c680bb929 | ||
|
|
160d1ca438 | ||
|
|
6e0622c793 | ||
|
|
7aaab81a18 | ||
|
|
526eacf936 | ||
|
|
bfb816fa63 | ||
|
|
2d4dcd9703 | ||
|
|
34748c5824 | ||
|
|
4b1b83b95c | ||
|
|
72a7c1043d | ||
|
|
33657feefb | ||
|
|
9867a91246 | ||
|
|
18b59e0f11 | ||
|
|
83b8e53ef3 | ||
|
|
9ade25d872 | ||
|
|
ffbf4472ca | ||
|
|
ed64a5acf9 | ||
|
|
ab69e108d3 | ||
|
|
c85403c719 | ||
|
|
57c80a3e4f | ||
|
|
443348f822 | ||
|
|
bb943b8551 | ||
|
|
2a1b9af033 | ||
|
|
caa73378e1 | ||
|
|
0b6cb4ba66 | ||
|
|
09270d47cd | ||
|
|
52afcecb0d | ||
|
|
e9743c648f | ||
|
|
064da3da9c | ||
|
|
a1abd4d5ca | ||
|
|
0377867200 | ||
|
|
acb0ac3913 | ||
|
|
cf5aa37633 | ||
|
|
97735aec43 | ||
|
|
a244fb7ffb | ||
|
|
5051a05adf | ||
|
|
89daee97cf | ||
|
|
f1a6d2821e | ||
|
|
00023986b3 | ||
|
|
23ee2630ef | ||
|
|
8ca9a9d628 | ||
|
|
286046b82a | ||
|
|
a868d5df44 | ||
|
|
0a78999463 | ||
|
|
a6211d3382 | ||
|
|
2dc44a92d3 | ||
|
|
925ff9fe90 | ||
|
|
989de97dde | ||
|
|
0d9996c6c8 | ||
|
|
cd56380d39 | ||
|
|
6bd47b2a13 | ||
|
|
bd91e82552 | ||
|
|
01ff467b07 | ||
|
|
da012e8009 | ||
|
|
37462b5e9a | ||
|
|
0cfccddc4d | ||
|
|
3b2251fe82 | ||
|
|
69f74da711 | ||
|
|
5c42aef340 | ||
|
|
0fb6614332 | ||
|
|
858fa2811a | ||
|
|
d4d5895455 | ||
|
|
09553fff82 | ||
|
|
0452f7f278 | ||
|
|
9383978499 | ||
|
|
aa15da3ffb |
@@ -1,15 +1,16 @@
|
|||||||
# apache
|
# # Apache
|
||||||
# LoadModule rewrite_module modules/mod_rewrite.so
|
# # LoadModule rewrite_module modules/mod_rewrite.so
|
||||||
# AllowOverride All
|
# # AllowOverride All
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
# RewriteCond $1 !^(.well-known)
|
||||||
RewriteRule ^(.*) index.php?/$1 [L]
|
RewriteRule ^(.*) index.php?/$1 [L]
|
||||||
|
|
||||||
#-----------------------------------
|
###-----------------------------------
|
||||||
# nginx
|
### nginx
|
||||||
# rewrite ^(.*) /index.php?/$1 last;
|
# rewrite ^/(?!.well-known)(.*)$ /index.php?/$1 last;
|
||||||
#
|
#
|
||||||
# caddy
|
### caddy
|
||||||
# rewrite {
|
# rewrite {
|
||||||
# to index.php?/$1
|
# to index.php?/$1
|
||||||
# }
|
# }
|
||||||
#-----------------------------------
|
###-----------------------------------
|
||||||
|
|||||||
+2886
File diff suppressed because it is too large
Load Diff
+121
-38
@@ -1,16 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
global $exts;
|
||||||
|
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', 'wav', 'ogg'];
|
$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', 'bat', 'sh', 'php', 'asp', 'js', 'json', 'html', 'c', 'md', 'py'];
|
$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'];
|
$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 = [
|
||||||
'languages' => [
|
'languages' => [
|
||||||
'en-us' => 'English',
|
'en-us' => 'English',
|
||||||
'zh-cn' => '中文',
|
'zh-cn' => '简体中文',
|
||||||
'ja' => '日本語',
|
'ja' => '日本語',
|
||||||
'ko-kr' => '한국어',
|
'ko-kr' => '한국어',
|
||||||
'fa' => 'فارسی',
|
'fa' => 'فارسی',
|
||||||
@@ -66,14 +69,24 @@ $constStr = [
|
|||||||
'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 \'?admin\', it is \'?{this value}\'.',
|
'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.',
|
||||||
|
'autoJumpFirstDisk' => 'used in multy disks, if 1, auto jump to first disk',
|
||||||
|
'customScript' => '<script> in all pages, e.g. http turn to https',
|
||||||
|
'customCss' => '<style> in <head>',
|
||||||
|
'customTheme' => 'an url of html',
|
||||||
'domain_path' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2',
|
'domain_path' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2',
|
||||||
'diskname' => 'The disk name you want show.',
|
'diskname' => 'The disk name you want show.',
|
||||||
'disktag' => 'A tag used in store config and url.',
|
'disktag' => 'A tag used in store config and url.',
|
||||||
|
'disableShowThumb' => 'if 1, the ShowThumbnail button will not display',
|
||||||
|
'disableChangeTheme' => 'if 1, the Theme selection button will not display',
|
||||||
'downloadencrypt' => '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',
|
||||||
'background' => 'Set an url as background photo, or put a \'background.jpg\' at showed path.',
|
'background' => 'Set an url as background photo.',
|
||||||
|
'backgroundm' => 'Set an url as background in mobile phone.',
|
||||||
|
'theme' => 'Select theme.',
|
||||||
|
'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' => '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 dir 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',
|
||||||
'public_path' => 'Show this Onedrive dir when through the long url of API Gateway; public show files less than private.',
|
'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',
|
'Onedrive_ver' => 'Onedrive version',
|
||||||
@@ -81,14 +94,24 @@ $constStr = [
|
|||||||
'zh-cn' => [
|
'zh-cn' => [
|
||||||
'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
|
'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
|
||||||
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
|
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
|
||||||
|
'autoJumpFirstDisk' => '用于多盘,如果设1,将会自动跳到第一个盘。',
|
||||||
|
'customScript' => '<script>,在所有页都会存在,例如放一个http跳转https',
|
||||||
|
'customCss' => '<style>,在<head>最后面',
|
||||||
|
'customTheme' => 'html格式的主题的url',
|
||||||
'domain_path' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。',
|
'domain_path' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。',
|
||||||
'diskname' => '这个盘你想显示什么名称。',
|
'diskname' => '这个盘你想显示什么名称。',
|
||||||
'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。',
|
'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。',
|
||||||
|
'disableShowThumb' => '如果填 1, ‘显示缩略’按钮将被隐藏。',
|
||||||
|
'disableChangeTheme' => '如果填 1, 主题选择切换将被隐藏',
|
||||||
'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
|
'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
|
||||||
'background' => '设置一个url作为背景,或者在你显示的目录放一个background.jpg文件。',
|
'background' => '设置一个url作为背景。',
|
||||||
|
'backgroundm' => '设置一个url作为手机用的背景。',
|
||||||
|
'theme' => '选择一个主题。',
|
||||||
|
'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=原域名',
|
||||||
'public_path' => '使用API长链接访问时,显示网盘文件的路径,不设置时默认为根目录;不能是private_path的上级(public看到的不能比private多,要么看到的就不一样)。',
|
'public_path' => '使用API长链接访问时,显示网盘文件的路径,不设置时默认为根目录;不能是private_path的上级(public看到的不能比private多,要么看到的就不一样)。',
|
||||||
'sitename' => '网站的名称',
|
'sitename' => '网站的名称',
|
||||||
'Onedrive_ver' => 'Onedrive版本',
|
'Onedrive_ver' => 'Onedrive版本',
|
||||||
@@ -114,7 +137,7 @@ $constStr = [
|
|||||||
'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?',
|
'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?',
|
||||||
'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.',
|
'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.',
|
||||||
'downloadencrypt' => '',
|
'downloadencrypt' => '',
|
||||||
'background' => 'URL을 배경으로 설정하거나 표시하는 디렉토리에 background.jpg 파일을 넣으십시오.',
|
'background' => 'URL을 배경으로 설정하거나 표시하는.',
|
||||||
'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).',
|
'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).',
|
||||||
'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.',
|
'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.',
|
||||||
'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.',
|
'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.',
|
||||||
@@ -178,7 +201,7 @@ $constStr = [
|
|||||||
'ko-kr' => '로그인',
|
'ko-kr' => '로그인',
|
||||||
'fa' => 'ورود',
|
'fa' => 'ورود',
|
||||||
],
|
],
|
||||||
'encrypt' => [
|
'Encrypt' => [
|
||||||
'en-us' => 'Encrypt',
|
'en-us' => 'Encrypt',
|
||||||
'zh-cn' => '加密',
|
'zh-cn' => '加密',
|
||||||
'ja' => '暗号化',
|
'ja' => '暗号化',
|
||||||
@@ -190,7 +213,7 @@ $constStr = [
|
|||||||
'zh-cn' => '先在环境变量设置passfile才能加密',
|
'zh-cn' => '先在环境变量设置passfile才能加密',
|
||||||
'ja' => '最初に暗号化する環境変数にパスファイルを設定します',
|
'ja' => '最初に暗号化する環境変数にパスファイルを設定します',
|
||||||
'ko-kr' => '암호화하기 전에 환경 변수에 패스 파일을 설정하십시오',
|
'ko-kr' => '암호화하기 전에 환경 변수에 패스 파일을 설정하십시오',
|
||||||
'fa' => 'قبل از رمزگذاری \ "pass file \" را در محیط تنظیم کنید',
|
'fa' => 'قبل از رمزگذاری \"pass file \" را در محیط تنظیم کنید',
|
||||||
],
|
],
|
||||||
'updateProgram' => [
|
'updateProgram' => [
|
||||||
'en-us' => 'Update Program',
|
'en-us' => 'Update Program',
|
||||||
@@ -220,6 +243,10 @@ $constStr = [
|
|||||||
'ko-kr' => '돌아 가기',
|
'ko-kr' => '돌아 가기',
|
||||||
'fa' => 'بازگشت',
|
'fa' => 'بازگشت',
|
||||||
],
|
],
|
||||||
|
'Theme' => [
|
||||||
|
'en-us' => 'Theme',
|
||||||
|
'zh-cn' => '主题',
|
||||||
|
],
|
||||||
'NotNeedUpdate' => [
|
'NotNeedUpdate' => [
|
||||||
'en-us' => 'Not Need Update',
|
'en-us' => 'Not Need Update',
|
||||||
'zh-cn' => '不需要更新',
|
'zh-cn' => '不需要更新',
|
||||||
@@ -255,6 +282,14 @@ $constStr = [
|
|||||||
'ko-kr' => '홈',
|
'ko-kr' => '홈',
|
||||||
'fa' => 'خانه',
|
'fa' => 'خانه',
|
||||||
],
|
],
|
||||||
|
'Preview' => [
|
||||||
|
'en-us' => 'Preview',
|
||||||
|
'zh-cn' => '预览',
|
||||||
|
],
|
||||||
|
'List' => [
|
||||||
|
'en-us' => 'List',
|
||||||
|
'zh-cn' => '列表',
|
||||||
|
],
|
||||||
'NeedUpdate' => [
|
'NeedUpdate' => [
|
||||||
'en-us' => 'Program can update<br>Click setup in Operate at top.',
|
'en-us' => 'Program can update<br>Click setup in Operate at top.',
|
||||||
'zh-cn' => '可以升级程序<br>在上方管理菜单中<br>进入设置页面升级',
|
'zh-cn' => '可以升级程序<br>在上方管理菜单中<br>进入设置页面升级',
|
||||||
@@ -325,6 +360,10 @@ $constStr = [
|
|||||||
'ko-kr' => '사진 섬네일',
|
'ko-kr' => '사진 섬네일',
|
||||||
'fa' => 'تصویر بندانگشتی',
|
'fa' => 'تصویر بندانگشتی',
|
||||||
],
|
],
|
||||||
|
'OriginalPic' => [
|
||||||
|
'en-us' => 'OriginalPic',
|
||||||
|
'zh-cn' => '原图',
|
||||||
|
],
|
||||||
'CopyAllDownloadUrl' => [
|
'CopyAllDownloadUrl' => [
|
||||||
'en-us' => 'CopyAllDownloadUrl',
|
'en-us' => 'CopyAllDownloadUrl',
|
||||||
'zh-cn' => '复制所有下载链接',
|
'zh-cn' => '复制所有下载链接',
|
||||||
@@ -332,6 +371,10 @@ $constStr = [
|
|||||||
'ko-kr' => '모든 다운로드 링크 복사',
|
'ko-kr' => '모든 다운로드 링크 복사',
|
||||||
'fa' => 'کپی از تمام لینک ها',
|
'fa' => 'کپی از تمام لینک ها',
|
||||||
],
|
],
|
||||||
|
'Search' => [
|
||||||
|
'en-us' => 'Search',
|
||||||
|
'zh-cn' => '搜索',
|
||||||
|
],
|
||||||
'EditTime' => [
|
'EditTime' => [
|
||||||
'en-us' => 'EditTime',
|
'en-us' => 'EditTime',
|
||||||
'zh-cn' => '修改时间',
|
'zh-cn' => '修改时间',
|
||||||
@@ -402,6 +445,14 @@ $constStr = [
|
|||||||
'ko-kr' => '업로드',
|
'ko-kr' => '업로드',
|
||||||
'fa' => 'آپلود',
|
'fa' => 'آپلود',
|
||||||
],
|
],
|
||||||
|
'UploadFile' => [
|
||||||
|
'en-us' => 'Upload File(s)',
|
||||||
|
'zh-cn' => '上传文件',
|
||||||
|
],
|
||||||
|
'UploadFolder' => [
|
||||||
|
'en-us' => 'Upload Folder',
|
||||||
|
'zh-cn' => '上传文件夹',
|
||||||
|
],
|
||||||
'FileSelected' => [
|
'FileSelected' => [
|
||||||
'en-us' => 'Select File',
|
'en-us' => 'Select File',
|
||||||
'zh-cn' => '选择文件',
|
'zh-cn' => '选择文件',
|
||||||
@@ -486,6 +537,10 @@ $constStr = [
|
|||||||
'ko-kr' => '업로드 링크 받기',
|
'ko-kr' => '업로드 링크 받기',
|
||||||
'fa' => 'دریافت لینک آپلود',
|
'fa' => 'دریافت لینک آپلود',
|
||||||
],
|
],
|
||||||
|
'Calculate' => [
|
||||||
|
'en-us' => 'Calculate',
|
||||||
|
'zh-cn' => '计算',
|
||||||
|
],
|
||||||
'UpFileTooLarge' => [
|
'UpFileTooLarge' => [
|
||||||
'en-us' => 'The File is too Large!',
|
'en-us' => 'The File is too Large!',
|
||||||
'zh-cn' => '文件过大,终止上传。',
|
'zh-cn' => '文件过大,终止上传。',
|
||||||
@@ -572,10 +627,6 @@ $constStr = [
|
|||||||
],
|
],
|
||||||
'defaultSitename' => [
|
'defaultSitename' => [
|
||||||
'en-us' => 'OneManager',
|
'en-us' => 'OneManager',
|
||||||
'zh-cn' => 'OneManager',
|
|
||||||
'ja' => 'OneManager',
|
|
||||||
'ko-kr' => 'OneManager',
|
|
||||||
'fa' => 'OneManager',
|
|
||||||
],
|
],
|
||||||
'SavingToken' => [
|
'SavingToken' => [
|
||||||
'en-us' => 'Saving refresh_token!',
|
'en-us' => 'Saving refresh_token!',
|
||||||
@@ -585,11 +636,11 @@ $constStr = [
|
|||||||
'fa' => 'در حال ذخیره refresh_token!',
|
'fa' => 'در حال ذخیره refresh_token!',
|
||||||
],
|
],
|
||||||
'MayinEnv' => [
|
'MayinEnv' => [
|
||||||
'en-us' => 'The \'Onedrive_ver\' may in Config',
|
'en-us' => 'The \'Drive_ver\' may in Config',
|
||||||
'zh-cn' => 'Onedrive_ver应该已经写入',
|
'zh-cn' => 'Drive_ver应该已经写入',
|
||||||
'ja' => 'Onedrive_verは環境変数に書き込まれている必要があります',
|
'ja' => 'Drive_verは環境変数に書き込まれている必要があります',
|
||||||
'ko-kr' => 'Onedrive_verが書き込まれている必要があります',
|
'ko-kr' => 'Drive_verが書き込まれている必要があります',
|
||||||
'fa' => 'The \'Onedrive_ver\' may in Config',
|
'fa' => 'The \'Drive_ver\' may in Config',
|
||||||
],
|
],
|
||||||
'Wait' => [
|
'Wait' => [
|
||||||
'en-us' => 'Wait',
|
'en-us' => 'Wait',
|
||||||
@@ -626,62 +677,78 @@ $constStr = [
|
|||||||
'ko-kr' => 'Onedrive 표시 이름',
|
'ko-kr' => 'Onedrive 표시 이름',
|
||||||
'fa' => 'نام نشان داده شده Onedrive',
|
'fa' => 'نام نشان داده شده Onedrive',
|
||||||
],
|
],
|
||||||
'OndriveVerMS' => [
|
'DriveVerMS' => [
|
||||||
'en-us' => 'default(Onedrive, Onedrive for business)',
|
'en-us' => 'Onedrive, Onedrive for business',
|
||||||
'zh-cn' => '默认(支持商业版与个人版)',
|
'zh-cn' => '国际版(商业版与个人版)',
|
||||||
'ja' => 'デフォルト(商用版および個人版をサポート)',
|
|
||||||
'ko-kr' => '기본 (상업용 및 개인용 버전 지원)',
|
|
||||||
'fa' => 'پیش فرض(Onedrive, Onedrive for business)',
|
|
||||||
],
|
],
|
||||||
'OndriveVerCN' => [
|
'DriveVerCN' => [
|
||||||
'en-us' => 'Onedrive in China',
|
'en-us' => 'Onedrive in China',
|
||||||
'zh-cn' => '世纪互联版',
|
'zh-cn' => '世纪互联版',
|
||||||
'ja' => '中国のOnedrive',
|
'ja' => '中国のOnedrive',
|
||||||
'ko-kr' => '중국 Onedrive',
|
'ko-kr' => '중국 Onedrive',
|
||||||
'fa' => 'Onedrive در چین',
|
'fa' => 'Onedrive در چین',
|
||||||
],
|
],
|
||||||
'OndriveVerMSC' =>[
|
'DriveVerShareurl' => [
|
||||||
'en-us' => 'default but use customer app id & secret',
|
'en-us' => 'A share link of a folder',
|
||||||
'zh-cn' => '国际版,自己申请应用ID与机密',
|
'zh-cn' => '共享链接',
|
||||||
'ja' => '国際版、アプリケーションIDとシークレットを自分で申請する',
|
],
|
||||||
'ko-kr' => '국제 버전, 응용 프로그램 ID 및 비밀 신청',
|
'UseShareLink' => [
|
||||||
|
'en-us' => 'Share a folder in Onedrive (enable EDIT for everyone), input the link url below.',
|
||||||
|
'zh-cn' => '对一个Onedrive文件夹共享,允许所有人编辑,然后将共享链接填在下方',
|
||||||
|
],
|
||||||
|
'CustomIdSecret' => [
|
||||||
|
'en-us' => 'Use custom client id & secret instead of OneManager default',
|
||||||
|
'zh-cn' => '自己申请应用ID与机密,不用OneManager默认的',
|
||||||
|
'ja' => 'アプリケーションIDとシークレットを自分で申請する',
|
||||||
|
'ko-kr' => '응용 프로그램 ID 및 비밀 신청',
|
||||||
'fa' => 'به طور پیش فرض اما از شناسه برنامه و سکرت استفاده کنید',
|
'fa' => 'به طور پیش فرض اما از شناسه برنامه و سکرت استفاده کنید',
|
||||||
],
|
],
|
||||||
'GetSecretIDandKEY' =>[
|
'GetSecretIDandKEY' => [
|
||||||
'en-us' => 'Get customer app id & secret',
|
'en-us' => 'Get custom client id & secret',
|
||||||
'zh-cn' => '申请应用ID与机密',
|
'zh-cn' => '申请应用ID与机密',
|
||||||
'ja' => 'アプリケーションIDとシークレット',
|
'ja' => 'アプリケーションIDとシークレット',
|
||||||
'fa' => 'دریافت شناسه برنامه و سکرت',
|
'fa' => 'دریافت شناسه برنامه و سکرت',
|
||||||
],
|
],
|
||||||
'TagFormatAlert' =>[
|
'UseSharepointInstead' => [
|
||||||
|
'en-us' => 'Use space in Sharepoint website instead of Onedrive',
|
||||||
|
'zh-cn' => '使用Sharepoint网站的空间,不使用Onedrive',
|
||||||
|
],
|
||||||
|
'GetSharepointSiteAddress' => [
|
||||||
|
'en-us' => 'Login office.com and click the SharePoint, create a website or find an exist website, input the Site address below',
|
||||||
|
'zh-cn' => '登录office.com,点击Sharepoint,创建一个网站(或使用原有网站),然后将它的站点地址填在下方',
|
||||||
|
],
|
||||||
|
'InputSharepointSiteAddress' => [
|
||||||
|
'en-us' => 'https://xxxxx.sharepoint.com/sites(teams)/{name}',
|
||||||
|
],
|
||||||
|
'TagFormatAlert' => [
|
||||||
'en-us' => 'Tag must start with a letter, end with a letter or digit and can only contain lowercase letters, digits, and dashes, at least 2 letters!',
|
'en-us' => 'Tag must start with a letter, end with a letter or digit and can only contain lowercase letters, digits, and dashes, at least 2 letters!',
|
||||||
'zh-cn' => '标签只能以字母开头,以字母或数字结尾,至少2位',
|
'zh-cn' => '标签只能以字母开头,以字母或数字结尾,至少2位',
|
||||||
'ja' => 'タグは、文字で始まり、文字または数字で終わる必要があります。少なくとも2つ',
|
'ja' => 'タグは、文字で始まり、文字または数字で終わる必要があります。少なくとも2つ',
|
||||||
'ko-kr' => '태그는 문자로 시작하고 문자 또는 숫자로 끝나야합니다 (2 이상).',
|
'ko-kr' => '태그는 문자로 시작하고 문자 또는 숫자로 끝나야합니다 (2 이상).',
|
||||||
'fa' => 'برچسب باید با یک حرف شروع شود، با یک حرف یا رقم پایان یابد و تنها میتواند حاوی حروف کوچک، ارقام و خط فاصله، حداقل ۲ حرف باشد!',
|
'fa' => 'برچسب باید با یک حرف شروع شود، با یک حرف یا رقم پایان یابد و تنها میتواند حاوی حروف کوچک، ارقام و خط فاصله، حداقل ۲ حرف باشد!',
|
||||||
],
|
],
|
||||||
'ClickInstall' =>[
|
'ClickInstall' => [
|
||||||
'en-us' => 'Click to install the project',
|
'en-us' => 'Click to install the project',
|
||||||
'zh-cn' => '点击开始安装程序',
|
'zh-cn' => '点击开始安装程序',
|
||||||
'ja' => 'クリックしてインストールプロセスを開始します',
|
'ja' => 'クリックしてインストールプロセスを開始します',
|
||||||
'ko-kr' => '설치 과정을 시작하려면 클릭',
|
'ko-kr' => '설치 과정을 시작하려면 클릭',
|
||||||
'fa' => 'برای نصب پروژه کلیک کنید',
|
'fa' => 'برای نصب پروژه کلیک کنید',
|
||||||
],
|
],
|
||||||
'LogintoBind' =>[
|
'LogintoBind' => [
|
||||||
'en-us' => 'then login and bind your onedrive in setup',
|
'en-us' => 'then login and bind your onedrive in setup',
|
||||||
'zh-cn' => '然后登录后在设置中绑定你的onedrive。',
|
'zh-cn' => '然后登录后在设置中绑定你的onedrive。',
|
||||||
'ja' => '次に、ログインして、設定でonedriveをバインドします。',
|
'ja' => '次に、ログインして、設定でonedriveをバインドします。',
|
||||||
'ko-kr' => '그런 다음 로그인하여 onedrive를 설정에 바인딩하십시오.',
|
'ko-kr' => '그런 다음 로그인하여 onedrive를 설정에 바인딩하십시오.',
|
||||||
'fa' => 'پس از آن وارد سیستم شوید و تنظیمات خود را در onedrive متصل کنید',
|
'fa' => 'پس از آن وارد سیستم شوید و تنظیمات خود را در onedrive متصل کنید',
|
||||||
],
|
],
|
||||||
'MakesuerWriteable' =>[
|
'MakesuerWriteable' => [
|
||||||
'en-us' => 'Plase make sure the config.php is writeable. run writeable.sh.',
|
'en-us' => 'Plase make sure the config.php is writeable. run writeable.sh.',
|
||||||
'zh-cn' => '确认config.php可写。',
|
'zh-cn' => '确认config.php可写。',
|
||||||
'ja' => 'config.phpが書き込み可能であることを確認してください。',
|
'ja' => 'config.phpが書き込み可能であることを確認してください。',
|
||||||
'ko-kr' => 'config.php가 쓰기 가능한지 확인하십시오.',
|
'ko-kr' => 'config.php가 쓰기 가능한지 확인하십시오.',
|
||||||
'fa' => 'اطمینان حاصل کنید که config.php قابل نوشتن است. writeable.sh را اجرا کنید.',
|
'fa' => 'اطمینان حاصل کنید که config.php قابل نوشتن است. writeable.sh را اجرا کنید.',
|
||||||
],
|
],
|
||||||
'MakesuerRewriteOn' =>[
|
'MakesuerRewriteOn' => [
|
||||||
'en-us' => 'Plase make sure the RewriteEngine is On.',
|
'en-us' => 'Plase make sure the RewriteEngine is On.',
|
||||||
'zh-cn' => '确认重写(伪静态)功能启用。',
|
'zh-cn' => '确认重写(伪静态)功能启用。',
|
||||||
'ja' => '書き換え(擬似静的)機能が有効になっていることを確認します。',
|
'ja' => '書き換え(擬似静的)機能が有効になっていることを確認します。',
|
||||||
@@ -721,4 +788,20 @@ $constStr = [
|
|||||||
'ko-kr' => '캐시 플러시',
|
'ko-kr' => '캐시 플러시',
|
||||||
'fa' => 'رفرش cache',
|
'fa' => 'رفرش cache',
|
||||||
],
|
],
|
||||||
|
'CannotOneKeyUpate' => [
|
||||||
|
'en-us' => 'Can not update by a click! run update.sh',
|
||||||
|
'zh-cn' => '不能一键更新,可以运行update.sh',
|
||||||
|
],
|
||||||
|
'QueryBranchs' => [
|
||||||
|
'en-us' => 'Query Branchs',
|
||||||
|
'zh-cn' => '查询分支',
|
||||||
|
],
|
||||||
|
'ONEMANAGER_CONFIG_SAVE_ENV' => [
|
||||||
|
'en-us' => 'Config save in Environments',
|
||||||
|
'zh-cn' => '配置保存在环境变量',
|
||||||
|
],
|
||||||
|
'ONEMANAGER_CONFIG_SAVE_FILE' => [
|
||||||
|
'en-us' => 'Config save in code file, may cause fee',
|
||||||
|
'zh-cn' => '配置保存在代码文件中,可能产生费用',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
-1474
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
error_reporting(E_ALL & ~E_NOTICE);
|
||||||
include 'vendor/autoload.php';
|
include 'vendor/autoload.php';
|
||||||
include 'conststr.php';
|
include 'conststr.php';
|
||||||
include 'function/common.php';
|
include 'common.php';
|
||||||
|
|
||||||
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
||||||
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
||||||
include 'function/scf.php';
|
if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/TencentSCF_file.php';
|
||||||
|
else include 'platform/TencentSCF_env.php';
|
||||||
|
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
||||||
|
include 'platform/AliyunFC.php';
|
||||||
|
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
|
||||||
|
//if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/HuaweiFG_file.php';
|
||||||
|
//else include 'platform/HuaweiFG_env.php';
|
||||||
|
echo 'FG' . PHP_EOL;
|
||||||
|
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
|
||||||
|
//set_include_path(get_include_path() . PATH_SEPARATOR . '/opt/php');
|
||||||
|
//include 'BaiduBce.phar';
|
||||||
|
include 'platform/BaiduCFC.php';
|
||||||
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
||||||
include 'function/heroku.php';
|
include 'platform/Heroku.php';
|
||||||
$path = getpath();
|
$path = getpath();
|
||||||
//echo 'path:'. $path;
|
//echo 'path:'. $path;
|
||||||
$_GET = getGET();
|
$_GET = getGET();
|
||||||
@@ -20,7 +32,7 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
|||||||
http_response_code($re['statusCode']);
|
http_response_code($re['statusCode']);
|
||||||
echo $re['body'];
|
echo $re['body'];
|
||||||
} else {
|
} else {
|
||||||
include 'function/normal.php';
|
include 'platform/Normal.php';
|
||||||
$path = getpath();
|
$path = getpath();
|
||||||
//echo 'path:'. $path;
|
//echo 'path:'. $path;
|
||||||
$_GET = getGET();
|
$_GET = getGET();
|
||||||
@@ -35,6 +47,7 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
|||||||
echo $re['body'];
|
echo $re['body'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tencent SCF
|
||||||
function main_handler($event, $context)
|
function main_handler($event, $context)
|
||||||
{
|
{
|
||||||
$event = json_decode(json_encode($event), true);
|
$event = json_decode(json_encode($event), true);
|
||||||
@@ -50,3 +63,101 @@ function main_handler($event, $context)
|
|||||||
|
|
||||||
return main($path);
|
return main($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Aliyun FC & Huawei FG & Baidu CFC
|
||||||
|
function handler($event, $context)
|
||||||
|
{
|
||||||
|
if (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
||||||
|
// Aliyun FC
|
||||||
|
set_error_handler("myErrorHandler");
|
||||||
|
$tmp = array(
|
||||||
|
'method' => $event->getMethod(),
|
||||||
|
'clientIP' => $event->getAttribute("clientIP"),
|
||||||
|
'eventURI' => $event->getAttribute("eventURI"),
|
||||||
|
'path' => spurlencode($event->getAttribute("path"), '/'),
|
||||||
|
'queryString' => $event->getQueryParams(),
|
||||||
|
'headers' => $event->getHeaders(),
|
||||||
|
'body' => $event->getBody()->getContents(),
|
||||||
|
);
|
||||||
|
$event = $tmp;
|
||||||
|
$context = json_decode(json_encode($context), true);
|
||||||
|
printInput($event, $context);
|
||||||
|
unset($_POST);
|
||||||
|
unset($_GET);
|
||||||
|
unset($_COOKIE);
|
||||||
|
unset($_SERVER);
|
||||||
|
GetGlobalVariable($event);
|
||||||
|
$path = GetPathSetting($event, $context);
|
||||||
|
|
||||||
|
$re = main($path);
|
||||||
|
|
||||||
|
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['body']);
|
||||||
|
|
||||||
|
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
|
||||||
|
// Huawei FG
|
||||||
|
global $contextUserData;
|
||||||
|
$contextUserData = $context;
|
||||||
|
if ($context->getUserData('ONEMANAGER_CONFIG_SAVE')=='file') include_once 'platform/HuaweiFG_file.php';
|
||||||
|
else include_once 'platform/HuaweiFG_env.php';
|
||||||
|
|
||||||
|
$event = json_decode(json_encode($event), true);
|
||||||
|
if ($event['isBase64Encoded']) $event['body'] = base64_decode($event['body']);
|
||||||
|
|
||||||
|
printInput($event, $context);
|
||||||
|
unset($_POST);
|
||||||
|
unset($_GET);
|
||||||
|
unset($_COOKIE);
|
||||||
|
unset($_SERVER);
|
||||||
|
GetGlobalVariable($event);
|
||||||
|
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
$path = GetPathSetting($event, $context);
|
||||||
|
|
||||||
|
return main($path);
|
||||||
|
|
||||||
|
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
|
||||||
|
// Baidu CFC
|
||||||
|
//$html = '<pre>'. json_encode($event, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
//$html .= '<pre>'. json_encode($context, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
//$html .= '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
//$html .= $event['path'];
|
||||||
|
//$html .= $context['functionBrn'];
|
||||||
|
//return json_encode(output($html), JSON_FORCE_OBJECT);
|
||||||
|
|
||||||
|
printInput($event, $context);
|
||||||
|
unset($_POST);
|
||||||
|
unset($_GET);
|
||||||
|
unset($_COOKIE);
|
||||||
|
unset($_SERVER);
|
||||||
|
GetGlobalVariable($event);
|
||||||
|
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
$path = GetPathSetting($event, $context);
|
||||||
|
|
||||||
|
return json_encode(main($path), JSON_FORCE_OBJECT);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// used by Aliyun FC
|
||||||
|
function myErrorHandler($errno, $errstr, $errfile, $errline) {
|
||||||
|
if (!(error_reporting() & $errno)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch ($errno) {
|
||||||
|
case E_USER_ERROR:
|
||||||
|
$errInfo = array(
|
||||||
|
"errorMessage" => $errstr,
|
||||||
|
"errorType" => \ServerlessFC\friendly_error_type($errno),
|
||||||
|
"stackTrace" => array(
|
||||||
|
"file" => $errfile,
|
||||||
|
"line" => $errline,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // E_USER_WARNING | E_USER_NOTICE
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,447 @@
|
|||||||
|
<?php
|
||||||
|
// https://help.aliyun.com/document_detail/53252.html
|
||||||
|
// https://github.com/aliyun/fc-php-sdk/blob/master/src/AliyunFC/Client.php
|
||||||
|
|
||||||
|
function printInput($event, $context)
|
||||||
|
{
|
||||||
|
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||||
|
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetGlobalVariable($event)
|
||||||
|
{
|
||||||
|
$_GET = $event['queryString'];
|
||||||
|
foreach ($_GET as $k => $v) {
|
||||||
|
if ($v=='') $_GET[$k] = true;
|
||||||
|
}
|
||||||
|
$postbody = explode("&",$event['body']);
|
||||||
|
foreach ($postbody as $postvalues) {
|
||||||
|
$pos = strpos($postvalues,"=");
|
||||||
|
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||||
|
}
|
||||||
|
$cookiebody = explode("; ",$event['headers']['Cookie'][0]);
|
||||||
|
foreach ($cookiebody as $cookievalues) {
|
||||||
|
$pos = strpos($cookievalues,"=");
|
||||||
|
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||||
|
}
|
||||||
|
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetPathSetting($event, $context)
|
||||||
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['Accept-Language'][0],';')[0],',')[0]);
|
||||||
|
$_SERVER['accountId'] = $context['accountId'];
|
||||||
|
$_SERVER['region'] = $context['region'];
|
||||||
|
$_SERVER['service_name'] = $context['service']['name'];
|
||||||
|
$_SERVER['function_name'] = $context['function']['name'];
|
||||||
|
|
||||||
|
$_SERVER['base_path'] = '/';
|
||||||
|
$path = $event['path'];
|
||||||
|
//$path = spurlencode($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['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'][0];
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig($str, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
if (in_array($str, $InnerEnv)) {
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$env = json_decode(getenv($disktag), true);
|
||||||
|
if (isset($env[$str])) {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||||
|
else return $env[$str];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||||
|
else return getenv($str);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfig($arr, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
|
$diskconfig = json_decode(getenv($disktag), true);
|
||||||
|
$tmp = [];
|
||||||
|
$indisk = 0;
|
||||||
|
$oparetdisk = 0;
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if (in_array($k, $InnerEnv)) {
|
||||||
|
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||||
|
else $diskconfig[$k] = $v;
|
||||||
|
$indisk = 1;
|
||||||
|
} elseif ($k=='disktag_add') {
|
||||||
|
array_push($disktags, $v);
|
||||||
|
$oparetdisk = 1;
|
||||||
|
} elseif ($k=='disktag_del') {
|
||||||
|
$disktags = array_diff($disktags, [ $v ]);
|
||||||
|
$tmp[$v] = '';
|
||||||
|
$oparetdisk = 1;
|
||||||
|
} else {
|
||||||
|
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||||
|
else $tmp[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($indisk) {
|
||||||
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
|
ksort($diskconfig);
|
||||||
|
$tmp[$disktag] = json_encode($diskconfig);
|
||||||
|
}
|
||||||
|
if ($oparetdisk) {
|
||||||
|
$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'] = '';
|
||||||
|
}
|
||||||
|
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||||
|
//';
|
||||||
|
$response = updateEnvironment($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], getConfig('AccessKeyID'), getConfig('AccessKeySecret'));
|
||||||
|
//WaitSCFStat();
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
global $constStr;
|
||||||
|
if ($_GET['install2']) {
|
||||||
|
$tmp['admin'] = $_POST['admin'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if (needUpdate()) {
|
||||||
|
OnekeyUpate();
|
||||||
|
return message('update to github version, reinstall.
|
||||||
|
<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=' . $url . '">', 'Program updating', 201);
|
||||||
|
}
|
||||||
|
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 ($_POST['admin']!='') {
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$AccessKeyID = getConfig('AccessKeyID');
|
||||||
|
if ($AccessKeyID=='') {
|
||||||
|
$AccessKeyID = $_POST['AccessKeyID'];
|
||||||
|
$tmp['AccessKeyID'] = $AccessKeyID;
|
||||||
|
}
|
||||||
|
$AccessKeySecret = getConfig('AccessKeySecret');
|
||||||
|
if ($AccessKeySecret=='') {
|
||||||
|
$AccessKeySecret = $_POST['AccessKeySecret'];
|
||||||
|
$tmp['AccessKeySecret'] = $AccessKeySecret;
|
||||||
|
}
|
||||||
|
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
} else {
|
||||||
|
$html .= '
|
||||||
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
|
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||||
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
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" 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>';
|
||||||
|
}
|
||||||
|
if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
|
||||||
|
<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="text" placeholder="" size=""></label><br>';
|
||||||
|
$html .= '
|
||||||
|
<input 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 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 (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
|
||||||
|
if (t.AccessKeyID.value==\'\') {
|
||||||
|
alert(\'input AccessKeyID\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.AccessKeySecret.value==\'\') {
|
||||||
|
alert(\'input SecretKey\');
|
||||||
|
return false;
|
||||||
|
}';
|
||||||
|
$html .= '
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SelectLanguage');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function FCAPI2016($config, $Method, $data = '')
|
||||||
|
{
|
||||||
|
$accountId = $config['accountId'];
|
||||||
|
$region = $config['region'];
|
||||||
|
$service_name = $config['service_name'];
|
||||||
|
$function_name = $config['function_name'];
|
||||||
|
$AccessKeyID = $config['AccessKeyID'];
|
||||||
|
$AccessKeySecret = $config['AccessKeySecret'];
|
||||||
|
|
||||||
|
$host = $accountId . '.' . $region . '-internal.fc.aliyuncs.com';
|
||||||
|
$path = '/2016-08-15/services/' . $service_name . '/functions/' . $function_name;
|
||||||
|
$url = 'https://' . $host . $path;
|
||||||
|
|
||||||
|
$ContentMd5 = '';
|
||||||
|
$ContentType = 'application/json';
|
||||||
|
date_default_timezone_set('UTC'); // unset last timezone setting
|
||||||
|
$Date = substr(gmdate("r", time()), 0, -5) . 'GMT';
|
||||||
|
$CanonicalizedFCHeaders = '';
|
||||||
|
$CanonicalizedResource = $path;
|
||||||
|
|
||||||
|
$signaturestr = $Method . "\n" . $ContentMd5 . "\n" . $ContentType . "\n" . $Date . "\n" . $CanonicalizedFCHeaders . $CanonicalizedResource;
|
||||||
|
$signature = base64_encode(hash_hmac('sha256', $signaturestr, $AccessKeySecret, true));
|
||||||
|
|
||||||
|
$header['Host'] = $host;
|
||||||
|
$header['Date'] = $Date;
|
||||||
|
$header['Content-Type'] = $ContentType;
|
||||||
|
$header['Authorization'] = 'FC ' . $AccessKeyID . ':' . $signature;
|
||||||
|
$header['Content-Length'] = strlen($data);
|
||||||
|
|
||||||
|
//return curl($Method, $url, $data, $header)['body'];
|
||||||
|
$p = 0;
|
||||||
|
while ($response['stat']==0 && $p<3) {
|
||||||
|
$response = curl($Method, $url, $data, $header);
|
||||||
|
$p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response['stat']==0) {
|
||||||
|
$tmp['ErrorCode'] = 'Network Error';
|
||||||
|
$tmp['ErrorMessage'] = 'Can not connect ' . $host;
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
if ($response['stat']!=200) {
|
||||||
|
$tmp = json_decode($response['body'], true);
|
||||||
|
$tmp['ErrorMessage'] .= '<br>' . $response['stat'] . '<br>' . $signaturestr . '<br>' . json_encode($header) . PHP_EOL;
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
return $response['body'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getfunctioninfo($config)
|
||||||
|
{
|
||||||
|
return FCAPI2016($config, 'GET');
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateEnvironment($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
|
||||||
|
{
|
||||||
|
//print_r($Envs);
|
||||||
|
$config['accountId'] = $accountId;
|
||||||
|
$config['region'] = $region;
|
||||||
|
$config['service_name'] = $service_name;
|
||||||
|
$config['function_name'] = $function_name;
|
||||||
|
$config['AccessKeyID'] = $AccessKeyID;
|
||||||
|
$config['AccessKeySecret'] = $AccessKeySecret;
|
||||||
|
|
||||||
|
$tmp = json_decode(getfunctioninfo($config), true);
|
||||||
|
foreach ($tmp['environmentVariables'] as $key => $value ) {
|
||||||
|
$tmp_env[$key] = $value;
|
||||||
|
}
|
||||||
|
foreach ($Envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
|
||||||
|
$tmpdata['environmentVariables'] = $tmp_env;
|
||||||
|
return FCAPI2016($config, 'PUT', json_encode($tmpdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetbaseConfig($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
|
||||||
|
{
|
||||||
|
$config['accountId'] = $accountId;
|
||||||
|
$config['region'] = $region;
|
||||||
|
$config['service_name'] = $service_name;
|
||||||
|
$config['function_name'] = $function_name;
|
||||||
|
$config['AccessKeyID'] = $AccessKeyID;
|
||||||
|
$config['AccessKeySecret'] = $AccessKeySecret;
|
||||||
|
|
||||||
|
$tmp = json_decode(getfunctioninfo($config), true);
|
||||||
|
foreach ($tmp['environmentVariables'] as $key => $value ) {
|
||||||
|
$tmp_env[$key] = $value;
|
||||||
|
}
|
||||||
|
foreach ($Envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
|
||||||
|
$tmpdata['description'] = 'Onedrive index and manager in Aliyun FC.';
|
||||||
|
$tmpdata['memorySize'] = 128;
|
||||||
|
$tmpdata['timeout'] = 30;
|
||||||
|
$tmpdata['environmentVariables'] = $tmp_env;
|
||||||
|
|
||||||
|
return FCAPI2016($config, 'PUT', json_encode($tmpdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProgram($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret, $source)
|
||||||
|
{
|
||||||
|
$config['accountId'] = $accountId;
|
||||||
|
$config['region'] = $region;
|
||||||
|
$config['service_name'] = $service_name;
|
||||||
|
$config['function_name'] = $function_name;
|
||||||
|
$config['AccessKeyID'] = $AccessKeyID;
|
||||||
|
$config['AccessKeySecret'] = $AccessKeySecret;
|
||||||
|
|
||||||
|
$tmp = json_decode(getfunctioninfo($config), true);
|
||||||
|
|
||||||
|
$tmpdata['code']['zipFile'] = base64_encode( file_get_contents($source) );
|
||||||
|
|
||||||
|
return FCAPI2016($config, 'PUT', json_encode($tmpdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error($response)
|
||||||
|
{
|
||||||
|
return isset($response['ErrorMessage']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error_msg($response)
|
||||||
|
{
|
||||||
|
return $response['ErrorCode'] . '<br>
|
||||||
|
' . $response['ErrorMessage'] . '<br><br>
|
||||||
|
|
||||||
|
accountId:' . $_SERVER['accountId'] . '<br>
|
||||||
|
region:' . $_SERVER['region'] . '<br>
|
||||||
|
service_name:' . $_SERVER['service_name'] . '<br>
|
||||||
|
function_name:' . $_SERVER['function_name'] . '<br>
|
||||||
|
|
||||||
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfigResponse($response)
|
||||||
|
{
|
||||||
|
return json_decode($response, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
|
{
|
||||||
|
$source = '/tmp/code.zip';
|
||||||
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
|
$phar = new PharData($tarfile);
|
||||||
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
|
// 获取解压出的目录名
|
||||||
|
/*
|
||||||
|
@ob_start();
|
||||||
|
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
|
||||||
|
$html.='状态:' . $stat . '
|
||||||
|
结果:
|
||||||
|
';
|
||||||
|
$archivefolder = ob_get_clean();
|
||||||
|
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
|
||||||
|
$outPath .= $archivefolder;
|
||||||
|
$html.=htmlspecialchars($archivefolder);
|
||||||
|
//return $html;
|
||||||
|
*/
|
||||||
|
$tmp = scandir($outPath);
|
||||||
|
$name = $auth.'-'.$project;
|
||||||
|
foreach ($tmp as $f) {
|
||||||
|
if ( substr($f, 0, strlen($name)) == $name) {
|
||||||
|
$outPath .= $f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将目录中文件打包成zip
|
||||||
|
$zip=new ZipArchive();
|
||||||
|
if($zip->open($source, ZipArchive::CREATE)){
|
||||||
|
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||||
|
$zip->close(); //关闭处理的zip文件
|
||||||
|
}
|
||||||
|
|
||||||
|
return updateProgram($_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], getConfig('AccessKeyID'), getConfig('AccessKeySecret'), $source);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFileToZip($zip, $rootpath, $path = '')
|
||||||
|
{
|
||||||
|
if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
|
||||||
|
if (substr($path,0,1)=='/') $path = substr($path, 1);
|
||||||
|
$handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
|
||||||
|
while($filename=readdir($handler)){
|
||||||
|
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||||
|
$nowname = path_format($rootpath.'/'.$path."/".$filename);
|
||||||
|
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
|
||||||
|
addFileToZip($zip, $rootpath, $path."/".$filename);
|
||||||
|
}else{ //将文件加入zip对象
|
||||||
|
$zip->addFile($nowname);
|
||||||
|
$newname = $path."/".$filename;
|
||||||
|
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
|
||||||
|
$zip->renameName($nowname, $newname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@closedir($path);
|
||||||
|
}
|
||||||
@@ -0,0 +1,407 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function printInput($event, $context)
|
||||||
|
{
|
||||||
|
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||||
|
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetGlobalVariable($event)
|
||||||
|
{
|
||||||
|
$_GET = $event['queryStringParameters'];
|
||||||
|
foreach ($_GET as $k => $v) {
|
||||||
|
if ($v == '') $_GET[$k] = true;
|
||||||
|
}
|
||||||
|
$postbody = explode("&",$event['body']);
|
||||||
|
foreach ($postbody as $postvalues) {
|
||||||
|
$pos = strpos($postvalues,"=");
|
||||||
|
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||||
|
}
|
||||||
|
$cookiebody = explode("; ",$event['headers']['Cookie']);
|
||||||
|
foreach ($cookiebody as $cookievalues) {
|
||||||
|
$pos = strpos($cookievalues,"=");
|
||||||
|
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||||
|
}
|
||||||
|
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['User-Agent'];
|
||||||
|
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||||
|
$_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetPathSetting($event, $context)
|
||||||
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['Accept-Language'],';')[0],',')[0]);
|
||||||
|
$_SERVER['functionBrn'] = $context['functionBrn'];
|
||||||
|
$_SERVER['base_path'] = '/';
|
||||||
|
$path = $event['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['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'];
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig($str, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
if (in_array($str, $InnerEnv)) {
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$env = json_decode(getenv($disktag), true);
|
||||||
|
if (isset($env[$str])) {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||||
|
else return $env[$str];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||||
|
else return getenv($str);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfig($arr, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
|
$diskconfig = json_decode(getenv($disktag), true);
|
||||||
|
$tmp = [];
|
||||||
|
$indisk = 0;
|
||||||
|
$oparetdisk = 0;
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if (in_array($k, $InnerEnv)) {
|
||||||
|
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||||
|
else $diskconfig[$k] = $v;
|
||||||
|
$indisk = 1;
|
||||||
|
} elseif ($k=='disktag_add') {
|
||||||
|
array_push($disktags, $v);
|
||||||
|
$oparetdisk = 1;
|
||||||
|
} elseif ($k=='disktag_del') {
|
||||||
|
$disktags = array_diff($disktags, [ $v ]);
|
||||||
|
$tmp[$v] = '';
|
||||||
|
$oparetdisk = 1;
|
||||||
|
} else {
|
||||||
|
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||||
|
else $tmp[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($indisk) {
|
||||||
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
|
ksort($diskconfig);
|
||||||
|
$tmp[$disktag] = json_encode($diskconfig);
|
||||||
|
}
|
||||||
|
if ($oparetdisk) {
|
||||||
|
$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'] = '';
|
||||||
|
}
|
||||||
|
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||||
|
//';
|
||||||
|
$response = updateEnvironment($tmp, getConfig('SecretId'), getConfig('SecretKey'));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
global $constStr;
|
||||||
|
if ($_GET['install2']) {
|
||||||
|
$tmp['admin'] = $_POST['admin'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if (needUpdate()) {
|
||||||
|
OnekeyUpate();
|
||||||
|
return message('update to github version, reinstall.
|
||||||
|
<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=' . $url . '">', 'Program updating', 201);
|
||||||
|
}
|
||||||
|
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']) {
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$SecretId = getConfig('SecretId');
|
||||||
|
if ($SecretId=='') {
|
||||||
|
$SecretId = $_POST['SecretId'];
|
||||||
|
$tmp['SecretId'] = $SecretId;
|
||||||
|
}
|
||||||
|
$SecretKey = getConfig('SecretKey');
|
||||||
|
if ($SecretKey=='') {
|
||||||
|
$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, 201);
|
||||||
|
} else {
|
||||||
|
$html .= '
|
||||||
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
|
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||||
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
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" 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>';
|
||||||
|
}
|
||||||
|
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||||
|
<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="text" placeholder="" size=""></label><br>';
|
||||||
|
$html .= '
|
||||||
|
<input 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 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 (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||||
|
if (t.SecretId.value==\'\') {
|
||||||
|
alert(\'input Access Key\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.SecretKey.value==\'\') {
|
||||||
|
alert(\'input Secret Key\');
|
||||||
|
return false;
|
||||||
|
}';
|
||||||
|
$html .= '
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SelectLanguage');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CFCAPIv1($Brn, $AccessKey, $SecretKey, $Method, $End, $data = '')
|
||||||
|
{
|
||||||
|
// brn:bce:cfc:bj:c094b1ca1XXXXXXXXb8dea6ab482:function:fdsa:$LATEST
|
||||||
|
$BRN = explode(':', $Brn);
|
||||||
|
if ( !($BRN[0]=='brn' && $BRN[1]=='bce' && $BRN[2]=='cfc') ) {
|
||||||
|
$tmp['code'] = 'BRN Error';
|
||||||
|
$tmp['message'] = 'The BRN expect start with "brn:bce:cfc:", given: ' . $Brn . ' .';
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
$Region = $BRN[3];
|
||||||
|
//$project_id = $BRN[4];
|
||||||
|
$FunctionName = $BRN[6];
|
||||||
|
$host = 'cfc.' . $Region . '.baidubce.com';
|
||||||
|
date_default_timezone_set('UTC'); // unset last timezone setting
|
||||||
|
$timestamp = date('Y-m-d\TH:i:s\Z');
|
||||||
|
//date_default_timezone_set(get_timezone($_SERVER['timezone']));
|
||||||
|
$authStringPrefix = 'bce-auth-v1/' . $AccessKey . '/' . $timestamp . '/1800' ;
|
||||||
|
$path = '/v1/functions/' . $FunctionName . '/' . $End;
|
||||||
|
$CanonicalURI = spurlencode($path, '/');
|
||||||
|
$CanonicalQueryString = '';
|
||||||
|
$CanonicalHeaders = 'host:' . $host;
|
||||||
|
$CanonicalRequest = $Method . "\n" . $CanonicalURI . "\n" . $CanonicalQueryString . "\n" . $CanonicalHeaders;
|
||||||
|
$SigningKey = hash_hmac('sha256', $authStringPrefix, $SecretKey);
|
||||||
|
$Signature = hash_hmac('sha256', $CanonicalRequest, $SigningKey);
|
||||||
|
$authorization = $authStringPrefix . '/host/' . $Signature;
|
||||||
|
|
||||||
|
$p = 0;
|
||||||
|
while ($response['stat']==0 && $p<3) {
|
||||||
|
$response = curl(
|
||||||
|
$Method,
|
||||||
|
'https://' . $host . $path,
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'Authorization' => $authorization,
|
||||||
|
'Content-type' => 'application/json'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response['stat']==0) {
|
||||||
|
$tmp['code'] = 'Network Error';
|
||||||
|
$tmp['message'] = 'Can not connect ' . $host;
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
if ($response['stat']!=200) {
|
||||||
|
$tmp = json_decode($response['body'], true);
|
||||||
|
$tmp['message'] .= '<br>' . $response['stat'] . '<br>' . $timestamp . PHP_EOL;
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
return $response['body'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getfunctioninfo($SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'GET', 'configuration');
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateEnvironment($Envs, $SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
$FunctionConfig = json_decode(getfunctioninfo($SecretId, $SecretKey), true);
|
||||||
|
$tmp_env = $FunctionConfig['Environment']['Variables'];
|
||||||
|
foreach ($Envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
|
||||||
|
$tmp['Environment']['Variables'] = $tmp_env;
|
||||||
|
$data = json_encode($tmp);
|
||||||
|
|
||||||
|
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'configuration', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetbaseConfig($Envs, $SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
$FunctionConfig = json_decode(getfunctioninfo($SecretId, $SecretKey), true);
|
||||||
|
$tmp_env = $FunctionConfig['Environment']['Variables'];
|
||||||
|
foreach ($Envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
|
||||||
|
$tmp['Timeout'] = 30;
|
||||||
|
$tmp['Description'] = 'Onedrive index and manager in Baidu CFC.';
|
||||||
|
$tmp['Environment']['Variables'] = $tmp_env;
|
||||||
|
$data = json_encode($tmp);
|
||||||
|
|
||||||
|
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'configuration', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProgram($SecretId, $SecretKey, $source)
|
||||||
|
{
|
||||||
|
$tmp['ZipFile'] = base64_encode( file_get_contents($source) );
|
||||||
|
$data = json_encode($tmp);
|
||||||
|
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'code', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error($response)
|
||||||
|
{
|
||||||
|
//return isset($response['code']);
|
||||||
|
return !(isset($response['FunctionBrn']) && $response['FunctionBrn'] == $_SERVER['functionBrn']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error_msg($response)
|
||||||
|
{
|
||||||
|
if (isset($response['code'])) $html = $response['code'] . '<br>
|
||||||
|
' . $response['message'];
|
||||||
|
else $html = var_dump($response);
|
||||||
|
return $html . '<br><br>
|
||||||
|
BRN: ' . $_SERVER['functionBrn'] . '<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')
|
||||||
|
{
|
||||||
|
$source = '/tmp/code.zip';
|
||||||
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
|
$phar = new PharData($tarfile);
|
||||||
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
|
// 获取包中目录名
|
||||||
|
$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=new ZipArchive();
|
||||||
|
$zip=new PharData($source);
|
||||||
|
//if($zip->open($source, ZipArchive::CREATE)){
|
||||||
|
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||||
|
// $zip->close(); //关闭处理的zip文件
|
||||||
|
//}
|
||||||
|
|
||||||
|
return updateProgram(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($path);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
function getpath()
|
function getpath()
|
||||||
{
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||||
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
@@ -45,11 +46,11 @@ function getConfig($str, $disktag = '')
|
|||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
$env = json_decode(getenv($disktag), true);
|
$env = json_decode(getenv($disktag), true);
|
||||||
if (isset($env[$str])) {
|
if (isset($env[$str])) {
|
||||||
if (in_array($str, $Base64Env)) return equal_replace($env[$str],1);
|
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||||
else return $env[$str];
|
else return $env[$str];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1);
|
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||||
else return getenv($str);
|
else return getenv($str);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
@@ -67,7 +68,7 @@ function setConfig($arr, $disktag = '')
|
|||||||
$oparetdisk = 0;
|
$oparetdisk = 0;
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
if (in_array($k, $InnerEnv)) {
|
if (in_array($k, $InnerEnv)) {
|
||||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v);
|
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||||
else $diskconfig[$k] = $v;
|
else $diskconfig[$k] = $v;
|
||||||
$indisk = 1;
|
$indisk = 1;
|
||||||
} elseif ($k=='disktag_add') {
|
} elseif ($k=='disktag_add') {
|
||||||
@@ -78,7 +79,7 @@ function setConfig($arr, $disktag = '')
|
|||||||
$tmp[$v] = '';
|
$tmp[$v] = '';
|
||||||
$oparetdisk = 1;
|
$oparetdisk = 1;
|
||||||
} else {
|
} else {
|
||||||
if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v);
|
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||||
else $tmp[$k] = $v;
|
else $tmp[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,7 +106,8 @@ function install()
|
|||||||
if ($_GET['install1']) {
|
if ($_GET['install1']) {
|
||||||
if ($_POST['admin']!='') {
|
if ($_POST['admin']!='') {
|
||||||
$tmp['admin'] = $_POST['admin'];
|
$tmp['admin'] = $_POST['admin'];
|
||||||
$tmp['language'] = $_POST['language'];
|
//$tmp['language'] = $_POST['language'];
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
$APIKey = getConfig('APIKey');
|
$APIKey = getConfig('APIKey');
|
||||||
if ($APIKey=='') {
|
if ($APIKey=='') {
|
||||||
$APIKey = $_POST['APIKey'];
|
$APIKey = $_POST['APIKey'];
|
||||||
@@ -124,7 +126,14 @@ function install()
|
|||||||
$html = api_error_msg($response);
|
$html = api_error_msg($response);
|
||||||
$title = 'Error';
|
$title = 'Error';
|
||||||
} else {
|
} else {
|
||||||
return output('Jump<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
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);
|
||||||
}
|
}
|
||||||
return message($html, $title, 201);
|
return message($html, $title, 201);
|
||||||
}
|
}
|
||||||
@@ -146,9 +155,18 @@ language:<br>';
|
|||||||
<input type="submit" value="'.getconstStr('Submit').'">
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<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 changelanguage(str)
|
function changelanguage(str)
|
||||||
{
|
{
|
||||||
document.cookie=\'language=\'+str+\'; path=/\';
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||||
location.href = location.href;
|
location.href = location.href;
|
||||||
}
|
}
|
||||||
function notnull(t)
|
function notnull(t)
|
||||||
@@ -219,9 +237,9 @@ function setHerokuConfig($env, $function_name, $apikey)
|
|||||||
return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
|
return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHerokuapp($function_name, $apikey)
|
function updateHerokuapp($function_name, $apikey, $source)
|
||||||
{
|
{
|
||||||
$tmp['source_blob']['url'] = 'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
|
$tmp['source_blob']['url'] = $source;
|
||||||
$data = json_encode($tmp);
|
$data = json_encode($tmp);
|
||||||
return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey);
|
return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey);
|
||||||
}
|
}
|
||||||
@@ -239,9 +257,11 @@ 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()
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true);
|
//'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
|
||||||
|
$source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
return updateHerokuapp(getConfig('function_name'), getConfig('APIKey'), $source);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfigResponse($response)
|
function setConfigResponse($response)
|
||||||
@@ -0,0 +1,464 @@
|
|||||||
|
<?php
|
||||||
|
global $contextUserData;
|
||||||
|
|
||||||
|
function printInput($event, $context)
|
||||||
|
{
|
||||||
|
$tmp['eventID'] = $context->geteventID();
|
||||||
|
$tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
|
||||||
|
$tmp['AccessKey'] = $context->getAccessKey();
|
||||||
|
$tmp['SecretKey'] = $context->getSecretKey();
|
||||||
|
$tmp['UserData']['HW_urn'] = $context->getUserData('HW_urn');
|
||||||
|
$tmp['FunctionName'] = $context->getFunctionName();
|
||||||
|
$tmp['RunningTimeInSeconds'] = $context->getRunningTimeInSeconds();
|
||||||
|
$tmp['Version'] = $context->getVersion();
|
||||||
|
$tmp['MemorySize'] = $context->getMemorySize();
|
||||||
|
$tmp['CPUNumber'] = $context->getCPUNumber();
|
||||||
|
$tmp['ProjectID'] = $context->getProjectID();
|
||||||
|
$tmp['Package'] = $context->Package();
|
||||||
|
$tmp['Token'] = $context->getToken();
|
||||||
|
$tmp['Logger'] = $context->getLogger();
|
||||||
|
|
||||||
|
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||||
|
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
' . urldecode(json_encode($tmp, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetGlobalVariable($event)
|
||||||
|
{
|
||||||
|
$_GET = $event['queryStringParameters'];
|
||||||
|
$postbody = explode("&",$event['body']);
|
||||||
|
foreach ($postbody as $postvalues) {
|
||||||
|
$pos = strpos($postvalues,"=");
|
||||||
|
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||||
|
}
|
||||||
|
$cookiebody = explode("; ",$event['headers']['cookie']);
|
||||||
|
foreach ($cookiebody as $cookievalues) {
|
||||||
|
$pos = strpos($cookievalues,"=");
|
||||||
|
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||||
|
}
|
||||||
|
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||||
|
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||||
|
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetPathSetting($event, $context)
|
||||||
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||||
|
$_SERVER['function_name'] = $context->getFunctionName();
|
||||||
|
$_SERVER['ProjectID'] = $context->getProjectID();
|
||||||
|
$host_name = $event['headers']['host'];
|
||||||
|
$_SERVER['HTTP_HOST'] = $host_name;
|
||||||
|
$path = path_format($event['pathParameters'][''].'/');
|
||||||
|
$_SERVER['base_path'] = path_format($event['path'].'/');
|
||||||
|
if ( $_SERVER['base_path'] == $path ) {
|
||||||
|
$_SERVER['base_path'] = '/';
|
||||||
|
} else {
|
||||||
|
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
|
||||||
|
if ($_SERVER['base_path']=='') $_SERVER['base_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['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig($str, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
global $contextUserData;
|
||||||
|
if (in_array($str, $InnerEnv)) {
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$env = json_decode($contextUserData->getUserData($disktag), true);
|
||||||
|
if (isset($env[$str])) {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||||
|
else return $env[$str];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($contextUserData->getUserData($str));
|
||||||
|
else return $contextUserData->getUserData($str);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfig($arr, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
global $contextUserData;
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
|
$diskconfig = json_decode($contextUserData->getUserData($disktag), true);
|
||||||
|
$tmp = [];
|
||||||
|
$indisk = 0;
|
||||||
|
$oparetdisk = 0;
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if (in_array($k, $InnerEnv)) {
|
||||||
|
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||||
|
else $diskconfig[$k] = $v;
|
||||||
|
$indisk = 1;
|
||||||
|
} elseif ($k=='disktag_add') {
|
||||||
|
array_push($disktags, $v);
|
||||||
|
$oparetdisk = 1;
|
||||||
|
} elseif ($k=='disktag_del') {
|
||||||
|
$disktags = array_diff($disktags, [ $v ]);
|
||||||
|
$tmp[$v] = '';
|
||||||
|
$oparetdisk = 1;
|
||||||
|
} else {
|
||||||
|
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||||
|
else $tmp[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($indisk) {
|
||||||
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
|
ksort($diskconfig);
|
||||||
|
$tmp[$disktag] = json_encode($diskconfig);
|
||||||
|
}
|
||||||
|
if ($oparetdisk) {
|
||||||
|
$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'] = '';
|
||||||
|
}
|
||||||
|
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||||
|
//';
|
||||||
|
$response = updateEnvironment($tmp, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
global $constStr;
|
||||||
|
global $contextUserData;
|
||||||
|
if ($_GET['install2']) {
|
||||||
|
$tmp['admin'] = $_POST['admin'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if (needUpdate()) {
|
||||||
|
OnekeyUpate();
|
||||||
|
return message('update to github version, reinstall.
|
||||||
|
<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=' . $url . '">', 'Program updating', 201);
|
||||||
|
}
|
||||||
|
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 ($_POST['admin']!='') {
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$tmp['HW_urn'] = getConfig('HW_urn');
|
||||||
|
if ($tmp['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_secret'] = getConfig('HW_secret');
|
||||||
|
if ($tmp['HW_secret']=='') {
|
||||||
|
$tmp['HW_secret'] = $_POST['HW_secret'];
|
||||||
|
}
|
||||||
|
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
|
||||||
|
//$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']) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
} else {
|
||||||
|
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
|
||||||
|
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||||
|
$title = 'Reinstall';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '
|
||||||
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
|
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||||
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
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" 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>';
|
||||||
|
}
|
||||||
|
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||||
|
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<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>,新增访问密钥,
|
||||||
|
在下载的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="text" placeholder="" size=""></label><br>';
|
||||||
|
$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" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||||
|
$html .= '
|
||||||
|
<input 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 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 (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||||
|
if (t.HW_urn.value==\'\') {
|
||||||
|
alert(\'input URN\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.HW_key.value==\'\') {
|
||||||
|
alert(\'input name\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.HW_secret.value==\'\') {
|
||||||
|
alert(\'input pwd\');
|
||||||
|
return false;
|
||||||
|
}';
|
||||||
|
$html .= '
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SelectLanguage');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function FGAPIV2($HW_urn, $HW_key, $HW_secret, $Method, $End, $data = '')
|
||||||
|
{
|
||||||
|
if ($HW_urn==''||$HW_key==''||$HW_secret=='') {
|
||||||
|
$tmp['error_code'] = 'Config Error';
|
||||||
|
$tmp['error_msg'] = 'HW urn or access key id or secret is empty.';
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
$URN = explode(':', $HW_urn);
|
||||||
|
$Region = $URN[2];
|
||||||
|
$project_id = $URN[3];
|
||||||
|
|
||||||
|
$host = 'functiongraph.' . $Region . '.myhuaweicloud.com';
|
||||||
|
$path = '/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/' . $End;
|
||||||
|
$url = 'https://' . $host . $path;
|
||||||
|
$CanonicalURI = spurlencode($path, '/') . '/';
|
||||||
|
$CanonicalQueryString = '';
|
||||||
|
|
||||||
|
date_default_timezone_set('UTC'); // unset last timezone setting
|
||||||
|
$timestamp = date('Ymd\THis\Z');
|
||||||
|
$header['X-Sdk-Date'] = $timestamp;
|
||||||
|
$header['Host'] = $host;
|
||||||
|
$header['Content-Type'] = 'application/json;charset=utf8';
|
||||||
|
ksort($header);
|
||||||
|
$CanonicalHeaders = '';
|
||||||
|
$SignedHeaders = '';
|
||||||
|
foreach ($header as $key => $value) {
|
||||||
|
$CanonicalHeaders .= strtolower($key) . ':' . $value . "\n";
|
||||||
|
$SignedHeaders .= strtolower($key) . ';';
|
||||||
|
}
|
||||||
|
$SignedHeaders = substr($SignedHeaders, 0, -1);
|
||||||
|
$Hashedbody = hash("sha256", $data);
|
||||||
|
$CanonicalRequest = $Method . "\n" . $CanonicalURI . "\n" . $CanonicalQueryString . "\n" . $CanonicalHeaders . "\n" . $SignedHeaders . "\n" . $Hashedbody;
|
||||||
|
$HashedCanonicalRequest = hash("sha256", $CanonicalRequest);
|
||||||
|
$Algorithm = 'SDK-HMAC-SHA256';
|
||||||
|
$StringToSign = $Algorithm . "\n" . $timestamp . "\n" . $HashedCanonicalRequest;
|
||||||
|
$signature = hash_hmac("sha256", $StringToSign, $HW_secret);
|
||||||
|
$Authorization = "$Algorithm Access=$HW_key, SignedHeaders=$SignedHeaders, Signature=$signature";
|
||||||
|
$header['Authorization'] = $Authorization;
|
||||||
|
|
||||||
|
//return curl($Method, $url, $data, $header)['body']; // . $CanonicalRequest;
|
||||||
|
$p = 0;
|
||||||
|
while ($response['stat']==0 && $p<3) {
|
||||||
|
$response = curl($Method, $url, $data, $header);
|
||||||
|
$p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response['stat']==0) {
|
||||||
|
$tmp['error_code'] = 'Network Error';
|
||||||
|
$tmp['error_msg'] = 'Can not connect ' . $host;
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
if ($response['stat']!=200) {
|
||||||
|
$tmp = json_decode($response['body'], true);
|
||||||
|
$tmp['error_code'] .= '.';
|
||||||
|
$tmp['error_msg'] .= '<br>' . $response['stat'] . '<br>' . $CanonicalRequest . '<br>' . json_encode($header) . PHP_EOL;
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
return $response['body'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getfunctioninfo($HW_urn, $HW_key, $HW_secret)
|
||||||
|
{
|
||||||
|
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'GET', 'config');
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
|
{
|
||||||
|
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||||
|
global $contextUserData;
|
||||||
|
$tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
|
||||||
|
foreach ($Envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
|
||||||
|
$tmpdata['handler'] = 'index.handler';
|
||||||
|
$tmpdata['memory_size'] = $contextUserData->getMemorySize()+1-1;
|
||||||
|
$tmpdata['runtime'] = 'PHP7.3';
|
||||||
|
$tmpdata['timeout'] = $contextUserData->getRunningTimeInSeconds()+1-1;
|
||||||
|
$tmpdata['user_data'] = json_encode($tmp_env);
|
||||||
|
|
||||||
|
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'config', json_encode($tmpdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
|
{
|
||||||
|
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||||
|
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||||
|
$tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
|
||||||
|
foreach ($Envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
|
||||||
|
$tmpdata['handler'] = 'index.handler';
|
||||||
|
$tmpdata['memory_size'] = 128;
|
||||||
|
$tmpdata['runtime'] = 'PHP7.3';
|
||||||
|
$tmpdata['timeout'] = 30;
|
||||||
|
$tmpdata['description'] = 'Onedrive index and manager in Huawei FG.';
|
||||||
|
$tmpdata['user_data'] = json_encode($tmp_env);
|
||||||
|
|
||||||
|
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'config', json_encode($tmpdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProgram($HW_urn, $HW_key, $HW_secret, $source)
|
||||||
|
{
|
||||||
|
$tmpdata['code_type'] = 'zip';
|
||||||
|
$tmpdata['func_code']['file'] = base64_encode( file_get_contents($source) );
|
||||||
|
|
||||||
|
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'code', json_encode($tmpdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error($response)
|
||||||
|
{
|
||||||
|
return isset($response['error_msg']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error_msg($response)
|
||||||
|
{
|
||||||
|
return $response['error_code'] . '<br>
|
||||||
|
' . $response['error_msg'] . '<br>
|
||||||
|
request_id: ' . $response['request_id'] . '<br><br>
|
||||||
|
function_name: ' . $_SERVER['function_name'] . '<br>
|
||||||
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfigResponse($response)
|
||||||
|
{
|
||||||
|
return json_decode( $response, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
|
{
|
||||||
|
$source = '/tmp/code.zip';
|
||||||
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
|
$phar = new PharData($tarfile);
|
||||||
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
|
// 获取解压出的目录名
|
||||||
|
$tmp = scandir($outPath);
|
||||||
|
$name = $auth.'-'.$project;
|
||||||
|
foreach ($tmp as $f) {
|
||||||
|
if ( substr($f, 0, strlen($name)) == $name) {
|
||||||
|
$outPath .= $f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将目录中文件打包成zip
|
||||||
|
//$zip=new ZipArchive();
|
||||||
|
$zip=new PharData($source);
|
||||||
|
//if($zip->open($source, ZipArchive::CREATE)){
|
||||||
|
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||||
|
// $zip->close(); //关闭处理的zip文件
|
||||||
|
//}
|
||||||
|
|
||||||
|
return updateProgram(getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'), $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($path);
|
||||||
|
}
|
||||||
@@ -0,0 +1,840 @@
|
|||||||
|
<?php
|
||||||
|
global $contextUserData;
|
||||||
|
|
||||||
|
function printInput($event, $context)
|
||||||
|
{
|
||||||
|
$tmp['eventID'] = $context->geteventID();
|
||||||
|
$tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
|
||||||
|
$tmp['AccessKey'] = $context->getAccessKey();
|
||||||
|
$tmp['SecretKey'] = $context->getSecretKey();
|
||||||
|
$tmp['UserData']['HW_urn'] = $context->getUserData('HW_urn');
|
||||||
|
$tmp['FunctionName'] = $context->getFunctionName();
|
||||||
|
$tmp['RunningTimeInSeconds'] = $context->getRunningTimeInSeconds();
|
||||||
|
$tmp['Version'] = $context->getVersion();
|
||||||
|
$tmp['MemorySize'] = $context->getMemorySize();
|
||||||
|
$tmp['CPUNumber'] = $context->getCPUNumber();
|
||||||
|
$tmp['ProjectID'] = $context->getProjectID();
|
||||||
|
$tmp['Package'] = $context->Package();
|
||||||
|
$tmp['Token'] = $context->getToken();
|
||||||
|
$tmp['Logger'] = $context->getLogger();
|
||||||
|
|
||||||
|
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||||
|
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
' . urldecode(json_encode($tmp, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetGlobalVariable($event)
|
||||||
|
{
|
||||||
|
$_GET = $event['queryStringParameters'];
|
||||||
|
$postbody = explode("&",$event['body']);
|
||||||
|
foreach ($postbody as $postvalues) {
|
||||||
|
$pos = strpos($postvalues,"=");
|
||||||
|
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||||
|
}
|
||||||
|
$cookiebody = explode("; ",$event['headers']['cookie']);
|
||||||
|
foreach ($cookiebody as $cookievalues) {
|
||||||
|
$pos = strpos($cookievalues,"=");
|
||||||
|
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||||
|
}
|
||||||
|
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||||
|
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||||
|
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetPathSetting($event, $context)
|
||||||
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||||
|
$_SERVER['function_name'] = $context->getFunctionName();
|
||||||
|
$_SERVER['ProjectID'] = $context->getProjectID();
|
||||||
|
$host_name = $event['headers']['host'];
|
||||||
|
$_SERVER['HTTP_HOST'] = $host_name;
|
||||||
|
$path = path_format($event['pathParameters'][''].'/');
|
||||||
|
$_SERVER['base_path'] = path_format($event['path'].'/');
|
||||||
|
if ( $_SERVER['base_path'] == $path ) {
|
||||||
|
$_SERVER['base_path'] = '/';
|
||||||
|
} else {
|
||||||
|
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
|
||||||
|
if ($_SERVER['base_path']=='') $_SERVER['base_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['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig($str, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
//include 'config.php';
|
||||||
|
$s = file_get_contents(__DIR__ . '/../config.php');
|
||||||
|
//$configs = substr($s, 18, -2);
|
||||||
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
|
if ($configs!='') {
|
||||||
|
$envs = json_decode($configs, true);
|
||||||
|
if (in_array($str, $InnerEnv)) {
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
if (isset($envs[$disktag][$str])) {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||||
|
else return $envs[$disktag][$str];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isset($envs[$str])) {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
|
||||||
|
else return $envs[$str];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfig($arr, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
//include 'config.php';
|
||||||
|
$s = file_get_contents(__DIR__ . '/../config.php');
|
||||||
|
//$configs = substr($s, 18, -2);
|
||||||
|
$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 (in_array($k, $InnerEnv)) {
|
||||||
|
if (in_array($k, $Base64Env)) $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;
|
||||||
|
} else {
|
||||||
|
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||||
|
else $envs[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($indisk) {
|
||||||
|
$diskconfig = $envs[$disktag];
|
||||||
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
|
ksort($diskconfig);
|
||||||
|
$envs[$disktag] = $diskconfig;
|
||||||
|
}
|
||||||
|
if ($operatedisk) {
|
||||||
|
$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');
|
||||||
|
ksort($envs);
|
||||||
|
$response = updateEnvironment($envs, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
global $constStr;
|
||||||
|
global $contextUserData;
|
||||||
|
if ($_GET['install2']) {
|
||||||
|
$tmp['admin'] = $_POST['admin'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if (needUpdate()) {
|
||||||
|
OnekeyUpate();
|
||||||
|
return message('update to github version, reinstall.
|
||||||
|
<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=' . $url . '">', 'Program updating', 201);
|
||||||
|
}
|
||||||
|
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 ($_POST['admin']!='') {
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$tmp['HW_urn'] = getConfig('HW_urn');
|
||||||
|
if ($tmp['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_secret'] = getConfig('HW_secret');
|
||||||
|
if ($tmp['HW_secret']=='') {
|
||||||
|
$tmp['HW_secret'] = $_POST['HW_secret'];
|
||||||
|
}
|
||||||
|
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
|
||||||
|
//return message($html, $title, 201);
|
||||||
|
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
} else {
|
||||||
|
if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
|
||||||
|
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||||
|
$title = 'Reinstall';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '
|
||||||
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
|
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||||
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
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" 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>';
|
||||||
|
}
|
||||||
|
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||||
|
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<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>,新增访问密钥,
|
||||||
|
在下载的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="text" placeholder="" size=""></label><br>';
|
||||||
|
$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" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||||
|
$html .= '
|
||||||
|
<input 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 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 (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||||
|
if (t.HW_urn.value==\'\') {
|
||||||
|
alert(\'input URN\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.HW_key.value==\'\') {
|
||||||
|
alert(\'input name\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.HW_secret.value==\'\') {
|
||||||
|
alert(\'input pwd\');
|
||||||
|
return false;
|
||||||
|
}';
|
||||||
|
$html .= '
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SelectLanguage');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getfunctioninfo($HW_urn, $HW_key, $HW_secret)
|
||||||
|
{
|
||||||
|
$URN = explode(':', $HW_urn);
|
||||||
|
$Region = $URN[2];
|
||||||
|
$project_id = $URN[3];
|
||||||
|
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/config';
|
||||||
|
$signer = new Signer();
|
||||||
|
$signer->Key = $HW_key;
|
||||||
|
$signer->Secret = $HW_secret;
|
||||||
|
$req = new Request('GET', $url);
|
||||||
|
$req->headers = array(
|
||||||
|
'content-type' => 'application/json;charset=utf8',
|
||||||
|
);
|
||||||
|
$req->body = '';
|
||||||
|
$curl = $signer->Sign($req);
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($curl);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getfunctioncode($HW_urn, $HW_key, $HW_secret)
|
||||||
|
{
|
||||||
|
$URN = explode(':', $HW_urn);
|
||||||
|
$Region = $URN[2];
|
||||||
|
$project_id = $URN[3];
|
||||||
|
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/code';
|
||||||
|
$signer = new Signer();
|
||||||
|
$signer->Key = $HW_key;
|
||||||
|
$signer->Secret = $HW_secret;
|
||||||
|
$req = new Request('GET', $url);
|
||||||
|
$req->headers = array(
|
||||||
|
'content-type' => 'application/json;charset=utf8',
|
||||||
|
);
|
||||||
|
$req->body = '';
|
||||||
|
$curl = $signer->Sign($req);
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($curl);
|
||||||
|
//return $response;
|
||||||
|
$url = json_decode($response, true)['func_code']['link'];
|
||||||
|
// return $url;
|
||||||
|
|
||||||
|
|
||||||
|
$bucket = splitfirst( splitfirst($url, '//')[1], '.')[0];
|
||||||
|
$path = splitfirst( splitfirst($url, '//')[1], '/')[1];
|
||||||
|
$date = gmdate('D, d M Y H:i:s') . ' GMT';
|
||||||
|
//$date = 'Wed, 05 Aug 2020 06:34:50 GMT';
|
||||||
|
$StringToSign = 'GET
|
||||||
|
' . '
|
||||||
|
' . '
|
||||||
|
' . '
|
||||||
|
' . 'x-obs-date:' . $date . '
|
||||||
|
' . '/' . $bucket . '/' . $path;
|
||||||
|
|
||||||
|
$signature = base64_encode(hash_hmac('sha1', $StringToSign, $HW_secret, true));
|
||||||
|
$response = curl_request($url, false, [ 'Authorization' => 'OBS ' . $HW_key . ':' . $signature, 'x-obs-date' => $date, 'Content-Type' => '' ]);
|
||||||
|
//if ($response['stat']==200) return $response['body'];
|
||||||
|
if ($response['stat']==0) return json_encode( [ 'error_code' => 'Network', 'error_msg' => 'Network error in getting code.' ] );
|
||||||
|
else return $response['body'];
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
$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 updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
|
{
|
||||||
|
|
||||||
|
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||||
|
global $contextUserData;
|
||||||
|
$source = '/tmp/code.zip';
|
||||||
|
$outPath = '/tmp/code/';
|
||||||
|
$oldcode = '/tmp/oldcode.zip';
|
||||||
|
|
||||||
|
// 获取当前代码,并解压
|
||||||
|
$coderoot = __DIR__ . '/../';
|
||||||
|
|
||||||
|
copyFolder($coderoot, $outPath);
|
||||||
|
|
||||||
|
// 将配置写入
|
||||||
|
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||||
|
$aftstr = PHP_EOL . '\';';
|
||||||
|
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||||
|
|
||||||
|
// 将目录中文件打包成zip
|
||||||
|
//$zip=new ZipArchive();
|
||||||
|
$zip=new PharData($source);
|
||||||
|
//if($zip->open($source, ZipArchive::CREATE)){
|
||||||
|
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||||
|
// $zip->close(); //关闭处理的zip文件
|
||||||
|
//}
|
||||||
|
|
||||||
|
return updateProgram($HW_urn, $HW_key, $HW_secret, $source);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
|
{
|
||||||
|
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||||
|
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||||
|
else {
|
||||||
|
$Envs['ONEMANAGER_CONFIG_SAVE'] == '';
|
||||||
|
$envs = $Envs;
|
||||||
|
$tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
|
||||||
|
foreach ($envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
$envs = $tmp_env;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://functiongraph.cn-north-4.myhuaweicloud.com/v2/{project_id}/fgs/functions/{function_urn}/config
|
||||||
|
$URN = explode(':', $HW_urn);
|
||||||
|
$Region = $URN[2];
|
||||||
|
$project_id = $URN[3];
|
||||||
|
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/config';
|
||||||
|
$signer = new Signer();
|
||||||
|
$signer->Key = $HW_key;
|
||||||
|
$signer->Secret = $HW_secret;
|
||||||
|
$req = new Request('PUT', $url);
|
||||||
|
$req->headers = array(
|
||||||
|
'content-type' => 'application/json;charset=utf8',
|
||||||
|
);
|
||||||
|
$tmpdata['handler'] = 'index.handler';
|
||||||
|
$tmpdata['memory_size'] = 128;
|
||||||
|
$tmpdata['runtime'] = 'PHP7.3';
|
||||||
|
$tmpdata['timeout'] = 30;
|
||||||
|
$tmpdata['description'] = 'Onedrive index and manager in Huawei FG.';
|
||||||
|
$tmpdata['user_data'] = json_encode($envs);
|
||||||
|
$req->body = json_encode($tmpdata);
|
||||||
|
$curl = $signer->Sign($req);
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($curl);
|
||||||
|
//return $response;
|
||||||
|
if (api_error(setConfigResponse($response))) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
$s = file_get_contents(__DIR__ . '/../config.php');
|
||||||
|
//$configs = substr($s, 18, -2);
|
||||||
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
|
if ($configs!='') $tmp_env = json_decode($configs, true);
|
||||||
|
foreach ($Envs as $k => $v) {
|
||||||
|
$tmp_env[$k] = $v;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null');
|
||||||
|
ksort($tmp_env);
|
||||||
|
$response = updateEnvironment($tmp_env, $HW_urn, $HW_key, $HW_secret);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProgram($HW_urn, $HW_key, $HW_secret, $source)
|
||||||
|
{
|
||||||
|
$URN = explode(':', $HW_urn);
|
||||||
|
$Region = $URN[2];
|
||||||
|
$project_id = $URN[3];
|
||||||
|
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/code';
|
||||||
|
$signer = new Signer();
|
||||||
|
$signer->Key = $HW_key;
|
||||||
|
$signer->Secret = $HW_secret;
|
||||||
|
$req = new Request('PUT', $url);
|
||||||
|
$req->headers = array(
|
||||||
|
'content-type' => 'application/json;charset=utf8',
|
||||||
|
);
|
||||||
|
$tmpdata['code_type'] = 'zip';
|
||||||
|
$tmpdata['func_code']['file'] = base64_encode( file_get_contents($source) );
|
||||||
|
$req->body = json_encode($tmpdata);
|
||||||
|
$curl = $signer->Sign($req);
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($curl);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error($response)
|
||||||
|
{
|
||||||
|
return isset($response['error_code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error_msg($response)
|
||||||
|
{
|
||||||
|
return $response['error_code'] . '<br>
|
||||||
|
' . $response['error_msg'] . '<br>
|
||||||
|
request_id: ' . $response['request_id'] . '<br><br>
|
||||||
|
function_name: ' . $_SERVER['function_name'] . '<br>
|
||||||
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfigResponse($response)
|
||||||
|
{
|
||||||
|
return json_decode( $response, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
|
{
|
||||||
|
$source = '/tmp/code.zip';
|
||||||
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
|
$phar = new PharData($tarfile);
|
||||||
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
|
// 获取解压出的目录名
|
||||||
|
/*
|
||||||
|
@ob_start();
|
||||||
|
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
|
||||||
|
$html.='状态:' . $stat . '
|
||||||
|
结果:
|
||||||
|
';
|
||||||
|
$archivefolder = ob_get_clean();
|
||||||
|
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
|
||||||
|
$outPath .= $archivefolder;
|
||||||
|
$html.=htmlspecialchars($archivefolder);
|
||||||
|
//return $html;
|
||||||
|
*/
|
||||||
|
$tmp = scandir($outPath);
|
||||||
|
$name = $auth.'-'.$project;
|
||||||
|
foreach ($tmp as $f) {
|
||||||
|
if ( substr($f, 0, strlen($name)) == $name) {
|
||||||
|
$outPath .= $f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 放入配置文件
|
||||||
|
file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
|
||||||
|
|
||||||
|
// 将目录中文件打包成zip
|
||||||
|
//$zip=new ZipArchive();
|
||||||
|
$zip=new PharData($source);
|
||||||
|
//if($zip->open($source, ZipArchive::CREATE)){
|
||||||
|
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||||
|
// $zip->close(); //关闭处理的zip文件
|
||||||
|
//}
|
||||||
|
|
||||||
|
return updateProgram(getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'), $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($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
define("BasicDateFormat", "Ymd\THis\Z");
|
||||||
|
define("Algorithm", "SDK-HMAC-SHA256");
|
||||||
|
define("HeaderXDate", "X-Sdk-Date");
|
||||||
|
define("HeaderHost", "host");
|
||||||
|
define("HeaderAuthorization", "Authorization");
|
||||||
|
define("HeaderContentSha256", "X-Sdk-Content-Sha256");
|
||||||
|
|
||||||
|
class Request
|
||||||
|
{
|
||||||
|
public $method = '';
|
||||||
|
public $scheme = '';
|
||||||
|
public $host = '';
|
||||||
|
public $uri = '';
|
||||||
|
public $query = array();
|
||||||
|
public $headers = array();
|
||||||
|
public $body = '';
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$args = func_get_args();
|
||||||
|
$i = count($args);
|
||||||
|
if ($i == 0) {
|
||||||
|
$this->construct(NULL, NULL, NULL, NULL);
|
||||||
|
} elseif ($i == 1) {
|
||||||
|
$this->construct($args[0], NULL, NULL, NULL);
|
||||||
|
} elseif ($i == 2) {
|
||||||
|
$this->construct($args[0], $args[1], NULL, NULL);
|
||||||
|
} elseif ($i == 3) {
|
||||||
|
$this->construct($args[0], $args[1], $args[2], NULL);
|
||||||
|
} else {
|
||||||
|
$this->construct($args[0], $args[1], $args[2], $args[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function construct($method, $url, $headers, $body)
|
||||||
|
{
|
||||||
|
if ($method != NULL) {
|
||||||
|
$this->method = $method;
|
||||||
|
}
|
||||||
|
if ($url != NULL) {
|
||||||
|
$spl = explode("://", $url, 2);
|
||||||
|
$scheme = 'http';
|
||||||
|
if (count($spl) > 1) {
|
||||||
|
$scheme = $spl[0];
|
||||||
|
$url = $spl[1];
|
||||||
|
}
|
||||||
|
$spl = explode("?", $url, 2);
|
||||||
|
$url = $spl[0];
|
||||||
|
$query = array();
|
||||||
|
if (count($spl) > 1) {
|
||||||
|
foreach (explode("&", $spl[1]) as $kv) {
|
||||||
|
$spl = explode("=", $kv, 2);
|
||||||
|
$key = $spl[0];
|
||||||
|
if (count($spl) == 1) {
|
||||||
|
$value = "";
|
||||||
|
} else {
|
||||||
|
$value = $spl[1];
|
||||||
|
}
|
||||||
|
if ($key != "") {
|
||||||
|
$key = urldecode($key);
|
||||||
|
$value = urldecode($value);
|
||||||
|
if (array_key_exists($key, $query)) {
|
||||||
|
array_push($query[$key], $value);
|
||||||
|
} else {
|
||||||
|
$query[$key] = array($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$spl = explode("/", $url, 2);
|
||||||
|
$host = $spl[0];
|
||||||
|
if (count($spl) == 1) {
|
||||||
|
$url = "/";
|
||||||
|
} else {
|
||||||
|
$url = "/" . $spl[1];
|
||||||
|
}
|
||||||
|
$this->scheme = $scheme;
|
||||||
|
$this->host = $host;
|
||||||
|
$this->uri = urldecode($url);
|
||||||
|
$this->query = $query;
|
||||||
|
}
|
||||||
|
if ($headers != NULL) {
|
||||||
|
$this->headers = $headers;
|
||||||
|
}
|
||||||
|
if ($body != NULL) {
|
||||||
|
$this->body = $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Signer
|
||||||
|
{
|
||||||
|
public $Key = '';
|
||||||
|
public $Secret = '';
|
||||||
|
|
||||||
|
function escape($string)
|
||||||
|
{
|
||||||
|
$entities = array('+', "%7E");
|
||||||
|
$replacements = array('%20', "~");
|
||||||
|
return str_replace($entities, $replacements, urlencode($string));
|
||||||
|
}
|
||||||
|
|
||||||
|
function findHeader($r, $header)
|
||||||
|
{
|
||||||
|
foreach ($r->headers as $key => $value) {
|
||||||
|
if (!strcasecmp($key, $header)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build a CanonicalRequest from a regular request string
|
||||||
|
//
|
||||||
|
// CanonicalRequest =
|
||||||
|
// HTTPRequestMethod + '\n' +
|
||||||
|
// CanonicalURI + '\n' +
|
||||||
|
// CanonicalQueryString + '\n' +
|
||||||
|
// CanonicalHeaders + '\n' +
|
||||||
|
// SignedHeaders + '\n' +
|
||||||
|
// HexEncode(Hash(RequestPayload))
|
||||||
|
function CanonicalRequest($r, $signedHeaders)
|
||||||
|
{
|
||||||
|
$CanonicalURI = $this->CanonicalURI($r);
|
||||||
|
$CanonicalQueryString = $this->CanonicalQueryString($r);
|
||||||
|
$canonicalHeaders = $this->CanonicalHeaders($r, $signedHeaders);
|
||||||
|
$signedHeadersString = join(";", $signedHeaders);
|
||||||
|
$hash = $this->findHeader($r, HeaderContentSha256);
|
||||||
|
if (!$hash) {
|
||||||
|
$hash = hash("sha256", $r->body);
|
||||||
|
}
|
||||||
|
return "$r->method\n$CanonicalURI\n$CanonicalQueryString\n$canonicalHeaders\n$signedHeadersString\n$hash";
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanonicalURI returns request uri
|
||||||
|
function CanonicalURI($r)
|
||||||
|
{
|
||||||
|
$pattens = explode("/", $r->uri);
|
||||||
|
$uri = array();
|
||||||
|
foreach ($pattens as $v) {
|
||||||
|
array_push($uri, $this->escape($v));
|
||||||
|
}
|
||||||
|
$urlpath = join("/", $uri);
|
||||||
|
if (substr($urlpath, -1) != "/") {
|
||||||
|
$urlpath = $urlpath . "/";
|
||||||
|
}
|
||||||
|
return $urlpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanonicalQueryString
|
||||||
|
function CanonicalQueryString($r)
|
||||||
|
{
|
||||||
|
$keys = array();
|
||||||
|
foreach ($r->query as $key => $value) {
|
||||||
|
array_push($keys, $key);
|
||||||
|
}
|
||||||
|
sort($keys);
|
||||||
|
$a = array();
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$k = $this->escape($key);
|
||||||
|
$value = $r->query[$key];
|
||||||
|
if (is_array($value)) {
|
||||||
|
sort($value);
|
||||||
|
foreach ($value as $v) {
|
||||||
|
$kv = "$k=" . $this->escape($v);
|
||||||
|
array_push($a, $kv);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$kv = "$k=" . $this->escape($value);
|
||||||
|
array_push($a, $kv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return join("&", $a);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanonicalHeaders
|
||||||
|
function CanonicalHeaders($r, $signedHeaders)
|
||||||
|
{
|
||||||
|
$headers = array();
|
||||||
|
foreach ($r->headers as $key => $value) {
|
||||||
|
$headers[strtolower($key)] = trim($value);
|
||||||
|
}
|
||||||
|
$a = array();
|
||||||
|
foreach ($signedHeaders as $key) {
|
||||||
|
array_push($a, $key . ':' . $headers[$key]);
|
||||||
|
}
|
||||||
|
return join("\n", $a) . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function curlHeaders($r)
|
||||||
|
{
|
||||||
|
$header = array();
|
||||||
|
foreach ($r->headers as $key => $value) {
|
||||||
|
array_push($header, strtolower($key) . ':' . trim($value));
|
||||||
|
}
|
||||||
|
return $header;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignedHeaders
|
||||||
|
function SignedHeaders($r)
|
||||||
|
{
|
||||||
|
$a = array();
|
||||||
|
foreach ($r->headers as $key => $value) {
|
||||||
|
array_push($a, strtolower($key));
|
||||||
|
}
|
||||||
|
sort($a);
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a "String to Sign".
|
||||||
|
function StringToSign($canonicalRequest, $t)
|
||||||
|
{
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
$date = date(BasicDateFormat, $t);
|
||||||
|
$hash = hash("sha256", $canonicalRequest);
|
||||||
|
return "SDK-HMAC-SHA256\n$date\n$hash";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the HWS Signature.
|
||||||
|
function SignStringToSign($stringToSign, $signingKey)
|
||||||
|
{
|
||||||
|
return hash_hmac("sha256", $stringToSign, $signingKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the finalized value for the "Authorization" header. The signature parameter is the output from SignStringToSign
|
||||||
|
function AuthHeaderValue($signature, $accessKey, $signedHeaders)
|
||||||
|
{
|
||||||
|
$signedHeadersString = join(";", $signedHeaders);
|
||||||
|
return "SDK-HMAC-SHA256 Access=$accessKey, SignedHeaders=$signedHeadersString, Signature=$signature";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Sign($r)
|
||||||
|
{
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
$date = $this->findHeader($r, HeaderXDate);
|
||||||
|
if ($date) {
|
||||||
|
$t = date_timestamp_get(date_create_from_format(BasicDateFormat, $date));
|
||||||
|
}
|
||||||
|
if (!@$t) {
|
||||||
|
$t = time();
|
||||||
|
$r->headers[HeaderXDate] = date(BasicDateFormat, $t);
|
||||||
|
}
|
||||||
|
$queryString = $this->CanonicalQueryString($r);
|
||||||
|
if ($queryString != "") {
|
||||||
|
$queryString = "?" . $queryString;
|
||||||
|
}
|
||||||
|
$signedHeaders = $this->SignedHeaders($r);
|
||||||
|
$canonicalRequest = $this->CanonicalRequest($r, $signedHeaders);
|
||||||
|
$stringToSign = $this->StringToSign($canonicalRequest, $t);
|
||||||
|
$signature = $this->SignStringToSign($stringToSign, $this->Secret);
|
||||||
|
$authValue = $this->AuthHeaderValue($signature, $this->Key, $signedHeaders);
|
||||||
|
$r->headers[HeaderAuthorization] = $authValue;
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
$uri = str_replace(array("%2F"), array("/"), rawurlencode($r->uri));
|
||||||
|
$url = $r->scheme . '://' . $r->host . $uri . $queryString;
|
||||||
|
$headers = $this->curlHeaders($r);
|
||||||
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $r->method);
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $r->body);
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
|
||||||
|
curl_setopt($curl, CURLOPT_NOBODY, FALSE);
|
||||||
|
return $curl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,17 +2,22 @@
|
|||||||
|
|
||||||
function getpath()
|
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'];
|
||||||
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||||
|
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||||
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 substr($path, 1);
|
return $path;
|
||||||
|
//return substr($path, 1);
|
||||||
//return spurlencode($path, '/');
|
//return spurlencode($path, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGET()
|
function getGET()
|
||||||
{
|
{
|
||||||
|
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
if ($p>0) {
|
if ($p>0) {
|
||||||
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
|
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
|
||||||
@@ -42,18 +47,19 @@ function getConfig($str, $disktag = '')
|
|||||||
global $Base64Env;
|
global $Base64Env;
|
||||||
//include 'config.php';
|
//include 'config.php';
|
||||||
$s = file_get_contents('config.php');
|
$s = file_get_contents('config.php');
|
||||||
$configs = substr($s, 18, -2);
|
//$configs = substr($s, 18, -2);
|
||||||
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') {
|
if ($configs!='') {
|
||||||
$envs = json_decode($configs, true);
|
$envs = json_decode($configs, true);
|
||||||
if (in_array($str, $InnerEnv)) {
|
if (in_array($str, $InnerEnv)) {
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
if (isset($envs[$disktag][$str])) {
|
if (isset($envs[$disktag][$str])) {
|
||||||
if (in_array($str, $Base64Env)) return equal_replace($envs[$disktag][$str],1);
|
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||||
else return $envs[$disktag][$str];
|
else return $envs[$disktag][$str];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isset($envs[$str])) {
|
if (isset($envs[$str])) {
|
||||||
if (in_array($str, $Base64Env)) return equal_replace($envs[$str],1);
|
if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
|
||||||
else return $envs[$str];
|
else return $envs[$str];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,17 +74,17 @@ function setConfig($arr, $disktag = '')
|
|||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
//include 'config.php';
|
//include 'config.php';
|
||||||
$s = file_get_contents('config.php');
|
$s = file_get_contents('config.php');
|
||||||
$configs = substr($s, 18, -2);
|
//$configs = substr($s, 18, -2);
|
||||||
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') $envs = json_decode($configs, true);
|
if ($configs!='') $envs = json_decode($configs, true);
|
||||||
$disktags = explode("|",getConfig('disktag'));
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
//$indisk = 0;
|
$indisk = 0;
|
||||||
$operatedisk = 0;
|
$operatedisk = 0;
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
if (in_array($k, $InnerEnv)) {
|
if (in_array($k, $InnerEnv)) {
|
||||||
if (in_array($k, $Base64Env)) $envs[$disktag][$k] = equal_replace($v);
|
if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
|
||||||
else $envs[$disktag][$k] = $v;
|
else $envs[$disktag][$k] = $v;
|
||||||
/*$diskconfig[$k] = $v;
|
$indisk = 1;
|
||||||
$indisk = 1;*/
|
|
||||||
} elseif ($k=='disktag_add') {
|
} elseif ($k=='disktag_add') {
|
||||||
array_push($disktags, $v);
|
array_push($disktags, $v);
|
||||||
$operatedisk = 1;
|
$operatedisk = 1;
|
||||||
@@ -87,15 +93,16 @@ function setConfig($arr, $disktag = '')
|
|||||||
$envs[$v] = '';
|
$envs[$v] = '';
|
||||||
$operatedisk = 1;
|
$operatedisk = 1;
|
||||||
} else {
|
} else {
|
||||||
if (in_array($k, $Base64Env)) $envs[$k] = equal_replace($v);
|
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||||
else $envs[$k] = $v;
|
else $envs[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if ($indisk) {
|
if ($indisk) {
|
||||||
|
$diskconfig = $envs[$disktag];
|
||||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
ksort($diskconfig);
|
ksort($diskconfig);
|
||||||
$tmp[$disktag] = json_encode($diskconfig);
|
$envs[$disktag] = $diskconfig;
|
||||||
}*/
|
}
|
||||||
if ($operatedisk) {
|
if ($operatedisk) {
|
||||||
$disktags = array_unique($disktags);
|
$disktags = array_unique($disktags);
|
||||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||||
@@ -105,11 +112,11 @@ function setConfig($arr, $disktag = '')
|
|||||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||||
ksort($envs);
|
ksort($envs);
|
||||||
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
|
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
|
||||||
$prestr = '<?php $configs = \'
|
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||||
';
|
$aftstr = PHP_EOL . '\';';
|
||||||
$aftstr = '
|
$response = file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||||
\';';
|
if ($response>0) return json_encode( [ 'response' => 'success' ] );
|
||||||
return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
|
return json_encode( [ 'message' => 'Failed to write config.', 'code' => 'failed' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
function install()
|
function install()
|
||||||
@@ -118,14 +125,22 @@ function install()
|
|||||||
if ($_GET['install2']) {
|
if ($_GET['install2']) {
|
||||||
if ($_POST['admin']!='') {
|
if ($_POST['admin']!='') {
|
||||||
$tmp['admin'] = $_POST['admin'];
|
$tmp['admin'] = $_POST['admin'];
|
||||||
$tmp['language'] = $_POST['language'];
|
//$tmp['language'] = $_COOKIE['language'];
|
||||||
$response = setConfig($tmp);
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
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, 201);
|
return message($html, $title, 201);
|
||||||
} else {
|
} else {
|
||||||
return output('Jump<script>document.cookie=\'language=; path=/\';</script><meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,6 +163,12 @@ function install()
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<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)
|
function notnull(t)
|
||||||
{
|
{
|
||||||
if (t.admin.value==\'\') {
|
if (t.admin.value==\'\') {
|
||||||
@@ -175,7 +196,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(url+"\n"+xhr4.status);
|
alert("Url: " + url + "\nExpect http code 201, but received " + xhr4.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,7 +218,10 @@ language:<br>';
|
|||||||
<script>
|
<script>
|
||||||
function changelanguage(str)
|
function changelanguage(str)
|
||||||
{
|
{
|
||||||
document.cookie=\'language=\'+str+\'; path=/\';
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||||
location.href = location.href;
|
location.href = location.href;
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
@@ -233,22 +257,92 @@ function RewriteEngineOn()
|
|||||||
|
|
||||||
function api_error($response)
|
function api_error($response)
|
||||||
{
|
{
|
||||||
return !$response;
|
return isset($response['message']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function api_error_msg($response)
|
function api_error_msg($response)
|
||||||
{
|
{
|
||||||
return $response . '<br>
|
return $response['code'] . '<br>
|
||||||
Can not write config to file.<br>
|
' . $response['message'] . '<br>
|
||||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate()
|
|
||||||
{
|
|
||||||
return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setConfigResponse($response)
|
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 0;
|
||||||
|
file_put_contents($tarfile, $githubfile);
|
||||||
|
if (splitfirst(PHP_VERSION, '.')[0] == '7') {
|
||||||
|
$phar = new PharData($tarfile); // need php7
|
||||||
|
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
} else {
|
||||||
|
ob_start();
|
||||||
|
passthru('tar -xzvf ' . $tarfile, $stat);
|
||||||
|
ob_get_clean();
|
||||||
|
}
|
||||||
|
unlink($tarfile);
|
||||||
|
|
||||||
|
$outPath = '';
|
||||||
|
$tmp = scandir($projectPath);
|
||||||
|
$name = $auth . '-' . $project;
|
||||||
|
foreach ($tmp as $f) {
|
||||||
|
if ( substr($f, 0, strlen($name)) == $name) {
|
||||||
|
$outPath = $projectPath . $slash . $f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//error_log($outPath);
|
||||||
|
if ($outPath=='') return 0;
|
||||||
|
|
||||||
|
//unlink($outPath.'/config.php');
|
||||||
|
$response = rename($projectPath . $slash . 'config.php', $outPath . $slash . 'config.php');
|
||||||
|
if (!$response) {
|
||||||
|
$tmp1['code'] = "Move Failed";
|
||||||
|
$tmp1['message'] = "Can not move " . $projectPath . $slash . 'config.php' . " to " . $outPath . $slash . 'config.php';
|
||||||
|
return json_encode($tmp1);
|
||||||
|
}
|
||||||
|
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 json_encode($tmp);
|
||||||
|
}
|
||||||
|
if (file_exists($fromfile)) unlink($fromfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handler);
|
||||||
|
rmdir($from);
|
||||||
|
return json_encode( [ 'response' => 'success' ] );
|
||||||
}
|
}
|
||||||
@@ -23,27 +23,25 @@ function GetGlobalVariable($event)
|
|||||||
$pos = strpos($cookievalues,"=");
|
$pos = strpos($cookievalues,"=");
|
||||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||||
}
|
}
|
||||||
|
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||||
|
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
|
||||||
$_SERVER['USER'] = 'qcloud';
|
$_SERVER['USER'] = 'qcloud';
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetPathSetting($event, $context)
|
function GetPathSetting($event, $context)
|
||||||
{
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||||
$_SERVER['function_name'] = $context['function_name'];
|
$_SERVER['function_name'] = $context['function_name'];
|
||||||
$_SERVER['namespace'] = $context['namespace'];
|
$_SERVER['namespace'] = $context['namespace'];
|
||||||
|
$_SERVER['Region'] = getenv('TENCENTCLOUD_REGION');
|
||||||
$host_name = $event['headers']['host'];
|
$host_name = $event['headers']['host'];
|
||||||
$_SERVER['HTTP_HOST'] = $host_name;
|
$_SERVER['HTTP_HOST'] = $host_name;
|
||||||
$serviceId = $event['requestContext']['serviceId'];
|
$serviceId = $event['requestContext']['serviceId'];
|
||||||
if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
|
if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
|
||||||
$_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
|
$_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
|
||||||
$_SERVER['Region'] = getenv('Region');
|
|
||||||
if ($_SERVER['Region'] == '') {
|
|
||||||
$_SERVER['Region'] = substr($host_name, strpos($host_name, '.')+1);
|
|
||||||
$_SERVER['Region'] = substr($_SERVER['Region'], 0, strpos($_SERVER['Region'], '.'));
|
|
||||||
}
|
|
||||||
$path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
|
$path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
|
||||||
} else {
|
} else {
|
||||||
$_SERVER['base_path'] = $event['requestContext']['path'];
|
$_SERVER['base_path'] = $event['requestContext']['path'];
|
||||||
$_SERVER['Region'] = getenv('Region');
|
|
||||||
$path = substr($event['path'], strlen($event['requestContext']['path']));
|
$path = substr($event['path'], strlen($event['requestContext']['path']));
|
||||||
}
|
}
|
||||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||||
@@ -62,11 +60,11 @@ function getConfig($str, $disktag = '')
|
|||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
$env = json_decode(getenv($disktag), true);
|
$env = json_decode(getenv($disktag), true);
|
||||||
if (isset($env[$str])) {
|
if (isset($env[$str])) {
|
||||||
if (in_array($str, $Base64Env)) return equal_replace($env[$str],1);
|
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||||
else return $env[$str];
|
else return $env[$str];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1);
|
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||||
else return getenv($str);
|
else return getenv($str);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
@@ -84,7 +82,7 @@ function setConfig($arr, $disktag = '')
|
|||||||
$oparetdisk = 0;
|
$oparetdisk = 0;
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
if (in_array($k, $InnerEnv)) {
|
if (in_array($k, $InnerEnv)) {
|
||||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v);
|
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||||
else $diskconfig[$k] = $v;
|
else $diskconfig[$k] = $v;
|
||||||
$indisk = 1;
|
$indisk = 1;
|
||||||
} elseif ($k=='disktag_add') {
|
} elseif ($k=='disktag_add') {
|
||||||
@@ -95,7 +93,7 @@ function setConfig($arr, $disktag = '')
|
|||||||
$tmp[$v] = '';
|
$tmp[$v] = '';
|
||||||
$oparetdisk = 1;
|
$oparetdisk = 1;
|
||||||
} else {
|
} else {
|
||||||
if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v);
|
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||||
else $tmp[$k] = $v;
|
else $tmp[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,35 +127,57 @@ function install()
|
|||||||
global $constStr;
|
global $constStr;
|
||||||
if ($_GET['install2']) {
|
if ($_GET['install2']) {
|
||||||
$tmp['admin'] = $_POST['admin'];
|
$tmp['admin'] = $_POST['admin'];
|
||||||
setConfig($tmp);
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
if (needUpdate()) {
|
if (api_error($response)) {
|
||||||
updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
|
$html = api_error_msg($response);
|
||||||
return message('update to github version, reinstall.<script>document.cookie=\'language=; path=/\';</script><meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
}
|
}
|
||||||
return output('Jump<script>document.cookie=\'language=; path=/\';</script><meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
if (needUpdate()) {
|
||||||
|
OnekeyUpate();
|
||||||
|
return message('update to github version, reinstall.
|
||||||
|
<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=' . $url . '">', 'Program updating', 201);
|
||||||
|
}
|
||||||
|
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 ($_GET['install1']) {
|
||||||
//if ($_POST['admin']!='') {
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
$tmp['language'] = $_POST['language'];
|
$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;
|
}
|
||||||
}
|
$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)) {
|
||||||
$html = api_error_msg($response);
|
$html = api_error_msg($response);
|
||||||
$html .= '<br>
|
$title = 'Error';
|
||||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
return message($html, $title, 201);
|
||||||
$title = 'Error';
|
} else {
|
||||||
|
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
|
||||||
|
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||||
|
$title = 'Reinstall';
|
||||||
return message($html, $title, 201);
|
return message($html, $title, 201);
|
||||||
} else {
|
}
|
||||||
$html .= '
|
$html .= '
|
||||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||||
<input type="submit" value="'.getconstStr('Submit').'">
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
@@ -172,10 +192,9 @@ function install()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
$title = getconstStr('SetAdminPassword');
|
$title = getconstStr('SetAdminPassword');
|
||||||
return message($html, $title, 201);
|
return message($html, $title, 201);
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
if ($_GET['install0']) {
|
if ($_GET['install0']) {
|
||||||
$html .= '
|
$html .= '
|
||||||
@@ -186,16 +205,28 @@ language:<br>';
|
|||||||
<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')=='') $html .= '
|
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $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="text" 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" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||||
|
$html .= '
|
||||||
<input type="submit" value="'.getconstStr('Submit').'">
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<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 changelanguage(str)
|
function changelanguage(str)
|
||||||
{
|
{
|
||||||
document.cookie=\'language=\'+str+\'; path=/\';
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||||
location.href = location.href;
|
location.href = location.href;
|
||||||
}
|
}
|
||||||
function notnull(t)
|
function notnull(t)
|
||||||
@@ -284,7 +315,7 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
|
|||||||
$tmp_env[$key1] = $value1;
|
$tmp_env[$key1] = $value1;
|
||||||
}
|
}
|
||||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
$tmp_env['Region'] = $Region;
|
//$tmp_env['Region'] = $Region;
|
||||||
ksort($tmp_env);
|
ksort($tmp_env);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@@ -312,7 +343,8 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
|
|||||||
|
|
||||||
function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||||
{
|
{
|
||||||
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' );
|
||||||
/*$trynum = 0;
|
/*$trynum = 0;
|
||||||
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
|
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
|
||||||
'.++$trynum;*/
|
'.++$trynum;*/
|
||||||
@@ -325,7 +357,7 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
|
|||||||
$tmp_env[$key1] = $value1;
|
$tmp_env[$key1] = $value1;
|
||||||
}
|
}
|
||||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
$tmp_env['Region'] = $Region;
|
//$tmp_env['Region'] = $Region;
|
||||||
ksort($tmp_env);
|
ksort($tmp_env);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@@ -345,7 +377,7 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
|
|||||||
$tmpdata['Timestamp'] = time();
|
$tmpdata['Timestamp'] = time();
|
||||||
$tmpdata['Token'] = '';
|
$tmpdata['Token'] = '';
|
||||||
$tmpdata['Version'] = '2018-04-16';
|
$tmpdata['Version'] = '2018-04-16';
|
||||||
$tmpdata['Description'] = 'Onedrive index and manager in SCF.';
|
$tmpdata['Description'] = 'Onedrive index and manager in Tencent SCF.';
|
||||||
$tmpdata['MemorySize'] = 64;
|
$tmpdata['MemorySize'] = 64;
|
||||||
$tmpdata['Timeout'] = 30;
|
$tmpdata['Timeout'] = 30;
|
||||||
$data = ReorganizeDate($tmpdata);
|
$data = ReorganizeDate($tmpdata);
|
||||||
@@ -355,13 +387,14 @@ 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($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
|
||||||
{
|
{
|
||||||
WaitSCFStat();
|
WaitSCFStat();
|
||||||
$meth = 'POST';
|
$meth = 'POST';
|
||||||
$host = 'scf.tencentcloudapi.com';
|
$host = 'scf.tencentcloudapi.com';
|
||||||
$tmpdata['Action'] = 'UpdateFunctionCode';
|
$tmpdata['Action'] = 'UpdateFunctionCode';
|
||||||
$tmpdata['Code.GitUrl'] = 'https://github.com/qkqpttgf/OneManager-php';
|
$tmpdata['Code.GitUrl'] = $source['url'];
|
||||||
|
$tmpdata['Code.GitBranch'] = $source['branch'];
|
||||||
$tmpdata['CodeSource'] = 'Git';
|
$tmpdata['CodeSource'] = 'Git';
|
||||||
$tmpdata['FunctionName'] = $function_name;
|
$tmpdata['FunctionName'] = $function_name;
|
||||||
$tmpdata['Handler'] = 'index.main_handler';
|
$tmpdata['Handler'] = 'index.main_handler';
|
||||||
@@ -393,9 +426,11 @@ namespace:' . $_SERVER['namespace'] . '<br>
|
|||||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate()
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
return json_decode(updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response'];
|
$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)
|
||||||
@@ -0,0 +1,621 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function printInput($event, $context)
|
||||||
|
{
|
||||||
|
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||||
|
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetGlobalVariable($event)
|
||||||
|
{
|
||||||
|
$_GET = $event['queryString'];
|
||||||
|
$postbody = explode("&",$event['body']);
|
||||||
|
foreach ($postbody as $postvalues) {
|
||||||
|
$pos = strpos($postvalues,"=");
|
||||||
|
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||||
|
}
|
||||||
|
$cookiebody = explode("; ",$event['headers']['cookie']);
|
||||||
|
foreach ($cookiebody as $cookievalues) {
|
||||||
|
$pos = strpos($cookievalues,"=");
|
||||||
|
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||||
|
}
|
||||||
|
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||||
|
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
|
||||||
|
$_SERVER['USER'] = 'qcloud';
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetPathSetting($event, $context)
|
||||||
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||||
|
$_SERVER['function_name'] = $context['function_name'];
|
||||||
|
$_SERVER['namespace'] = $context['namespace'];
|
||||||
|
$_SERVER['Region'] = getenv('TENCENTCLOUD_REGION');
|
||||||
|
$host_name = $event['headers']['host'];
|
||||||
|
$_SERVER['HTTP_HOST'] = $host_name;
|
||||||
|
$serviceId = $event['requestContext']['serviceId'];
|
||||||
|
if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
|
||||||
|
$_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
|
||||||
|
$path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
|
||||||
|
} else {
|
||||||
|
$_SERVER['base_path'] = $event['requestContext']['path'];
|
||||||
|
$path = substr($event['path'], strlen($event['requestContext']['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['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig($str, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
//include 'config.php';
|
||||||
|
$s = file_get_contents('config.php');
|
||||||
|
//$configs = substr($s, 18, -2);
|
||||||
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
|
if ($configs!='') {
|
||||||
|
$envs = json_decode($configs, true);
|
||||||
|
if (in_array($str, $InnerEnv)) {
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
if (isset($envs[$disktag][$str])) {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||||
|
else return $envs[$disktag][$str];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isset($envs[$str])) {
|
||||||
|
if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
|
||||||
|
else return $envs[$str];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfig($arr, $disktag = '')
|
||||||
|
{
|
||||||
|
global $InnerEnv;
|
||||||
|
global $Base64Env;
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
//include 'config.php';
|
||||||
|
$s = file_get_contents('config.php');
|
||||||
|
//$configs = substr($s, 18, -2);
|
||||||
|
$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 (in_array($k, $InnerEnv)) {
|
||||||
|
if (in_array($k, $Base64Env)) $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;
|
||||||
|
} else {
|
||||||
|
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||||
|
else $envs[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($indisk) {
|
||||||
|
$diskconfig = $envs[$disktag];
|
||||||
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
|
ksort($diskconfig);
|
||||||
|
$envs[$disktag] = $diskconfig;
|
||||||
|
}
|
||||||
|
if ($operatedisk) {
|
||||||
|
$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');
|
||||||
|
ksort($envs);
|
||||||
|
$response = updateEnvironment($envs, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
|
||||||
|
WaitSCFStat($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
$trynum = 0;
|
||||||
|
while( json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
|
||||||
|
'.++$trynum;
|
||||||
|
}
|
||||||
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
global $constStr;
|
||||||
|
if ($_GET['install2']) {
|
||||||
|
$tmp['admin'] = $_POST['admin'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if (needUpdate()) {
|
||||||
|
OnekeyUpate();
|
||||||
|
return message('update to github version, reinstall.
|
||||||
|
<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=' . $url . '">', 'Program updating', 201);
|
||||||
|
}
|
||||||
|
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']) {
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$SecretId = getConfig('SecretId');
|
||||||
|
if ($SecretId=='') {
|
||||||
|
$SecretId = $_POST['SecretId'];
|
||||||
|
$tmp['SecretId'] = $SecretId;
|
||||||
|
}
|
||||||
|
$SecretKey = getConfig('SecretKey');
|
||||||
|
if ($SecretKey=='') {
|
||||||
|
$SecretKey = $_POST['SecretKey'];
|
||||||
|
$tmp['SecretKey'] = $SecretKey;
|
||||||
|
}
|
||||||
|
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
|
||||||
|
$response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
} else {
|
||||||
|
if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
|
||||||
|
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||||
|
$title = 'Reinstall';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '
|
||||||
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
|
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||||
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
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" 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>';
|
||||||
|
}
|
||||||
|
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||||
|
<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="text" placeholder="" size=""></label><br>';
|
||||||
|
$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" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||||
|
$html .= '
|
||||||
|
<input 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 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 (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||||
|
if (t.SecretId.value==\'\') {
|
||||||
|
alert(\'input SecretId\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.SecretKey.value==\'\') {
|
||||||
|
alert(\'input SecretKey\');
|
||||||
|
return false;
|
||||||
|
}';
|
||||||
|
$html .= '
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SelectLanguage');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function post2url($url, $data)
|
||||||
|
{
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
//echo $response;
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ReorganizeDate($arr)
|
||||||
|
{
|
||||||
|
$str = '';
|
||||||
|
ksort($arr);
|
||||||
|
foreach ($arr as $k1 => $v1) {
|
||||||
|
$str .= '&' . $k1 . '=' . $v1;
|
||||||
|
}
|
||||||
|
$str = substr($str, 1); // remove first '&'. 去掉第一个&
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
//$meth = 'GET';
|
||||||
|
$meth = 'POST';
|
||||||
|
$host = 'scf.tencentcloudapi.com';
|
||||||
|
$tmpdata['Action'] = 'GetFunction';
|
||||||
|
$tmpdata['FunctionName'] = $function_name;
|
||||||
|
$tmpdata['Namespace'] = $Namespace;
|
||||||
|
$tmpdata['Nonce'] = time();
|
||||||
|
$tmpdata['Region'] = $Region;
|
||||||
|
$tmpdata['SecretId'] = $SecretId;
|
||||||
|
$tmpdata['Timestamp'] = time();
|
||||||
|
$tmpdata['Token'] = '';
|
||||||
|
$tmpdata['Version'] = '2018-04-16';
|
||||||
|
$data = ReorganizeDate($tmpdata);
|
||||||
|
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||||
|
//echo urlencode($signStr);
|
||||||
|
//return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
|
||||||
|
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getfunctioncodeurl($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
//$meth = 'GET';
|
||||||
|
$meth = 'POST';
|
||||||
|
$host = 'scf.tencentcloudapi.com';
|
||||||
|
$tmpdata['Action'] = 'GetFunctionAddress';
|
||||||
|
$tmpdata['FunctionName'] = $function_name;
|
||||||
|
$tmpdata['Namespace'] = $Namespace;
|
||||||
|
$tmpdata['Nonce'] = time();
|
||||||
|
$tmpdata['Region'] = $Region;
|
||||||
|
$tmpdata['SecretId'] = $SecretId;
|
||||||
|
$tmpdata['Timestamp'] = time();
|
||||||
|
$tmpdata['Token'] = '';
|
||||||
|
$tmpdata['Version'] = '2018-04-16';
|
||||||
|
$data = ReorganizeDate($tmpdata);
|
||||||
|
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||||
|
//echo urlencode($signStr);
|
||||||
|
//return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
|
||||||
|
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
$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 updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
// 获取当前代码并解压
|
||||||
|
//$codeurl = json_decode(getfunctioncodeurl($function_name, $Region, $Namespace, $SecretId, $SecretKey), true)['Response']['Url'];
|
||||||
|
//$codezip = '/tmp/oldcode.zip';
|
||||||
|
$outPath = '/tmp/code/';
|
||||||
|
|
||||||
|
//file_put_contents($codezip, file_get_contents($codeurl));
|
||||||
|
//$zip=new ZipArchive();
|
||||||
|
//$zip->open($codezip);
|
||||||
|
//$html = $zip->extractTo($outPath);
|
||||||
|
|
||||||
|
$coderoot = __DIR__ . '/../';
|
||||||
|
copyFolder($coderoot, $outPath);
|
||||||
|
|
||||||
|
// 将配置写入
|
||||||
|
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||||
|
$aftstr = PHP_EOL . '\';';
|
||||||
|
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||||
|
|
||||||
|
// 将目录中文件打包成zip
|
||||||
|
$source = '/tmp/code.zip';
|
||||||
|
//$zip=new ZipArchive();
|
||||||
|
$zip=new PharData($source);
|
||||||
|
//if($zip->open($source, ZipArchive::CREATE)){
|
||||||
|
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||||
|
// $zip->close(); //关闭处理的zip文件
|
||||||
|
//}
|
||||||
|
|
||||||
|
return updateProgram($function_name, $Region, $namespace, $SecretId, $SecretKey, $source);
|
||||||
|
$tmp1['Response']['Error']['Message'] = $codeurl;
|
||||||
|
error_log($tmp1['Response']['Error']['Message']);
|
||||||
|
return json_encode($tmp1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||||
|
{
|
||||||
|
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $tmp_env = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||||
|
else {
|
||||||
|
$Envs['ONEMANAGER_CONFIG_SAVE'] == '';
|
||||||
|
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
|
||||||
|
foreach ($tmp as $tmp1) {
|
||||||
|
$tmp_env[$tmp1['Key']] = $tmp1['Value'];
|
||||||
|
}
|
||||||
|
foreach ($Envs as $key1 => $value1) {
|
||||||
|
$tmp_env[$key1] = $value1;
|
||||||
|
}
|
||||||
|
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||||
|
ksort($tmp_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($tmp_env as $key1 => $value1) {
|
||||||
|
$tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
|
||||||
|
$tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$meth = 'POST';
|
||||||
|
$host = 'scf.tencentcloudapi.com';
|
||||||
|
$tmpdata['Action'] = 'UpdateFunctionConfiguration';
|
||||||
|
$tmpdata['FunctionName'] = $function_name;
|
||||||
|
$tmpdata['Namespace'] = $Namespace;
|
||||||
|
$tmpdata['Nonce'] = time();
|
||||||
|
$tmpdata['Region'] = $Region;
|
||||||
|
$tmpdata['SecretId'] = $SecretId;
|
||||||
|
$tmpdata['Timestamp'] = time();
|
||||||
|
$tmpdata['Token'] = '';
|
||||||
|
$tmpdata['Version'] = '2018-04-16';
|
||||||
|
$tmpdata['Description'] = 'Onedrive index and manager in Tencent SCF.';
|
||||||
|
$tmpdata['MemorySize'] = 64;
|
||||||
|
$tmpdata['Timeout'] = 30;
|
||||||
|
$data = ReorganizeDate($tmpdata);
|
||||||
|
//echo $data;
|
||||||
|
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||||
|
//echo urlencode($signStr);
|
||||||
|
$response = post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||||
|
if (api_error(setConfigResponse($response))) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if ( json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Timeout'] < 25 ) {
|
||||||
|
$tmp['Response']['Error']['Message'] = 'Operating, please try again.';
|
||||||
|
$tmp['Response']['Error']['Code'] = 'Retry';
|
||||||
|
return json_encode($tmp);
|
||||||
|
}
|
||||||
|
WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey);
|
||||||
|
|
||||||
|
$s = file_get_contents('config.php');
|
||||||
|
//$configs = substr($s, 18, -2);
|
||||||
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
|
if ($configs!='') $envs = json_decode($configs, true);
|
||||||
|
foreach ($Envs as $k => $v) {
|
||||||
|
$envs[$k] = $v;
|
||||||
|
}
|
||||||
|
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||||
|
ksort($envs);
|
||||||
|
$response = updateEnvironment($envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
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_log( $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_request('https://'.$host, $payload, $headers)['body'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error($response)
|
||||||
|
{
|
||||||
|
return isset($response['Error']);
|
||||||
|
return ($response==null)||isset($response['Error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error_msg($response)
|
||||||
|
{
|
||||||
|
return $response['Error']['Code'] . '<br>
|
||||||
|
' . $response['Error']['Message'] . '<br><br>
|
||||||
|
function_name:' . $_SERVER['function_name'] . '<br>
|
||||||
|
Region:' . $_SERVER['Region'] . '<br>
|
||||||
|
namespace:' . $_SERVER['namespace'] . '<br>
|
||||||
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfigResponse($response)
|
||||||
|
{
|
||||||
|
return json_decode( $response, true )['Response'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
|
{
|
||||||
|
$source = '/tmp/code.zip';
|
||||||
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
|
$phar = new PharData($tarfile);
|
||||||
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
|
// 获取包中目录名
|
||||||
|
$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=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($path);
|
||||||
|
}
|
||||||
@@ -1,14 +1,25 @@
|
|||||||
Install program first, then add onedrive in setup after login.
|
Install program first, then add onedrive in setup after login.
|
||||||
先安装程序,登录后在设置中添加onedrive。
|
先安装程序,登录后在设置中添加onedrive。
|
||||||
|
|
||||||
# Deploy to heroku
|
# Deploy to Heroku
|
||||||
Official: https://heroku.com
|
Official: https://heroku.com
|
||||||
|
Demo: https://herooneindex.herokuapp.com/
|
||||||
|
|
||||||
How to Install: Click the button [](https://heroku.com/deploy) to Deploy a new app, or create an app then deploy via connect to your github fork.
|
How to Install: Click the button [](https://heroku.com/deploy?template=https://github.com/qkqpttgf/OneManager-php) to Deploy a new app, or create an app then deploy via connect to your github fork.
|
||||||
|
|
||||||
DEMO: https://herooneindex.herokuapp.com/
|
|
||||||
|
|
||||||
# Deploy to VPS(Virtual Private Server) 部署到VPS或空间
|
# Deploy to Tencent Serverless Cloud Function (SCF 腾讯无服务器云函数)
|
||||||
|
Official: https://cloud.tencent.com/product/scf
|
||||||
|
DEMO: 无
|
||||||
|
注意:SCF新增限制,环境变量整体最大4KB,所以最多添加4个盘。
|
||||||
|
|
||||||
|
How to Install: 无,(重点:勾选集成响应)
|
||||||
|
|
||||||
|
添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。
|
||||||
|
|
||||||
|
|
||||||
|
# Deploy to Virtual Private Server (VPS 或空间)
|
||||||
|
DEMO: 无
|
||||||
How to Install:
|
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服务器,确保你能访问到。
|
启动web服务器,确保你能访问到。
|
||||||
@@ -21,15 +32,46 @@ How to Install:
|
|||||||
5.View the website in chrome or other.
|
5.View the website in chrome or other.
|
||||||
在浏览器中访问。
|
在浏览器中访问。
|
||||||
|
|
||||||
# Deploy to SCF
|
|
||||||
Official: https://cloud.tencent.com/product/scf
|
|
||||||
|
|
||||||
~~How to Install: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/%E6%97%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%87%BD%E6%95%B0SCF%E6%90%AD%E5%BB%BAOneDrive.mp4?preview~~
|
# Deploy to Huawei cloud Function Graph (FG 华为云函数工作流)
|
||||||
|
Official: https://console.huaweicloud.com/functiongraph/
|
||||||
|
DEMO: 无
|
||||||
|
注意:FG中,环境变量整体大小为2KB,所以最多添加2个盘。
|
||||||
|
|
||||||
先手动在环境变量添加Region,ap-hongkong或ap-guangzhou之类,具体看 https://cloud.tencent.com/document/api/583/17238 最底下,然后再安装。
|
How to Install:
|
||||||
添加网盘时,SCF反应不过来,会添加失败,请不要删除,再添加一次相同的就可以了。
|
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,开始安装
|
||||||
|
|
||||||
DEMO: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/
|
|
||||||
|
|
||||||
# Features 特性
|
# 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.
|
||||||
@@ -49,5 +91,5 @@ If there is 'index.html' file, program will only show the content of 'index.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.
|
||||||
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
|
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
|
||||||
|
|
||||||
QQ Group: 943919989
|
QQ Group: 943919989 (请看完上面的中英双语再加群,谢谢!)
|
||||||
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
|
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
|
||||||
|
|||||||
@@ -0,0 +1,572 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="<!--constStr@language-->">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><!--Title--></title>
|
||||||
|
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||||
|
<!--https://p.sfx.ms/images/favicon.ico-->
|
||||||
|
<style>
|
||||||
|
/* 通用样式 */
|
||||||
|
/* 用于消除默认自带样式 */
|
||||||
|
html, body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
color: #333;
|
||||||
|
font-family: "Segoe UI", Tahoma, Arial, sans-serif;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
input[type="radio"] {
|
||||||
|
margin: 0;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 兼容样式 */
|
||||||
|
body {
|
||||||
|
-webkit-user-select:none;
|
||||||
|
-moz-user-select:none;
|
||||||
|
-ms-user-select:none;
|
||||||
|
user-select:none;
|
||||||
|
}
|
||||||
|
select:-moz-focusring {
|
||||||
|
color: transparent;
|
||||||
|
text-shadow: 0 0 0 #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 自定义样式 */
|
||||||
|
.container {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
max-width: 1100px;
|
||||||
|
}
|
||||||
|
.pull-left {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.pull-right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 字体外部引用 */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'iconfont'; /* project id 1634400 */
|
||||||
|
src: url('//at.alicdn.com/t/font_1634400_9yg8f5s278.eot');
|
||||||
|
src: url('//at.alicdn.com/t/font_1634400_9yg8f5s278.eot?#iefix') format('embedded-opentype'),
|
||||||
|
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.woff2') format('woff2'),
|
||||||
|
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.woff') format('woff'),
|
||||||
|
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.ttf') format('truetype'),
|
||||||
|
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.svg#iconfont') format('svg');
|
||||||
|
}
|
||||||
|
.iconfont {
|
||||||
|
font-family:"iconfont" !important;
|
||||||
|
font-size:16px;font-style:normal;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-webkit-text-stroke-width: 0.2px;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* header */
|
||||||
|
header {
|
||||||
|
width: 100%;
|
||||||
|
/*height: 88px;*/
|
||||||
|
line-height: 48px;
|
||||||
|
font-size: 16px;
|
||||||
|
background-color: #0078D4;
|
||||||
|
}
|
||||||
|
header nav {
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0 10px;
|
||||||
|
height: 48px;
|
||||||
|
color: #FFF;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
header nav a {
|
||||||
|
color: #FFF;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
header nav .lang .language { outline: none; }
|
||||||
|
header .control {
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
}
|
||||||
|
header .control .control-item {
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* main */
|
||||||
|
main {
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
main .scroll {
|
||||||
|
overflow-y: scroll;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
main .main-item-list {
|
||||||
|
padding-left: 32px;
|
||||||
|
padding-right: 32px;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
font-size: 12px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
main .main-title h1 {
|
||||||
|
margin: 0;
|
||||||
|
padding: 32px;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 100;
|
||||||
|
}
|
||||||
|
main .main-items:hover {
|
||||||
|
background-color: #F4F4F4;
|
||||||
|
}
|
||||||
|
main .main-items:hover .main-items-radio {
|
||||||
|
display: inline-block!important;
|
||||||
|
}
|
||||||
|
main .main-item-list .inner-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
height: 32px;
|
||||||
|
border-bottom: 1px solid #FFF;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
main .main-item-list .inner-container > div {
|
||||||
|
padding-left: 12px;
|
||||||
|
padding-right: 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-item-title {
|
||||||
|
border-bottom: 1px solid #EAEAEA;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-radio-box {
|
||||||
|
width: 48px;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-radio-box .main-items-radio {
|
||||||
|
display: none;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-radio-box .main-items-radio[currstatus=true] {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-icon {
|
||||||
|
min-width: 38px;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
main .main-item-title .main-items-icon {
|
||||||
|
height: 32px!important;
|
||||||
|
line-height: 9px!important;
|
||||||
|
}
|
||||||
|
main .main-item-title .main-items-icon:hover,
|
||||||
|
main .main-item-list .main-items-displayName:hover,
|
||||||
|
main .main-item-list .main-items-dateModified:hover,
|
||||||
|
main .main-item-list .main-items-size:hover {
|
||||||
|
background-color: #EAEAEA;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-icon .iconfont {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-icon img {
|
||||||
|
display: inline-block;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
main .main-items {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
border-bottom: 1px solid #F4F4F4;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-displayName,
|
||||||
|
main .main-item-list .main-items-fileName {
|
||||||
|
width: 520px;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-dateModified,
|
||||||
|
main .main-item-list .main-items-dateTime {
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-size,
|
||||||
|
main .main-item-list .main-items-fileSize {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-radio-box,
|
||||||
|
main .main-item-list .main-items-icon,
|
||||||
|
main .main-item-list .main-items-fileName,
|
||||||
|
main .main-item-list .main-items-dateTime,
|
||||||
|
main .main-item-list .main-items-fileSize {
|
||||||
|
padding: 11px 8px 11px 12px;
|
||||||
|
height: 42px;
|
||||||
|
line-height: 22px;
|
||||||
|
font-family: "Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", "Helvetica Neue", sans-serif;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
box-sizing: border-box;
|
||||||
|
/*overflow: hidden;*/
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-fileName a {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
main .main-item-list .main-items-fileName a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.more-disk{
|
||||||
|
vertical-align: middle;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow:ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 100px;
|
||||||
|
}
|
||||||
|
.more-disk div{
|
||||||
|
list-style:none;
|
||||||
|
position:absolute;
|
||||||
|
display:none;background:#ffffff;border-radius:5px;margin:0 0 0 -10px;/*padding:0 7px;*/color:#205D67;z-index:1;
|
||||||
|
box-shadow: 0 0.5em 3em rgba(161,177,204,.4);
|
||||||
|
}
|
||||||
|
.more-disk:hover div{display:block}
|
||||||
|
.more-disk div li{line-height:normal;padding: 3px 10px;}
|
||||||
|
.more-disk div li a{text-decoration: none; color:rgba(0,0,0,.3);}
|
||||||
|
.more-disk div li a:hover{color:rgba(0,0,0,.87);}
|
||||||
|
.more-disk div li a[now]{color:rgba(0,0,0,1);}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="container">
|
||||||
|
<div class="title pull-left">
|
||||||
|
<a href="<!--base_path-->"><!--Sitename--></a>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<!--LoginStart-->
|
||||||
|
<a class="pull-left" onclick="/*login();*/"><!--constStr@Login--></a>
|
||||||
|
<!--LoginEnd-->
|
||||||
|
<!--AdminStart-->
|
||||||
|
<a class="pull-left" onclick="logout();"><!--constStr@Logout--></a>
|
||||||
|
<!--AdminEnd-->
|
||||||
|
|
|
||||||
|
<div class="pull-right lang">
|
||||||
|
<select name="language" id="language" class="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
|
||||||
|
<option value="">Language</option>
|
||||||
|
<!--SelectLanguageStart-->
|
||||||
|
<option value="<!--SelectLanguageKey-->" <!--SelectLanguageSelected-->><!--SelectLanguageValue--></option>
|
||||||
|
<!--SelectLanguageEnd-->
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<!--AdminStart-->
|
||||||
|
<div class="control">
|
||||||
|
<div class="container">
|
||||||
|
<div class="control-item">
|
||||||
|
<button class="control-items">
|
||||||
|
<i class="iconfont control-items-icon"></i>
|
||||||
|
<span class="control-items-content"><!--constStr@Create--></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--AdminEnd-->
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<!--ListStart-->
|
||||||
|
<div class="scroll">
|
||||||
|
<div class="container">
|
||||||
|
<div class="main-title">
|
||||||
|
<h1 class="main-title-path">
|
||||||
|
<a href="<!--base_path-->"><!--constStr@Home--></a>
|
||||||
|
<!--DiskPathArrayStart-->
|
||||||
|
>
|
||||||
|
<a href="<!--PathArrayLink-->"><!--PathArrayName--></a>
|
||||||
|
<!--DiskPathArrayEnd-->
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<!--IsFileStart-->
|
||||||
|
<div class="main-item-list">
|
||||||
|
<div class="main-items main-item-title">
|
||||||
|
<div class="inner-container">
|
||||||
|
<div>
|
||||||
|
<div style="margin: 24px">
|
||||||
|
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
||||||
|
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<!--IsimgFileStart-->
|
||||||
|
<img src="<!--FileDownUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';" />
|
||||||
|
<!--IsimgFileEnd-->
|
||||||
|
<!--IsvideoFileStart-->
|
||||||
|
<div id="video-a0"></div>
|
||||||
|
<!--IsvideoFileEnd-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--IsFileEnd-->
|
||||||
|
<!--IsFolderStart-->
|
||||||
|
<div class="main-item-list">
|
||||||
|
<div class="main-items main-item-title">
|
||||||
|
<div class="inner-container">
|
||||||
|
<!--AdminStart-->
|
||||||
|
<div class="main-items-radio-box">
|
||||||
|
<!-- <input class="main-items-radio main-items-check-all" type="radio" name="" id=""> -->
|
||||||
|
</div>
|
||||||
|
<!--AdminEnd-->
|
||||||
|
<div class="main-items-icon">
|
||||||
|
<i class="iconfont"></i>
|
||||||
|
</div>
|
||||||
|
<div class="main-items-displayName"><!--constStr@File--></div>
|
||||||
|
<div class="main-items-dateModified"><!--constStr@EditTime--></div>
|
||||||
|
<div class="main-items-size"><!--constStr@Size--></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--FolderListStart-->
|
||||||
|
<div class="main-items">
|
||||||
|
<!--AdminStart-->
|
||||||
|
<div class="main-items-radio-box">
|
||||||
|
<input class="main-items-radio" type="radio" checked name="file" id="">
|
||||||
|
</div>
|
||||||
|
<!--AdminEnd-->
|
||||||
|
<div class="main-items-icon">
|
||||||
|
<img src="https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/folder.svg" alt="folder icon">
|
||||||
|
</div>
|
||||||
|
<div class="main-items-fileName">
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->/"><!--FileEncodeReplaceName--></a>
|
||||||
|
</div>
|
||||||
|
<div class="main-items-dateTime" ><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="main-items-fileSize" ><!--size--></div>
|
||||||
|
</div>
|
||||||
|
<!--FolderListEnd-->
|
||||||
|
<!--FileListStart-->
|
||||||
|
<div class="main-items">
|
||||||
|
<!--AdminStart-->
|
||||||
|
<div class="main-items-radio-box">
|
||||||
|
<input class="main-items-radio" type="radio" checked name="file" id="">
|
||||||
|
</div>
|
||||||
|
<!--AdminEnd-->
|
||||||
|
<div class="main-items-icon">
|
||||||
|
<i class="iconfont"></i>
|
||||||
|
</div>
|
||||||
|
<div class="main-items-fileName">
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->?preview" target="_blank"><!--FileEncodeReplaceName--></a>
|
||||||
|
</div>
|
||||||
|
<div class="main-items-dateTime" ><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="main-items-fileSize" ><!--size--></div>
|
||||||
|
</div>
|
||||||
|
<!--FileListEnd-->
|
||||||
|
</div>
|
||||||
|
<!--IsFolderEnd-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--ListEnd-->
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<!-- OneDrive程序 -->
|
||||||
|
</footer>
|
||||||
|
<div id="mask" class="mask" style="display:none;"></div>
|
||||||
|
<!--LoginStart-->
|
||||||
|
<div id="login_div" class="operatediv" style="display:none">
|
||||||
|
<div style="margin:50px">
|
||||||
|
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
|
||||||
|
<center>
|
||||||
|
<form action="<!--IsPreview?-->admin" method="post">
|
||||||
|
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
|
||||||
|
<input type="submit" value="<!--constStr@Login-->">
|
||||||
|
</form>
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--LoginEnd-->
|
||||||
|
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function ()
|
||||||
|
{
|
||||||
|
// 获取所有radios元素
|
||||||
|
var allRadios = document.getElementsByClassName("main-items-radio");
|
||||||
|
RegisterRadioClick(allRadios);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 为所有radio注册点击事件
|
||||||
|
function RegisterRadioClick(radios)
|
||||||
|
{
|
||||||
|
if (radios != null)
|
||||||
|
{
|
||||||
|
var radio;
|
||||||
|
for (var i = 0; i < radios.length ; i++)
|
||||||
|
{
|
||||||
|
// 获取单个radio元素
|
||||||
|
radio = radios[i];
|
||||||
|
// 为每个radio元素设置当前状态为:False
|
||||||
|
//radio.setAttribute("currStatus", "false");
|
||||||
|
// 页面刚加载后,取消因缓存的checked属性
|
||||||
|
radio.checked = false;
|
||||||
|
// 为页面中每个radio元素注册点击事件
|
||||||
|
radio.onclick = function()
|
||||||
|
{
|
||||||
|
// 获取当前点击对象的自定义属性
|
||||||
|
var currStatus = this.getAttribute("currStatus");
|
||||||
|
AllRadioCurrentStatus2False(radios);
|
||||||
|
if (currStatus === "true")
|
||||||
|
{
|
||||||
|
AllRadioCurrentStatus2False(radios);
|
||||||
|
this.setAttribute("currStatus", false);
|
||||||
|
this.checked = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setAttribute("currStatus", true);
|
||||||
|
this.checked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 把页面里所有radio元素自定义属性变成为false
|
||||||
|
// 不然会出现需要点击两次才会被选中
|
||||||
|
function AllRadioCurrentStatus2False(radios)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < radios.length; i++)
|
||||||
|
{
|
||||||
|
radios[i].setAttribute("currStatus", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function changelanguage(str)
|
||||||
|
{
|
||||||
|
if (str=='Language') str = '';
|
||||||
|
document.cookie='language='+str+'; path=/';
|
||||||
|
location.href = location.href;
|
||||||
|
}
|
||||||
|
<!--ListStart-->
|
||||||
|
/*var root = '<!--base_disk_path-->';
|
||||||
|
function path_format(path) {
|
||||||
|
path = '/' + path + '/';
|
||||||
|
while (path.indexOf('//') !== -1) {
|
||||||
|
path = path.replace('//', '/')
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
document.querySelectorAll('.main-title-path').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 = '<a href="' + root + '"><!--constStr@Home--></a> > ';
|
||||||
|
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-->
|
||||||
|
var $url = document.getElementById('url');
|
||||||
|
if ($url) {
|
||||||
|
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
||||||
|
$url.style.height = $url.scrollHeight + 'px';
|
||||||
|
}
|
||||||
|
<!--IsvideoFileStart-->
|
||||||
|
function loadResources(type, src, callback) {
|
||||||
|
let script = document.createElement(type);
|
||||||
|
let loaded = false;
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
script.onload = script.onreadystatechange = () => {
|
||||||
|
if (!loaded && (!script.readyState || /loaded|complete/.test(script.readyState))) {
|
||||||
|
script.onload = script.onreadystatechange = null;
|
||||||
|
loaded = true;
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type === 'link') {
|
||||||
|
script.href = src;
|
||||||
|
script.rel = 'stylesheet';
|
||||||
|
} else {
|
||||||
|
script.src = src;
|
||||||
|
}
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(script);
|
||||||
|
}
|
||||||
|
function addVideos(videos) {
|
||||||
|
let host = 'https://s0.pstatp.com/cdn/expire-1-M';
|
||||||
|
let unloadedResourceCount = 4;
|
||||||
|
let callback = (() => {
|
||||||
|
return () => {
|
||||||
|
if (!--unloadedResourceCount) {
|
||||||
|
createDplayers(videos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(unloadedResourceCount, videos);
|
||||||
|
loadResources(
|
||||||
|
'link',
|
||||||
|
host + '/dplayer/1.25.0/DPlayer.min.css',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
loadResources(
|
||||||
|
'script',
|
||||||
|
host + '/dplayer/1.25.0/DPlayer.min.js',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
loadResources(
|
||||||
|
'script',
|
||||||
|
host + '/hls.js/0.12.4/hls.light.min.js',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
loadResources(
|
||||||
|
'script',
|
||||||
|
host + '/flv.js/1.5.0/flv.min.js',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function createDplayers(videos) {
|
||||||
|
for (i = 0; i < videos.length; i++) {
|
||||||
|
console.log(videos[i]);
|
||||||
|
new DPlayer({
|
||||||
|
container: document.getElementById('video-a' + i),
|
||||||
|
screenshot: true,
|
||||||
|
video: {
|
||||||
|
url: videos[i]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addVideos(['<!--FileDownUrl-->']);
|
||||||
|
<!--IsvideoFileEnd-->
|
||||||
|
<!--IsFileEnd-->
|
||||||
|
<!--ListEnd-->
|
||||||
|
<!--AdminStart-->
|
||||||
|
function logout() {
|
||||||
|
document.cookie = "admin=; path=/";
|
||||||
|
location.href = location.href;
|
||||||
|
}
|
||||||
|
<!--AdminEnd-->
|
||||||
|
<!--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();
|
||||||
|
}
|
||||||
|
<!--LoginEnd-->
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+1245
File diff suppressed because it is too large
Load Diff
+47
-63
@@ -2,7 +2,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<?php echo $constStr['language']; ?>">
|
<html lang="<?php echo $constStr['language']; ?>">
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) echo ' - ' . getConfig('diskname');?> - <?php echo $_SERVER['sitename'];?></title>
|
<title><?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) { if (getConfig('diskname')!='') $diskname = getConfig('diskname'); else $diskname = $_SERVER['disktag']; echo ' - ' . $diskname; } ?> - <?php echo $_SERVER['sitename'];?></title>
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
<meta http-equiv=X-UA-Compatible content="IE=edge">
|
<meta http-equiv=X-UA-Compatible content="IE=edge">
|
||||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div style="padding:1px">
|
<div style="padding:1px">
|
||||||
<?php
|
<?php
|
||||||
@@ -67,11 +68,10 @@
|
|||||||
<a class="login" onclick="login();"><ion-icon name="log-in"></ion-icon><?php echo getconstStr('Login'); ?></a>
|
<a class="login" onclick="login();"><ion-icon name="log-in"></ion-icon><?php echo getconstStr('Login'); ?></a>
|
||||||
<?php }
|
<?php }
|
||||||
} else { ?>
|
} else { ?>
|
||||||
|
|
||||||
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?><ul>
|
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?><ul>
|
||||||
<?php if (isset($files['folder'])) { ?>
|
<?php if (isset($files['folder'])) { ?>
|
||||||
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><?php echo getconstStr('Create'); ?></a></li>
|
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><?php echo getconstStr('Create'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><?php echo getconstStr('Encrypt'); ?></a></li>
|
||||||
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><?php echo getconstStr('RefreshCache'); ?></a></li>
|
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><?php echo getconstStr('RefreshCache'); ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li><a href="<?php echo isset($_GET['preview'])?'?preview&':'?';?>setup"><ion-icon name="settings"></ion-icon><?php echo getconstStr('Setup'); ?></a></li>
|
<li><a href="<?php echo isset($_GET['preview'])?'?preview&':'?';?>setup"><ion-icon name="settings"></ion-icon><?php echo getconstStr('Setup'); ?></a></li>
|
||||||
@@ -79,6 +79,7 @@
|
|||||||
</ul></li>
|
</ul></li>
|
||||||
<?php
|
<?php
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
<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>
|
||||||
<?php
|
<?php
|
||||||
@@ -104,7 +105,7 @@
|
|||||||
<?php foreach ($disktags as $disk) {
|
<?php foreach ($disktags as $disk) {
|
||||||
$diskname = getConfig('diskname', $disk);
|
$diskname = getConfig('diskname', $disk);
|
||||||
if ($diskname=='') $diskname = $disk;
|
if ($diskname=='') $diskname = $disk;
|
||||||
echo ' <a href="'.path_format($_SERVER['base_path'].'/'.$disk).'"'.($_SERVER['disktag']==$disk?' now':'').'>'.$diskname.'</a>
|
echo ' <a href="'.path_format($_SERVER['base_path'].'/'.$disk.'/').'"'.($_SERVER['disktag']==$disk?' now':'').'>'.$diskname.'</a>
|
||||||
';
|
';
|
||||||
} ?>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
@@ -112,7 +113,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php }
|
<?php }
|
||||||
if ($files) { ?>
|
if ($files) {
|
||||||
|
if (isset($files['children']['head.md'])) { ?>
|
||||||
|
<div class="list-wrapper" id="head-div">
|
||||||
|
<div class="list-container">
|
||||||
|
<div class="list-header-container">
|
||||||
|
<div class="readme">
|
||||||
|
<div class="markdown-body" id="head">
|
||||||
|
<textarea id="head-md" style="display:none;"><?php echo fetch_files(spurlencode(path_format($path . '/head.md'),'/'))['content']['body']; ?></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<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">
|
||||||
@@ -136,8 +150,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="list-body-container">
|
<div class="list-body-container">
|
||||||
<?php
|
<?php
|
||||||
$head = false;
|
|
||||||
$readme = false;
|
|
||||||
$pdfurl = false;
|
$pdfurl = false;
|
||||||
$DPvideo = false;
|
$DPvideo = false;
|
||||||
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) { ?>
|
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) { ?>
|
||||||
@@ -227,7 +239,7 @@
|
|||||||
<?php if ($_SERVER['admin']) { ?>
|
<?php if ($_SERVER['admin']) { ?>
|
||||||
<li class="operate"><ion-icon name="construct"></ion-icon><a><?php echo getconstStr('Operate'); ?></a>
|
<li class="operate"><ion-icon name="construct"></ion-icon><a><?php echo getconstStr('Operate'); ?></a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><ion-icon name="lock"></ion-icon><?php echo getconstStr('Encrypt'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'copy',<?php echo $filenum;?>);"><ion-icon name="copy"></ion-icon><?php echo getconstStr('Copy'); ?></a></li>
|
<li><a onclick="showdiv(event, 'copy',<?php echo $filenum;?>);"><ion-icon name="copy"></ion-icon><?php echo getconstStr('Copy'); ?></a></li>
|
||||||
@@ -247,12 +259,6 @@
|
|||||||
foreach ($files['children'] as $file) {
|
foreach ($files['children'] as $file) {
|
||||||
// Files
|
// Files
|
||||||
if (isset($file['file'])) {
|
if (isset($file['file'])) {
|
||||||
if (strtolower($file['name']) === 'head.md') $head = $file;
|
|
||||||
if (strtolower($file['name']) === 'readme.md') $readme = $file;
|
|
||||||
if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) {
|
|
||||||
$html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body'];
|
|
||||||
return output($html,200);
|
|
||||||
}
|
|
||||||
if ($_SERVER['admin'] or !isHideFile($file['name'])) {
|
if ($_SERVER['admin'] or !isHideFile($file['name'])) {
|
||||||
$filenum++; ?>
|
$filenum++; ?>
|
||||||
<tr data-to id="tr<?php echo $filenum;?>">
|
<tr data-to id="tr<?php echo $filenum;?>">
|
||||||
@@ -354,25 +360,7 @@
|
|||||||
echo 'Unknown path or file.';
|
echo 'Unknown path or file.';
|
||||||
echo json_encode($files, JSON_PRETTY_PRINT);
|
echo json_encode($files, JSON_PRETTY_PRINT);
|
||||||
}
|
}
|
||||||
if ($head) {
|
if (isset($files['children']['readme.md'])) {
|
||||||
echo '
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="list-wrapper" id="head-div">
|
|
||||||
<div class="list-container">
|
|
||||||
<div class="list-header-container">
|
|
||||||
<div class="readme">
|
|
||||||
<!--<svg class="octicon octicon-book" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M3 5h4v1H3V5zm0 3h4V7H3v1zm0 2h4V9H3v1zm11-5h-4v1h4V5zm0 2h-4v1h4V7zm0 2h-4v1h4V9zm2-6v9c0 .55-.45 1-1 1H9.5l-1 1-1-1H2c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h5.5l1 1 1-1H15c.55 0 1 .45 1 1zm-8 .5L7.5 3H2v9h6V3.5zm7-.5H9.5l-.5.5V12h6V3z"></path></svg>
|
|
||||||
<span style="line-height: 16px;vertical-align: top;">'.$head['name'].'</span>-->
|
|
||||||
<div class="markdown-body" id="head">
|
|
||||||
<textarea id="head-md" style="display:none;">' . curl_request(fetch_files(spurlencode(path_format($path . '/' .$head['name']),'/'))['@microsoft.graph.downloadUrl'])['body'] . '
|
|
||||||
</textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
';
|
|
||||||
}
|
|
||||||
if ($readme) {
|
|
||||||
echo '
|
echo '
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -381,11 +369,8 @@
|
|||||||
<div class="list-container">
|
<div class="list-container">
|
||||||
<div class="list-header-container">
|
<div class="list-header-container">
|
||||||
<div class="readme">
|
<div class="readme">
|
||||||
<!--<svg class="octicon octicon-book" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M3 5h4v1H3V5zm0 3h4V7H3v1zm0 2h4V9H3v1zm11-5h-4v1h4V5zm0 2h-4v1h4V7zm0 2h-4v1h4V9zm2-6v9c0 .55-.45 1-1 1H9.5l-1 1-1-1H2c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h5.5l1 1 1-1H15c.55 0 1 .45 1 1zm-8 .5L7.5 3H2v9h6V3.5zm7-.5H9.5l-.5.5V12h6V3z"></path></svg>
|
|
||||||
<span style="line-height: 16px;vertical-align: top;">'.$readme['name'].'</span>-->
|
|
||||||
<div class="markdown-body" id="readme">
|
<div class="markdown-body" id="readme">
|
||||||
<textarea id="readme-md" style="display:none;">' . curl_request(fetch_files(spurlencode(path_format($path . '/' .$readme['name']),'/'))['@microsoft.graph.downloadUrl'])['body'] . '
|
<textarea id="readme-md" style="display:none;">' . fetch_files(spurlencode(path_format($path . '/readme.md'),'/'))['content']['body'] . '</textarea>
|
||||||
</textarea>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
';
|
';
|
||||||
@@ -443,7 +428,7 @@
|
|||||||
<input id="encrypt_sid" name="encrypt_sid" type="hidden" value="">
|
<input id="encrypt_sid" name="encrypt_sid" 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="<?php echo getconstStr('InputPasswordUWant'); ?>">
|
<input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<?php echo getconstStr('InputPasswordUWant'); ?>">
|
||||||
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo getconstStr('encrypt'); ?>"><?php } else { ?><br><label><?php echo getconstStr('SetpassfileBfEncrypt'); ?></label><?php } ?>
|
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo getconstStr('Encrypt'); ?>"><?php } else { ?><br><label><?php echo getconstStr('SetpassfileBfEncrypt'); ?></label><?php } ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -575,18 +560,24 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
<center>
|
<center>
|
||||||
<span id="clock"><span> <!--顶部span的id为clock-->
|
<span id="clock"><span> <!--顶部span的id为clock-->
|
||||||
<div class="footer_copyright">
|
<div class="footer_copyright">
|
||||||
Copyright © 2019-2020 - <span id="footyear"></span>OneManager,Power_by_逸笙 <em> 主题归彼岸云端版权所有</em>
|
Copyright © 2019-2020 - <span id="footyear"></span>OneManager Powered_by_逸笙 <em> 本主题(归彼岸云端)版权所有</em>
|
||||||
</div>
|
</div>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<?php if ($files) { ?>
|
<?php if ($files) { ?>
|
||||||
<?php if ($head||$readme) { ?><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
<?php if (isset($files['children']['head.md'])||isset($files['children']['readme.md'])) { ?><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
||||||
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><?php } ?>
|
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><?php } ?>
|
||||||
<?php if (isset($files['folder']) && $_SERVER['is_guestup_path'] && !$_SERVER['admin']) { ?><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><?php } ?>
|
<?php if (isset($files['folder']) && $_SERVER['is_guestup_path'] && !$_SERVER['admin']) { ?><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><?php } ?>
|
||||||
<?php if ($pdfurl!='') { ?><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><?php } ?>
|
<?php if ($pdfurl!='') { ?><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
function changelanguage(str)
|
||||||
|
{
|
||||||
|
if (str=='Language') str = '';
|
||||||
|
document.cookie='language='+str+'; path=/';
|
||||||
|
location.href = location.href;
|
||||||
|
}
|
||||||
<?php if ($files) { ?>
|
<?php if ($files) { ?>
|
||||||
var root = '<?php echo $_SERVER["base_disk_path"]; ?>';
|
var root = '<?php echo $_SERVER["base_disk_path"]; ?>';
|
||||||
function path_format(path) {
|
function path_format(path) {
|
||||||
@@ -608,23 +599,6 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
e.innerHTML += paths[paths.length - 1];
|
e.innerHTML += paths[paths.length - 1];
|
||||||
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
|
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
|
||||||
});
|
});
|
||||||
|
|
||||||
function changelanguage(str)
|
|
||||||
{
|
|
||||||
if (str=='Language') str = '';
|
|
||||||
document.cookie='language='+str+'; path=/';
|
|
||||||
location.href = location.href;
|
|
||||||
}
|
|
||||||
var $head = document.getElementById('head');
|
|
||||||
if ($head) {
|
|
||||||
document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div'));
|
|
||||||
$head.innerHTML = marked(document.getElementById('head-md').innerText);
|
|
||||||
|
|
||||||
}
|
|
||||||
var $readme = document.getElementById('readme');
|
|
||||||
if ($readme) {
|
|
||||||
$readme.innerHTML = marked(document.getElementById('readme-md').innerText);
|
|
||||||
}
|
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET['preview'])) { //is preview mode. 在预览时处理 ?>
|
if (isset($_GET['preview'])) { //is preview mode. 在预览时处理 ?>
|
||||||
var $url = document.getElementById('url');
|
var $url = document.getElementById('url');
|
||||||
@@ -737,6 +711,16 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
}
|
}
|
||||||
<?php }
|
<?php }
|
||||||
} else { // view folder. 不预览,即浏览目录时?>
|
} else { // view folder. 不预览,即浏览目录时?>
|
||||||
|
var $head = document.getElementById('head');
|
||||||
|
if ($head) {
|
||||||
|
//document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div'));
|
||||||
|
$head.innerHTML = marked(document.getElementById('head-md').innerText);
|
||||||
|
|
||||||
|
}
|
||||||
|
var $readme = document.getElementById('readme');
|
||||||
|
if ($readme) {
|
||||||
|
$readme.innerHTML = marked(document.getElementById('readme-md').innerText);
|
||||||
|
}
|
||||||
function showthumbnails(obj) {
|
function showthumbnails(obj) {
|
||||||
var files=document.getElementsByName('filelist');
|
var files=document.getElementsByName('filelist');
|
||||||
for ($i=0;$i<files.length;$i++) {
|
for ($i=0;$i<files.length;$i++) {
|
||||||
@@ -774,8 +758,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
tmptextarea.select();
|
tmptextarea.select();
|
||||||
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
|
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
alert(tmptextarea.innerHTML);
|
alert(tmptextarea.innerHTML+'<?php echo getconstStr('Success'); ?>');
|
||||||
//alert('Success');
|
|
||||||
}
|
}
|
||||||
var sort=0;
|
var sort=0;
|
||||||
function sortby(string) {
|
function sortby(string) {
|
||||||
@@ -928,7 +911,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var xhr1 = new XMLHttpRequest();
|
var xhr1 = new XMLHttpRequest();
|
||||||
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent(file.name) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent((file.webkitRelativePath||file.name)) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
||||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr1.send(null);
|
xhr1.send(null);
|
||||||
xhr1.onload = function(e){
|
xhr1.onload = function(e){
|
||||||
@@ -1039,7 +1022,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
if (response['size']>0) {
|
if (response['size']>0) {
|
||||||
// contain size, upload finish. 有size说明是最终返回,上传结束
|
// contain size, upload finish. 有size说明是最终返回,上传结束
|
||||||
var xhr3 = new XMLHttpRequest();
|
var xhr3 = new XMLHttpRequest();
|
||||||
xhr3.open("GET", '?action=del_upload_cache&filename=.'+file.lastModified+ '_' +file.size+ '_' +encodeURIComponent(file.name)+'.tmp');
|
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+encodeURIComponent((file.webkitRelativePath||file.name)));
|
||||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr3.send(null);
|
xhr3.send(null);
|
||||||
xhr3.onload = function(e){
|
xhr3.onload = function(e){
|
||||||
@@ -1048,7 +1031,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
<?php if (!$_SERVER['admin']) { ?>
|
<?php if (!$_SERVER['admin']) { ?>
|
||||||
var filemd5 = spark.end();
|
var filemd5 = spark.end();
|
||||||
var xhr4 = new XMLHttpRequest();
|
var xhr4 = new XMLHttpRequest();
|
||||||
xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent(file.name)+'&filemd5='+filemd5);
|
xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent((file.webkitRelativePath||file.name))+'&filemd5='+filemd5);
|
||||||
xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr4.send(null);
|
xhr4.send(null);
|
||||||
xhr4.onload = function(e){
|
xhr4.onload = function(e){
|
||||||
@@ -1068,6 +1051,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
//window.open(lasturl);
|
//window.open(lasturl);
|
||||||
document.getElementById('upfile_a_'+tdnum).href = lasturl;
|
document.getElementById('upfile_a_'+tdnum).href = lasturl;
|
||||||
document.getElementById('upfile_a1_'+tdnum).href = filename;
|
document.getElementById('upfile_a1_'+tdnum).href = filename;
|
||||||
|
document.getElementById('upfile_cpbt_'+tdnum).style.display = "";
|
||||||
}
|
}
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
EndTime=new Date();
|
EndTime=new Date();
|
||||||
@@ -1077,7 +1061,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
} else {
|
} else {
|
||||||
MiddleStr += '<?php echo getconstStr('ThisTime').getconstStr('AverageSpeed'); ?>:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
MiddleStr += '<?php echo getconstStr('ThisTime').getconstStr('AverageSpeed'); ?>:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||||
}
|
}
|
||||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="'+response.name+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="'+response.name+'" id="upfile_a1_'+tdnum+'"></a><?php echo getconstStr('UploadComplete'); ?><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');"><?php echo getconstStr('CopyUrl'); ?></button></div>';
|
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<?php echo $_SERVER['base_disk_path']; ?>'+response.name+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<?php echo $_SERVER['base_disk_path']; ?>'+response.name+'" id="upfile_a1_'+tdnum+'"></a><?php echo getconstStr('UploadComplete'); ?><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <?php if (!$_SERVER['admin']) echo 'style="display:none"'; ?> ><?php echo getconstStr('CopyUrl'); ?></button></div>';
|
||||||
label.innerHTML=StartStr+MiddleStr;
|
label.innerHTML=StartStr+MiddleStr;
|
||||||
uploadbuttonshow();
|
uploadbuttonshow();
|
||||||
<?php if ($_SERVER['admin']) { ?>
|
<?php if ($_SERVER['admin']) { ?>
|
||||||
|
|||||||
+6
-6
@@ -74,7 +74,7 @@
|
|||||||
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?><ul>
|
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?><ul>
|
||||||
<?php if (isset($files['folder'])) { ?>
|
<?php if (isset($files['folder'])) { ?>
|
||||||
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><?php echo getconstStr('Create'); ?></a></li>
|
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><?php echo getconstStr('Create'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><?php echo getconstStr('Encrypt'); ?></a></li>
|
||||||
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><?php echo getconstStr('RefreshCache'); ?></a></li>
|
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><?php echo getconstStr('RefreshCache'); ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li><a href="<?php echo $_GET['preview']?'?preview&':'?';?>setup"><ion-icon name="settings"></ion-icon><?php echo getconstStr('Setup'); ?></a></li>
|
<li><a href="<?php echo $_GET['preview']?'?preview&':'?';?>setup"><ion-icon name="settings"></ion-icon><?php echo getconstStr('Setup'); ?></a></li>
|
||||||
@@ -229,7 +229,7 @@
|
|||||||
<?php if ($_SERVER['admin']) { ?>
|
<?php if ($_SERVER['admin']) { ?>
|
||||||
<li class="operate"><ion-icon name="construct"></ion-icon><a><?php echo getconstStr('Operate'); ?></a>
|
<li class="operate"><ion-icon name="construct"></ion-icon><a><?php echo getconstStr('Operate'); ?></a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><ion-icon name="lock"></ion-icon><?php echo getconstStr('Encrypt'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'copy',<?php echo $filenum;?>);"><ion-icon name="copy"></ion-icon><?php echo getconstStr('Copy'); ?></a></li>
|
<li><a onclick="showdiv(event, 'copy',<?php echo $filenum;?>);"><ion-icon name="copy"></ion-icon><?php echo getconstStr('Copy'); ?></a></li>
|
||||||
@@ -445,7 +445,7 @@
|
|||||||
<input id="encrypt_sid" name="encrypt_sid" type="hidden" value="">
|
<input id="encrypt_sid" name="encrypt_sid" 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="<?php echo getconstStr('InputPasswordUWant'); ?>">
|
<input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<?php echo getconstStr('InputPasswordUWant'); ?>">
|
||||||
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo getconstStr('encrypt'); ?>"><?php } else { ?><br><label><?php echo getconstStr('SetpassfileBfEncrypt'); ?></label><?php } ?>
|
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo getconstStr('Encrypt'); ?>"><?php } else { ?><br><label><?php echo getconstStr('SetpassfileBfEncrypt'); ?></label><?php } ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -908,7 +908,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var xhr1 = new XMLHttpRequest();
|
var xhr1 = new XMLHttpRequest();
|
||||||
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent(file.name) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent((file.webkitRelativePath||file.name)) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
||||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr1.send(null);
|
xhr1.send(null);
|
||||||
xhr1.onload = function(e){
|
xhr1.onload = function(e){
|
||||||
@@ -1019,7 +1019,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
if (response['size']>0) {
|
if (response['size']>0) {
|
||||||
// contain size, upload finish. 有size说明是最终返回,上传结束
|
// contain size, upload finish. 有size说明是最终返回,上传结束
|
||||||
var xhr3 = new XMLHttpRequest();
|
var xhr3 = new XMLHttpRequest();
|
||||||
xhr3.open("GET", '?action=del_upload_cache&filename=.'+file.lastModified+ '_' +file.size+ '_' +encodeURIComponent(file.name)+'.tmp');
|
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+encodeURIComponent((file.webkitRelativePath||file.name)));
|
||||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr3.send(null);
|
xhr3.send(null);
|
||||||
xhr3.onload = function(e){
|
xhr3.onload = function(e){
|
||||||
@@ -1028,7 +1028,7 @@ echo 'IPv4: ' ,$ip, "\n";
|
|||||||
<?php if (!$_SERVER['admin']) { ?>
|
<?php if (!$_SERVER['admin']) { ?>
|
||||||
var filemd5 = spark.end();
|
var filemd5 = spark.end();
|
||||||
var xhr4 = new XMLHttpRequest();
|
var xhr4 = new XMLHttpRequest();
|
||||||
xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent(file.name)+'&filemd5='+filemd5);
|
xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent((file.webkitRelativePath||file.name))+'&filemd5='+filemd5);
|
||||||
xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr4.send(null);
|
xhr4.send(null);
|
||||||
xhr4.onload = function(e){
|
xhr4.onload = function(e){
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,377 @@
|
|||||||
|
<!--IconValuesStart-->
|
||||||
|
{
|
||||||
|
"music":"audiotrack",
|
||||||
|
"video":"ondemand_video",
|
||||||
|
"img":"image",
|
||||||
|
"default":"insert_drive_file"
|
||||||
|
}
|
||||||
|
<!--IconValuesEnd-->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="<!--constStr@language-->">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
|
||||||
|
<title><!--Title--></title>
|
||||||
|
<link rel="icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="stylesheet" href="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/css/mdui.css">
|
||||||
|
<style>
|
||||||
|
body{background-color:#f2f5fa;padding-bottom:60px;<!--BackgroundStart-->background-position:center bottom;background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-image:url("<!--BackgroundUrl-->");<!--BackgroundEnd-->}
|
||||||
|
.nexmoe-item{margin:20px -8px 0!important;padding:15px!important;border-radius:5px;background-color:#fff;-webkit-box-shadow:0 .5em 3em rgba(161,177,204,.4);box-shadow:0 .5em 3em rgba(161,177,204,.4);background-color:#fff}
|
||||||
|
.mdui-img-fluid,.mdui-video-fluid{border-radius:5px;border:1px solid #eee}
|
||||||
|
.mdui-list{padding:0}
|
||||||
|
.mdui-list-item{margin:0!important;border-radius:5px;padding:0 10px 0 5px!important;border:1px solid #eee;margin-bottom:10px!important}
|
||||||
|
.mdui-list-item:last-child{margin-bottom:0!important}
|
||||||
|
.mdui-list-item:first-child{border:none}
|
||||||
|
.mdui-toolbar{width:auto;margin-top:60px!important}
|
||||||
|
.mdui-appbar .mdui-toolbar{height:56px;font-size:16px}
|
||||||
|
.mdui-toolbar>*{padding:0 6px;margin:0 2px;}
|
||||||
|
.mdui-toolbar>.mdui-typo-headline{padding:0 16px 0 0}
|
||||||
|
.mdui-toolbar>i{padding:0}
|
||||||
|
.mdui-toolbar>a{padding:0 16px;line-height:30px;border-radius:30px;border:1px solid #eee;opacity:.87}
|
||||||
|
.mdui-toolbar>a:hover,a.mdui-typo-headline,a.active{opacity:1}
|
||||||
|
.mdui-container{max-width:980px}
|
||||||
|
.mdui-list>.th{background-color:initial}
|
||||||
|
.mdui-list-item>a{width:100%;line-height:48px}
|
||||||
|
.mdui-toolbar>a:last-child{opacity:1;background-color:#1e89f2;color:#ffff}
|
||||||
|
.more-disk{display: inline-block;max-width: 100px;}
|
||||||
|
.more-disk div{
|
||||||
|
list-style:none;
|
||||||
|
position:absolute;display:none;background:#ffffff;border-radius:5px;margin:0 0 0 -10px;/*padding:0 7px;*/color:#205D67;z-index:1;
|
||||||
|
box-shadow: 0 0.5em 3em rgba(161,177,204,.4);
|
||||||
|
}
|
||||||
|
.more-disk:hover div{display:block}
|
||||||
|
.more-disk div li{line-height:normal;padding: 3px 10px;}
|
||||||
|
.more-disk div li a{text-decoration: none; color:rgba(0,0,0,.3);}
|
||||||
|
.more-disk div li a:hover{color:rgba(0,0,0,.87);}
|
||||||
|
.more-disk div li a[now]{color:rgba(0,0,0,1);}
|
||||||
|
@media screen and (max-width:980px){
|
||||||
|
.mdui-list-item .mdui-text-right{display:none}
|
||||||
|
.mdui-container{width:100%!important;margin:0}
|
||||||
|
/*.mdui-toolbar>*{display:none}*/
|
||||||
|
.mdui-toolbar>a:last-child,.mdui-toolbar>.mdui-typo-headline,.mdui-toolbar>i:first-child{display:block}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<!--customCss-->
|
||||||
|
<script src="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/js/mdui.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body class="mdui-theme-primary-blue-grey mdui-theme-accent-blue">
|
||||||
|
<div class="mdui-container">
|
||||||
|
<div class="mdui-container-fluid">
|
||||||
|
<div class="mdui-toolbar nexmoe-item" id="toolbar">
|
||||||
|
<a href="<!--base_path-->"><!--Sitename--></a>
|
||||||
|
<!--MultiDiskAreaStart-->
|
||||||
|
<i class="mdui-icon material-icons mdui-icon-dark" style="margin:0;">chevron_right</i>
|
||||||
|
<div class="more-disk">
|
||||||
|
<span><!--DiskNameNow--></span>
|
||||||
|
<div>
|
||||||
|
<!--MultiDisksStart-->
|
||||||
|
<li><a href="<!--MultiDisksUrl-->" <!--MultiDisksNow-->><!--MultiDisksName--></a></li>
|
||||||
|
<!--MultiDisksEnd-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--MultiDiskAreaEnd-->
|
||||||
|
<!--PathArrayStart-->
|
||||||
|
<i class="mdui-icon material-icons mdui-icon-dark" style="margin:0;">chevron_right</i>
|
||||||
|
<a href="<!--PathArrayLink-->"><!--PathArrayName--></a>
|
||||||
|
<!--PathArrayEnd-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--ListStart-->
|
||||||
|
<div class="mdui-container-fluid">
|
||||||
|
<!--EncryptedStart-->
|
||||||
|
<div class="mdui-col-md-6 mdui-col-offset-md-3">
|
||||||
|
<!--<center><h1 class="mdui-typo-display-2-opacity">这是一个受保护的文件夹,您需要提供访问密码才能查看。</h1></center>-->
|
||||||
|
<form action="" method="post">
|
||||||
|
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||||
|
<i class="mdui-icon material-icons">https</i>
|
||||||
|
<label class="mdui-textfield-label"><!--constStr@InputPassword--></label>
|
||||||
|
<input name="password1" class="mdui-textfield-input" type="password"/>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<button type="submit" class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme">
|
||||||
|
<i class="mdui-icon material-icons">fingerprint</i>
|
||||||
|
<!--constStr@Submit-->
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!--EncryptedEnd-->
|
||||||
|
<!--GuestUploadStart-->
|
||||||
|
<!--
|
||||||
|
<div class="nexmoe-item" style="padding: 100px!important;">
|
||||||
|
<div class="mdui-typo-display-3-opacity" style="text-align:center;">OneImages</div>
|
||||||
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
|
<input class="mdui-center" type="file" style="margin: 50px 0;" name="file" />
|
||||||
|
<div class="mdui-row-xs-3">
|
||||||
|
<div class="mdui-col"></div>
|
||||||
|
<div class="mdui-col">
|
||||||
|
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple"><!--constStr@Upload--></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
<!--GuestUploadEnd-->
|
||||||
|
<!--HeadomfStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--HeadomfContent-->
|
||||||
|
</div>
|
||||||
|
<!--HeadomfEnd-->
|
||||||
|
<!--HeadmdStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--HeadmdContent-->
|
||||||
|
</div>
|
||||||
|
<!--HeadmdEnd-->
|
||||||
|
<!--IsFileStart-->
|
||||||
|
<!--IsimgFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<img class="mdui-img-fluid mdui-center" src="<!--FileDownUrl-->"/>
|
||||||
|
</div>
|
||||||
|
<!--IsimgFileEnd-->
|
||||||
|
<!--IstxtFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<pre id="editor" style="white-space: pre-wrap;"><!--TxtContent--></pre>
|
||||||
|
</div>
|
||||||
|
<!--IstxtFileEnd-->
|
||||||
|
<!--IsmusicFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<audio class="mdui-center" src="<!--FileDownUrl-->" controls autoplay style="width: 100%;" ></audio>
|
||||||
|
</div>
|
||||||
|
<!--IsmusicFileEnd-->
|
||||||
|
<!--IsofficeFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->" style="width: 100%;height: 800px" frameborder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
<!--IsofficeFileEnd-->
|
||||||
|
<!--IsvideoFileStart-->
|
||||||
|
<link class="dplayer-css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<div class="mdui-center" id="dplayer"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const dp = new DPlayer({
|
||||||
|
container: document.getElementById('dplayer'),
|
||||||
|
lang:'zh-cn',
|
||||||
|
video: {
|
||||||
|
url: '<!--FileDownUrl-->',
|
||||||
|
type: 'auto'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<!--IsvideoFileEnd-->
|
||||||
|
<!--IsOtherFileStart-->
|
||||||
|
<div class="nexmoe-item"><!--constStr@FileNotSupport--></div>
|
||||||
|
<!--IsOtherFileEnd-->
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">file_download</i></a>
|
||||||
|
<!--IsFileEnd-->
|
||||||
|
<!--IsFolderStart-->
|
||||||
|
<style>
|
||||||
|
.thumb .th{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.thumb .mdui-text-right{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.thumb .mdui-list-item a ,.thumb .mdui-list-item {
|
||||||
|
width:217px;
|
||||||
|
height: 230px;
|
||||||
|
float: left;
|
||||||
|
margin: 10px 10px !important;
|
||||||
|
}
|
||||||
|
.thumb .mdui-col-xs-12,.thumb .mdui-col-sm-7{
|
||||||
|
width:100% !important;
|
||||||
|
height:230px;
|
||||||
|
}
|
||||||
|
.thumb .mdui-list-item .mdui-icon{
|
||||||
|
font-size:100px;
|
||||||
|
display: block;
|
||||||
|
margin-top: 40px;
|
||||||
|
color: #7ab5ef;
|
||||||
|
}
|
||||||
|
.thumb .mdui-list-item span{
|
||||||
|
float: left;
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
width:100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 180px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
|
||||||
|
<div class="mdui-row">
|
||||||
|
<ul class="mdui-list">
|
||||||
|
<li class="mdui-list-item th">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7"><!--constStr@File--> <i class="mdui-icon material-icons icon-sort" data-sort="name" data-order="downward">expand_more</i></div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--constStr@EditTime--> <i class="mdui-icon material-icons icon-sort" data-sort="date" data-order="downward">expand_more</i></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--constStr@Size--> <i class="mdui-icon material-icons icon-sort" data-sort="size" data-order="downward">expand_more</i></div>
|
||||||
|
</li>
|
||||||
|
<!--BackArrowStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple">
|
||||||
|
<a href="<!--BackArrowUrl-->">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7">
|
||||||
|
<i class="mdui-icon material-icons">arrow_upward</i>
|
||||||
|
..
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"></div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<!--BackArrowEnd-->
|
||||||
|
|
||||||
|
<!--FolderListStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple">
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->/">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||||
|
<i class="mdui-icon material-icons">folder_open</i>
|
||||||
|
<span><!--FileEncodeReplaceName--></span>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<!--FolderListEnd-->
|
||||||
|
<!--FileListStart-->
|
||||||
|
<li class="mdui-list-item file mdui-ripple">
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->?preview" target="_blank">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||||
|
<i class="mdui-icon material-icons"><!--IconValue--></i>
|
||||||
|
<span><!--FileEncodeReplaceName--></span>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<!--FileListEnd-->
|
||||||
|
|
||||||
|
<!--MorePageStart-->
|
||||||
|
<form action="" method="POST" id="nextpageform">
|
||||||
|
<input type="hidden" id="pagenum" name="pagenum" value="">
|
||||||
|
<li class="mdui-list-item th">
|
||||||
|
<div class="mdui-col-sm-6 mdui-left mdui-text-left">
|
||||||
|
<!--PrePageStart-->
|
||||||
|
<a onclick="nextpage(<!--PrePageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@PrePage--></a>
|
||||||
|
<!--PrePageEnd-->
|
||||||
|
<!--NextPageStart-->
|
||||||
|
<a onclick="nextpage(<!--NextPageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@NextPage--></a>
|
||||||
|
<!--NextPageEnd-->
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-6 mdui-right mdui-text-right">
|
||||||
|
<div class="mdui-right mdui-text-right"><span class="mdui-chip-title">Page: <!--MorePageListStart--><!--MorePageListEnd--><!--MorePageListNowStart--><!--PageNum--><!--MorePageListNowEnd-->/<!--MaxPageNum--></span></div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</form>
|
||||||
|
<!--MorePageEnd-->
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--ReadmemdStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--ReadmemdContent-->
|
||||||
|
</div>
|
||||||
|
<!--ReadmemdEnd-->
|
||||||
|
<!--FootomfStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--FootomfContent-->
|
||||||
|
</div>
|
||||||
|
<!--FootomfEnd-->
|
||||||
|
</div>
|
||||||
|
<!--ShowThumbnailsStart-->
|
||||||
|
<a href="javascript:thumb();" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">format_list_bulleted</i></a>
|
||||||
|
<!--ShowThumbnailsEnd-->
|
||||||
|
<!--IsFolderEnd-->
|
||||||
|
<!--ListEnd-->
|
||||||
|
<!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
||||||
|
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
|
||||||
|
<script>
|
||||||
|
<!--MorePageStart-->
|
||||||
|
function nextpage(num) {
|
||||||
|
document.getElementById('pagenum').value=num;
|
||||||
|
document.getElementById('nextpageform').submit();
|
||||||
|
}
|
||||||
|
<!--MorePageEnd-->
|
||||||
|
$ = mdui.JQ;
|
||||||
|
$.fn.extend({
|
||||||
|
sortElements: function (comparator, getSortable) {
|
||||||
|
getSortable = getSortable || function () { return this; };
|
||||||
|
var placements = this.map(function () {
|
||||||
|
var sortElement = getSortable.call(this),
|
||||||
|
parentNode = sortElement.parentNode,
|
||||||
|
nextSibling = parentNode.insertBefore(
|
||||||
|
document.createTextNode(''),
|
||||||
|
sortElement.nextSibling
|
||||||
|
);
|
||||||
|
return function () {
|
||||||
|
parentNode.insertBefore(this, nextSibling);
|
||||||
|
parentNode.removeChild(nextSibling);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return [].sort.call(this, comparator).each(function (i) {
|
||||||
|
placements[i].call(getSortable.call(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function downall() {
|
||||||
|
let dl_link_list = Array.from(document.querySelectorAll("li a"))
|
||||||
|
.map(x => x.href) // 所有list中的链接
|
||||||
|
.filter(x => x.slice(-1) != "/"); // 筛选出非文件夹的文件下载链接
|
||||||
|
let blob = new Blob([dl_link_list.join("\r\n")], {
|
||||||
|
type: 'text/plain'
|
||||||
|
}); // 构造Blog对象
|
||||||
|
let a = document.createElement('a'); // 伪造一个a对象
|
||||||
|
a.href = window.URL.createObjectURL(blob); // 构造href属性为Blob对象生成的链接
|
||||||
|
a.download = "folder_download_link.txt"; // 文件名称,你可以根据你的需要构造
|
||||||
|
a.click() // 模拟点击
|
||||||
|
a.remove();
|
||||||
|
}
|
||||||
|
<!--ShowThumbnailsStart-->
|
||||||
|
function thumb(){
|
||||||
|
if($('.mdui-fab i').text() == "apps"){
|
||||||
|
$('.mdui-fab i').text("format_list_bulleted");
|
||||||
|
$('.nexmoe-item').removeClass('thumb');
|
||||||
|
$('.nexmoe-item .mdui-icon').show();
|
||||||
|
$('.nexmoe-item .mdui-list-item').css("background","");
|
||||||
|
}else{
|
||||||
|
$('.mdui-fab i').text("apps");
|
||||||
|
$('.nexmoe-item').addClass('thumb');
|
||||||
|
$('.mdui-col-xs-12 i.mdui-icon').each(function(){
|
||||||
|
if($(this).text() == "image"){
|
||||||
|
var thumbnails = $(this).parent().parent().attr('href');
|
||||||
|
thumbnails = thumbnails.substr(0, thumbnails.length-8)+'?thumbnails&location';
|
||||||
|
$(this).hide();
|
||||||
|
$(this).parent().parent().parent().css("background","url("+thumbnails+") no-repeat center top");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<!--ShowThumbnailsEnd-->
|
||||||
|
$(function(){
|
||||||
|
$('.file a').each(function(){
|
||||||
|
$(this).on('click', function () {
|
||||||
|
var form = $('<form target=_blank method=post></form>').attr('action', $(this).attr('href')).get(0);
|
||||||
|
$(document.body).append(form);
|
||||||
|
form.submit();
|
||||||
|
$(form).remove();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('.icon-sort').on('click', function () {
|
||||||
|
let sort_type = $(this).attr("data-sort"), sort_order = $(this).attr("data-order");
|
||||||
|
let sort_order_to = (sort_order === "less") ? "more" : "less";
|
||||||
|
$('li[data-sort]').sortElements(function (a, b) {
|
||||||
|
let data_a = $(a).attr("data-sort-" + sort_type), data_b = $(b).attr("data-sort-" + sort_type);
|
||||||
|
let rt = data_a.localeCompare(data_b, undefined, {numeric: true});
|
||||||
|
return (sort_order === "more") ? 0-rt : rt;
|
||||||
|
});
|
||||||
|
$(this).attr("data-order", sort_order_to).text("expand_" + sort_order_to);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.markdown').forEach(function (e) {
|
||||||
|
e.innerHTML = marked(e.innerHTML);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,580 @@
|
|||||||
|
<!--IconValuesStart-->
|
||||||
|
{
|
||||||
|
"music":"audiotrack",
|
||||||
|
"video":"ondemand_video",
|
||||||
|
"img":"image",
|
||||||
|
"default":"insert_drive_file"
|
||||||
|
}
|
||||||
|
<!--IconValuesEnd-->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="<!--constStr@language-->">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
|
||||||
|
<title><!--Title--></title>
|
||||||
|
<link rel="stylesheet" href="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/css/mdui.css">
|
||||||
|
<script src="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/js/mdui.min.js"></script>
|
||||||
|
<script src="//cdn.bootcss.com/jquery/1.12.3/jquery.min.js"></script>
|
||||||
|
<script src="//cdn.staticfile.org/layer/2.3/layer.js"></script>
|
||||||
|
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css">
|
||||||
|
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
|
||||||
|
<link rel="icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body{<!--BackgroundStart-->background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-image:url("<!--BackgroundUrl-->");<!--BackgroundEnd-->}
|
||||||
|
.mdui-appbar .mdui-toolbar{
|
||||||
|
height:64px;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>*{
|
||||||
|
padding: 0 6px;
|
||||||
|
margin: 0 2px;
|
||||||
|
opacity:0.5;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>.mdui-typo-headline{
|
||||||
|
padding: 0 1px 0 0;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>i{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>a:hover,a.mdui-typo-headline,a.active{
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
.mdui-container{
|
||||||
|
max-width:950px;
|
||||||
|
}
|
||||||
|
.mdui-list-item{
|
||||||
|
-webkit-transition:none;
|
||||||
|
transition:none;
|
||||||
|
}
|
||||||
|
.mdui-list>.th{
|
||||||
|
background-color:initial;
|
||||||
|
}
|
||||||
|
.mdui-list-item>a{
|
||||||
|
width:100%;
|
||||||
|
line-height: 48px
|
||||||
|
}
|
||||||
|
.mdui-list-item{
|
||||||
|
margin: 2px 0px;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>a:last-child{
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
#instantclick-bar {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
.mdui-video-fluid {
|
||||||
|
height: -webkit-fill-available;
|
||||||
|
}
|
||||||
|
.dplayer-video-wrap .dplayer-video {
|
||||||
|
height: -webkit-fill-available !important;
|
||||||
|
}
|
||||||
|
.gslide iframe, .gslide video {
|
||||||
|
height: -webkit-fill-available;
|
||||||
|
}
|
||||||
|
@media screen and (max-width:950px) {
|
||||||
|
.mdui-list-item .mdui-text-right{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.mdui-container{
|
||||||
|
width:100% !important;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>*{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>a:last-child,.mdui-toolbar>a:nth-last-of-type(2),.mdui-toolbar>.mdui-typo-headline,.mdui-toolbar>i:first-child,.mdui-toolbar-spacer{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.spec-col{padding:.9em;display:flex;align-items:center;white-space:nowrap;flex:1 50%;min-width:225px}
|
||||||
|
.spec-type{font-size:1.35em}
|
||||||
|
.spec-value{font-size:1.25em}
|
||||||
|
.spec-text{float:left}
|
||||||
|
.device-section{padding-top:30px}
|
||||||
|
.spec-device-img{height:auto;height:340px;padding-bottom:30px}
|
||||||
|
#dl-header{margin:0}
|
||||||
|
#dl-section{padding-top:10px}
|
||||||
|
#dl-latest{position:relative;top:50%;transform:translateY(-50%)}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class=" mdui-appbar-with-toolbar mdui-theme-primary-indigo mdui-theme-accent-pink">
|
||||||
|
<header class="mdui-appbar mdui-appbar-fixed mdui-color-theme mdui-appbar-inset">
|
||||||
|
<div class="mdui-toolbar mdui-color-theme">
|
||||||
|
<span class="mdui-btn mdui-typo-headline mdui-btn-icon mdui-ripple mdui-ripple-white" mdui-drawer="{target: '#main-drawer', swipe: true}" mdui-tooltip="{content: '菜单'}"><i class="mdui-icon material-icons">menu</i></span>
|
||||||
|
<a href="<!--base_path-->" class="mdui-typo-headline"><!--Sitename--></a>
|
||||||
|
<!--PathArrayStart-->
|
||||||
|
<i class="mdui-icon material-icons mdui-icon-dark" style="margin:0;">chevron_right</i>
|
||||||
|
<a href="<!--PathArrayLink-->"><!--PathArrayName--></a>
|
||||||
|
<!--PathArrayEnd-->
|
||||||
|
<div class="mdui-toolbar-spacer"></div>
|
||||||
|
<!--ShowThumbnailsStart-->
|
||||||
|
<a href="javascript:thumb();" id="thumb" class="mdui-btn mdui-btn-icon" mdui-tooltip="{content: '切换显示'}"><i class="mdui-icon material-icons">format_list_bulleted</i></a>
|
||||||
|
<!--ShowThumbnailsEnd-->
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="mdui-drawer mdui-drawer-close mdui-color-indigo-50" id="main-drawer">
|
||||||
|
<div class="mdui-grid-tile">
|
||||||
|
<!--<a><img src="//image.suning.cn/uimg/ZR/share_order/158562104413864293.jpg"/></a>-->
|
||||||
|
<div class="mdui-grid-tile-actions mdui-grid-tile-actions-gradient">
|
||||||
|
<div class="mdui-grid-tile-text">
|
||||||
|
<div class="mdui-grid-tile-title"><!--Title--></div>
|
||||||
|
<div class="mdui-grid-tile-subtitle">OneManager</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-list" mdui-collapse="{accordion: true}">
|
||||||
|
<a href="<!--base_path-->" class="mdui-list-item mdui-ripple">
|
||||||
|
<i class="mdui-list-item-icon mdui-icon material-icons">home</i>
|
||||||
|
<div class="mdui-list-item-content"><!--constStr@Home--></div>
|
||||||
|
</a>
|
||||||
|
<!--MultiDiskAreaStart-->
|
||||||
|
<!--MultiDisksStart-->
|
||||||
|
<a href="<!--MultiDisksUrl-->" class="mdui-list-item mdui-ripple" <!--MultiDisksNow-->>
|
||||||
|
<i class="mdui-list-item-icon mdui-icon material-icons">cloud</i>
|
||||||
|
<div class="mdui-list-item-content"><!--MultiDisksName--></div>
|
||||||
|
</a>
|
||||||
|
<!--MultiDisksEnd-->
|
||||||
|
<!--MultiDiskAreaEnd-->
|
||||||
|
<a href="https://github.com/qkqpttgf/OneManager-php" class="mdui-list-item mdui-ripple">
|
||||||
|
<i class="mdui-list-item-icon mdui-icon material-icons">code</i>
|
||||||
|
<div class="mdui-list-item-content">Github</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--ListStart-->
|
||||||
|
|
||||||
|
<!--EncryptedStart-->
|
||||||
|
<div class="mdui-col-md-6 mdui-col-offset-md-3">
|
||||||
|
<!--<center><h1 class="mdui-typo-display-2-opacity">这是一个受保护的文件夹,您需要提供访问密码才能查看。</h1></center>-->
|
||||||
|
<form action="" method="post">
|
||||||
|
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||||
|
<i class="mdui-icon material-icons">https</i>
|
||||||
|
<label class="mdui-textfield-label"><!--constStr@InputPassword--></label>
|
||||||
|
<input name="password1" class="mdui-textfield-input" type="password"/>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<button type="submit" class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme">
|
||||||
|
<i class="mdui-icon material-icons">fingerprint</i>
|
||||||
|
<!--constStr@Submit-->
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!--EncryptedEnd-->
|
||||||
|
<!--GuestUploadStart-->
|
||||||
|
<!--
|
||||||
|
<div class="nexmoe-item" style="padding: 100px!important;">
|
||||||
|
<div class="mdui-typo-display-3-opacity" style="text-align:center;">OneImages</div>
|
||||||
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
|
<input class="mdui-center" type="file" style="margin: 50px 0;" name="file" />
|
||||||
|
<div class="mdui-row-xs-3">
|
||||||
|
<div class="mdui-col"></div>
|
||||||
|
<div class="mdui-col">
|
||||||
|
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple"><!--constStr@Upload--></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
<!--GuestUploadEnd-->
|
||||||
|
|
||||||
|
<!--IsFileStart-->
|
||||||
|
<div class="mdui-container-fluid">
|
||||||
|
<!--IsimgFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<img class="mdui-img-fluid mdui-center" src="<!--FileDownUrl-->"/>
|
||||||
|
</div>
|
||||||
|
<!--IsimgFileEnd-->
|
||||||
|
<!--IstxtFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<pre id="editor" style="white-space: pre-wrap;"><!--TxtContent--></pre>
|
||||||
|
</div>
|
||||||
|
<!--IstxtFileEnd-->
|
||||||
|
<!--IsmusicFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<audio class="mdui-center" src="<!--FileDownUrl-->" controls autoplay style="width: 100%;" ></audio>
|
||||||
|
</div>
|
||||||
|
<!--IsmusicFileEnd-->
|
||||||
|
<!--IsofficeFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->" style="width: 100%;height: 800px" frameborder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
<!--IsofficeFileEnd-->
|
||||||
|
<!--IsvideoFileStart-->
|
||||||
|
<link class="dplayer-css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<div class="mdui-center" id="dplayer"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const dp = new DPlayer({
|
||||||
|
container: document.getElementById('dplayer'),
|
||||||
|
lang:'zh-cn',
|
||||||
|
video: {
|
||||||
|
url: '<!--FileDownUrl-->',
|
||||||
|
type: 'auto'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<!--IsvideoFileEnd-->
|
||||||
|
<!--IsOtherFileStart-->
|
||||||
|
<div class="nexmoe-item"><!--constStr@FileNotSupport--></div>
|
||||||
|
<!--IsOtherFileEnd-->
|
||||||
|
</div>
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">file_download</i></a>
|
||||||
|
|
||||||
|
<!--IsFileEnd-->
|
||||||
|
|
||||||
|
<!--IsFolderStart-->
|
||||||
|
<div class="mdui-container">
|
||||||
|
<div class="mdui-container-fluid"></div>
|
||||||
|
<div class="mdui-container-fluid">
|
||||||
|
<!--HeadomfStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--HeadomfContent-->
|
||||||
|
</div>
|
||||||
|
<!--HeadomfEnd-->
|
||||||
|
<!--HeadmdStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--HeadmdContent-->
|
||||||
|
</div>
|
||||||
|
<!--HeadmdEnd-->
|
||||||
|
<style>
|
||||||
|
.thumb .th{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.thumb .mdui-text-right{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.thumb .mdui-list-item a ,.thumb .mdui-list-item {
|
||||||
|
width:213px;
|
||||||
|
height: 230px;
|
||||||
|
float: left;
|
||||||
|
margin: 10px 10px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumb .mdui-col-xs-12,.thumb .mdui-col-sm-7{
|
||||||
|
width:100% !important;
|
||||||
|
height:230px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumb .mdui-list-item .mdui-icon{
|
||||||
|
font-size:100px;
|
||||||
|
display: block;
|
||||||
|
margin-top: 40px;
|
||||||
|
color: #7ab5ef;
|
||||||
|
}
|
||||||
|
.thumb .mdui-list-item span{
|
||||||
|
float: left;
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
width:100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 180px;
|
||||||
|
}
|
||||||
|
.thumb .forcedownload {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<div class="mdui-row">
|
||||||
|
<ul class="mdui-list">
|
||||||
|
<li class="mdui-list-item th" style="padding-right:36px;">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7"><!--constStr@File--> <i class="mdui-icon material-icons icon-sort" data-sort="name" data-order="downward">expand_more</i></div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--constStr@EditTime--> <i class="mdui-icon material-icons icon-sort" data-sort="date" data-order="downward">expand_more</i></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--constStr@Size--> <i class="mdui-icon material-icons icon-sort" data-sort="size" data-order="downward">expand_more</i></div>
|
||||||
|
</li>
|
||||||
|
<!--BackArrowStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple">
|
||||||
|
<a href="<!--BackArrowUrl-->">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7">
|
||||||
|
<i class="mdui-icon material-icons">arrow_upward</i>
|
||||||
|
..
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"></div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<!--BackArrowEnd-->
|
||||||
|
|
||||||
|
<!--FolderListStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple" data-sort data-sort-name="<!--FileEncodeReplaceName-->" data-sort-date="<!--lastModifiedDateTime-->" data-sort-size="<!--size-->" style="padding-right:36px;">
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->/">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||||
|
<i class="mdui-icon material-icons">folder_open</i>
|
||||||
|
<span><!--FileEncodeReplaceName--></span>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<!--FolderListEnd-->
|
||||||
|
<!--FileListStart-->
|
||||||
|
<li class="mdui-list-item file mdui-ripple" data-sort data-sort-name="<!--FileEncodeReplaceName-->" data-sort-date="<!--lastModifiedDateTime-->" data-sort-size="<!--size-->" data-readypreview="<!--FileExt-->">
|
||||||
|
<a class="<!--FileExtType-->" data-name="<!--FileEncodeReplaceName-->" href="<!--FileEncodeReplaceUrl-->?preview" target="_blank">
|
||||||
|
<!--<?php if(isImage($item['name']) and $_COOKIE["image_mode"] == "1"):?>
|
||||||
|
<img class="mdui-img-fluid" src="<?php echo get_absolute_path($root.$path).rawurlencode($item['name']); ?>">
|
||||||
|
<?php else:?>-->
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||||
|
<i class="mdui-icon material-icons"><!--IconValue--></i>
|
||||||
|
<span><!--FileEncodeReplaceName--></span>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="forcedownload " >
|
||||||
|
<a title="<!--constStr@Download-->" href="<!--FileEncodeReplaceUrl-->">
|
||||||
|
<button class="mdui-btn mdui-ripple mdui-btn-icon"><i class="mdui-icon material-icons">file_download</i></button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<!--FileListEnd-->
|
||||||
|
|
||||||
|
<!--MorePageStart-->
|
||||||
|
<form action="" method="POST" id="nextpageform">
|
||||||
|
<input type="hidden" id="pagenum" name="pagenum" value="">
|
||||||
|
<li class="mdui-list-item th">
|
||||||
|
<div class="mdui-col-sm-6 mdui-left mdui-text-left">
|
||||||
|
<!--PrePageStart-->
|
||||||
|
<a onclick="nextpage(<!--PrePageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@PrePage--></a>
|
||||||
|
<!--PrePageEnd-->
|
||||||
|
<!--NextPageStart-->
|
||||||
|
<a onclick="nextpage(<!--NextPageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@NextPage--></a>
|
||||||
|
<!--NextPageEnd-->
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-6 mdui-right mdui-text-right">
|
||||||
|
<div class="mdui-right mdui-text-right"><span class="mdui-chip-title">Page: <!--MorePageListStart--><!--MorePageListEnd--><!--MorePageListNowStart--><!--PageNum--><!--MorePageListNowEnd-->/<!--MaxPageNum--></span></div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</form>
|
||||||
|
<!--MorePageEnd-->
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--ReadmemdStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--ReadmemdContent-->
|
||||||
|
</div>
|
||||||
|
<!--ReadmemdEnd-->
|
||||||
|
<!--FootomfStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--FootomfContent-->
|
||||||
|
</div>
|
||||||
|
<!--FootomfEnd-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--IsFolderEnd-->
|
||||||
|
<!--ListEnd-->
|
||||||
|
<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>
|
||||||
|
<!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
||||||
|
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
|
||||||
|
<script>
|
||||||
|
<!--MorePageStart-->
|
||||||
|
function nextpage(num) {
|
||||||
|
document.getElementById('pagenum').value=num;
|
||||||
|
document.getElementById('nextpageform').submit();
|
||||||
|
}
|
||||||
|
<!--MorePageEnd-->
|
||||||
|
var $$ = mdui.JQ;
|
||||||
|
$$(function() {
|
||||||
|
$$('.file .iframe').each(function() {
|
||||||
|
$$(this).on('click', function() {
|
||||||
|
url=$$(this).attr('href');
|
||||||
|
//url=url.substr(0,url.length-8);
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '<a target="_blank" href="'+url+'">'+ $$(this).find('span').text()+'(点击新窗口打开)</a>', //jia,
|
||||||
|
//shadeClose: true,
|
||||||
|
move: false,
|
||||||
|
shade: false,
|
||||||
|
maxmin: true,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
content: url //le
|
||||||
|
,min: function(layero){
|
||||||
|
//zi;
|
||||||
|
layero.css({top: '90%'})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('.file .dl').each(function () {
|
||||||
|
$(this).on('click', function () {
|
||||||
|
var form = $('<form target=_blank method=post></form>').attr('action', $(this).attr('href')).get(0);
|
||||||
|
$(document.body).append(form);
|
||||||
|
form.submit();
|
||||||
|
$(form).remove();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
window.TC=window.TC||{};
|
||||||
|
jQuery(".file .audio").click(function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
TC.preview_audio(this);
|
||||||
|
});
|
||||||
|
TC.preview_audio = function(aud){
|
||||||
|
if(!TC.aplayer){
|
||||||
|
TC.aplayerList=[];
|
||||||
|
jQuery(".file .audio").each(function(){
|
||||||
|
var ext = jQuery(this).data("readypreview");
|
||||||
|
var n = jQuery(this).find("span").text();
|
||||||
|
var l = n.replace("."+ext,".lrc");
|
||||||
|
var la = jQuery('a[data-name="'+l+'"]');
|
||||||
|
var lrc = undefined;
|
||||||
|
if(la.length>0){
|
||||||
|
lrc = la[0].href+"?s";
|
||||||
|
}
|
||||||
|
TC.aplayerList.push({
|
||||||
|
name:n,
|
||||||
|
url:this.href.substr(0,this.href.length-8),
|
||||||
|
artist:" ",
|
||||||
|
lrc:lrc
|
||||||
|
});
|
||||||
|
})
|
||||||
|
jQuery('<div id="aplayer">').appendTo("body");
|
||||||
|
TC.aplayer = new APlayer({
|
||||||
|
container: document.getElementById('aplayer'),
|
||||||
|
fixed: true,
|
||||||
|
audio: TC.aplayerList,
|
||||||
|
lrcType: 3
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var k=-1;
|
||||||
|
for(var i in TC.aplayerList){
|
||||||
|
if(TC.aplayerList[i].name==jQuery(aud).data("name")){
|
||||||
|
k=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(k>=0){
|
||||||
|
TC.aplayer.list.switch(k);
|
||||||
|
TC.aplayer.play();
|
||||||
|
TC.aplayer.setMode("normal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ = mdui.JQ;
|
||||||
|
$.fn.extend({
|
||||||
|
sortElements: function (comparator, getSortable) {
|
||||||
|
getSortable = getSortable || function () { return this; };
|
||||||
|
|
||||||
|
var placements = this.map(function () {
|
||||||
|
var sortElement = getSortable.call(this),
|
||||||
|
parentNode = sortElement.parentNode,
|
||||||
|
nextSibling = parentNode.insertBefore(
|
||||||
|
document.createTextNode(''),
|
||||||
|
sortElement.nextSibling
|
||||||
|
);
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
parentNode.insertBefore(this, nextSibling);
|
||||||
|
parentNode.removeChild(nextSibling);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return [].sort.call(this, comparator).each(function (i) {
|
||||||
|
placements[i].call(getSortable.call(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var lightbox = GLightbox();
|
||||||
|
function downall() {
|
||||||
|
let dl_link_list = Array.from(document.querySelectorAll("li a"))
|
||||||
|
.map(x => x.href) // 所有list中的链接
|
||||||
|
.filter(x => x.slice(-1) != "/"); // 筛选出非文件夹的文件下载链接
|
||||||
|
|
||||||
|
let blob = new Blob([dl_link_list.join("\r\n")], {
|
||||||
|
type: 'text/plain'
|
||||||
|
}); // 构造Blog对象
|
||||||
|
let a = document.createElement('a'); // 伪造一个a对象
|
||||||
|
a.href = window.URL.createObjectURL(blob); // 构造href属性为Blob对象生成的链接
|
||||||
|
a.download = "folder_download_link.txt"; // 文件名称,你可以根据你的需要构造
|
||||||
|
a.click() // 模拟点击
|
||||||
|
a.remove();
|
||||||
|
}
|
||||||
|
<!--ShowThumbnailsStart-->
|
||||||
|
function thumb(){
|
||||||
|
if($('#thumb i').text() == "apps"){
|
||||||
|
$('#thumb i').text("format_list_bulleted");
|
||||||
|
$('.nexmoe-item').removeClass('thumb');
|
||||||
|
$('.nexmoe-item .mdui-icon').show();
|
||||||
|
$('.nexmoe-item .mdui-list-item').css("background","");
|
||||||
|
}else{
|
||||||
|
$('#thumb i').text("apps");
|
||||||
|
$('.nexmoe-item').addClass('thumb');
|
||||||
|
$('.mdui-col-xs-12 i.mdui-icon').each(function(){
|
||||||
|
//if($(this).text() == "image" || $(this).text() == "ondemand_video"){
|
||||||
|
if($(this).text() == "image"){
|
||||||
|
var thumbnails = $(this).parent().parent().attr('href');
|
||||||
|
//var thumb =(href.indexOf('?') == -1)?'?t=220':'&t=220';
|
||||||
|
thumbnails = thumbnails.substr(0, thumbnails.length-8)+'?thumbnails&location';
|
||||||
|
$(this).hide();
|
||||||
|
//$(this).parent().parent().parent().css("background","url("+href+thumb+") no-repeat center top");
|
||||||
|
$(this).parent().parent().parent().css("background","url("+thumbnails+") no-repeat center top");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
<!--ShowThumbnailsEnd-->
|
||||||
|
$(function(){
|
||||||
|
$('.icon-sort').on('click', function () {
|
||||||
|
let sort_type = $(this).attr("data-sort"), sort_order = $(this).attr("data-order");
|
||||||
|
let sort_order_to = (sort_order === "less") ? "more" : "less";
|
||||||
|
|
||||||
|
$('li[data-sort]').sortElements(function (a, b) {
|
||||||
|
let data_a = $(a).attr("data-sort-" + sort_type), data_b = $(b).attr("data-sort-" + sort_type);
|
||||||
|
let rt = data_a.localeCompare(data_b, undefined, {numeric: true});
|
||||||
|
return (sort_order === "more") ? 0-rt : rt;
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this).attr("data-order", sort_order_to).text("expand_" + sort_order_to);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var ckname='image_mode';
|
||||||
|
function getCookie(name)
|
||||||
|
{
|
||||||
|
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||||
|
if(arr=document.cookie.match(reg))
|
||||||
|
return unescape(arr[2]);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function setCookie(key,value,day){
|
||||||
|
var exp = new Date();
|
||||||
|
exp.setTime(exp.getTime() - 1);
|
||||||
|
var cval=getCookie(key);
|
||||||
|
if(cval!=null)
|
||||||
|
document.cookie= key + "="+cval+";expires="+exp.toGMTString();
|
||||||
|
var date = new Date();
|
||||||
|
var nowDate = date.getDate();
|
||||||
|
date.setDate(nowDate + day);
|
||||||
|
var cookie = key+"="+value+"; expires="+date;
|
||||||
|
document.cookie = cookie;
|
||||||
|
return cookie;
|
||||||
|
}
|
||||||
|
$('#image_view').on('click', function () {
|
||||||
|
if($(this).prop('checked') == true){
|
||||||
|
setCookie(ckname,1,1);
|
||||||
|
window.location.href=window.location.href;
|
||||||
|
}else{
|
||||||
|
setCookie(ckname,0,1);
|
||||||
|
window.location.href=window.location.href;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.markdown').forEach(function (e) {
|
||||||
|
e.innerHTML = marked(e.innerHTML);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+1204
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
|
<!-- theme purenice designed & coded by wendale v1.1 Responsive fixed on May 1st-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<?php echo $constStr['language']; ?>">
|
<html lang="<?php echo $constStr['language']; ?>">
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) echo ' - ' . getConfig('diskname');?> - <?php echo $_SERVER['sitename'];?></title>
|
<title><?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) { if (getConfig('diskname')!='') $diskname = getConfig('diskname'); else $diskname = $_SERVER['disktag']; echo ' - ' . $diskname; } ?> - <?php echo $_SERVER['sitename'];?></title>
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
<meta http-equiv=X-UA-Compatible content="IE=edge">
|
<meta http-equiv=X-UA-Compatible content="IE=edge">
|
||||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||||
@@ -10,54 +11,91 @@
|
|||||||
<link rel="icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
<link rel="icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
||||||
<link rel="shortcut icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:14px;line-height:1em;color:#000;background-color:#f7f7f9;<?php if (getConfig('background')) { ?>background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-image:url("<?php echo getConfig('background'); ?>");<?php } ?>}
|
body{margin:0;padding:0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:14px;line-height:1em;color:#000;background-color:#F9FAFB;}
|
||||||
a{color:#24292e;cursor:pointer;text-decoration:none}
|
.topbar{width:100%;height:40px;background-color:#463C6A;}
|
||||||
ion-icon{font-size:15px;vertical-align:bottom}
|
.topbar .login{display:block;line-height:40px;color:#ffffff;margin-left:10%;float:left;}
|
||||||
.changelanguage{position:absolute;right:5px;}
|
.topbar .login ion-icon{display:block;height:40px;line-height:40px;margin-right:5px;float:left;}
|
||||||
.title{text-align:center;margin-top:1rem;letter-spacing:2px;margin-bottom:2rem}
|
.topbar .operate{display:block;line-height:40px;color:#ffffff;margin-left:10%;float:left;}
|
||||||
.title a{color:#333;text-decoration:none}
|
.topbar .operate ul{}
|
||||||
.list-wrapper{width:80%;margin:0 auto 30px;position:relative;box-shadow:0 0 32px 0 rgb(128,128,128);border-radius:15px;}
|
.topbar .operate ion-icon{display:block;height:40px;line-height:40px;margin-right:5px;float:left;}
|
||||||
.list-container{position:relative;overflow:hidden;border-radius:15px;}
|
a{color:#171D33;cursor:pointer;text-decoration:none;}
|
||||||
.list-header-container{position:relative}
|
ion-icon{font-size:15px;vertical-align:middle;}
|
||||||
.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}
|
.changelanguage{display:block;height:30px;line-height:30px;float:right;margin-right:10%;margin-top:5px;}
|
||||||
|
.title{text-align:center;margin-top:1rem;letter-spacing:2px;margin-bottom:2rem;}
|
||||||
|
.title a{color:#171D33;line-height:42px;font-size:32px;text-decoration:none}
|
||||||
|
.list-wrapper{width:80%;margin:0 auto;position:relative;}
|
||||||
|
.list-container{position:relative;}
|
||||||
|
.list-header-container{position:relative;width:100%;}
|
||||||
|
.list-header-container a.back-link{position:absolute;float:left;color:#ffffff;display:inline-block;margin:10px;height:40px;width:40px;background:#613EEA;line-height:40px;text-decoration:none;text-align:center;border-radius:20px;box-shadow: 0px 4px 12px rgba(97, 62, 234, 0.5);}
|
||||||
|
.list-header-container a.back-link ion-icon{font-size:20px;}
|
||||||
|
.list-header-container a.back-link:hover{color:white}
|
||||||
.list-container,.list-header-container,.list-wrapper,a.back-link:hover,body{color:#24292e}
|
.list-container,.list-header-container,.list-wrapper,a.back-link:hover,body{color:#24292e}
|
||||||
.table-header{margin:0;border:0 none;padding:30px 60px;text-align:left;font-weight:400;color:#000;background-color:rgba(245,245,245,0.5);word-break: break-all;word-wrap: break-word;}
|
.table-header{display:block;float:left;margin:10px 0 0 60px;height:40px;line-height:40px;text-align:left;font-weight:400;color:#A0A4B0;word-break: break-all;word-wrap: break-word;}
|
||||||
.list-body-container{position:relative;left:0;overflow-x:hidden;overflow-y:auto;box-sizing:border-box;background:rgba(245,245,245,0.5)}
|
.fix{height:60px;}
|
||||||
.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;}
|
.list-body-container{position:relative;left:0;overflow-x:hidden;overflow-y:auto;box-sizing:border-box;}
|
||||||
.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{border-bottom:1px solid #E8E9EC;height:40px;white-space:nowrap;overflow:auto;}
|
||||||
.more-disk a:hover, .more-disk a[now]{ background-color: rgba(85,85,85,0.7); color: white; }
|
.more-disk a{display:block;float:left;width:30%;height:38px;text-align:center;font-weight: bold;font-size: 18px;line-height:38px;color:#A6AAB4; }
|
||||||
.list-table{width:100%;padding:0 20px 20px 20px;border-spacing:0}
|
.more-disk a:hover, .more-disk a[now]{ color: #3B414B;border-bottom:2px solid #FF7D00;}
|
||||||
.list-table tr{height:40px}
|
.list-table{width:100%;border-spacing:0;margin-bottom:20px;}
|
||||||
.list-table tr[data-to]:hover{background:rgba(85,85,85,0.7);color:white;}
|
.list-table tr{display:block;margin:10px 10px;width:96%;float:left;background:#ffffff;box-shadow: 0px 4px 26px rgba(0, 0, 0, 0.06);border-radius: 6px;}
|
||||||
|
.list-table tr[data-to]:hover{background:#10C971;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 td,.list-table th{display:block;float:left;line-height:60px;text-align:left;}
|
||||||
.list-table td,.list-table th{padding:0 10px;text-align:left}
|
.list-table td button,.list-table th button{cursor:pointer;color:#ffffff;height:30px;background:#FF7D00;padding:0 20px;border-width:0;border-radius:6px;box-shadow: 0px 4px 12px rgba(255, 125, 0, 0.5);}
|
||||||
|
.list-table td.file,.list-table th.file{width:60%;color:#171D33;padding-left:20px;}
|
||||||
|
.list-table td.file ion-icon{float:left;margin-top:22px;margin-right:5px;}
|
||||||
|
.list-table td.file:hover>ion-icon,.list-table td.file:hover .operate>ion-icon{color:#fff;}
|
||||||
|
.list-table td.file a[name="filelist"]{float:left;}
|
||||||
|
.list-table td.file a[name="filelist"] img{border-radius:6px;margin-top:20px;}
|
||||||
|
.list-table td.updated_at,.list-table th.updated_at{width:25%;}
|
||||||
|
.list-table td.size,.list-table th.size{width:10%;}
|
||||||
.list-table .size,.list-table .updated_at{text-align:right}
|
.list-table .size,.list-table .updated_at{text-align:right}
|
||||||
.mask{position:absolute;left:0px;top:0px;width:100%;background-color:#000;filter:alpha(opacity=50);opacity:0.5;z-index:2;}
|
.mask{position:absolute;left:0px;top:0px;width:100%;background-color:#000;filter:alpha(opacity=50);opacity:0.5;z-index:2;}
|
||||||
<?php if ($_SERVER['admin']) { ?>
|
<?php if ($_SERVER['admin']) { ?>
|
||||||
.operate{display:inline-table;margin:0;margin-right:5px;list-style:none}
|
.operate{display:inline-table;margin:0;margin-right:5px;list-style:none;float:left;}
|
||||||
.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:0;border-radius:5px;margin:0;padding:0 7px;color:#205D67;z-index:1;box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);}
|
||||||
.operate:hover ul{position:absolute;display:inline-table;}
|
.operate:hover ul{position:absolute;display:inline-table;}
|
||||||
.operate ul li{padding:7px;list-style:none;display:block;}
|
.operate ul li{list-style:none;display:block;line-height:40px;}
|
||||||
.list-table tr[data-to]:hover .operate ul li a{color:black}
|
.list-table tr[data-to]:hover .operate ul li a{color:black}
|
||||||
|
.list-table tr[data-to]:hover .operate ul li a ion-icon{margin-top:12px;}
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
.operatediv{position:absolute;border:1px #CCCCCC;background-color:#FFFFCC;z-index:2;}
|
.operatediv{position:absolute;background-color:#ffffff;z-index:2;border-radius:10px;background-color:#F9FAFB;}
|
||||||
.operatediv div{margin:16px}
|
.loginstyle{width:250px;height:124px;}
|
||||||
.operatediv_close{position:absolute;right:3px;top:3px;}
|
.loginstyle input[type="password"]{width:244px;height:40px;margin-top:30px;border-radius:6px;outline:none;border: 2px solid #E8E9EC;text-indent:10px}
|
||||||
|
.loginstyle input[type="password"]::-webkit-input-placeholder { color: #A6AAB4;font-size: 16px;}
|
||||||
|
.loginstyle input[type="submit"]{color:#fff;font-size:16px;width:250px;height:40px;margin-top:5px;border-radius:6px;padding:0;cursor:pointer;background:#FF7D00;border-width:0;box-shadow: 0px 4px 12px rgba(255, 125, 0, 0.5);}
|
||||||
|
.operatediv div{margin:16px;}
|
||||||
|
.operatediv_close{position:absolute;right:15px;top:15px;}
|
||||||
.readme{padding:8px;background-color:rgba(245,245,245,0.5);}
|
.readme{padding:8px;background-color:rgba(245,245,245,0.5);}
|
||||||
.markdown-body{padding:20px;text-align:left}
|
.markdown-body{padding:20px;text-align:left}
|
||||||
|
|
||||||
|
.update_notice{position:absolute;color:#A6AAB4;left:10%;margin-top:10px;}
|
||||||
|
.upload_style{height:60px;width:96%;margin:10px;background:#ffffff;box-shadow: 0px 4px 26px rgba(0, 0, 0, 0.06);border-radius: 6px;}
|
||||||
|
.upload_style input[type="file"]{display:block;color:#A6AAB4;float:left;height:38px;margin:20px 0 0 20px;outline:none;font-size:14px;text-align:center;}
|
||||||
|
.upload_style input[type="button"]{display:block;color:#fff;float:right;height:60px;width:160px;outline:none;font-size:16px;background:#613EEA;border-radius:6px;border:0;}
|
||||||
|
.upload_style .list-table tr td{line-height:30px;margin:10px 20px;}
|
||||||
|
.upload_style .list-table tr td button{margin-left:10px;}
|
||||||
@media only screen and (max-width:480px){
|
@media only screen and (max-width:480px){
|
||||||
.title{margin-bottom:24px}
|
.title{margin-bottom:24px}
|
||||||
.list-wrapper{width:95%; margin-bottom:24px;}
|
.list-wrapper{width:95%; margin-bottom:24px;}
|
||||||
.list-table {padding:8px}
|
.list-table {padding:8px}
|
||||||
.list-table td, .list-table th{white-space:nowrap;overflow:auto;max-width:80px}
|
.list-table td button,.list-table th button{cursor:pointer;color:#ffffff;height:24px;background:#FF7D00;padding:0 8px;border-width:0;border-radius:6px;box-shadow: 0px 2px 6px rgba(255, 125, 0, 0.5);}
|
||||||
|
.list-table td, .list-table th{white-space:nowrap;overflow:auto;line-height:40px;}
|
||||||
|
.list-table td.file,.list-table th.file{padding-left: 10px;width: 96%;}
|
||||||
.size, .updated_at{display:none}
|
.size, .updated_at{display:none}
|
||||||
|
.changelanguage{color:#fff;}
|
||||||
|
.list-table td.updated_at,.list-table th.updated_at{width:50%;text-align:left;margin-left:10px;}
|
||||||
|
.list-table td.size,.list-table th.size{width:30%;text-align:left;}
|
||||||
|
.list-table td.file ion-icon{float:left;margin-top:13px;margin-right:5px;}
|
||||||
|
.upload_style input[type="file"]{display:block;color:#A6AAB4;float:left;height:38px;margin:18px 0 0 10px;outline:none;font-size:14px;text-align:center;width:70%;}
|
||||||
|
.upload_style input[type="button"]{display:block;color:#fff;float:right;height:60px;width:25%;outline:none;font-size:16px;background:#613EEA;border-radius:6px;border:0;}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div style="padding:1px">
|
<div class="topbar">
|
||||||
<?php
|
<?php
|
||||||
if (getConfig('admin')!='') if (!$_SERVER['admin']) {
|
if (getConfig('admin')!='') if (!$_SERVER['admin']) {
|
||||||
if (getConfig('adminloginpage')=='') { ?>
|
if (getConfig('adminloginpage')=='') { ?>
|
||||||
@@ -67,7 +105,7 @@
|
|||||||
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?><ul>
|
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?><ul>
|
||||||
<?php if (isset($files['folder'])) { ?>
|
<?php if (isset($files['folder'])) { ?>
|
||||||
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><?php echo getconstStr('Create'); ?></a></li>
|
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><?php echo getconstStr('Create'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><?php echo getconstStr('Encrypt'); ?></a></li>
|
||||||
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><?php echo getconstStr('RefreshCache'); ?></a></li>
|
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><?php echo getconstStr('RefreshCache'); ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li><a href="<?php echo isset($_GET['preview'])?'?preview&':'?';?>setup"><ion-icon name="settings"></ion-icon><?php echo getconstStr('Setup'); ?></a></li>
|
<li><a href="<?php echo isset($_GET['preview'])?'?preview&':'?';?>setup"><ion-icon name="settings"></ion-icon><?php echo getconstStr('Setup'); ?></a></li>
|
||||||
@@ -85,9 +123,10 @@
|
|||||||
} ?>
|
} ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) { ?>
|
if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) { ?>
|
||||||
<div style='position:absolute;'><font color='red'><?php echo getconstStr('NeedUpdate'); ?></font></div>
|
<div class="update_notice" style='position:absolute;'><?php echo getconstStr('NeedUpdate'); ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<h1 class="title">
|
<h1 class="title">
|
||||||
<a href="<?php echo $_SERVER['base_path']; ?>"><?php echo $_SERVER['sitename']; ?></a>
|
<a href="<?php echo $_SERVER['base_path']; ?>"><?php echo $_SERVER['sitename']; ?></a>
|
||||||
@@ -125,7 +164,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<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 fix">
|
||||||
<?php
|
<?php
|
||||||
if ($path !== '/') {
|
if ($path !== '/') {
|
||||||
$current_url = $_SERVER['PHP_SELF'];
|
$current_url = $_SERVER['PHP_SELF'];
|
||||||
@@ -149,11 +188,9 @@
|
|||||||
$pdfurl = false;
|
$pdfurl = false;
|
||||||
$DPvideo = false;
|
$DPvideo = false;
|
||||||
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) { ?>
|
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) { ?>
|
||||||
<div id="upload_div" style="margin:10px">
|
<div id="upload_div" class="upload_style">
|
||||||
<center>
|
<input id="upload_file" type="file" name="upload_filename" value="<?php echo getconstStr('FileSelected'); ?>">
|
||||||
<input id="upload_file" type="file" name="upload_filename">
|
|
||||||
<input id="upload_submit" onclick="preup();" value="<?php echo getconstStr('Upload'); ?>" type="button">
|
<input id="upload_submit" onclick="preup();" value="<?php echo getconstStr('Upload'); ?>" type="button">
|
||||||
<center>
|
|
||||||
</div>
|
</div>
|
||||||
<?php } else {
|
<?php } else {
|
||||||
if ($_SERVER['ishidden']<4) {
|
if ($_SERVER['ishidden']<4) {
|
||||||
@@ -221,8 +258,8 @@
|
|||||||
<table class="list-table" id="list-table">
|
<table class="list-table" id="list-table">
|
||||||
<tr id="tr0">
|
<tr id="tr0">
|
||||||
<th class="file"><a onclick="sortby('a');"><?php echo getconstStr('File'); ?></a><?php if (!(isset($_SERVER['USER'])&&$_SERVER['USER']=='qcloud')) { ?> <button onclick="showthumbnails(this);"><?php echo getconstStr('ShowThumbnails'); ?></button><?php } ?> <button onclick="CopyAllDownloadUrl('.download');"><?php echo getconstStr('CopyAllDownloadUrl'); ?></button></th>
|
<th class="file"><a onclick="sortby('a');"><?php echo getconstStr('File'); ?></a><?php if (!(isset($_SERVER['USER'])&&$_SERVER['USER']=='qcloud')) { ?> <button onclick="showthumbnails(this);"><?php echo getconstStr('ShowThumbnails'); ?></button><?php } ?> <button onclick="CopyAllDownloadUrl('.download');"><?php echo getconstStr('CopyAllDownloadUrl'); ?></button></th>
|
||||||
<th class="updated_at" width="25%"><a onclick="sortby('time');"><?php echo getconstStr('EditTime'); ?></a></th>
|
<th class="updated_at"><a onclick="sortby('time');"><?php echo getconstStr('EditTime'); ?></a></th>
|
||||||
<th class="size" width="15%"><a onclick="sortby('size');"><?php echo getconstStr('Size'); ?></a></th>
|
<th class="size"><a onclick="sortby('size');"><?php echo getconstStr('Size'); ?></a></th>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Dirs -->
|
<!-- Dirs -->
|
||||||
<?php //echo json_encode($files['children'], JSON_PRETTY_PRINT);
|
<?php //echo json_encode($files['children'], JSON_PRETTY_PRINT);
|
||||||
@@ -235,7 +272,7 @@
|
|||||||
<?php if ($_SERVER['admin']) { ?>
|
<?php if ($_SERVER['admin']) { ?>
|
||||||
<li class="operate"><ion-icon name="construct"></ion-icon><a><?php echo getconstStr('Operate'); ?></a>
|
<li class="operate"><ion-icon name="construct"></ion-icon><a><?php echo getconstStr('Operate'); ?></a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><ion-icon name="lock"></ion-icon><?php echo getconstStr('Encrypt'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
||||||
<li><a onclick="showdiv(event, 'copy',<?php echo $filenum;?>);"><ion-icon name="copy"></ion-icon><?php echo getconstStr('Copy'); ?></a></li>
|
<li><a onclick="showdiv(event, 'copy',<?php echo $filenum;?>);"><ion-icon name="copy"></ion-icon><?php echo getconstStr('Copy'); ?></a></li>
|
||||||
@@ -344,11 +381,10 @@
|
|||||||
echo $prepagenext;
|
echo $prepagenext;
|
||||||
}
|
}
|
||||||
if ($_SERVER['admin']) { ?>
|
if ($_SERVER['admin']) { ?>
|
||||||
<div id="upload_div" style="margin:0 0 16px 0">
|
<div id="upload_div" class="upload_style">
|
||||||
<center>
|
<input id="upload_file" type="file" name="upload_filename" value="<?php echo getconstStr('FileSelected'); ?>" multiple="multiple">
|
||||||
<input id="upload_file" type="file" name="upload_filename" multiple="multiple">
|
|
||||||
<input id="upload_submit" onclick="preup();" value="<?php echo getconstStr('Upload'); ?>" type="button">
|
<input id="upload_submit" onclick="preup();" value="<?php echo getconstStr('Upload'); ?>" type="button">
|
||||||
</center>
|
|
||||||
</div>
|
</div>
|
||||||
<?php }
|
<?php }
|
||||||
} else {
|
} else {
|
||||||
@@ -424,7 +460,7 @@
|
|||||||
<input id="encrypt_sid" name="encrypt_sid" type="hidden" value="">
|
<input id="encrypt_sid" name="encrypt_sid" 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="<?php echo getconstStr('InputPasswordUWant'); ?>">
|
<input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<?php echo getconstStr('InputPasswordUWant'); ?>">
|
||||||
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo getconstStr('encrypt'); ?>"><?php } else { ?><br><label><?php echo getconstStr('SetpassfileBfEncrypt'); ?></label><?php } ?>
|
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo getconstStr('Encrypt'); ?>"><?php } else { ?><br><label><?php echo getconstStr('SetpassfileBfEncrypt'); ?></label><?php } ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -498,7 +534,7 @@
|
|||||||
} else {
|
} else {
|
||||||
if (getConfig('admin')!='') if (getConfig('adminloginpage')=='') { ?>
|
if (getConfig('admin')!='') if (getConfig('adminloginpage')=='') { ?>
|
||||||
<div id="login_div" class="operatediv" style="display:none">
|
<div id="login_div" class="operatediv" style="display:none">
|
||||||
<div style="margin:50px">
|
<div class="loginstyle">
|
||||||
<a onclick="operatediv_close('login')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
<a onclick="operatediv_close('login')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
||||||
<center>
|
<center>
|
||||||
<form action="<?php echo isset($_GET['preview'])?'?preview&':'?';?>admin" method="post">
|
<form action="<?php echo isset($_GET['preview'])?'?preview&':'?';?>admin" method="post">
|
||||||
@@ -541,7 +577,7 @@
|
|||||||
e.innerHTML = '/ ';
|
e.innerHTML = '/ ';
|
||||||
for (var i = 1; i < paths.length - 1; i++) {
|
for (var i = 1; i < paths.length - 1; i++) {
|
||||||
var to = path_format(root + paths.slice(0, i + 1).join('/'));
|
var to = path_format(root + paths.slice(0, i + 1).join('/'));
|
||||||
e.innerHTML += '<a href="' + to + '">' + paths[i] + '</a> / '
|
e.innerHTML += paths[i] + ' / '
|
||||||
}
|
}
|
||||||
e.innerHTML += paths[paths.length - 1];
|
e.innerHTML += paths[paths.length - 1];
|
||||||
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
|
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
|
||||||
@@ -705,8 +741,7 @@
|
|||||||
tmptextarea.select();
|
tmptextarea.select();
|
||||||
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
|
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
//alert(tmptextarea.innerHTML);
|
alert(tmptextarea.innerHTML+'<?php echo getconstStr('Success'); ?>');
|
||||||
alert('Success');
|
|
||||||
}
|
}
|
||||||
var sort=0;
|
var sort=0;
|
||||||
function sortby(string) {
|
function sortby(string) {
|
||||||
@@ -859,7 +894,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var xhr1 = new XMLHttpRequest();
|
var xhr1 = new XMLHttpRequest();
|
||||||
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent(file.name) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent((file.webkitRelativePath||file.name)) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
||||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr1.send(null);
|
xhr1.send(null);
|
||||||
xhr1.onload = function(e){
|
xhr1.onload = function(e){
|
||||||
@@ -970,7 +1005,7 @@
|
|||||||
if (response['size']>0) {
|
if (response['size']>0) {
|
||||||
// contain size, upload finish. 有size说明是最终返回,上传结束
|
// contain size, upload finish. 有size说明是最终返回,上传结束
|
||||||
var xhr3 = new XMLHttpRequest();
|
var xhr3 = new XMLHttpRequest();
|
||||||
xhr3.open("GET", '?action=del_upload_cache&filename=.'+file.lastModified+ '_' +file.size+ '_' +encodeURIComponent(file.name)+'.tmp');
|
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+encodeURIComponent((file.webkitRelativePath||file.name)));
|
||||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr3.send(null);
|
xhr3.send(null);
|
||||||
xhr3.onload = function(e){
|
xhr3.onload = function(e){
|
||||||
@@ -979,7 +1014,7 @@
|
|||||||
<?php if (!$_SERVER['admin']) { ?>
|
<?php if (!$_SERVER['admin']) { ?>
|
||||||
var filemd5 = spark.end();
|
var filemd5 = spark.end();
|
||||||
var xhr4 = new XMLHttpRequest();
|
var xhr4 = new XMLHttpRequest();
|
||||||
xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent(file.name)+'&filemd5='+filemd5);
|
xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent((file.webkitRelativePath||file.name))+'&filemd5='+filemd5);
|
||||||
xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
|
xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||||
xhr4.send(null);
|
xhr4.send(null);
|
||||||
xhr4.onload = function(e){
|
xhr4.onload = function(e){
|
||||||
@@ -0,0 +1,639 @@
|
|||||||
|
<!--IconValuesStart-->
|
||||||
|
{
|
||||||
|
"music":"audiotrack",
|
||||||
|
"video":"ondemand_video",
|
||||||
|
"img":"image",
|
||||||
|
"default":"insert_drive_file"
|
||||||
|
}
|
||||||
|
<!--IconValuesEnd-->
|
||||||
|
<script>
|
||||||
|
var primary_color = "orange";
|
||||||
|
var accent_color = "deep-orange";
|
||||||
|
var bug = 0;
|
||||||
|
</script>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="<!--constStr@language-->">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
|
||||||
|
<title><!--Title--></title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mdui@0.4.3/dist/css/mdui.min.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/mdui@0.4.3/dist/js/mdui.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
|
||||||
|
<!--<script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.js"></script>-->
|
||||||
|
<link rel="icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body{
|
||||||
|
<!--BackgroundStart-->
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
background-size:cover;
|
||||||
|
background-attachment:fixed;
|
||||||
|
background-image:url("<!--BackgroundUrl-->");
|
||||||
|
<!--BackgroundEnd-->
|
||||||
|
}
|
||||||
|
.mdui-appbar .mdui-toolbar{
|
||||||
|
height:64px;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>*{
|
||||||
|
padding: 0 6px;
|
||||||
|
margin: 0 2px;
|
||||||
|
opacity:0.5;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>.mdui-typo-headline{
|
||||||
|
padding: 0 1px 0 0;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>i{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>a:hover,a.mdui-typo-headline,a.active{
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
.mdui-container{
|
||||||
|
max-width:950px;
|
||||||
|
}
|
||||||
|
.mdui-list-item{
|
||||||
|
-webkit-transition:none;
|
||||||
|
transition:none;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>a:last-child{
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
#instantclick-bar {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
.mdui-video-fluid {
|
||||||
|
height: -webkit-fill-available;
|
||||||
|
}
|
||||||
|
.dplayer-video-wrap .dplayer-video {
|
||||||
|
height: -webkit-fill-available !important;
|
||||||
|
}
|
||||||
|
.gslide iframe, .gslide video {
|
||||||
|
height: -webkit-fill-available;
|
||||||
|
}
|
||||||
|
@media screen and (max-width:950px) {
|
||||||
|
.mdui-list-item .mdui-text-right{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.mdui-container{
|
||||||
|
width:100% !important;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>*{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.mdui-toolbar>a:last-child,.mdui-toolbar>a:nth-last-of-type(2),.mdui-toolbar>.mdui-typo-headline,.mdui-toolbar>i:first-child,.mdui-toolbar-spacer{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.spec-col{padding:.9em;display:flex;align-items:center;white-space:nowrap;flex:1 50%;min-width:225px}
|
||||||
|
.spec-type{font-size:1.35em}
|
||||||
|
.spec-value{font-size:1.25em}
|
||||||
|
.spec-text{float:left}
|
||||||
|
.device-section{padding-top:30px}
|
||||||
|
.spec-device-img{height:auto;height:340px;padding-bottom:30px}
|
||||||
|
#dl-header{margin:0}
|
||||||
|
#dl-section{padding-top:10px}
|
||||||
|
#dl-latest{position:relative;top:50%;transform:translateY(-50%)}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body id="main-body">
|
||||||
|
<header class="mdui-appbar">
|
||||||
|
<div class="mdui-toolbar mdui-color-theme mdui-appbar-inset">
|
||||||
|
<span class="mdui-btn mdui-typo-headline mdui-btn-icon mdui-ripple" mdui-drawer="{target: '#main-drawer', swipe: true}" mdui-tooltip="{content: '菜单'}"><i class="mdui-icon material-icons mdui-text-color-white-icon">menu</i></span>
|
||||||
|
<a href="<!--base_path-->" class="mdui-typo-headline"><!--Sitename--></a>
|
||||||
|
<!--PathArrayStart-->
|
||||||
|
<i class="mdui-icon material-icons mdui-icon-dark" style="margin:0;">chevron_right</i>
|
||||||
|
<a href="<!--PathArrayLink-->"><!--PathArrayName--></a>
|
||||||
|
<!--PathArrayEnd-->
|
||||||
|
<div class="mdui-toolbar-spacer"></div>
|
||||||
|
<!--ShowThumbnailsStart-->
|
||||||
|
<a href="javascript:thumb();" id="thumb" class="mdui-btn mdui-btn-icon mdui-ripple" mdui-tooltip="{content: '切换显示'}"><i class="mdui-icon material-icons">format_list_bulleted</i></a>
|
||||||
|
<!--ShowThumbnailsEnd-->
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="mdui-drawer mdui-drawer-close" id="main-drawer">
|
||||||
|
<div class="mdui-list" mdui-collapse="{accordion: true}">
|
||||||
|
<!--LoginStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple" 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>
|
||||||
|
<!--LoginEnd-->
|
||||||
|
<!--AdminStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple" href="?setup">
|
||||||
|
<a class="mdui-list-item-icon mdui-icon material-icons" href="?setup">account_circle</a>
|
||||||
|
<a class="mdui-list-item-content" href="?setup">管理</a>
|
||||||
|
</li>
|
||||||
|
<!--AdminEnd-->
|
||||||
|
<li class="mdui-list-item mdui-ripple" href="javascript:void(0);" onclick="darkmod_use()">
|
||||||
|
<a class="mdui-list-item-icon mdui-icon material-icons">brightness_4</a>
|
||||||
|
<a class="mdui-list-item-content">深色模式</a>
|
||||||
|
</li>
|
||||||
|
<li class="mdui-list-item mdui-ripple">
|
||||||
|
<a href="<!--base_path-->" class="mdui-list-item-icon mdui-icon material-icons">home</a>
|
||||||
|
<a href="<!--base_path-->" class="mdui-list-item-content"><!--constStr@Home--></a>
|
||||||
|
</li>
|
||||||
|
<!--MultiDiskAreaStart-->
|
||||||
|
<!--MultiDisksStart-->
|
||||||
|
<a href="<!--MultiDisksUrl-->" class="mdui-list-item mdui-ripple" <!--MultiDisksNow-->>
|
||||||
|
<i class="mdui-list-item-icon mdui-icon material-icons">cloud</i>
|
||||||
|
<div class="mdui-list-item-content"><!--MultiDisksName--></div>
|
||||||
|
</a>
|
||||||
|
<!--MultiDisksEnd-->
|
||||||
|
<!--MultiDiskAreaEnd-->
|
||||||
|
<a href="https://github.com/qkqpttgf/OneManager-php" class="mdui-list-item mdui-ripple">
|
||||||
|
<i class="mdui-list-item-icon mdui-icon material-icons">code</i>
|
||||||
|
<div class="mdui-list-item-content">Github</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--ListStart-->
|
||||||
|
|
||||||
|
<!--EncryptedStart-->
|
||||||
|
<div class="mdui-col-md-6 mdui-col-offset-md-3" id="pjax-main">
|
||||||
|
<!--<center><h1 class="mdui-typo-display-2-opacity">这是一个受保护的文件夹,您需要提供访问密码才能查看。</h1></center>-->
|
||||||
|
<form action="" method="post">
|
||||||
|
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||||
|
<i class="mdui-icon material-icons">https</i>
|
||||||
|
<label class="mdui-textfield-label"><!--constStr@InputPassword--></label>
|
||||||
|
<input name="password1" class="mdui-textfield-input" type="password"/>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<button type="submit" class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme">
|
||||||
|
<i class="mdui-icon material-icons">fingerprint</i>
|
||||||
|
<!--constStr@Submit-->
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!--EncryptedEnd-->
|
||||||
|
<!--GuestUploadStart-->
|
||||||
|
<div class="nexmoe-item" style="padding: 100px!important;" id="content">
|
||||||
|
<div class="mdui-typo-display-3-opacity" style="text-align:center;">OneImages</div>
|
||||||
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
|
<input class="mdui-center" type="file" style="margin: 50px 0;" name="file" />
|
||||||
|
<div class="mdui-row-xs-3">
|
||||||
|
<div class="mdui-col"></div>
|
||||||
|
<div class="mdui-col">
|
||||||
|
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple"><!--constStr@Upload--></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!--GuestUploadEnd-->
|
||||||
|
|
||||||
|
<!--IsFileStart-->
|
||||||
|
<div class="mdui-container-fluid" id="content">
|
||||||
|
<!--IsimgFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<img class="mdui-img-fluid mdui-center mdui-m-t-5 "src="<!--FileDownUrl-->"/>
|
||||||
|
</div>
|
||||||
|
<!--IsimgFileEnd-->
|
||||||
|
<!--IstxtFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<pre id="editor" style="white-space: pre-wrap;"><!--TxtContent--></pre>
|
||||||
|
</div>
|
||||||
|
<!--IstxtFileEnd-->
|
||||||
|
<!--IsmusicFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<audio class="mdui-center" src="<!--FileDownUrl-->" controls autoplay style="width: 100%;" ></audio>
|
||||||
|
</div>
|
||||||
|
<!--IsmusicFileEnd-->
|
||||||
|
<!--IsofficeFileStart-->
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->" style="width: 100%;height: 800px" frameborder="0"></iframe>
|
||||||
|
</div>
|
||||||
|
<!--IsofficeFileEnd-->
|
||||||
|
<!--IsvideoFileStart-->
|
||||||
|
<link class="dplayer-css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
|
||||||
|
<div class="nexmoe-item mdui-center" style="width: 70%;height:90%;" >
|
||||||
|
<div id="dplayer"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const dp = new DPlayer({
|
||||||
|
container: document.getElementById('dplayer'),
|
||||||
|
lang:'zh-cn',
|
||||||
|
video: {
|
||||||
|
url: '<!--FileDownUrl-->',
|
||||||
|
type: 'auto'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<!--IsvideoFileEnd-->
|
||||||
|
<!--IsOtherFileStart-->
|
||||||
|
<div class="nexmoe-item"><!--constStr@FileNotSupport--></div>
|
||||||
|
<!--IsOtherFileEnd-->
|
||||||
|
</div>
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">file_download</i></a>
|
||||||
|
|
||||||
|
<!--IsFileEnd-->
|
||||||
|
|
||||||
|
<!--IsFolderStart-->
|
||||||
|
<div class="mdui-container" id="content">
|
||||||
|
<div class="mdui-container-fluid">
|
||||||
|
<form action="?admin" method="post">
|
||||||
|
<div class="mdui-dialog" id="login_input">
|
||||||
|
<div class="mdui-dialog-title">登录</div>
|
||||||
|
<div class="mdui-dialog-content">
|
||||||
|
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||||
|
<i class="mdui-icon material-icons">lock</i>
|
||||||
|
<label class="mdui-textfield-label">密码</label>
|
||||||
|
<input class="mdui-textfield-input" type="password"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-dialog-actions">
|
||||||
|
<button class="mdui-btn mdui-ripple" mdui-dialog-close>取消</button>
|
||||||
|
<button class="mdui-btn mdui-ripple" type="submit">登录</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-container-fluid">
|
||||||
|
<!--HeadomfStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--HeadomfContent-->
|
||||||
|
</div>
|
||||||
|
<!--HeadomfEnd-->
|
||||||
|
<!--HeadmdStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--<div class="mdui-chip">
|
||||||
|
<span class="mdui-chip-icon"><i class="mdui-icon material-icons">face</i></span>
|
||||||
|
<span class="mdui-chip-title">HEAD.md</span>
|
||||||
|
</div>-->
|
||||||
|
<!--HeadmdContent-->
|
||||||
|
</div>
|
||||||
|
<!--HeadmdEnd-->
|
||||||
|
<style>
|
||||||
|
.thumb .th{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.thumb .mdui-text-right{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.thumb .mdui-list-item a ,.thumb .mdui-list-item {
|
||||||
|
width:213px;
|
||||||
|
height: 230px;
|
||||||
|
float: left;
|
||||||
|
margin: 10px 10px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumb .mdui-col-xs-12,.thumb .mdui-col-sm-7{
|
||||||
|
width:100% !important;
|
||||||
|
height:230px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumb .mdui-list-item .mdui-icon{
|
||||||
|
font-size:100px;
|
||||||
|
display: block;
|
||||||
|
margin-top: 40px;
|
||||||
|
color: #7ab5ef;
|
||||||
|
}
|
||||||
|
.thumb .mdui-list-item span{
|
||||||
|
float: left;
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
width:100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 180px;
|
||||||
|
}
|
||||||
|
.thumb .forcedownload {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="nexmoe-item">
|
||||||
|
<div class="mdui-row">
|
||||||
|
<ul class="mdui-list">
|
||||||
|
<li class="mdui-list-item th mdui-ripple" style="padding-right:36px;">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7"><!--constStr@File--> <i class="mdui-icon material-icons icon-sort" data-sort="name" data-order="downward">expand_more</i></div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--constStr@EditTime--> <i class="mdui-icon material-icons icon-sort" data-sort="date" data-order="downward">expand_more</i></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--constStr@Size--> <i class="mdui-icon material-icons icon-sort" data-sort="size" data-order="downward">expand_more</i></div>
|
||||||
|
</li>
|
||||||
|
<!--BackArrowStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple">
|
||||||
|
<div class="mdui-row mdui-col-sm-12">
|
||||||
|
<a href="<!--BackArrowUrl-->">
|
||||||
|
<div class="mdui-col-xs-7">
|
||||||
|
<i class="mdui-icon material-icons">arrow_upward</i>
|
||||||
|
..
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-xs-3 mdui-text-right"></div>
|
||||||
|
<div class="mdui-col-xs-2 mdui-text-right"></div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<!--BackArrowEnd-->
|
||||||
|
|
||||||
|
<!--FolderListStart-->
|
||||||
|
<li class="mdui-list-item mdui-ripple" data-sort data-sort-name="<!--FileEncodeReplaceName-->" data-sort-date="<!--lastModifiedDateTime-->" data-sort-size="<!--size-->" style="padding-right:36px;">
|
||||||
|
<div class="mdui-row mdui-col-sm-12">
|
||||||
|
<a href="<!--FileEncodeReplaceUrl-->/">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||||
|
<i class="mdui-icon material-icons">folder_open</i>
|
||||||
|
<span><!--FileEncodeReplaceName--></span>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-xs-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="mdui-col-xs-2 mdui-text-right"><!--size--></div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<!--FolderListEnd-->
|
||||||
|
<!--FileListStart-->
|
||||||
|
<li class="mdui-list-item file mdui-ripple" data-sort data-sort-name="<!--FileEncodeReplaceName-->" data-sort-date="<!--lastModifiedDateTime-->" data-sort-size="<!--size-->" data-readypreview="<!--FileExt-->">
|
||||||
|
<a class="<!--FileExtType-->" data-name="<!--FileEncodeReplaceName-->" href="<!--FileEncodeReplaceUrl-->?preview" target="_blank">
|
||||||
|
<!--<?php if(isImage($item['name']) and $_COOKIE["image_mode"] == "1"):?>
|
||||||
|
<img class="mdui-img-fluid" src="<?php echo get_absolute_path($root.$path).rawurlencode($item['name']); ?>">
|
||||||
|
<?php else:?>-->
|
||||||
|
<div class="mdui-row mdui-col-sm-12">
|
||||||
|
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||||
|
<i class="mdui-icon material-icons"><!--IconValue--></i>
|
||||||
|
<span><!--FileEncodeReplaceName--></span>
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||||
|
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="forcedownload mdui-text-right" >
|
||||||
|
<a title="<!--constStr@Download-->" href="<!--FileEncodeReplaceUrl-->">
|
||||||
|
<button class="mdui-btn mdui-ripple mdui-btn-icon"><i class="mdui-icon material-icons">file_download</i></button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<!--FileListEnd-->
|
||||||
|
|
||||||
|
<!--MorePageStart-->
|
||||||
|
<form action="" method="POST" id="nextpageform">
|
||||||
|
<input type="hidden" id="pagenum" name="pagenum" value="">
|
||||||
|
<li class="mdui-list-item th">
|
||||||
|
<div class="mdui-col-sm-6 mdui-left mdui-text-left">
|
||||||
|
<!--PrePageStart-->
|
||||||
|
<a onclick="nextpage(<!--PrePageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@PrePage--></a>
|
||||||
|
<!--PrePageEnd-->
|
||||||
|
<!--NextPageStart-->
|
||||||
|
<a onclick="nextpage(<!--NextPageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@NextPage--></a>
|
||||||
|
<!--NextPageEnd-->
|
||||||
|
</div>
|
||||||
|
<div class="mdui-col-sm-6 mdui-right mdui-text-right">
|
||||||
|
<div class="mdui-right mdui-text-right"><span class="mdui-chip-title">Page: <!--MorePageListStart--><!--MorePageListEnd--><!--MorePageListNowStart--><!--PageNum--><!--MorePageListNowEnd-->/<!--MaxPageNum--></span></div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</form>
|
||||||
|
<!--MorePageEnd-->
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--ReadmemdStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--<div class="mdui-chip">
|
||||||
|
<span class="mdui-chip-icon"><i class="mdui-icon material-icons">face</i></span>
|
||||||
|
<span class="mdui-chip-title">README.md</span>
|
||||||
|
</div>-->
|
||||||
|
<!--ReadmemdContent-->
|
||||||
|
</div>
|
||||||
|
<!--ReadmemdEnd-->
|
||||||
|
<!--FootomfStart-->
|
||||||
|
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||||
|
<!--FootomfContent-->
|
||||||
|
</div>
|
||||||
|
<!--FootomfEnd-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--IsFolderEnd-->
|
||||||
|
<!--ListEnd-->
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<!--MorePageStart-->
|
||||||
|
function nextpage(num) {
|
||||||
|
document.getElementById('pagenum').value=num;
|
||||||
|
document.getElementById('nextpageform').submit();
|
||||||
|
}
|
||||||
|
<!--MorePageEnd-->
|
||||||
|
var $ = mdui.JQ;
|
||||||
|
var $$ = mdui.JQ;
|
||||||
|
var jQuery = mdui.JQ;
|
||||||
|
$$(function() {
|
||||||
|
$$('.file .iframe').each(function() {
|
||||||
|
$$(this).on('click', function() {
|
||||||
|
url=$$(this).attr('href');
|
||||||
|
//url=url.substr(0,url.length-8);
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '<a target="_blank" href="'+url+'">'+ $$(this).find('span').text()+'(点击新窗口打开)</a>', //jia,
|
||||||
|
//shadeClose: true,
|
||||||
|
move: false,
|
||||||
|
shade: false,
|
||||||
|
maxmin: true,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
content: url //le
|
||||||
|
,min: function(layero){
|
||||||
|
//zi;
|
||||||
|
layero.css({top: '90%'})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('.file .dl').each(function () {
|
||||||
|
$(this).on('click', function () {
|
||||||
|
var form = $('<form target=_blank method=post></form>').attr('action', $(this).attr('href')).get(0);
|
||||||
|
$(document.body).append(form);
|
||||||
|
form.submit();
|
||||||
|
$(form).remove();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
window.TC=window.TC||{};
|
||||||
|
$$(".file .audio").on('click',function(e){e.preventDefault();TC.preview_audio(this);});
|
||||||
|
TC.preview_audio = function(aud){
|
||||||
|
if(!TC.aplayer){
|
||||||
|
TC.aplayerList=[];
|
||||||
|
jQuery(".file .audio").each(function(){
|
||||||
|
var ext = jQuery(this).data("readypreview");
|
||||||
|
var n = jQuery(this).find("span").text();
|
||||||
|
var l = n.replace("."+ext,".lrc");
|
||||||
|
var la = jQuery('a[data-name="'+l+'"]');
|
||||||
|
var lrc = undefined;
|
||||||
|
if(la.length>0){
|
||||||
|
lrc = la[0].href+"?s";
|
||||||
|
}
|
||||||
|
TC.aplayerList.push({
|
||||||
|
name:n,
|
||||||
|
url:this.href.substr(0,this.href.length-8),
|
||||||
|
artist:" ",
|
||||||
|
lrc:lrc
|
||||||
|
});
|
||||||
|
})
|
||||||
|
jQuery('<div id="aplayer">').appendTo("body");
|
||||||
|
TC.aplayer = new APlayer({
|
||||||
|
container: document.getElementById('aplayer'),
|
||||||
|
fixed: true,
|
||||||
|
audio: TC.aplayerList,
|
||||||
|
lrcType: 3
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var k=-1;
|
||||||
|
for(var i in TC.aplayerList){
|
||||||
|
if(TC.aplayerList[i].name==jQuery(aud).data("name")){
|
||||||
|
k=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(k>=0){
|
||||||
|
TC.aplayer.list.switch(k);
|
||||||
|
TC.aplayer.play();
|
||||||
|
TC.aplayer.setMode("normal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ = mdui.JQ;
|
||||||
|
$.fn.extend({
|
||||||
|
sortElements: function (comparator, getSortable) {
|
||||||
|
getSortable = getSortable || function () { return this; };
|
||||||
|
|
||||||
|
var placements = this.map(function () {
|
||||||
|
var sortElement = getSortable.call(this),
|
||||||
|
parentNode = sortElement.parentNode,
|
||||||
|
nextSibling = parentNode.insertBefore(
|
||||||
|
document.createTextNode(''),
|
||||||
|
sortElement.nextSibling
|
||||||
|
);
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
parentNode.insertBefore(this, nextSibling);
|
||||||
|
parentNode.removeChild(nextSibling);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return [].sort.call(this, comparator).each(function (i) {
|
||||||
|
placements[i].call(getSortable.call(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var lightbox = GLightbox();
|
||||||
|
function downall() {
|
||||||
|
let dl_link_list = Array.from(document.querySelectorAll("li a"))
|
||||||
|
.map(x => x.href) // 所有list中的链接
|
||||||
|
.filter(x => x.slice(-1) != "/"); // 筛选出非文件夹的文件下载链接
|
||||||
|
|
||||||
|
let blob = new Blob([dl_link_list.join("\r\n")], {
|
||||||
|
type: 'text/plain'
|
||||||
|
}); // 构造Blog对象
|
||||||
|
let a = document.createElement('a'); // 伪造一个a对象
|
||||||
|
a.href = window.URL.createObjectURL(blob); // 构造href属性为Blob对象生成的链接
|
||||||
|
a.download = "folder_download_link.txt"; // 文件名称,你可以根据你的需要构造
|
||||||
|
a.click() // 模拟点击
|
||||||
|
a.remove();
|
||||||
|
}
|
||||||
|
<!--ShowThumbnailsStart-->
|
||||||
|
function thumb(){
|
||||||
|
if($('#thumb i').text() == "apps"){
|
||||||
|
$('#thumb i').text("format_list_bulleted");
|
||||||
|
$('.nexmoe-item').removeClass('thumb');
|
||||||
|
$('.nexmoe-item .mdui-icon').show();
|
||||||
|
$('.nexmoe-item .mdui-list-item').css("background","");
|
||||||
|
}else{
|
||||||
|
$('#thumb i').text("apps");
|
||||||
|
$('.nexmoe-item').addClass('thumb');
|
||||||
|
$('.mdui-col-xs-12 i.mdui-icon').each(function(){
|
||||||
|
//if($(this).text() == "image" || $(this).text() == "ondemand_video"){
|
||||||
|
if($(this).text() == "image"){
|
||||||
|
var thumbnails = $(this).parent().parent().attr('href');
|
||||||
|
//var thumb =(href.indexOf('?') == -1)?'?t=220':'&t=220';
|
||||||
|
thumbnails = thumbnails.substr(0, thumbnails.length-8)+'?thumbnails&location';
|
||||||
|
$(this).hide();
|
||||||
|
//$(this).parent().parent().parent().css("background","url("+href+thumb+") no-repeat center top");
|
||||||
|
$(this).parent().parent().parent().css("background","url("+thumbnails+") no-repeat center top");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
<!--ShowThumbnailsEnd-->
|
||||||
|
$(function(){
|
||||||
|
|
||||||
|
|
||||||
|
$('.icon-sort').on('click', function () {
|
||||||
|
let sort_type = $(this).attr("data-sort"), sort_order = $(this).attr("data-order");
|
||||||
|
let sort_order_to = (sort_order === "less") ? "more" : "less";
|
||||||
|
|
||||||
|
$('li[data-sort]').sortElements(function (a, b) {
|
||||||
|
let data_a = $(a).attr("data-sort-" + sort_type), data_b = $(b).attr("data-sort-" + sort_type);
|
||||||
|
let rt = data_a.localeCompare(data_b, undefined, {numeric: true});
|
||||||
|
return (sort_order === "more") ? 0-rt : rt;
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this).attr("data-order", sort_order_to).text("expand_" + sort_order_to);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
var ckname='image_mode';
|
||||||
|
function getCookie(name)
|
||||||
|
{
|
||||||
|
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||||
|
if(arr=document.cookie.match(reg))
|
||||||
|
return unescape(arr[2]);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function setCookie(key,value,day){
|
||||||
|
var exp = new Date();
|
||||||
|
exp.setTime(exp.getTime() - 1);
|
||||||
|
var cval=getCookie(key);
|
||||||
|
if(cval!=null)
|
||||||
|
document.cookie= key + "="+cval+";expires="+exp.toGMTString();
|
||||||
|
var date = new Date();
|
||||||
|
var nowDate = date.getDate();
|
||||||
|
date.setDate(nowDate + day);
|
||||||
|
var cookie = key+"="+value+"; expires="+date;
|
||||||
|
document.cookie = cookie;
|
||||||
|
return cookie;
|
||||||
|
}
|
||||||
|
$('#image_view').on('click', function () {
|
||||||
|
if($(this).prop('checked') == true){
|
||||||
|
setCookie(ckname,1,1);
|
||||||
|
window.location.href=window.location.href;
|
||||||
|
}else{
|
||||||
|
setCookie(ckname,0,1);
|
||||||
|
window.location.href=window.location.href;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var mainbody = document.getElementById("main-body");
|
||||||
|
var darkmod = 0;
|
||||||
|
var pri_class = "mdui-theme-primary-"+primary_color;
|
||||||
|
var acc_class = "mdui-theme-accent-"+accent_color;
|
||||||
|
mainbody.classList.add(acc_class);
|
||||||
|
mainbody.classList.add(pri_class);
|
||||||
|
if (window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||||
|
{mainbody.classList.add("mdui-theme-layout-dark");darkmod = 1}
|
||||||
|
function darkmod_use(){
|
||||||
|
if (darkmod == 1){
|
||||||
|
mainbody.classList.remove("mdui-theme-layout-dark");darkmod = 0;
|
||||||
|
} else {
|
||||||
|
mainbody.classList.add("mdui-theme-layout-dark");darkmod = 1;
|
||||||
|
}};
|
||||||
|
function login() {
|
||||||
|
$$("content").write("")
|
||||||
|
}
|
||||||
|
//var pjax = new Pjax({
|
||||||
|
// selectors :[
|
||||||
|
// "content"
|
||||||
|
// ],
|
||||||
|
// debug: true,
|
||||||
|
// timeout: 8000
|
||||||
|
//})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<link rel="icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
<link rel="icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
||||||
<link rel="shortcut icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;line-height:1em;color:#1E90FF;background:url("http://www.qqzzz.net/www/images/bj.png")}
|
body{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;line-height:1em;color:#1E90FF;background:url("//www.qqzzz.net/www/images/bj.png")}
|
||||||
a{color:#1E90FF;cursor:pointer;text-decoration:none}
|
a{color:#1E90FF;cursor:pointer;text-decoration:none}
|
||||||
a:hover{color:#1E90FF}
|
a:hover{color:#1E90FF}
|
||||||
.login ion-icon{vertical-align:bottom}
|
.login ion-icon{vertical-align:bottom}
|
||||||
|
|||||||
+1296
File diff suppressed because it is too large
Load Diff
+1296
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,68 @@
|
|||||||
#!bash
|
#!bash
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "
|
||||||
|
"$0" -i|u [-b branch]
|
||||||
|
i a new install with empty config.
|
||||||
|
u update use exist config.
|
||||||
|
b install the branch after parameter b, default master
|
||||||
|
|
||||||
|
example:
|
||||||
|
"$0" -i
|
||||||
|
"$0" -u
|
||||||
|
"$0" -b master
|
||||||
|
"$0" -u -b master
|
||||||
|
"$0" -ib test
|
||||||
|
"
|
||||||
|
# exit
|
||||||
|
echo "###############
|
||||||
|
0, new install
|
||||||
|
1, update"
|
||||||
|
read -p "Input:" c
|
||||||
|
[ g"$c" == g"0" ] && install=1
|
||||||
|
[ g"$c" == g"1" ] && update=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
i=0
|
||||||
|
para[$i]=$0
|
||||||
|
for av in "$@"
|
||||||
|
do
|
||||||
|
#echo $av
|
||||||
|
((i++))
|
||||||
|
para[$i]=$av
|
||||||
|
if [ g"${av:0:1}" == g"-" ]; then
|
||||||
|
while [ g"$av" != g"" ]
|
||||||
|
do
|
||||||
|
ag=${av:0:1}
|
||||||
|
av=${av:1}
|
||||||
|
[ g"$ag" == g"b" ] && isbranch=1
|
||||||
|
[ g"$ag" == g"i" ] && install=1
|
||||||
|
[ g"$ag" == g"u" ] && update=1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
if [ g"$isbranch" == g"1" ]; then
|
||||||
|
branch="-b $av"
|
||||||
|
isbranch=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ g"$install" == g"1" -a g"$update" == g"1" ]; then
|
||||||
|
echo "Both install & update, exit"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [ g"$install" != g"1" -a g"$update" != g"1" ]; then
|
||||||
|
echo "Not install & Not update, exit"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
gitsource='https://github.com/qkqpttgf/OneManager-php'
|
gitsource='https://github.com/qkqpttgf/OneManager-php'
|
||||||
|
|
||||||
OneManagerPath=`cd $(dirname $0);pwd -P`
|
OneManagerPath=`cd $(dirname $0);pwd -P`
|
||||||
cd ${OneManagerPath}
|
cd ${OneManagerPath}
|
||||||
|
|
||||||
git clone ${gitsource}
|
git clone ${branch} ${gitsource}
|
||||||
\mv -b config.php OneManager-php/
|
[ g"$install" == g"1" ] || \mv -b config.php OneManager-php/
|
||||||
\mv -b OneManager-php/* ./
|
\mv -b OneManager-php/* ./
|
||||||
\mv -b OneManager-php/.[^.]* ./
|
\mv -b OneManager-php/.[^.]* ./
|
||||||
rm -rf *~
|
rm -rf *~
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APC cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @deprecated since version 1.6, use ApcuCache instead
|
|
||||||
* @since 2.0
|
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
* @author Jonathan Wage <jonwage@gmail.com>
|
|
||||||
* @author Roman Borschel <roman@code-factory.org>
|
|
||||||
* @author David Abdemoulaie <dave@hobodave.com>
|
|
||||||
*/
|
|
||||||
class ApcCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return apc_fetch($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return apc_exists($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
return apc_store($id, $data, $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
// apc_delete returns false if the id does not exist
|
|
||||||
return apc_delete($id) || ! apc_exists($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return apc_clear_cache() && apc_clear_cache('user');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetchMultiple(array $keys)
|
|
||||||
{
|
|
||||||
return apc_fetch($keys) ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
|
||||||
{
|
|
||||||
$result = apc_store($keysAndValues, null, $lifetime);
|
|
||||||
|
|
||||||
return empty($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$info = apc_cache_info('', true);
|
|
||||||
$sma = apc_sma_info();
|
|
||||||
|
|
||||||
// @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42
|
|
||||||
if (PHP_VERSION_ID >= 50500) {
|
|
||||||
$info['num_hits'] = isset($info['num_hits']) ? $info['num_hits'] : $info['nhits'];
|
|
||||||
$info['num_misses'] = isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses'];
|
|
||||||
$info['start_time'] = isset($info['start_time']) ? $info['start_time'] : $info['stime'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $info['num_hits'],
|
|
||||||
Cache::STATS_MISSES => $info['num_misses'],
|
|
||||||
Cache::STATS_UPTIME => $info['start_time'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APCu cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 1.6
|
|
||||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
||||||
*/
|
|
||||||
class ApcuCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return apcu_fetch($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return apcu_exists($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
return apcu_store($id, $data, $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
// apcu_delete returns false if the id does not exist
|
|
||||||
return apcu_delete($id) || ! apcu_exists($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return apcu_clear_cache();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetchMultiple(array $keys)
|
|
||||||
{
|
|
||||||
return apcu_fetch($keys) ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
|
||||||
{
|
|
||||||
$result = apcu_store($keysAndValues, null, $lifetime);
|
|
||||||
|
|
||||||
return empty($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$info = apcu_cache_info(true);
|
|
||||||
$sma = apcu_sma_info();
|
|
||||||
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $info['num_hits'],
|
|
||||||
Cache::STATS_MISSES => $info['num_misses'],
|
|
||||||
Cache::STATS_UPTIME => $info['start_time'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Array cache driver.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.0
|
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
* @author Jonathan Wage <jonwage@gmail.com>
|
|
||||||
* @author Roman Borschel <roman@code-factory.org>
|
|
||||||
* @author David Abdemoulaie <dave@hobodave.com>
|
|
||||||
*/
|
|
||||||
class ArrayCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array[] $data each element being a tuple of [$data, $expiration], where the expiration is int|bool
|
|
||||||
*/
|
|
||||||
private $data = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $hitsCount = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $missesCount = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $upTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->upTime = time();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
if (! $this->doContains($id)) {
|
|
||||||
$this->missesCount += 1;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->hitsCount += 1;
|
|
||||||
|
|
||||||
return $this->data[$id][0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
if (! isset($this->data[$id])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$expiration = $this->data[$id][1];
|
|
||||||
|
|
||||||
if ($expiration && $expiration < time()) {
|
|
||||||
$this->doDelete($id);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
$this->data[$id] = [$data, $lifeTime ? time() + $lifeTime : false];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
unset($this->data[$id]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
$this->data = [];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Cache::STATS_HITS => $this->hitsCount,
|
|
||||||
Cache::STATS_MISSES => $this->missesCount,
|
|
||||||
Cache::STATS_UPTIME => $this->upTime,
|
|
||||||
Cache::STATS_MEMORY_USAGE => null,
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => null,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cache provider that allows to easily chain multiple cache providers
|
|
||||||
*
|
|
||||||
* @author Michaël Gallego <mic.gallego@gmail.com>
|
|
||||||
*/
|
|
||||||
class ChainCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var CacheProvider[]
|
|
||||||
*/
|
|
||||||
private $cacheProviders = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param CacheProvider[] $cacheProviders
|
|
||||||
*/
|
|
||||||
public function __construct($cacheProviders = array())
|
|
||||||
{
|
|
||||||
$this->cacheProviders = $cacheProviders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function setNamespace($namespace)
|
|
||||||
{
|
|
||||||
parent::setNamespace($namespace);
|
|
||||||
|
|
||||||
foreach ($this->cacheProviders as $cacheProvider) {
|
|
||||||
$cacheProvider->setNamespace($namespace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
foreach ($this->cacheProviders as $key => $cacheProvider) {
|
|
||||||
if ($cacheProvider->doContains($id)) {
|
|
||||||
$value = $cacheProvider->doFetch($id);
|
|
||||||
|
|
||||||
// We populate all the previous cache layers (that are assumed to be faster)
|
|
||||||
for ($subKey = $key - 1 ; $subKey >= 0 ; $subKey--) {
|
|
||||||
$this->cacheProviders[$subKey]->doSave($id, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
foreach ($this->cacheProviders as $cacheProvider) {
|
|
||||||
if ($cacheProvider->doContains($id)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
$stored = true;
|
|
||||||
|
|
||||||
foreach ($this->cacheProviders as $cacheProvider) {
|
|
||||||
$stored = $cacheProvider->doSave($id, $data, $lifeTime) && $stored;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $stored;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
$deleted = true;
|
|
||||||
|
|
||||||
foreach ($this->cacheProviders as $cacheProvider) {
|
|
||||||
$deleted = $cacheProvider->doDelete($id) && $deleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $deleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
$flushed = true;
|
|
||||||
|
|
||||||
foreach ($this->cacheProviders as $cacheProvider) {
|
|
||||||
$flushed = $cacheProvider->doFlush() && $flushed;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $flushed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
// We return all the stats from all adapters
|
|
||||||
$stats = array();
|
|
||||||
|
|
||||||
foreach ($this->cacheProviders as $cacheProvider) {
|
|
||||||
$stats[] = $cacheProvider->doGetStats();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $stats;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use \Couchbase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Couchbase cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.4
|
|
||||||
* @author Michael Nitschinger <michael@nitschinger.at>
|
|
||||||
*/
|
|
||||||
class CouchbaseCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Couchbase|null
|
|
||||||
*/
|
|
||||||
private $couchbase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Couchbase instance to use.
|
|
||||||
*
|
|
||||||
* @param Couchbase $couchbase
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setCouchbase(Couchbase $couchbase)
|
|
||||||
{
|
|
||||||
$this->couchbase = $couchbase;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Couchbase instance used by the cache.
|
|
||||||
*
|
|
||||||
* @return Couchbase|null
|
|
||||||
*/
|
|
||||||
public function getCouchbase()
|
|
||||||
{
|
|
||||||
return $this->couchbase;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return $this->couchbase->get($id) ?: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return (null !== $this->couchbase->get($id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
if ($lifeTime > 30 * 24 * 3600) {
|
|
||||||
$lifeTime = time() + $lifeTime;
|
|
||||||
}
|
|
||||||
return $this->couchbase->set($id, $data, (int) $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return $this->couchbase->delete($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return $this->couchbase->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$stats = $this->couchbase->getStats();
|
|
||||||
$servers = $this->couchbase->getServers();
|
|
||||||
$server = explode(":", $servers[0]);
|
|
||||||
$key = $server[0] . ":" . "11210";
|
|
||||||
$stats = $stats[$key];
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $stats['get_hits'],
|
|
||||||
Cache::STATS_MISSES => $stats['get_misses'],
|
|
||||||
Cache::STATS_UPTIME => $stats['uptime'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use \Memcache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memcache cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.0
|
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
* @author Jonathan Wage <jonwage@gmail.com>
|
|
||||||
* @author Roman Borschel <roman@code-factory.org>
|
|
||||||
* @author David Abdemoulaie <dave@hobodave.com>
|
|
||||||
*/
|
|
||||||
class MemcacheCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Memcache|null
|
|
||||||
*/
|
|
||||||
private $memcache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the memcache instance to use.
|
|
||||||
*
|
|
||||||
* @param Memcache $memcache
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setMemcache(Memcache $memcache)
|
|
||||||
{
|
|
||||||
$this->memcache = $memcache;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the memcache instance used by the cache.
|
|
||||||
*
|
|
||||||
* @return Memcache|null
|
|
||||||
*/
|
|
||||||
public function getMemcache()
|
|
||||||
{
|
|
||||||
return $this->memcache;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return $this->memcache->get($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
$flags = null;
|
|
||||||
$this->memcache->get($id, $flags);
|
|
||||||
|
|
||||||
//if memcache has changed the value of "flags", it means the value exists
|
|
||||||
return ($flags !== null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
if ($lifeTime > 30 * 24 * 3600) {
|
|
||||||
$lifeTime = time() + $lifeTime;
|
|
||||||
}
|
|
||||||
return $this->memcache->set($id, $data, 0, (int) $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
// Memcache::delete() returns false if entry does not exist
|
|
||||||
return $this->memcache->delete($id) || ! $this->doContains($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return $this->memcache->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$stats = $this->memcache->getStats();
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $stats['get_hits'],
|
|
||||||
Cache::STATS_MISSES => $stats['get_misses'],
|
|
||||||
Cache::STATS_UPTIME => $stats['uptime'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use \Memcached;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memcached cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.2
|
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
* @author Jonathan Wage <jonwage@gmail.com>
|
|
||||||
* @author Roman Borschel <roman@code-factory.org>
|
|
||||||
* @author David Abdemoulaie <dave@hobodave.com>
|
|
||||||
*/
|
|
||||||
class MemcachedCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Memcached|null
|
|
||||||
*/
|
|
||||||
private $memcached;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the memcache instance to use.
|
|
||||||
*
|
|
||||||
* @param Memcached $memcached
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setMemcached(Memcached $memcached)
|
|
||||||
{
|
|
||||||
$this->memcached = $memcached;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the memcached instance used by the cache.
|
|
||||||
*
|
|
||||||
* @return Memcached|null
|
|
||||||
*/
|
|
||||||
public function getMemcached()
|
|
||||||
{
|
|
||||||
return $this->memcached;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return $this->memcached->get($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetchMultiple(array $keys)
|
|
||||||
{
|
|
||||||
return $this->memcached->getMulti($keys) ?: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
|
||||||
{
|
|
||||||
if ($lifetime > 30 * 24 * 3600) {
|
|
||||||
$lifetime = time() + $lifetime;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->memcached->setMulti($keysAndValues, $lifetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
$this->memcached->get($id);
|
|
||||||
|
|
||||||
return $this->memcached->getResultCode() === Memcached::RES_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
if ($lifeTime > 30 * 24 * 3600) {
|
|
||||||
$lifeTime = time() + $lifeTime;
|
|
||||||
}
|
|
||||||
return $this->memcached->set($id, $data, (int) $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return $this->memcached->delete($id)
|
|
||||||
|| $this->memcached->getResultCode() === Memcached::RES_NOTFOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return $this->memcached->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$stats = $this->memcached->getStats();
|
|
||||||
$servers = $this->memcached->getServerList();
|
|
||||||
$key = $servers[0]['host'] . ':' . $servers[0]['port'];
|
|
||||||
$stats = $stats[$key];
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $stats['get_hits'],
|
|
||||||
Cache::STATS_MISSES => $stats['get_misses'],
|
|
||||||
Cache::STATS_UPTIME => $stats['uptime'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use MongoBinData;
|
|
||||||
use MongoCollection;
|
|
||||||
use MongoCursorException;
|
|
||||||
use MongoDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MongoDB cache provider.
|
|
||||||
*
|
|
||||||
* @since 1.1
|
|
||||||
* @author Jeremy Mikola <jmikola@gmail.com>
|
|
||||||
*/
|
|
||||||
class MongoDBCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The data field will store the serialized PHP value.
|
|
||||||
*/
|
|
||||||
const DATA_FIELD = 'd';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The expiration field will store a MongoDate value indicating when the
|
|
||||||
* cache entry should expire.
|
|
||||||
*
|
|
||||||
* With MongoDB 2.2+, entries can be automatically deleted by MongoDB by
|
|
||||||
* indexing this field with the "expireAfterSeconds" option equal to zero.
|
|
||||||
* This will direct MongoDB to regularly query for and delete any entries
|
|
||||||
* whose date is older than the current time. Entries without a date value
|
|
||||||
* in this field will be ignored.
|
|
||||||
*
|
|
||||||
* The cache provider will also check dates on its own, in case expired
|
|
||||||
* entries are fetched before MongoDB's TTLMonitor pass can expire them.
|
|
||||||
*
|
|
||||||
* @see http://docs.mongodb.org/manual/tutorial/expire-data/
|
|
||||||
*/
|
|
||||||
const EXPIRATION_FIELD = 'e';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var MongoCollection
|
|
||||||
*/
|
|
||||||
private $collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* This provider will default to the write concern and read preference
|
|
||||||
* options set on the MongoCollection instance (or inherited from MongoDB or
|
|
||||||
* MongoClient). Using an unacknowledged write concern (< 1) may make the
|
|
||||||
* return values of delete() and save() unreliable. Reading from secondaries
|
|
||||||
* may make contain() and fetch() unreliable.
|
|
||||||
*
|
|
||||||
* @see http://www.php.net/manual/en/mongo.readpreferences.php
|
|
||||||
* @see http://www.php.net/manual/en/mongo.writeconcerns.php
|
|
||||||
* @param MongoCollection $collection
|
|
||||||
*/
|
|
||||||
public function __construct(MongoCollection $collection)
|
|
||||||
{
|
|
||||||
$this->collection = $collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
$document = $this->collection->findOne(array('_id' => $id), array(self::DATA_FIELD, self::EXPIRATION_FIELD));
|
|
||||||
|
|
||||||
if ($document === null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->isExpired($document)) {
|
|
||||||
$this->doDelete($id);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return unserialize($document[self::DATA_FIELD]->bin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
$document = $this->collection->findOne(array('_id' => $id), array(self::EXPIRATION_FIELD));
|
|
||||||
|
|
||||||
if ($document === null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->isExpired($document)) {
|
|
||||||
$this->doDelete($id);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$result = $this->collection->update(
|
|
||||||
array('_id' => $id),
|
|
||||||
array('$set' => array(
|
|
||||||
self::EXPIRATION_FIELD => ($lifeTime > 0 ? new MongoDate(time() + $lifeTime) : null),
|
|
||||||
self::DATA_FIELD => new MongoBinData(serialize($data), MongoBinData::BYTE_ARRAY),
|
|
||||||
)),
|
|
||||||
array('upsert' => true, 'multiple' => false)
|
|
||||||
);
|
|
||||||
} catch (MongoCursorException $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isset($result['ok']) ? $result['ok'] == 1 : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
$result = $this->collection->remove(array('_id' => $id));
|
|
||||||
|
|
||||||
return isset($result['ok']) ? $result['ok'] == 1 : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
// Use remove() in lieu of drop() to maintain any collection indexes
|
|
||||||
$result = $this->collection->remove();
|
|
||||||
|
|
||||||
return isset($result['ok']) ? $result['ok'] == 1 : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$serverStatus = $this->collection->db->command(array(
|
|
||||||
'serverStatus' => 1,
|
|
||||||
'locks' => 0,
|
|
||||||
'metrics' => 0,
|
|
||||||
'recordStats' => 0,
|
|
||||||
'repl' => 0,
|
|
||||||
));
|
|
||||||
|
|
||||||
$collStats = $this->collection->db->command(array('collStats' => 1));
|
|
||||||
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => null,
|
|
||||||
Cache::STATS_MISSES => null,
|
|
||||||
Cache::STATS_UPTIME => (isset($serverStatus['uptime']) ? (int) $serverStatus['uptime'] : null),
|
|
||||||
Cache::STATS_MEMORY_USAGE => (isset($collStats['size']) ? (int) $collStats['size'] : null),
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the document is expired.
|
|
||||||
*
|
|
||||||
* @param array $document
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function isExpired(array $document)
|
|
||||||
{
|
|
||||||
return isset($document[self::EXPIRATION_FIELD]) &&
|
|
||||||
$document[self::EXPIRATION_FIELD] instanceof MongoDate &&
|
|
||||||
$document[self::EXPIRATION_FIELD]->sec < time();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Php file cache driver.
|
|
||||||
*
|
|
||||||
* @since 2.3
|
|
||||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
|
||||||
*/
|
|
||||||
class PhpFileCache extends FileCache
|
|
||||||
{
|
|
||||||
const EXTENSION = '.doctrinecache.php';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function __construct($directory, $extension = self::EXTENSION, $umask = 0002)
|
|
||||||
{
|
|
||||||
parent::__construct($directory, $extension, $umask);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
$value = $this->includeFileForId($id);
|
|
||||||
|
|
||||||
if (! $value) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($value['lifetime'] !== 0 && $value['lifetime'] < time()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value['data'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
$value = $this->includeFileForId($id);
|
|
||||||
|
|
||||||
if (! $value) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value['lifetime'] === 0 || $value['lifetime'] > time();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
if ($lifeTime > 0) {
|
|
||||||
$lifeTime = time() + $lifeTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_object($data) && ! method_exists($data, '__set_state')) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
"Invalid argument given, PhpFileCache only allows objects that implement __set_state() " .
|
|
||||||
"and fully support var_export(). You can use the FilesystemCache to save arbitrary object " .
|
|
||||||
"graphs using serialize()/deserialize()."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename = $this->getFilename($id);
|
|
||||||
|
|
||||||
$value = array(
|
|
||||||
'lifetime' => $lifeTime,
|
|
||||||
'data' => $data
|
|
||||||
);
|
|
||||||
|
|
||||||
$value = var_export($value, true);
|
|
||||||
$code = sprintf('<?php return %s;', $value);
|
|
||||||
|
|
||||||
return $this->writeFile($filename, $code);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $id
|
|
||||||
*
|
|
||||||
* @return array|false
|
|
||||||
*/
|
|
||||||
private function includeFileForId($id)
|
|
||||||
{
|
|
||||||
$fileName = $this->getFilename($id);
|
|
||||||
|
|
||||||
// note: error suppression is still faster than `file_exists`, `is_file` and `is_readable`
|
|
||||||
$value = @include $fileName;
|
|
||||||
|
|
||||||
if (! isset($value['lifetime'])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use Predis\ClientInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Predis cache provider.
|
|
||||||
*
|
|
||||||
* @author othillo <othillo@othillo.nl>
|
|
||||||
*/
|
|
||||||
class PredisCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var ClientInterface
|
|
||||||
*/
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ClientInterface $client
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(ClientInterface $client)
|
|
||||||
{
|
|
||||||
$this->client = $client;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
$result = $this->client->get($id);
|
|
||||||
if (null === $result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return unserialize($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetchMultiple(array $keys)
|
|
||||||
{
|
|
||||||
$fetchedItems = call_user_func_array(array($this->client, 'mget'), $keys);
|
|
||||||
|
|
||||||
return array_map('unserialize', array_filter(array_combine($keys, $fetchedItems)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
|
||||||
{
|
|
||||||
if ($lifetime) {
|
|
||||||
$success = true;
|
|
||||||
|
|
||||||
// Keys have lifetime, use SETEX for each of them
|
|
||||||
foreach ($keysAndValues as $key => $value) {
|
|
||||||
$response = $this->client->setex($key, $lifetime, serialize($value));
|
|
||||||
|
|
||||||
if ((string) $response != 'OK') {
|
|
||||||
$success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No lifetime, use MSET
|
|
||||||
$response = $this->client->mset(array_map(function ($value) {
|
|
||||||
return serialize($value);
|
|
||||||
}, $keysAndValues));
|
|
||||||
|
|
||||||
return (string) $response == 'OK';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return (bool) $this->client->exists($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
$data = serialize($data);
|
|
||||||
if ($lifeTime > 0) {
|
|
||||||
$response = $this->client->setex($id, $lifeTime, $data);
|
|
||||||
} else {
|
|
||||||
$response = $this->client->set($id, $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $response === true || $response == 'OK';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return $this->client->del($id) >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
$response = $this->client->flushdb();
|
|
||||||
|
|
||||||
return $response === true || $response == 'OK';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$info = $this->client->info();
|
|
||||||
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $info['Stats']['keyspace_hits'],
|
|
||||||
Cache::STATS_MISSES => $info['Stats']['keyspace_misses'],
|
|
||||||
Cache::STATS_UPTIME => $info['Server']['uptime_in_seconds'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $info['Memory']['used_memory'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use Redis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redis cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.2
|
|
||||||
* @author Osman Ungur <osmanungur@gmail.com>
|
|
||||||
*/
|
|
||||||
class RedisCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Redis|null
|
|
||||||
*/
|
|
||||||
private $redis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the redis instance to use.
|
|
||||||
*
|
|
||||||
* @param Redis $redis
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setRedis(Redis $redis)
|
|
||||||
{
|
|
||||||
$redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue());
|
|
||||||
$this->redis = $redis;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the redis instance used by the cache.
|
|
||||||
*
|
|
||||||
* @return Redis|null
|
|
||||||
*/
|
|
||||||
public function getRedis()
|
|
||||||
{
|
|
||||||
return $this->redis;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return $this->redis->get($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetchMultiple(array $keys)
|
|
||||||
{
|
|
||||||
$fetchedItems = array_combine($keys, $this->redis->mget($keys));
|
|
||||||
|
|
||||||
// Redis mget returns false for keys that do not exist. So we need to filter those out unless it's the real data.
|
|
||||||
$foundItems = array();
|
|
||||||
|
|
||||||
foreach ($fetchedItems as $key => $value) {
|
|
||||||
if (false !== $value || $this->redis->exists($key)) {
|
|
||||||
$foundItems[$key] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $foundItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
|
||||||
{
|
|
||||||
if ($lifetime) {
|
|
||||||
$success = true;
|
|
||||||
|
|
||||||
// Keys have lifetime, use SETEX for each of them
|
|
||||||
foreach ($keysAndValues as $key => $value) {
|
|
||||||
if (!$this->redis->setex($key, $lifetime, $value)) {
|
|
||||||
$success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No lifetime, use MSET
|
|
||||||
return (bool) $this->redis->mset($keysAndValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return $this->redis->exists($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
if ($lifeTime > 0) {
|
|
||||||
return $this->redis->setex($id, $lifeTime, $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redis->set($id, $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return $this->redis->delete($id) >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return $this->redis->flushDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$info = $this->redis->info();
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $info['keyspace_hits'],
|
|
||||||
Cache::STATS_MISSES => $info['keyspace_misses'],
|
|
||||||
Cache::STATS_UPTIME => $info['uptime_in_seconds'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $info['used_memory'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the serializer constant to use. If Redis is compiled with
|
|
||||||
* igbinary support, that is used. Otherwise the default PHP serializer is
|
|
||||||
* used.
|
|
||||||
*
|
|
||||||
* @return integer One of the Redis::SERIALIZER_* constants
|
|
||||||
*/
|
|
||||||
protected function getSerializerValue()
|
|
||||||
{
|
|
||||||
if (defined('HHVM_VERSION')) {
|
|
||||||
return Redis::SERIALIZER_PHP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) {
|
|
||||||
return Redis::SERIALIZER_IGBINARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Redis::SERIALIZER_PHP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,250 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use Riak\Bucket;
|
|
||||||
use Riak\Connection;
|
|
||||||
use Riak\Input;
|
|
||||||
use Riak\Exception;
|
|
||||||
use Riak\Object;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Riak cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 1.1
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
*/
|
|
||||||
class RiakCache extends CacheProvider
|
|
||||||
{
|
|
||||||
const EXPIRES_HEADER = 'X-Riak-Meta-Expires';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Riak\Bucket
|
|
||||||
*/
|
|
||||||
private $bucket;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the riak bucket instance to use.
|
|
||||||
*
|
|
||||||
* @param \Riak\Bucket $bucket
|
|
||||||
*/
|
|
||||||
public function __construct(Bucket $bucket)
|
|
||||||
{
|
|
||||||
$this->bucket = $bucket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$response = $this->bucket->get($id);
|
|
||||||
|
|
||||||
// No objects found
|
|
||||||
if ( ! $response->hasObject()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for attempted siblings
|
|
||||||
$object = ($response->hasSiblings())
|
|
||||||
? $this->resolveConflict($id, $response->getVClock(), $response->getObjectList())
|
|
||||||
: $response->getFirstObject();
|
|
||||||
|
|
||||||
// Check for expired object
|
|
||||||
if ($this->isExpired($object)) {
|
|
||||||
$this->bucket->delete($object);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return unserialize($object->getContent());
|
|
||||||
} catch (Exception\RiakException $e) {
|
|
||||||
// Covers:
|
|
||||||
// - Riak\ConnectionException
|
|
||||||
// - Riak\CommunicationException
|
|
||||||
// - Riak\UnexpectedResponseException
|
|
||||||
// - Riak\NotFoundException
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
// We only need the HEAD, not the entire object
|
|
||||||
$input = new Input\GetInput();
|
|
||||||
|
|
||||||
$input->setReturnHead(true);
|
|
||||||
|
|
||||||
$response = $this->bucket->get($id, $input);
|
|
||||||
|
|
||||||
// No objects found
|
|
||||||
if ( ! $response->hasObject()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$object = $response->getFirstObject();
|
|
||||||
|
|
||||||
// Check for expired object
|
|
||||||
if ($this->isExpired($object)) {
|
|
||||||
$this->bucket->delete($object);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (Exception\RiakException $e) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$object = new Object($id);
|
|
||||||
|
|
||||||
$object->setContent(serialize($data));
|
|
||||||
|
|
||||||
if ($lifeTime > 0) {
|
|
||||||
$object->addMetadata(self::EXPIRES_HEADER, (string) (time() + $lifeTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->bucket->put($object);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (Exception\RiakException $e) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->bucket->delete($id);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (Exception\BadArgumentsException $e) {
|
|
||||||
// Key did not exist on cluster already
|
|
||||||
} catch (Exception\RiakException $e) {
|
|
||||||
// Covers:
|
|
||||||
// - Riak\Exception\ConnectionException
|
|
||||||
// - Riak\Exception\CommunicationException
|
|
||||||
// - Riak\Exception\UnexpectedResponseException
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$keyList = $this->bucket->getKeyList();
|
|
||||||
|
|
||||||
foreach ($keyList as $key) {
|
|
||||||
$this->bucket->delete($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (Exception\RiakException $e) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
// Only exposed through HTTP stats API, not Protocol Buffers API
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a given Riak Object have expired.
|
|
||||||
*
|
|
||||||
* @param \Riak\Object $object
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function isExpired(Object $object)
|
|
||||||
{
|
|
||||||
$metadataMap = $object->getMetadataMap();
|
|
||||||
|
|
||||||
return isset($metadataMap[self::EXPIRES_HEADER])
|
|
||||||
&& $metadataMap[self::EXPIRES_HEADER] < time();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* On-read conflict resolution. Applied approach here is last write wins.
|
|
||||||
* Specific needs may override this method to apply alternate conflict resolutions.
|
|
||||||
*
|
|
||||||
* {@internal Riak does not attempt to resolve a write conflict, and store
|
|
||||||
* it as sibling of conflicted one. By following this approach, it is up to
|
|
||||||
* the next read to resolve the conflict. When this happens, your fetched
|
|
||||||
* object will have a list of siblings (read as a list of objects).
|
|
||||||
* In our specific case, we do not care about the intermediate ones since
|
|
||||||
* they are all the same read from storage, and we do apply a last sibling
|
|
||||||
* (last write) wins logic.
|
|
||||||
* If by any means our resolution generates another conflict, it'll up to
|
|
||||||
* next read to properly solve it.}
|
|
||||||
*
|
|
||||||
* @param string $id
|
|
||||||
* @param string $vClock
|
|
||||||
* @param array $objectList
|
|
||||||
*
|
|
||||||
* @return \Riak\Object
|
|
||||||
*/
|
|
||||||
protected function resolveConflict($id, $vClock, array $objectList)
|
|
||||||
{
|
|
||||||
// Our approach here is last-write wins
|
|
||||||
$winner = $objectList[count($objectList)];
|
|
||||||
|
|
||||||
$putInput = new Input\PutInput();
|
|
||||||
$putInput->setVClock($vClock);
|
|
||||||
|
|
||||||
$mergedObject = new Object($id);
|
|
||||||
$mergedObject->setContent($winner->getContent());
|
|
||||||
|
|
||||||
$this->bucket->put($mergedObject, $putInput);
|
|
||||||
|
|
||||||
return $mergedObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
use SQLite3;
|
|
||||||
use SQLite3Result;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SQLite3 cache provider.
|
|
||||||
*
|
|
||||||
* @since 1.4
|
|
||||||
* @author Jake Bell <jake@theunraveler.com>
|
|
||||||
*/
|
|
||||||
class SQLite3Cache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The ID field will store the cache key.
|
|
||||||
*/
|
|
||||||
const ID_FIELD = 'k';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The data field will store the serialized PHP value.
|
|
||||||
*/
|
|
||||||
const DATA_FIELD = 'd';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The expiration field will store a date value indicating when the
|
|
||||||
* cache entry should expire.
|
|
||||||
*/
|
|
||||||
const EXPIRATION_FIELD = 'e';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var SQLite3
|
|
||||||
*/
|
|
||||||
private $sqlite;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $table;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* Calling the constructor will ensure that the database file and table
|
|
||||||
* exist and will create both if they don't.
|
|
||||||
*
|
|
||||||
* @param SQLite3 $sqlite
|
|
||||||
* @param string $table
|
|
||||||
*/
|
|
||||||
public function __construct(SQLite3 $sqlite, $table)
|
|
||||||
{
|
|
||||||
$this->sqlite = $sqlite;
|
|
||||||
$this->table = (string) $table;
|
|
||||||
|
|
||||||
list($id, $data, $exp) = $this->getFields();
|
|
||||||
|
|
||||||
return $this->sqlite->exec(sprintf(
|
|
||||||
'CREATE TABLE IF NOT EXISTS %s(%s TEXT PRIMARY KEY NOT NULL, %s BLOB, %s INTEGER)',
|
|
||||||
$table,
|
|
||||||
$id,
|
|
||||||
$data,
|
|
||||||
$exp
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
if ($item = $this->findById($id)) {
|
|
||||||
return unserialize($item[self::DATA_FIELD]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return null !== $this->findById($id, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
$statement = $this->sqlite->prepare(sprintf(
|
|
||||||
'INSERT OR REPLACE INTO %s (%s) VALUES (:id, :data, :expire)',
|
|
||||||
$this->table,
|
|
||||||
implode(',', $this->getFields())
|
|
||||||
));
|
|
||||||
|
|
||||||
$statement->bindValue(':id', $id);
|
|
||||||
$statement->bindValue(':data', serialize($data), SQLITE3_BLOB);
|
|
||||||
$statement->bindValue(':expire', $lifeTime > 0 ? time() + $lifeTime : null);
|
|
||||||
|
|
||||||
return $statement->execute() instanceof SQLite3Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
list($idField) = $this->getFields();
|
|
||||||
|
|
||||||
$statement = $this->sqlite->prepare(sprintf(
|
|
||||||
'DELETE FROM %s WHERE %s = :id',
|
|
||||||
$this->table,
|
|
||||||
$idField
|
|
||||||
));
|
|
||||||
|
|
||||||
$statement->bindValue(':id', $id);
|
|
||||||
|
|
||||||
return $statement->execute() instanceof SQLite3Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return $this->sqlite->exec(sprintf('DELETE FROM %s', $this->table));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
// no-op.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a single row by ID.
|
|
||||||
*
|
|
||||||
* @param mixed $id
|
|
||||||
* @param bool $includeData
|
|
||||||
*
|
|
||||||
* @return array|null
|
|
||||||
*/
|
|
||||||
private function findById($id, $includeData = true)
|
|
||||||
{
|
|
||||||
list($idField) = $fields = $this->getFields();
|
|
||||||
|
|
||||||
if (!$includeData) {
|
|
||||||
$key = array_search(static::DATA_FIELD, $fields);
|
|
||||||
unset($fields[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$statement = $this->sqlite->prepare(sprintf(
|
|
||||||
'SELECT %s FROM %s WHERE %s = :id LIMIT 1',
|
|
||||||
implode(',', $fields),
|
|
||||||
$this->table,
|
|
||||||
$idField
|
|
||||||
));
|
|
||||||
|
|
||||||
$statement->bindValue(':id', $id, SQLITE3_TEXT);
|
|
||||||
|
|
||||||
$item = $statement->execute()->fetchArray(SQLITE3_ASSOC);
|
|
||||||
|
|
||||||
if ($item === false) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->isExpired($item)) {
|
|
||||||
$this->doDelete($id);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an array of the fields in our table.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getFields()
|
|
||||||
{
|
|
||||||
return array(static::ID_FIELD, static::DATA_FIELD, static::EXPIRATION_FIELD);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the item is expired.
|
|
||||||
*
|
|
||||||
* @param array $item
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function isExpired(array $item)
|
|
||||||
{
|
|
||||||
return isset($item[static::EXPIRATION_FIELD]) &&
|
|
||||||
$item[self::EXPIRATION_FIELD] !== null &&
|
|
||||||
$item[self::EXPIRATION_FIELD] < time();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
class Version
|
|
||||||
{
|
|
||||||
const VERSION = '1.6.1-DEV';
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Void cache driver. The cache could be of use in tests where you don`t need to cache anything.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 1.5
|
|
||||||
* @author Kotlyar Maksim <kotlyar.maksim@gmail.com>
|
|
||||||
*/
|
|
||||||
class VoidCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WinCache cache provider.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.2
|
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
* @author Jonathan Wage <jonwage@gmail.com>
|
|
||||||
* @author Roman Borschel <roman@code-factory.org>
|
|
||||||
* @author David Abdemoulaie <dave@hobodave.com>
|
|
||||||
*/
|
|
||||||
class WinCacheCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return wincache_ucache_get($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return wincache_ucache_exists($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
return wincache_ucache_set($id, $data, $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return wincache_ucache_delete($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
return wincache_ucache_clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetchMultiple(array $keys)
|
|
||||||
{
|
|
||||||
return wincache_ucache_get($keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
|
||||||
{
|
|
||||||
$result = wincache_ucache_set($keysAndValues, null, $lifetime);
|
|
||||||
|
|
||||||
return empty($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$info = wincache_ucache_info();
|
|
||||||
$meminfo = wincache_ucache_meminfo();
|
|
||||||
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $info['total_hit_count'],
|
|
||||||
Cache::STATS_MISSES => $info['total_miss_count'],
|
|
||||||
Cache::STATS_UPTIME => $info['total_cache_uptime'],
|
|
||||||
Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Xcache cache driver.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.0
|
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
* @author Jonathan Wage <jonwage@gmail.com>
|
|
||||||
* @author Roman Borschel <roman@code-factory.org>
|
|
||||||
* @author David Abdemoulaie <dave@hobodave.com>
|
|
||||||
*/
|
|
||||||
class XcacheCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return $this->doContains($id) ? unserialize(xcache_get($id)) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return xcache_isset($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
return xcache_set($id, serialize($data), (int) $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return xcache_unset($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
$this->checkAuthorization();
|
|
||||||
|
|
||||||
xcache_clear_cache(XC_TYPE_VAR);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that xcache.admin.enable_auth is Off.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @throws \BadMethodCallException When xcache.admin.enable_auth is On.
|
|
||||||
*/
|
|
||||||
protected function checkAuthorization()
|
|
||||||
{
|
|
||||||
if (ini_get('xcache.admin.enable_auth')) {
|
|
||||||
throw new \BadMethodCallException(
|
|
||||||
'To use all features of \Doctrine\Common\Cache\XcacheCache, '
|
|
||||||
. 'you must set "xcache.admin.enable_auth" to "Off" in your php.ini.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
$this->checkAuthorization();
|
|
||||||
|
|
||||||
$info = xcache_info(XC_TYPE_VAR, 0);
|
|
||||||
return array(
|
|
||||||
Cache::STATS_HITS => $info['hits'],
|
|
||||||
Cache::STATS_MISSES => $info['misses'],
|
|
||||||
Cache::STATS_UPTIME => null,
|
|
||||||
Cache::STATS_MEMORY_USAGE => $info['size'],
|
|
||||||
Cache::STATS_MEMORY_AVAILABLE => $info['avail'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This software consists of voluntary contributions made by many individuals
|
|
||||||
* and is licensed under the MIT license. For more information, see
|
|
||||||
* <http://www.doctrine-project.org>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Doctrine\Common\Cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Zend Data Cache cache driver.
|
|
||||||
*
|
|
||||||
* @link www.doctrine-project.org
|
|
||||||
* @since 2.0
|
|
||||||
* @author Ralph Schindler <ralph.schindler@zend.com>
|
|
||||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
|
||||||
*/
|
|
||||||
class ZendDataCache extends CacheProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFetch($id)
|
|
||||||
{
|
|
||||||
return zend_shm_cache_fetch($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doContains($id)
|
|
||||||
{
|
|
||||||
return (false !== zend_shm_cache_fetch($id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doSave($id, $data, $lifeTime = 0)
|
|
||||||
{
|
|
||||||
return zend_shm_cache_store($id, $data, $lifeTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doDelete($id)
|
|
||||||
{
|
|
||||||
return zend_shm_cache_delete($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doFlush()
|
|
||||||
{
|
|
||||||
$namespace = $this->getNamespace();
|
|
||||||
if (empty($namespace)) {
|
|
||||||
return zend_shm_cache_clear();
|
|
||||||
}
|
|
||||||
return zend_shm_cache_clear($namespace);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function doGetStats()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,45 @@
|
|||||||
20200321-1830.15
|
20200828-1420.26
|
||||||
<font color=red>本次更新后,'index.html'功能在其它主题会导致bug。</font>
|
nginx rewrite rule exclude .well-known folder, as auto SSL. add web.config to rewrite in IIS. now in windwos can do with \ in path. in aliyun FC & huawei FG API, use my code. CN 21Vianet client_id&secret expire. update description now only show new.
|
||||||
文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。
|
nginx的伪静态中排除.well-known目录,方便自动SSL。添加IIS的伪静态。与linux不同,处理windows下目录用\分隔。FC、FG中使用自己代码对接平台。<font color=red>世纪互联旧API即将过期失效,升级后世纪互联的盘需要删除重新添加。</font>更新说明只显示部分。
|
||||||
<font color=red>after this update, then 'index.html' function will bug in other theme.</font>
|
|
||||||
cache text file content;add hideFunctionalityFile;list exist disktags when AddDisk。
|
|
||||||
|
|
||||||
|
20200817-1740.25
|
||||||
|
when multy disks, now will default show disks as folders in root, if set autoJumpFirstDisk 1, it will auto jump to first disk.
|
||||||
|
多盘时,在网站根目录,默认会将各盘当成文件夹显示,可以去设置中设置autoJumpFirstDisk为1,这样可以跟以前一样自动跳到第一个盘。
|
||||||
|
20200816-1145.24
|
||||||
|
add platform: Baidu CFC. add setting: mobile background.
|
||||||
|
新增百度CFC平台。可以分别设置PC与手机的背景。
|
||||||
|
20200808-1130.23
|
||||||
|
FG: select save in env or file.
|
||||||
|
在FG中安装时,选择配置保存在环境变量还是文件中。
|
||||||
|
20200806-1130.23
|
||||||
|
SCF: select save in env or file.
|
||||||
|
在SCF中安装时,选择配置保存在环境变量还是文件中。
|
||||||
|
20200804-1453.22
|
||||||
|
fix: once error will stop the after files in uploading multy files. SCF can get region now, change install. SCF config save in code file now not in env, <font color=red>if use SCF, you must reinstall after update</font>.
|
||||||
|
修复,当上传多个文件时,一个文件出错将导致后续文件不再上传。SCF可以获取到region了,安装过程修改。在SCF中,现在将配置保存到代码文件中,不受环境变量4K大小限制,<font color=red>升级后,用SCF的要重装</font>。
|
||||||
|
20200723-1430.21
|
||||||
|
fix content-type in "?json". can not custom microsoft API id & secret by a link now, so show the return uri.
|
||||||
|
当使用"?json"时,现在content-type是json了。现在微软不能一键创建API应用了,提供回调URI。
|
||||||
|
20200713-1800.20
|
||||||
|
add platform: Huawei cloud Function Graph. now you can use "?json" to get a json of folder or file. fix some bug.
|
||||||
|
新增白嫖平台:华为云函数工作流FG。可以用"?json"来获得目录或文件的json。修复bug。
|
||||||
|
20200607-1856.19
|
||||||
|
add platform: Aliyun Function Compute. add setting: replace sharepoint.com to a proxy server name. add setting: disableShowThumb,customTheme. add function: php hosting website can update by a click
|
||||||
|
现在可以安装到阿里函数计算FC了。php空间可以一键更新了。可以设置某个盘替换sharpoint.com域名为你的反代域名。新增disableShowThumb,customTheme。
|
||||||
|
20200503-1848.18
|
||||||
|
Rebuild theme. Add custom Css & custom Script, add FunctionalityFile: head.omf & foot.omf.
|
||||||
|
重建主题文件结构。增加自定义css与自定义script。增加2个功能文件:head.omf、foot.omf。
|
||||||
|
20200402-1830.17
|
||||||
|
Oneclick update can select which branch to update. Now use the accept language instead of the language config.
|
||||||
|
一键更新可以选择哪个分支了。现在开始使用浏览器语言,抛弃language设置。
|
||||||
|
20200326-0001.16
|
||||||
|
You can add sharepoint site drive as a disk, <font color=red>you must reinstall after update</font>.
|
||||||
|
可以将sharepoint网站添加成一个盘,<font color=red>由于结构改变,升级后只能重装</font>。
|
||||||
|
20200321-1830.15
|
||||||
|
本次更新后,'index.html'功能在其它主题会导致bug。
|
||||||
|
文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。
|
||||||
|
after this update, then 'index.html' function will bug in other theme.
|
||||||
|
cache text file content;add hideFunctionalityFile;list exist disktags when AddDisk。
|
||||||
20200311-2150.14
|
20200311-2150.14
|
||||||
Add a switch, can download a known file or not, while the folder is encrypted.
|
Add a switch, can download a known file or not, while the folder is encrypted.
|
||||||
Hide time and size in mobile.
|
Hide time and size in mobile.
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<system.webServer>
|
||||||
|
<rewrite>
|
||||||
|
<rules>
|
||||||
|
<rule name="OneManagerIISRewrite" patternSyntax="Wildcard" stopProcessing="true">
|
||||||
|
<match url="*" />
|
||||||
|
<action type="Rewrite" url="index.php" appendQueryString="false" logRewrittenUrl="false" />
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</rewrite>
|
||||||
|
</system.webServer>
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user