Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea278dc2b3 | ||
|
|
ca4ec6f497 | ||
|
|
671481c284 | ||
|
|
449ead425a | ||
|
|
c0852bc979 | ||
|
|
8a5d22f699 | ||
|
|
ff74c9b50c | ||
|
|
d9d34d32c9 | ||
|
|
d591812c7f | ||
|
|
599b937f99 | ||
|
|
7ea726c9c7 | ||
|
|
1295ad92ef | ||
|
|
32649ccc62 | ||
|
|
e83648a332 | ||
|
|
ec6e9d50ce | ||
|
|
58482e88c5 | ||
|
|
d377410b19 | ||
|
|
75710ec7e9 | ||
|
|
43b1046aba | ||
|
|
0f5c7587d5 | ||
|
|
d5c456bc0b | ||
|
|
7b51e773f3 | ||
|
|
82e8d5d0e7 | ||
|
|
06db4a70f6 | ||
|
|
3118222734 | ||
|
|
2850db0699 | ||
|
|
273f41d90b | ||
|
|
fab8a996e3 | ||
|
|
5543c0314e | ||
|
|
19549e0612 | ||
|
|
6f2a4c4a40 | ||
|
|
9717e32254 | ||
|
|
377a9f8aaa | ||
|
|
119ac5280d | ||
|
|
6230773e52 | ||
|
|
bc66f43bea | ||
|
|
0649f19e21 | ||
|
|
8ef5e3d4a6 | ||
|
|
4c0daaca80 | ||
|
|
ab49796661 | ||
|
|
5c29afd5fe | ||
|
|
4cecf6f5af | ||
|
|
6e66ec05d8 | ||
|
|
6949fae7eb | ||
|
|
928d028d7f | ||
|
|
55e7a840d2 | ||
|
|
dd4dde83f3 | ||
|
|
2aec731ab1 | ||
|
|
d42547bdfb | ||
|
|
07edb1aadf | ||
|
|
cee88dba69 | ||
|
|
c06b8c0992 | ||
|
|
77198ddf8b | ||
|
|
4e008e0b2f | ||
|
|
1af93af86f | ||
|
|
6f9235bc33 | ||
|
|
8c5c61508c | ||
|
|
dad086da6b | ||
|
|
86ddf9e388 | ||
|
|
e07e036fb6 | ||
|
|
ae14fd6ca8 | ||
|
|
cba994cf41 | ||
|
|
36048cd773 | ||
|
|
cb69900c32 | ||
|
|
61811b60ac | ||
|
|
fb6306c316 | ||
|
|
5d524529b4 | ||
|
|
e9ed4dc7f1 | ||
|
|
c234dd62d1 | ||
|
|
3aaa18ee59 | ||
|
|
366a477ae2 | ||
|
|
a05ba3ed44 | ||
|
|
46b9fb9296 | ||
|
|
7c23cdfba1 | ||
|
|
c610eb6a85 | ||
|
|
8254f279ef | ||
|
|
a9be0e3fbf | ||
|
|
57e6c481d3 | ||
|
|
d613780312 | ||
|
|
cce6e32b61 | ||
|
|
2b5bb6d3b5 | ||
|
|
c09453080c | ||
|
|
71675b58b7 | ||
|
|
f8e3db2e37 | ||
|
|
ba471ab650 | ||
|
|
c186cee4d3 | ||
|
|
bb9b76a427 | ||
|
|
9987651af9 | ||
|
|
38bd4e4041 | ||
|
|
558d34c9e3 | ||
|
|
79b7357b70 | ||
|
|
12ff9da6f4 | ||
|
|
0b6adc077c | ||
|
|
bdedf7a4b0 | ||
|
|
bde862ffb5 | ||
|
|
0521bc08c0 | ||
|
|
89de647c2f | ||
|
|
ee6f9c9761 | ||
|
|
fbfc683c1b | ||
|
|
2d18450872 | ||
|
|
6b08d8edf2 | ||
|
|
1251195b8f | ||
|
|
71d57052da | ||
|
|
11e87f9ea8 | ||
|
|
85cdc6b211 | ||
|
|
8e3a165d60 | ||
|
|
562cd246c4 | ||
|
|
d8c1cd619b | ||
|
|
1b8d29354d | ||
|
|
c4fcd55669 | ||
|
|
ff85f901f8 | ||
|
|
4ea8cb5bef | ||
|
|
ec9ba6c20e | ||
|
|
0617d258d5 | ||
|
|
ecb2aad3bb | ||
|
|
49e602e7e6 | ||
|
|
96ce1a91d3 | ||
|
|
fe876dd87c | ||
|
|
c36621b400 | ||
|
|
1367dd72fb | ||
|
|
34599a6e71 | ||
|
|
5e49a44ec1 | ||
|
|
01e094d95d | ||
|
|
66238a6d54 | ||
|
|
be96d3aa8b | ||
|
|
b44f15f141 | ||
|
|
15a7ea192a | ||
|
|
0535fcc709 | ||
|
|
4d83358ee1 | ||
|
|
27ec89e172 | ||
|
|
0b0f80c135 | ||
|
|
d5120aa390 | ||
|
|
1102d4234f | ||
|
|
894121d0c6 | ||
|
|
399fb38fd4 | ||
|
|
661a6f89fe | ||
|
|
0169c5bb9a | ||
|
|
3f63374740 | ||
|
|
404ee22905 | ||
|
|
4c836880a1 | ||
|
|
e8f1fd7175 | ||
|
|
372a42bc05 | ||
|
|
b8c4cc1312 | ||
|
|
4e434ede6b | ||
|
|
086ac6d3e0 | ||
|
|
26b49c7a69 | ||
|
|
10a071df64 | ||
|
|
352a078829 | ||
|
|
de5ccd74cb | ||
|
|
218e7e5230 | ||
|
|
40eca60aba | ||
|
|
67da665f11 | ||
|
|
6b5c26b897 | ||
|
|
4d48228d8a | ||
|
|
20d210945e | ||
|
|
95a62a9d81 | ||
|
|
6ed09dde72 | ||
|
|
bc38d419e0 | ||
|
|
432fdc5f46 | ||
|
|
7c09b0f33c | ||
|
|
b0f10e1434 | ||
|
|
7a4398a55b | ||
|
|
9ed1b58c8d | ||
|
|
4add1167db |
+1142
-1378
File diff suppressed because it is too large
Load Diff
+263
-47
@@ -13,11 +13,12 @@ $exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar'];
|
||||
$constStr = [
|
||||
'languages' => [
|
||||
'en-us' => 'English',
|
||||
'zh-cn' => '简体中文',
|
||||
'zh-tw' => '繁體中文',
|
||||
'zh-cn' => '简体中文',
|
||||
'ja' => '日本語',
|
||||
'ko-kr' => '한국어',
|
||||
'fa' => 'فارسی',
|
||||
'ar-sa' => 'السعودية',
|
||||
],
|
||||
'Week' => [
|
||||
'en-us' => [
|
||||
@@ -74,6 +75,15 @@ $constStr = [
|
||||
5 => 'جمعه',
|
||||
6 => 'شنبه',
|
||||
],
|
||||
'ar-sa' => [
|
||||
6 => 'بيوم الأحد',
|
||||
0 => 'الإثنين',
|
||||
1 => 'الثلاثاء',
|
||||
2 => 'الأربعاء',
|
||||
3 => 'الخميس',
|
||||
4 => 'يوم الجمعة',
|
||||
5 => 'في. يوم السبت',
|
||||
],
|
||||
],
|
||||
'EnvironmentsDescription' => [
|
||||
'en-us' => [
|
||||
@@ -83,12 +93,15 @@ $constStr = [
|
||||
'customScript' => '<script> in all pages, e.g. http turn to https',
|
||||
'customCss' => '<style> in <head>',
|
||||
'customTheme' => 'an url of html',
|
||||
'referrer' => 'only these domains can refer resourse in this site, format is a1.com|b2.com',
|
||||
'domain_path' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2',
|
||||
'diskname' => 'The disk name you want show.',
|
||||
'diskDescription' => ' Some tips of this disk, not used in code.',
|
||||
'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',
|
||||
'dontBasicAuth' => 'if 1, will not popup user/pass windows in encrypted folder, but show the page in theme.',
|
||||
'background' => 'Set an url as background photo.',
|
||||
'backgroundm' => 'Set an url as background in mobile phone.',
|
||||
'theme' => 'Select theme.',
|
||||
@@ -104,18 +117,21 @@ $constStr = [
|
||||
'zh-cn' => [
|
||||
'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
|
||||
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
|
||||
'autoJumpFirstDisk' => '用于多盘,如果设1,将会自动跳到第一个盘。',
|
||||
'autoJumpFirstDisk' => '用于多个磁盘,如果为1,则自动跳转到第一个磁盘',
|
||||
'customScript' => '<script>,在所有页都会存在,例如放一个http跳转https',
|
||||
'customCss' => '<style>,在<head>最后面',
|
||||
'customTheme' => 'html格式的主题的url',
|
||||
'referrer' => '只有这些域名能引用本站资源。格式为a1.com|b1.com',
|
||||
'domain_path' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。',
|
||||
'diskname' => '这个盘你想显示什么名称。',
|
||||
'diskDescription' => '对这个盘的一些描述,随便写,代码不引用这个。',
|
||||
'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。',
|
||||
'disableShowThumb' => '如果填 1, ‘显示缩略’按钮将被隐藏。',
|
||||
'disableChangeTheme' => '如果填 1, 主题选择切换将被隐藏',
|
||||
'disableChangeTheme' => '如果为 1,则不会显示主题选择按钮',
|
||||
'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
|
||||
'dontBasicAuth' => '如果为 1,加密目录不再弹出用户名密码窗口,只会显示主题自带的页面。',
|
||||
'background' => '设置一个url作为背景。',
|
||||
'backgroundm' => '设置一个url作为手机用的背景。',
|
||||
'backgroundm' => '设置一个url作为手机端用的背景。',
|
||||
'theme' => '选择一个主题。',
|
||||
'timezone' => '设置默认时区。',
|
||||
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
|
||||
@@ -127,12 +143,13 @@ $constStr = [
|
||||
'Onedrive_ver' => 'Onedrive版本',
|
||||
],
|
||||
'zh-tw' => [
|
||||
'admin' => '管理密碼,不添加時不顯示登入頁面且無法登入。',
|
||||
'admin' => '管理密碼,不設定密碼將不顯示登入頁面且無法登入。',
|
||||
'adminloginpage' => '如果設定,登入按鈕及頁面隱藏。管理登入的頁面不再是\'?admin\',而是\'?此設置的值\'。',
|
||||
'autoJumpFirstDisk' => '用於多盤,如果設1,將會自動跳到第一個盤。',
|
||||
'customScript' => '<script>,在所有頁都會存在,例如放一個http跳轉https',
|
||||
'customCss' => '<style>,在<head>最後面',
|
||||
'customTheme' => 'html格式的主題的url',
|
||||
'referrer' => '',
|
||||
'domain_path' => '使用多個自訂域名時,指定每個域名看到的目錄。格式為a1.com:/dirto/path1|b1.com:/path2,比private_path優先。',
|
||||
'diskname' => '這個盤你想顯示什麼名稱。',
|
||||
'disktag' => '一個標籤,用於儲存配置,多盤時會顯示在url中。',
|
||||
@@ -154,13 +171,25 @@ $constStr = [
|
||||
'ja' => [
|
||||
'admin' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。',
|
||||
'adminloginpage' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?admin \'ではなく、\'?この設定の値\'。',
|
||||
'domain_path' => '複数のカスタムドメイン名を使用する場合、各ドメイン名に表示されるディレクトリを指定します。形式はa1.com:/dirto/path1|b1.com:/path2で、private_pathよりも優先されます。',
|
||||
'diskname' => '',
|
||||
'disktag' => '',
|
||||
'downloadencrypt' => '',
|
||||
'background' => '',
|
||||
'autoJumpFirstDisk' => '複数のディスクを使って、1を設定すると、自動的に最初のディスクにジャンプします。',
|
||||
'customScript' => '<script>は、すべてのページに存在します。例えば、httpを置いてhttpsをジャンプします。',
|
||||
'customCss' => '<style>は、<head>の一番後ろにあります。',
|
||||
'customTheme' => 'htmlフォーマットのテーマのurl',
|
||||
'referrer' => '',
|
||||
'domain_path' => '複数のドメイン名を使用する場合、ドメイン名ごとに見られるディレクトリを指定します。フォーマットはa 1.com:/dirto/path 1.com:/path 2で、prvate_path優先。',
|
||||
'diskname' => 'このディスクの名前を表示したいですか?',
|
||||
'disktag' => '一つのラベルは保存配置に使い、複数のディスクはurlに表示されます。',
|
||||
'disableShowThumb' => '1を記入すると、「表示サムネイル」ボタンが隠れます。',
|
||||
'disableChangeTheme' => '1を記入すると、テーマ選択の切り替えが隠れます。',
|
||||
'downloadencrypt' => '0または1です。もし1なら、暗号化されたディレクトリ内のファイルはパスワードなしでダウンロードできます。',
|
||||
'background' => '背景にurlを設定します。',
|
||||
'backgroundm' => '携帯電話用の背景としてurlを設定します。',
|
||||
'theme' => 'テーマを選択します。',
|
||||
'timezone' => 'プリセットタイムゾーンを設定します。',
|
||||
'guestup_path' => 'マップベッドのパスを設定します。この値が設定されていない場合、ディレクトリの内容は通常ファイルにリストされ、設定後はアップロードインターフェイスのみが表示されます。',
|
||||
'hideFunctionalityFile' => '0または1です。もし1ならば、いくつかの書類はリストで観光客に見せませんが、その機能は正常です。readme.md',
|
||||
'passfile' => 'カスタムパスワードファイルの名前は、\'pppppp \'、\'aaaa.txt \'などの場合があります。ディレクトリをリストするときには表示されません。パスワードを知っている場合にのみ、このファイルを表示またはダウンロードできます。 パスワードはこのファイルの内容であり、スペースまたは漢字を使用できます。',
|
||||
'domainforproxy' => '会将https://xxxy-my.sharepoint.comこの値に代えて、目標には自分で反世代を設定する必要があります。に加えて&Originndomain=元のドメイン名',
|
||||
'public_path' => 'APIのロングリンクアクセスを使用する場合、ネットワークディスクファイルのパスが表示されますが、設定されていない場合はデフォルトでルートディレクトリになり、private_pathの上位にはなりません(publicはprivate以上のものを見ることができません。それ以外は異なります。)。',
|
||||
'sitename' => 'ウェブサイト名',
|
||||
'Onedrive_ver' => 'Onedriveバージョン',
|
||||
@@ -168,13 +197,25 @@ $constStr = [
|
||||
'ko-kr' => [
|
||||
'admin' => '비밀번호를 관리하고 로그인 페이지를 표시하지 않으며 추가하지 않으면 로그인 할 수 없습니다.',
|
||||
'adminloginpage' => '설정하면 로그인 버튼과 페이지가 숨겨집니다. 로그인 관리 페이지는 더 이상 \ ?Admin\'이 아니라 \ ?이 설정의 값 \'입니다.',
|
||||
'domain_path' => '여러 개의 사용자 정의 도메인 이름을 사용하는 경우 각 도메인 이름에 표시되는 디렉토리를 지정하십시오. 형식은 a1.com:/dirto/path1|b1.com:/path2이며 private_path보다 우선합니다.',
|
||||
'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?',
|
||||
'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.',
|
||||
'downloadencrypt' => '',
|
||||
'background' => 'URL을 배경으로 설정하거나 표시하는.',
|
||||
'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).',
|
||||
'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.',
|
||||
'autoJumpFirstDisk' => '여러 개의 디스크 에 사용 되 며, 1 이 되면 첫 번 째 디스크 로 자동 으로 이동 합 니 다.',
|
||||
'customScript' => '< script > 은 모든 페이지 에 존재 합 니 다. 예 를 들 어 http 을 하나 넣 고 https 로 이동 합 니 다.',
|
||||
'customCss' => '< 스타일 >, < 헤드 > 맨 뒤에',
|
||||
'customTheme' => 'html 형식의 테마 url',
|
||||
'referrer' => '',
|
||||
'domain_path' => '도 메 인 이름 을 여러 개 사용자 정의 할 때 도 메 인 이름 마다 보 이 는 디 렉 터 리 를 지정 합 니 다.형식 은 a1. com: / dirto / path 1 | b1. com: / path 2, privatepath 우선.',
|
||||
'diskname' => '이 접시 에 당신 은 어떤 명칭 을 표시 하고 싶 습 니까?',
|
||||
'disktag' => '디스크가 여러 개인 경우 구성을 저장하는 데 사용되는 레이블이 url에 표시됩니다.',
|
||||
'disableShowThumb' => '1을 입력하면 “썸네일 표시”버튼이 숨겨집니다.',
|
||||
'disableChangeTheme' => '1이면 테마 선택 버튼이 표시되지 않습니다.',
|
||||
'downloadencrypt' => '0 또는 1 1이면 암호화 된 디렉토리의 파일을 암호없이 다운로드 할 수 있습니다.',
|
||||
'background' => 'URL을 배경으로 설정하십시오.',
|
||||
'backgroundm' => 'URL을 휴대폰의 배경으로 설정합니다.',
|
||||
'theme' => '주제를 선택하십시오.',
|
||||
'timezone' => '기본 시간대를 설정합니다.',
|
||||
'guestup_path' => '게스트 업로드 경로 (사진 침대 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 나열됩니다. 설정 후 업로드 인터페이스 만 표시되지 않습니다 (로그인 후 표시됨).',
|
||||
'hideFunctionalityFile' => '0 또는 1 1 인 경우 일부 파일이 관광객 용으로 나열되지 않지만 readme.md와 같은 기능은 정상입니다.',
|
||||
'passfile' => '사용자 지정 암호 파일의 이름은 \ “pppppp \”또는 \ “aaaa.txt \”등이 될 수 있습니다. 디렉터리가 나열 될 때 표시되지 않으며 암호를 알고있는 경우에만 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 중국어 일 수 있습니다.',
|
||||
'domainforproxy' => 'https://xxxxx-my.sharepoint.com을이 값으로 바꾸고 대상에서 안티 생성을 설정해야합니다. & Origindomain = Original domain name 을 추가합니다.',
|
||||
'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.',
|
||||
'sitename' => '웹 사이트 이름',
|
||||
'Onedrive_ver' => 'Onedrive 버전',
|
||||
@@ -182,6 +223,7 @@ $constStr = [
|
||||
'fa' => [
|
||||
'admin' => 'رمز عبور ادمین، در صورت خالی بودن دکمه لاگین به نمایش در نمیآید',
|
||||
'adminloginpage' => 'در صورت تنظیم ، دکمه ورود نمایش داده نمی شود و صفحه ورود دیگر \?admin\ نیست بلکه \?{مقدار ورودی شما}\ است.',
|
||||
'referrer' => '',
|
||||
'domain_path' => 'تنظیم دامنه سفارشی، به صورت a1.com:/dirto/path1|b2.com:/path2',
|
||||
'diskname' => 'نام دیسک که میخواهید نشان دهید.',
|
||||
'disktag' => 'تگی که در ذخیره پیکربندی و نشانی اینترنتی استفاده میشود.',
|
||||
@@ -193,6 +235,32 @@ $constStr = [
|
||||
'sitename' => 'نام سایت',
|
||||
'Onedrive_ver' => 'ورژن Onedrive',
|
||||
],
|
||||
'ar-sa' => [
|
||||
'admin' => ' إدارة كلمة السر ، لا يمكنك عرض صفحة تسجيل الدخول دون إضافة',
|
||||
'adminloginpage' => 'إذا كان الإعداد ، زر تسجيل الدخول و الصفحة المخفية إدارة صفحة تسجيل الدخول لم تعد قيمة هذا الإعداد ؟',
|
||||
'autoJumpFirstDisk' => 'على أقراص متعددة ، إذا كان واحد ، ثم الانتقال تلقائيا إلى القرص الأول',
|
||||
'customScript' => 'في جميع الصفحات ، على سبيل المثال ، وضع النص المتشعب القفز HTTPS',
|
||||
'customCss' => '<style>,في الجزء الخلفي من',
|
||||
'customTheme' => 'أتش تي أم أل شكل عنوان الموضوع',
|
||||
'referrer' => '',
|
||||
'domain_path' => 'عند استخدام العديد من أسماء النطاقات المخصصة ، حدد الدليل الذي يرى كل اسم النطاق هذا هو القانون ؛ بات اولا',
|
||||
'diskname' => 'ما اسم هذا القرص الذي تريد أن تظهر ؟',
|
||||
'disktag' => 'العلامة التي تستخدم لحفظ التكوين ، يتم عرضها في عناوين المواقع عند تعدد الأقراص',
|
||||
'disableShowThumb' => 'إذا كنت ملء ، زر عرض الاختصارات سوف تكون مخفية',
|
||||
'disableChangeTheme' => 'إذا كان واحد ، لا يتم عرض زر اختيار الموضوع',
|
||||
'downloadencrypt' => 'أو واحد إذا كان واحد ، ثم تشفير الملفات في الدليل يمكن تحميلها بدون كلمة السر',
|
||||
'background' => 'وضع رابط كخلفية',
|
||||
'backgroundm' => 'وضع رابط كخلفية على الهاتف',
|
||||
'theme' => 'اختر موضوع واحد',
|
||||
'timezone' => 'تعيين المنطقة الزمنية الافتراضية',
|
||||
'guestup_path' => 'إذا كنت لا تضع هذه القيمة ، محتويات الدليل سوف تظهر بشكل صحيح ، فقط واجهة تحميل بعد الإعداد ، لا تظهر الملفات بعد تسجيل الدخول.',
|
||||
'hideFunctionalityFile' => 'أو واحد إذا كان واحد ، بعض الملفات لا تظهر في قائمة الزوار ، ولكن وظيفتها هي طبيعية ، مثل قراءة',
|
||||
'passfile' => 'يمكنك تحديد اسم ملف كلمة السر الخاصة بك ؟ النص انتظر ، لا تظهر في الكتالوج إلا إذا كنت تعرف كلمة السر ، يمكنك عرض أو تحميل هذا الملف كلمة السر هي محتوى هذه الوثيقة ، يمكنك الفضاء ، يمكنك الصينية ؛',
|
||||
'domainforproxy' => 'سوف لا شيء استبدال هذه القيمة ، تحتاج إلى تعيين جيل معاكس في الهدف الخاص بك إضافة اسم النطاق الأصلي',
|
||||
'public_path' => 'عند استخدام API وصلة طويلة للوصول إلى عرض مسار الملف على القرص ، إذا لم يتم تعيين الافتراضي هو الجذر ، لا يمكن أن يكون private ش لا يمكن أن نرى أكثر من private publics ، أو لا',
|
||||
'sitename' => 'اسم الموقع',
|
||||
'Onedrive_ver' => 'أوندريف',
|
||||
],
|
||||
],
|
||||
'SetSecretsFirst' => [
|
||||
'en-us' => 'Set API in Config first! or reinstall.',
|
||||
@@ -201,6 +269,7 @@ $constStr = [
|
||||
'ja' => '最初に環境変数にAPIを設定してください!',
|
||||
'ko-kr' => '먼저 환경 변수에서 API를 설정하십시오! 또는 다시 설치하십시오.',
|
||||
'fa' => 'ابتدا API را در پیکربندی تنظیم کنید! یا دوباره نصب کنید.',
|
||||
'ar-sa' => 'وضع المعهد في بيئة متغيرة أو أعد التحميل',
|
||||
],
|
||||
'RefreshtoLogin' => [
|
||||
'en-us' => '<font color="red">Refresh</font> and login.',
|
||||
@@ -209,6 +278,7 @@ $constStr = [
|
||||
'ja' => 'ページを<font color = "red">更新</font>して、再度ログインしてください',
|
||||
'ko-kr' => '페이지를 <font color = "red"> 새로 고침 </ font> 하시고 다시 로그인하십시오',
|
||||
'fa' => '<font color="red">رفرش</font> و لاگین.',
|
||||
'ar-sa' => 'الرجاء إعادة تسجيل الدخول بعد تحديث الصفحة',
|
||||
],
|
||||
'AdminLogin' => [
|
||||
'en-us' => 'Admin Login',
|
||||
@@ -217,6 +287,7 @@ $constStr = [
|
||||
'ja' => 'ログインを管理する',
|
||||
'ko-kr' => '로그인 관리',
|
||||
'fa' => 'ورود ادمین',
|
||||
'ar-sa' => 'إدارة تسجيل الدخول',
|
||||
],
|
||||
'LoginSuccess' => [
|
||||
'en-us' => 'Login Success!',
|
||||
@@ -225,6 +296,7 @@ $constStr = [
|
||||
'ja' => 'ログイン成功、ジャンプ',
|
||||
'ko-kr' => '로그인 성공, 점프',
|
||||
'fa' => 'ورود با موفقیت انجام شد!',
|
||||
'ar-sa' => 'تسجيل الدخول بنجاح ، القفز',
|
||||
],
|
||||
'InputPassword' => [
|
||||
'en-us' => 'Input Password',
|
||||
@@ -233,6 +305,7 @@ $constStr = [
|
||||
'ja' => 'パスワードを入力してください',
|
||||
'ko-kr' => '비밀번호 입력',
|
||||
'fa' => 'رمز عبور را وارد کنید',
|
||||
'ar-sa' => 'أدخل كلمة المرور',
|
||||
],
|
||||
'Login' => [
|
||||
'en-us' => 'Login',
|
||||
@@ -241,6 +314,7 @@ $constStr = [
|
||||
'ja' => 'サインイン',
|
||||
'ko-kr' => '로그인',
|
||||
'fa' => 'ورود',
|
||||
'ar-sa' => 'تسجيل الدخول',
|
||||
],
|
||||
'Encrypt' => [
|
||||
'en-us' => 'Encrypt',
|
||||
@@ -249,14 +323,16 @@ $constStr = [
|
||||
'ja' => '暗号化',
|
||||
'ko-kr' => '암호화',
|
||||
'fa' => 'رمزگذاری',
|
||||
'ar-sa' => 'مشفر',
|
||||
],
|
||||
'SetpassfileBfEncrypt' => [
|
||||
'en-us' => 'Set \'passfile\' in Environments before encrypt',
|
||||
'zh-cn' => '先在环境变量设置passfile才能加密',
|
||||
'zh-tw' => '先在環境變數設定passfile才能加密',
|
||||
'ja' => '最初に暗号化する環境変数にパスファイルを設定します',
|
||||
'zh-cn' => '先设置passfile才能加密',
|
||||
'zh-tw' => '先設定passfile才能加密',
|
||||
'ja' => '最初に暗号化する変数にパスファイルを設定します',
|
||||
'ko-kr' => '암호화하기 전에 환경 변수에 패스 파일을 설정하십시오',
|
||||
'fa' => 'قبل از رمزگذاری \"pass file \" را در محیط تنظیم کنید',
|
||||
'fa' => 'قبل از رمزگذاری \"passfile \" را در محیط تنظیم کنید',
|
||||
'ar-sa' => 'أولا تعيين متغير البيئة passfile لتشفير',
|
||||
],
|
||||
'updateProgram' => [
|
||||
'en-us' => 'Update Program',
|
||||
@@ -265,6 +341,7 @@ $constStr = [
|
||||
'ja' => 'ワンクリック更新',
|
||||
'ko-kr' => '원 클릭 업데이트',
|
||||
'fa' => 'برنامه را به روز کنید',
|
||||
'ar-sa' => 'تحديث',
|
||||
],
|
||||
'UpdateSuccess' => [
|
||||
'en-us' => 'Program update Success!',
|
||||
@@ -273,6 +350,7 @@ $constStr = [
|
||||
'ja' => 'プログラムのアップグレードに成功しました!',
|
||||
'ko-kr' => '프로그램 업그레이드 성공!',
|
||||
'fa' => 'موفقیت به روز رسانی برنامه!',
|
||||
'ar-sa' => 'ترقية البرنامج بنجاح',
|
||||
],
|
||||
'Setup' => [
|
||||
'en-us' => 'Setup',
|
||||
@@ -281,6 +359,7 @@ $constStr = [
|
||||
'ja' => '設定する',
|
||||
'ko-kr' => '설정',
|
||||
'fa' => 'نصب',
|
||||
'ar-sa' => 'إعداد',
|
||||
],
|
||||
'Back' => [
|
||||
'en-us' => 'Back',
|
||||
@@ -289,11 +368,16 @@ $constStr = [
|
||||
'ja' => 'back',
|
||||
'ko-kr' => '돌아 가기',
|
||||
'fa' => 'بازگشت',
|
||||
'ar-sa' => 'رجع',
|
||||
],
|
||||
'Theme' => [
|
||||
'en-us' => 'Theme',
|
||||
'zh-cn' => '主题',
|
||||
'zh-tw' => '主題',
|
||||
'ja' => 'テーマ',
|
||||
'ko-kr' => '주제.',
|
||||
'fa' => 'عنوان',
|
||||
'ar-sa' => 'الثيمات',
|
||||
],
|
||||
'NotNeedUpdate' => [
|
||||
'en-us' => 'Not Need Update',
|
||||
@@ -302,6 +386,7 @@ $constStr = [
|
||||
'ja' => '更新不要',
|
||||
'ko-kr' => '업데이트가 필요하지 않습니다',
|
||||
'fa' => 'آپدیت لازم نیست',
|
||||
'ar-sa' => 'لا تحتاج إلى تحديث',
|
||||
],
|
||||
'PlatformConfig' => [
|
||||
'en-us' => 'Platform Config',
|
||||
@@ -310,6 +395,17 @@ $constStr = [
|
||||
'ja' => 'プラットフォーム変数',
|
||||
'ko-kr' => '플랫폼 변수',
|
||||
'fa' => 'پیکربندی پلتفرم',
|
||||
'ar-sa' => 'منصة متغير',
|
||||
],
|
||||
'DragSort' => [
|
||||
'en-us' => 'Drag to Sort Disk',
|
||||
'zh-cn' => '拖拽改变顺序',
|
||||
'zh-tw' => '拖曳改變順序',
|
||||
],
|
||||
'SubmitSortdisks' => [
|
||||
'en-us' => 'Submit Sort',
|
||||
'zh-cn' => '确认排序',
|
||||
'zh-tw' => '確認排序',
|
||||
],
|
||||
'DelDisk' => [
|
||||
'en-us' => 'Del This Disk',
|
||||
@@ -318,14 +414,30 @@ $constStr = [
|
||||
'ja' => 'このディスクを削除',
|
||||
'ko-kr' => '이 디스크를 삭제',
|
||||
'fa' => 'پاک کردن این دیسک',
|
||||
'ar-sa' => 'حذف هذا القرص',
|
||||
],
|
||||
'CopyDisk' => [
|
||||
'en-us' => 'Copy this Disk',
|
||||
'zh-cn' => '复制此盘',
|
||||
],
|
||||
'RenameDisk' => [
|
||||
'en-us' => 'Rename Disk Tag',
|
||||
'zh-cn' => '改变标签',
|
||||
'zh-tw' => '修改標籤',
|
||||
'ar-sa' => 'تغيير التسمية',
|
||||
],
|
||||
'ChangeDrivetype' => [
|
||||
'en-us' => 'Change',
|
||||
'zh-cn' => '切换',
|
||||
],
|
||||
'AddDisk' => [
|
||||
'en-us' => 'Add Onedrive Disk',
|
||||
'zh-cn' => '添加Onedrive盘',
|
||||
'zh-tw' => '添加Onedrive盤',
|
||||
'ja' => 'Onedriveを追加',
|
||||
'ko-kr' => 'Onedrive 추가',
|
||||
'fa' => 'اضافه کردن دیسک Onedrive',
|
||||
'en-us' => 'Add Disk',
|
||||
'zh-cn' => '添加盘',
|
||||
'zh-tw' => '新增盤',
|
||||
'ja' => 'を追加',
|
||||
'ko-kr' => '추가',
|
||||
'fa' => 'اضافه کردن دیسک ',
|
||||
'ar-sa' => 'إضافة قرص',
|
||||
],
|
||||
'Home' => [
|
||||
'en-us' => 'Home',
|
||||
@@ -334,16 +446,25 @@ $constStr = [
|
||||
'ja' => 'ホーム',
|
||||
'ko-kr' => '홈',
|
||||
'fa' => 'خانه',
|
||||
'ar-sa' => 'فرونت بيج',
|
||||
],
|
||||
'Preview' => [
|
||||
'en-us' => 'Preview',
|
||||
'zh-cn' => '预览',
|
||||
'zh-tw' => '預覽',
|
||||
'ja' => 'プレビュー',
|
||||
'ko-kr' => '미리보기',
|
||||
'fa' => 'پیشنمایش',
|
||||
'ar-sa' => 'معاينة',
|
||||
],
|
||||
'List' => [
|
||||
'en-us' => 'List',
|
||||
'zh-cn' => '列表',
|
||||
'zh-tw' => '列表',
|
||||
'ja' => 'リスト',
|
||||
'ko-kr' => '리스트',
|
||||
'fa' => 'فهرست',
|
||||
'ar-sa' => 'الليست',
|
||||
],
|
||||
'NeedUpdate' => [
|
||||
'en-us' => 'Program can update<br>Click setup in Operate at top.',
|
||||
@@ -352,6 +473,7 @@ $constStr = [
|
||||
'ja' => 'プログラムをアップグレードできます<br>上記の管理メニューで<br>アップグレードする設定ページに入ります',
|
||||
'ko-kr' => '프로그램을 업그레이드 할 수 있습니다. <br> 위의 관리 메뉴에서 <br> 업그레이드 할 설정 페이지를 입력하십시오.',
|
||||
'fa' => 'برنامه می تواند آپدیت شود<br>روی گزینه نصب در بالای صفحه کلیک کنید.',
|
||||
'ar-sa' => 'يمكن ترقية البرنامج في القائمة أعلاه إدارة',
|
||||
],
|
||||
'Operate' => [
|
||||
'en-us' => 'Operate',
|
||||
@@ -360,14 +482,16 @@ $constStr = [
|
||||
'ja' => '管理',
|
||||
'ko-kr' => '관리',
|
||||
'fa' => 'مدیریت',
|
||||
'ar-sa' => 'الإدارة',
|
||||
],
|
||||
'Logout' => [
|
||||
'en-us' => 'Logout',
|
||||
'zh-cn' => '登出',
|
||||
'zh-cn' => '退出',
|
||||
'zh-tw' => '登出',
|
||||
'ja' => 'ログアウトする',
|
||||
'ko-kr' => '로그 아웃',
|
||||
'fa' => 'خروج',
|
||||
'ar-sa' => 'انسحب',
|
||||
],
|
||||
'Create' => [
|
||||
'en-us' => 'Create',
|
||||
@@ -376,6 +500,7 @@ $constStr = [
|
||||
'ja' => '新しい',
|
||||
'ko-kr' => '새로운',
|
||||
'fa' => 'ایجاد کردن',
|
||||
'ar-sa' => 'بنيت حديثا',
|
||||
],
|
||||
'Download' => [
|
||||
'en-us' => 'download',
|
||||
@@ -384,6 +509,7 @@ $constStr = [
|
||||
'ja' => 'ダウンロードする',
|
||||
'ko-kr' => '다운로드',
|
||||
'fa' => 'دانلود',
|
||||
'ar-sa' => 'داون لود',
|
||||
],
|
||||
'ClicktoEdit' => [
|
||||
'en-us' => 'Click to edit',
|
||||
@@ -392,6 +518,7 @@ $constStr = [
|
||||
'ja' => 'クリック後に編集',
|
||||
'ko-kr' => '클릭 후 편집',
|
||||
'fa' => 'برای ویرایش کلیک کنید',
|
||||
'ar-sa' => 'انقر فوق تحرير',
|
||||
],
|
||||
'Save' => [
|
||||
'en-us' => 'Save',
|
||||
@@ -400,6 +527,7 @@ $constStr = [
|
||||
'ja' => '保存する',
|
||||
'ko-kr' => '저장',
|
||||
'fa' => 'ذخیره',
|
||||
'ar-sa' => 'حفظ',
|
||||
],
|
||||
'FileNotSupport' => [
|
||||
'en-us' => 'File not support preview.',
|
||||
@@ -408,6 +536,7 @@ $constStr = [
|
||||
'ja' => 'ファイル形式はプレビューをサポートしていません',
|
||||
'ko-kr' => '파일 형식은 미리보기를 지원하지 않습니다',
|
||||
'fa' => 'پیش نمایش برای این فایل پشتیبانی نمی شود.',
|
||||
'ar-sa' => 'معاينة الملف غير معتمد',
|
||||
],
|
||||
'File' => [
|
||||
'en-us' => 'File',
|
||||
@@ -416,6 +545,7 @@ $constStr = [
|
||||
'ja' => 'ファイル',
|
||||
'ko-kr' => '파일',
|
||||
'fa' => 'فایل',
|
||||
'ar-sa' => 'فايل',
|
||||
],
|
||||
'ShowThumbnails' => [
|
||||
'en-us' => 'Thumbnails',
|
||||
@@ -424,11 +554,16 @@ $constStr = [
|
||||
'ja' => '画像のサムネイル',
|
||||
'ko-kr' => '사진 섬네일',
|
||||
'fa' => 'تصویر بندانگشتی',
|
||||
'ar-sa' => 'تجاهل الصورة',
|
||||
],
|
||||
'OriginalPic' => [
|
||||
'en-us' => 'OriginalPic',
|
||||
'zh-cn' => '原图',
|
||||
'zh-tw' => '原圖',
|
||||
'ja' => '原図',
|
||||
'ko-kr' => '원 도',
|
||||
'fa' => 'تصویر اصلی',
|
||||
'ar-sa' => 'الصورة الأصلية',
|
||||
],
|
||||
'CopyAllDownloadUrl' => [
|
||||
'en-us' => 'CopyAllDownloadUrl',
|
||||
@@ -437,11 +572,16 @@ $constStr = [
|
||||
'ja' => 'すべてのダウンロードリンクをコピー',
|
||||
'ko-kr' => '모든 다운로드 링크 복사',
|
||||
'fa' => 'کپی از تمام لینک ها',
|
||||
'ar-sa' => 'نسخ جميع روابط التحميل',
|
||||
],
|
||||
'Search' => [
|
||||
'en-us' => 'Search',
|
||||
'zh-cn' => '搜索',
|
||||
'zh-tw' => '搜尋',
|
||||
'ja' => '検索',
|
||||
'ko-kr' => '수색 하 다.',
|
||||
'fa' => 'جستجو',
|
||||
'ar-sa' => 'بحث',
|
||||
],
|
||||
'EditTime' => [
|
||||
'en-us' => 'EditTime',
|
||||
@@ -450,6 +590,7 @@ $constStr = [
|
||||
'ja' => '変更時間',
|
||||
'ko-kr' => '수정 시간',
|
||||
'fa' => 'زمان ویرایش',
|
||||
'ar-sa' => 'تعديل الوقت',
|
||||
],
|
||||
'Size' => [
|
||||
'en-us' => 'Size',
|
||||
@@ -458,6 +599,7 @@ $constStr = [
|
||||
'ja' => 'サイズ ',
|
||||
'ko-kr' => '사이즈',
|
||||
'fa' => 'سایز',
|
||||
'ar-sa' => 'مقاس',
|
||||
],
|
||||
'Rename' => [
|
||||
'en-us' => 'Rename',
|
||||
@@ -466,6 +608,7 @@ $constStr = [
|
||||
'ja' => '名前を変更',
|
||||
'ko-kr' => '이름 바꾸기',
|
||||
'fa' => 'تغییر نام',
|
||||
'ar-sa' => 'إعادة تسمية',
|
||||
],
|
||||
'Move' => [
|
||||
'en-us' => 'Move',
|
||||
@@ -474,6 +617,7 @@ $constStr = [
|
||||
'ja' => '移動する',
|
||||
'ko-kr' => '이동',
|
||||
'fa' => 'انتقال',
|
||||
'ar-sa' => 'تحرك',
|
||||
],
|
||||
'Copy' => [
|
||||
'en-us' => 'Copy',
|
||||
@@ -482,6 +626,7 @@ $constStr = [
|
||||
'ja' => 'コピー',
|
||||
'ko-kr' => '복사',
|
||||
'fa' => 'کپی',
|
||||
'ar-sa' => 'نسخ',
|
||||
],
|
||||
'CannotMove' => [
|
||||
'en-us' => 'Can not Move!',
|
||||
@@ -490,6 +635,7 @@ $constStr = [
|
||||
'ja' => '動かない!',
|
||||
'ko-kr' => '움직일 수 없어!',
|
||||
'fa' => 'نمیتواند منتقل شود!',
|
||||
'ar-sa' => 'لا تتحرك',
|
||||
],
|
||||
'Delete' => [
|
||||
'en-us' => 'Delete',
|
||||
@@ -498,6 +644,7 @@ $constStr = [
|
||||
'ja' => '削除する',
|
||||
'ko-kr' => '삭제',
|
||||
'fa' => 'حذف کردن',
|
||||
'ar-sa' => 'حذف',
|
||||
],
|
||||
'PrePage' => [
|
||||
'en-us' => 'PrePage',
|
||||
@@ -506,6 +653,7 @@ $constStr = [
|
||||
'ja' => '前へ',
|
||||
'ko-kr' => '이전',
|
||||
'fa' => 'صفحه قبل',
|
||||
'ar-sa' => 'الصفحة السابقة',
|
||||
],
|
||||
'NextPage' => [
|
||||
'en-us' => 'NextPage',
|
||||
@@ -514,6 +662,7 @@ $constStr = [
|
||||
'ja' => '次のページ',
|
||||
'ko-kr' => '다음 페이지',
|
||||
'fa' => 'صفحه بعد',
|
||||
'ar-sa' => 'الصفحة التالية',
|
||||
],
|
||||
'Upload' => [
|
||||
'en-us' => 'Upload',
|
||||
@@ -522,16 +671,25 @@ $constStr = [
|
||||
'ja' => 'アップロードする',
|
||||
'ko-kr' => '업로드',
|
||||
'fa' => 'آپلود',
|
||||
'ar-sa' => 'ابلود',
|
||||
],
|
||||
'UploadFile' => [
|
||||
'en-us' => 'Upload File(s)',
|
||||
'zh-cn' => '上传文件',
|
||||
'zh-tw' => '上傳文件',
|
||||
'ja' => 'ファイルをアップロード',
|
||||
'ko-kr' => '문건 을 업로드 하 다',
|
||||
'fa' => 'بارگذاری پرونده',
|
||||
'ar-sa' => 'تحميل الملف',
|
||||
],
|
||||
'UploadFolder' => [
|
||||
'en-us' => 'Upload Folder',
|
||||
'zh-cn' => '上传文件夹',
|
||||
'zh-tw' => '上傳資料夾',
|
||||
'ja' => 'フォルダをアップロード',
|
||||
'ko-kr' => '폴 더 업로드',
|
||||
'fa' => 'بارگذاری پوشه',
|
||||
'ar-sa' => 'تحميل ملف',
|
||||
],
|
||||
'FileSelected' => [
|
||||
'en-us' => 'Select File',
|
||||
@@ -540,6 +698,7 @@ $constStr = [
|
||||
'ja' => 'ファイルを選択',
|
||||
'ko-kr' => '파일 선택',
|
||||
'fa' => 'انتخاب فایل',
|
||||
'ar-sa' => 'اختر ملف',
|
||||
],
|
||||
'NoFileSelected' => [
|
||||
'en-us' => 'Not Select File',
|
||||
@@ -548,6 +707,7 @@ $constStr = [
|
||||
'ja' => 'ファイルが選択されていません',
|
||||
'ko-kr' => '선택된 파일이 없습니다',
|
||||
'fa' => 'فایل را انتخاب نکنید',
|
||||
'ar-sa' => 'لا يوجد ملف محدد',
|
||||
],
|
||||
'Submit' => [
|
||||
'en-us' => 'Submit',
|
||||
@@ -556,6 +716,7 @@ $constStr = [
|
||||
'ja' => '確認する',
|
||||
'ko-kr' => '확인',
|
||||
'fa' => 'ارسال',
|
||||
'ar-sa' => 'أكد',
|
||||
],
|
||||
'Close' => [
|
||||
'en-us' => 'Close',
|
||||
@@ -564,6 +725,7 @@ $constStr = [
|
||||
'ja' => '閉じる',
|
||||
'ko-kr' => '닫기',
|
||||
'fa' => 'بستن',
|
||||
'ar-sa' => 'مغلق',
|
||||
],
|
||||
'InputPasswordUWant' => [
|
||||
'en-us' => 'Input Password you Want',
|
||||
@@ -572,6 +734,7 @@ $constStr = [
|
||||
'ja' => '設定するパスワードを入力してください',
|
||||
'ko-kr' => '설정하려는 비밀번호를 입력하십시오',
|
||||
'fa' => 'پسورد خود را وارد کنید',
|
||||
'ar-sa' => 'أدخل كلمة السر التي تريد تعيين',
|
||||
],
|
||||
'ParentDir' => [
|
||||
'en-us' => 'Parent Dir',
|
||||
@@ -580,6 +743,7 @@ $constStr = [
|
||||
'ja' => '親ディレクトリ',
|
||||
'ko-kr' => '부모 디렉토리',
|
||||
'fa' => 'مسیر',
|
||||
'ar-sa' => 'الدليل السابق',
|
||||
],
|
||||
'Folder' => [
|
||||
'en-us' => 'Folder',
|
||||
@@ -588,6 +752,7 @@ $constStr = [
|
||||
'ja' => 'フォルダー',
|
||||
'ko-kr' => '폴더',
|
||||
'fa' => 'پوشه',
|
||||
'ar-sa' => 'فولدر',
|
||||
],
|
||||
'Name' => [
|
||||
'en-us' => 'Name',
|
||||
@@ -596,6 +761,7 @@ $constStr = [
|
||||
'ja' => '名前',
|
||||
'ko-kr' => '이름',
|
||||
'fa' => 'نام',
|
||||
'ar-sa' => 'إسم',
|
||||
],
|
||||
'Content' => [
|
||||
'en-us' => 'Content',
|
||||
@@ -604,6 +770,7 @@ $constStr = [
|
||||
'ja' => '内容',
|
||||
'ko-kr' => '내용',
|
||||
'fa' => 'محتوا',
|
||||
'ar-sa' => 'المحتويات',
|
||||
],
|
||||
'CancelEdit' => [
|
||||
'en-us' => 'Cancel Edit',
|
||||
@@ -612,6 +779,7 @@ $constStr = [
|
||||
'ja' => '編集をキャンセル',
|
||||
'ko-kr' => '편집 취소',
|
||||
'fa' => 'لغو ویرایش',
|
||||
'ar-sa' => 'إلغاء تحرير',
|
||||
],
|
||||
'GetFileNameFail' => [
|
||||
'en-us' => 'Fail to Get File Name!',
|
||||
@@ -620,6 +788,7 @@ $constStr = [
|
||||
'ja' => 'ファイル名を取得できませんでした!',
|
||||
'ko-kr' => '파일 이름을 가져 오지 못했습니다!',
|
||||
'fa' => 'نام فایل به دست نیامد!',
|
||||
'ar-sa' => 'فشل الحصول على اسم الملف',
|
||||
],
|
||||
'GetUploadLink' => [
|
||||
'en-us' => 'Get Upload Link',
|
||||
@@ -628,11 +797,16 @@ $constStr = [
|
||||
'ja' => 'アップロードリンクを取得',
|
||||
'ko-kr' => '업로드 링크 받기',
|
||||
'fa' => 'دریافت لینک آپلود',
|
||||
'ar-sa' => 'الحصول على رابط التحميل',
|
||||
],
|
||||
'Calculate' => [
|
||||
'en-us' => 'Calculate',
|
||||
'zh-cn' => '计算',
|
||||
'zh-tw' => '計算',
|
||||
'ja' => '計算する',
|
||||
'ko-kr' => '계산 하 다.',
|
||||
'fa' => 'محاسبه',
|
||||
'ar-sa' => 'محسوب',
|
||||
],
|
||||
'UpFileTooLarge' => [
|
||||
'en-us' => 'The File is too Large!',
|
||||
@@ -641,6 +815,7 @@ $constStr = [
|
||||
'ja' => '超えると、アップロードは終了します。',
|
||||
'ko-kr' => '파일이 너무 커서 업로드가 종료되었습니다.',
|
||||
'fa' => 'فایل خیلی بزرگ است!',
|
||||
'ar-sa' => 'الملف كبير جدا ، إنهاء التحميل',
|
||||
],
|
||||
'UploadStart' => [
|
||||
'en-us' => 'Upload Start',
|
||||
@@ -649,6 +824,7 @@ $constStr = [
|
||||
'ja' => 'アップロードを開始',
|
||||
'ko-kr' => '업로드 시작',
|
||||
'fa' => 'شروع آپلود',
|
||||
'ar-sa' => 'بدء التحميل',
|
||||
],
|
||||
'UploadStartAt' => [
|
||||
'en-us' => 'Start At',
|
||||
@@ -657,6 +833,7 @@ $constStr = [
|
||||
'ja' => 'で開始',
|
||||
'ko-kr' => '에서 시작',
|
||||
'fa' => 'شروع از',
|
||||
'ar-sa' => 'تبدأ في',
|
||||
],
|
||||
'ThisTime' => [
|
||||
'en-us' => 'This Time',
|
||||
@@ -665,6 +842,7 @@ $constStr = [
|
||||
'ja' => '今回は',
|
||||
'ko-kr' => '이번에는',
|
||||
'fa' => 'این زمان',
|
||||
'ar-sa' => 'هذه المرة',
|
||||
],
|
||||
'LastUpload' => [
|
||||
'en-us' => 'Last time Upload',
|
||||
@@ -673,6 +851,7 @@ $constStr = [
|
||||
'ja' => '上回は',
|
||||
'ko-kr' => '마지막 업로드',
|
||||
'fa' => 'آخرین زمان آپلود',
|
||||
'ar-sa' => 'آخر تحميل',
|
||||
],
|
||||
'AverageSpeed' => [
|
||||
'en-us' => 'AverageSpeed',
|
||||
@@ -681,6 +860,7 @@ $constStr = [
|
||||
'ja' => '平均速度',
|
||||
'ko-kr' => '평균 속도',
|
||||
'fa' => 'میانگین سرعت',
|
||||
'ar-sa' => 'متوسط السرعة',
|
||||
],
|
||||
'CurrentSpeed' => [
|
||||
'en-us' => 'CurrentSpeed',
|
||||
@@ -689,6 +869,7 @@ $constStr = [
|
||||
'ja' => 'インスタントスピード',
|
||||
'ko-kr' => '즉각적인 속도',
|
||||
'fa' => 'سرعت فعلی',
|
||||
'ar-sa' => 'سرعة فورية',
|
||||
],
|
||||
'Expect' => [
|
||||
'en-us' => 'Expect',
|
||||
@@ -697,6 +878,7 @@ $constStr = [
|
||||
'ja' => '期待される',
|
||||
'ko-kr' => '예상',
|
||||
'fa' => 'انتظار',
|
||||
'ar-sa' => 'ومن المتوقع أيضا',
|
||||
],
|
||||
'EndAt' => [
|
||||
'en-us' => 'End At',
|
||||
@@ -705,6 +887,7 @@ $constStr = [
|
||||
'ja' => 'で終了',
|
||||
'ko-kr' => '에 끝남',
|
||||
'fa' => 'پایان از',
|
||||
'ar-sa' => 'نهاية',
|
||||
],
|
||||
'UploadErrorUpAgain' => [
|
||||
'en-us' => 'Maybe error, do upload again.',
|
||||
@@ -713,6 +896,7 @@ $constStr = [
|
||||
'ja' => '間違っている可能性があります。もう一度アップロードしてください。',
|
||||
'ko-kr' => '잘못되었을 수 있습니다. 다시 업로드하십시오.',
|
||||
'fa' => 'خطا، دوباره آپلود کنید',
|
||||
'ar-sa' => 'قد تكون خاطئة ، إعادة تحميل',
|
||||
],
|
||||
'UploadComplete' => [
|
||||
'en-us' => 'Upload Complete',
|
||||
@@ -721,6 +905,7 @@ $constStr = [
|
||||
'ja' => 'アップロード完了',
|
||||
'ko-kr' => '업로드 완료',
|
||||
'fa' => 'آپلود با موفقیت انجام شد',
|
||||
'ar-sa' => 'تحميل كامل',
|
||||
],
|
||||
'UploadFail23' => [
|
||||
'en-us' => 'Upload Fail, contain #.',
|
||||
@@ -729,6 +914,7 @@ $constStr = [
|
||||
'ja' => 'ディレクトリまたはファイル名に#が含まれています。アップロードに失敗しました。',
|
||||
'ko-kr' => '디렉토리 또는 파일 이름에 #이 포함되어 있습니다. 업로드하지 못했습니다.',
|
||||
'fa' => 'بارگذاری ناموفق، حاوی #.',
|
||||
'ar-sa' => 'دليل أو اسم الملف يحتوي على تحميل فشلت',
|
||||
],
|
||||
'defaultSitename' => [
|
||||
'en-us' => 'OneManager',
|
||||
@@ -740,6 +926,7 @@ $constStr = [
|
||||
'ja' => 'refresh_tokenを保存しています!',
|
||||
'ko-kr' => 'refresh_token 저장 중!',
|
||||
'fa' => 'در حال ذخیره refresh_token!',
|
||||
'ar-sa' => 'حفظ refresh ش توكن',
|
||||
],
|
||||
'MayinEnv' => [
|
||||
'en-us' => 'The \'Drive_ver\' may in Config',
|
||||
@@ -748,6 +935,7 @@ $constStr = [
|
||||
'ja' => 'Drive_verは環境変数に書き込まれている必要があります',
|
||||
'ko-kr' => 'Drive_verが書き込まれている必要があります',
|
||||
'fa' => 'The \'Drive_ver\' may in Config',
|
||||
'ar-sa' => 'درايو يجب أن يكون مكتوب على',
|
||||
],
|
||||
'Wait' => [
|
||||
'en-us' => 'Wait',
|
||||
@@ -756,6 +944,7 @@ $constStr = [
|
||||
'ja' => 'ちょっと待って',
|
||||
'ko-kr' => '잠깐만',
|
||||
'fa' => 'منتظر بمانید',
|
||||
'ar-sa' => 'انتظر لحظة',
|
||||
],
|
||||
'WaitJumpIndex' => [
|
||||
'en-us' => 'Wait 5s jump to Home page',
|
||||
@@ -764,6 +953,7 @@ $constStr = [
|
||||
'ja' => '5秒待ってホームページにジャンプします',
|
||||
'ko-kr' => '5 초 동안 홈페이지로 이동',
|
||||
'fa' => '۵ دقیقه صبر کنید تا به صفحه نخست برگردید',
|
||||
'ar-sa' => 'انتظر 5S القفز إلى الصفحة الرئيسية',
|
||||
],
|
||||
'JumptoOffice' => [
|
||||
'en-us' => 'Login Office and Get a refresh_token',
|
||||
@@ -772,27 +962,34 @@ $constStr = [
|
||||
'ja' => 'Officeにジャンプしてログインし、refresh_tokenを取得します',
|
||||
'ko-kr' => '사무실로 이동하여 로그인하여 refresh_token을 받으십시오.',
|
||||
'fa' => 'وارد Office شوید و یک refresh_token دریافت کنید',
|
||||
'ar-sa' => 'Login Office and Get a refresh_token',
|
||||
],
|
||||
'OnedriveDiskTag' => [
|
||||
'en-us' => 'Onedrive Disk Tag',
|
||||
'zh-cn' => 'Onedrive 标签',
|
||||
'zh-tw' => 'Onedrive 標籤',
|
||||
'ja' => 'Onedriveタグ',
|
||||
'ko-kr' => 'Onedrive 태그',
|
||||
'fa' => 'برچسب دیسک Onedrive',
|
||||
'DiskTag' => [
|
||||
'en-us' => 'Disk Tag',
|
||||
'zh-cn' => '标签',
|
||||
'zh-tw' => '標籤',
|
||||
'ja' => 'タグ',
|
||||
'ko-kr' => '태그',
|
||||
'fa' => 'برچسب دیسک ',
|
||||
'ar-sa' => 'تاغ',
|
||||
],
|
||||
'OnedriveDiskName' => [
|
||||
'en-us' => 'Onedrive Showed Name',
|
||||
'zh-cn' => 'Onedrive 显示名称',
|
||||
'zh-tw' => 'Onedrive 顯示名稱',
|
||||
'ja' => 'Onedrive表示名',
|
||||
'ko-kr' => 'Onedrive 표시 이름',
|
||||
'fa' => 'نام نشان داده شده Onedrive',
|
||||
'DiskName' => [
|
||||
'en-us' => 'Showed Name',
|
||||
'zh-cn' => '显示名称',
|
||||
'zh-tw' => '顯示名稱',
|
||||
'ja' => '表示名',
|
||||
'ko-kr' => '표시 이름',
|
||||
'fa' => 'نام نشان داده شده ',
|
||||
'ar-sa' => 'عرض الاسم',
|
||||
],
|
||||
'DriveVerMS' => [
|
||||
'en-us' => 'Onedrive, Onedrive for business',
|
||||
'zh-cn' => '国际版(商业版与个人版)',
|
||||
'zh-tw' => '國際版(商業版與個人版)',
|
||||
'ja' => '国際版(商業版と個人版)',
|
||||
'ko-kr' => '국제 판 (상업 판 과 개인 판)',
|
||||
'fa' => 'International Edition (Business Edition and Personal Edition)',
|
||||
'ar-sa' => 'الأعمال التجارية الدولية الطبعة الطبعة الشخصية',
|
||||
],
|
||||
'DriveVerCN' => [
|
||||
'en-us' => 'Onedrive in China',
|
||||
@@ -801,6 +998,7 @@ $constStr = [
|
||||
'ja' => '中国のOnedrive',
|
||||
'ko-kr' => '중국 Onedrive',
|
||||
'fa' => 'Onedrive در چین',
|
||||
'ar-sa' => 'Onedrive النسخة الصينية',
|
||||
],
|
||||
'DriveVerShareurl' => [
|
||||
'en-us' => 'A share link of a folder',
|
||||
@@ -809,16 +1007,17 @@ $constStr = [
|
||||
],
|
||||
'UseShareLink' => [
|
||||
'en-us' => 'Share a folder in Onedrive (enable EDIT for everyone), input the link url below.',
|
||||
'zh-cn' => '对一个Onedrive文件夹共享,允许所有人编辑,然后将共享链接填在下方',
|
||||
'zh-cn' => '<font color="red">只有国际版能用,</font>对一个Onedrive文件夹共享,允许所有人编辑,然后将共享链接填在下方',
|
||||
'zh-tw' => '對一個Onedrive資料夾共享,允許所有人編輯,然後將共享連結填在下方',
|
||||
],
|
||||
'CustomIdSecret' => [
|
||||
'en-us' => 'Use custom client id & secret instead of OneManager default',
|
||||
'zh-cn' => '自己申请应用ID与机密,不用OneManager默认的',
|
||||
'zh-tw' => '自己申請應用ID與機密,不用OneManager預設的',
|
||||
'zh-cn' => '用自己申请的应用ID与机密,不用OneManager默认的',
|
||||
'zh-tw' => '用自己申請的應用ID與機密,不用OneManager預設的',
|
||||
'ja' => 'アプリケーションIDとシークレットを自分で申請する',
|
||||
'ko-kr' => '응용 프로그램 ID 및 비밀 신청',
|
||||
'fa' => 'به طور پیش فرض اما از شناسه برنامه و سکرت استفاده کنید',
|
||||
'ar-sa' => 'استخدام التطبيق الخاص بك معرف وسرية ، لا أحد مدير الافتراضية',
|
||||
],
|
||||
'GetSecretIDandKEY' => [
|
||||
'en-us' => 'Get custom client id & secret',
|
||||
@@ -826,6 +1025,7 @@ $constStr = [
|
||||
'zh-tw' => '申請應用ID與機密',
|
||||
'ja' => 'アプリケーションIDとシークレット',
|
||||
'fa' => 'دریافت شناسه برنامه و سکرت',
|
||||
'ar-sa' => 'تطبيق الهوية والسرية',
|
||||
],
|
||||
'UseSharepointInstead' => [
|
||||
'en-us' => 'Use space in Sharepoint website instead of Onedrive',
|
||||
@@ -847,6 +1047,7 @@ $constStr = [
|
||||
'ja' => 'タグは、文字で始まり、文字または数字で終わる必要があります。少なくとも2つ',
|
||||
'ko-kr' => '태그는 문자로 시작하고 문자 또는 숫자로 끝나야합니다 (2 이상).',
|
||||
'fa' => 'برچسب باید با یک حرف شروع شود، با یک حرف یا رقم پایان یابد و تنها میتواند حاوی حروف کوچک، ارقام و خط فاصله، حداقل ۲ حرف باشد!',
|
||||
'ar-sa' => 'التسمية يمكن أن تبدأ فقط مع الحروف ، وتنتهي مع الحروف أو الأرقام ، على الأقل',
|
||||
],
|
||||
'ClickInstall' => [
|
||||
'en-us' => 'Click to install the project',
|
||||
@@ -855,6 +1056,7 @@ $constStr = [
|
||||
'ja' => 'クリックしてインストールプロセスを開始します',
|
||||
'ko-kr' => '설치 과정을 시작하려면 클릭',
|
||||
'fa' => 'برای نصب پروژه کلیک کنید',
|
||||
'ar-sa' => 'انقر فوق بدء الإعداد',
|
||||
],
|
||||
'LogintoBind' => [
|
||||
'en-us' => 'then login and bind your onedrive in setup',
|
||||
@@ -863,6 +1065,7 @@ $constStr = [
|
||||
'ja' => '次に、ログインして、設定でonedriveをバインドします。',
|
||||
'ko-kr' => '그런 다음 로그인하여 onedrive를 설정에 바인딩하십시오.',
|
||||
'fa' => 'پس از آن وارد سیستم شوید و تنظیمات خود را در onedrive متصل کنید',
|
||||
'ar-sa' => 'ثم قم بتسجيل الدخول بعد ربط أحد السائقين في الإعدادات',
|
||||
],
|
||||
'MakesuerWriteable' => [
|
||||
'en-us' => 'Plase make sure the config.php is writeable. run writeable.sh.',
|
||||
@@ -871,6 +1074,7 @@ $constStr = [
|
||||
'ja' => 'config.phpが書き込み可能であることを確認してください。',
|
||||
'ko-kr' => 'config.php가 쓰기 가능한지 확인하십시오.',
|
||||
'fa' => 'اطمینان حاصل کنید که config.php قابل نوشتن است. writeable.sh را اجرا کنید.',
|
||||
'ar-sa' => 'أكد بي إتش بي قابل للكتابة',
|
||||
],
|
||||
'MakesuerRewriteOn' => [
|
||||
'en-us' => 'Plase make sure the RewriteEngine is On.',
|
||||
@@ -879,16 +1083,25 @@ $constStr = [
|
||||
'ja' => '書き換え(擬似静的)機能が有効になっていることを確認します。',
|
||||
'ko-kr' => '다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오.',
|
||||
'fa' => 'لطفاً مطمئن شوید که RewriteEngine روشن است.',
|
||||
'ar-sa' => 'يؤكد أن الكتابة يمكن أن تكون وظيفة شبه استاتي',
|
||||
],
|
||||
'CopyUrl' => [
|
||||
'en-us' => 'Copy URL',
|
||||
'zh-cn' => '复制链接',
|
||||
'zh-tw' => '複製連結',
|
||||
'ja' => 'リンクをコピー',
|
||||
'ko-kr' => '링크 복사',
|
||||
'fa' => 'کپی ارتباط',
|
||||
'ar-sa' => 'نسخ الرابط',
|
||||
],
|
||||
'Success' => [
|
||||
'en-us' => 'Success',
|
||||
'zh-cn' => '成功',
|
||||
'zh-tw' => '成功',
|
||||
'ja' => '成功',
|
||||
'ko-kr' => '성공 하 다.',
|
||||
'fa' => 'موفقیت',
|
||||
'ar-sa' => 'نجح',
|
||||
],
|
||||
'SetAdminPassword' => [
|
||||
'en-us' => 'Set Admin Password',
|
||||
@@ -902,6 +1115,7 @@ $constStr = [
|
||||
'ja' => 'リフレッシュ',
|
||||
'ko-kr' => '새로 고침',
|
||||
'fa' => 'رفرش',
|
||||
'ar-sa' => 'منعش',
|
||||
],
|
||||
'SelectLanguage' => [
|
||||
'en-us' => 'Select Language',
|
||||
@@ -910,6 +1124,7 @@ $constStr = [
|
||||
'ja' => '言語を選択してください',
|
||||
'ko-kr' => '언어를 선택하십시오',
|
||||
'fa' => 'زبان را انتخاب کنید',
|
||||
'ar-sa' => 'اختيار اللغة',
|
||||
],
|
||||
'RefreshCache' => [
|
||||
'en-us' => 'RefreshCache',
|
||||
@@ -918,6 +1133,7 @@ $constStr = [
|
||||
'ja' => 'キャッシュを再構築',
|
||||
'ko-kr' => '캐시 플러시',
|
||||
'fa' => 'رفرش cache',
|
||||
'ar-sa' => 'تحديث الكاش',
|
||||
],
|
||||
'CannotOneKeyUpate' => [
|
||||
'en-us' => 'Can not update by a click! run update.sh',
|
||||
@@ -935,8 +1151,8 @@ $constStr = [
|
||||
'zh-tw' => '配置儲存在環境變數',
|
||||
],
|
||||
'ONEMANAGER_CONFIG_SAVE_FILE' => [
|
||||
'en-us' => 'Config save in code file, may cause fee',
|
||||
'zh-cn' => '配置保存在代码文件中,可能产生费用',
|
||||
'en-us' => 'Config save in code file, may cause fee, please reinstall later',
|
||||
'zh-cn' => '配置保存在代码文件中,可能产生费用,切换后,请从头再安装一次。',
|
||||
'zh-tw' => '配置儲存在程式碼文件中,可能產生費用',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -0,0 +1,835 @@
|
||||
<?php
|
||||
|
||||
class Aliyundrive {
|
||||
protected $access_token;
|
||||
protected $disktag;
|
||||
|
||||
function __construct($tag) {
|
||||
$this->disktag = $tag;
|
||||
//$this->auth_url = 'https://websv.aliyundrive.com/token/refresh';
|
||||
$this->auth_url = 'https://auth.aliyundrive.com/v2/account/token';
|
||||
$this->api_url = 'https://api.aliyundrive.com/v2';
|
||||
$this->driveId = getConfig('driveId', $tag);
|
||||
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
||||
}
|
||||
|
||||
public function isfine()
|
||||
{
|
||||
if (!$this->access_token) return false;
|
||||
else return true;
|
||||
}
|
||||
public function show_base_class()
|
||||
{
|
||||
return get_class();
|
||||
//$tmp[0] = get_class();
|
||||
//$tmp[1] = get_class($this);
|
||||
//return $tmp;
|
||||
}
|
||||
|
||||
public function ext_show_innerenv()
|
||||
{
|
||||
return ['driveId'];
|
||||
}
|
||||
|
||||
public function list_files($path = '/')
|
||||
{
|
||||
|
||||
$files = $this->list_path($path);
|
||||
|
||||
return $this->files_format($files);
|
||||
}
|
||||
|
||||
protected function files_format($files)
|
||||
{
|
||||
//return $files;
|
||||
if ($files['type']=='file') {
|
||||
$tmp['type'] = 'file';
|
||||
$tmp['id'] = $files['file_id'];
|
||||
if (isset($files['name'])) $tmp['name'] = $files['name'];
|
||||
elseif (isset($files['file_name'])) $tmp['name'] = $files['file_name'];
|
||||
$tmp['time'] = $files['updated_at'];
|
||||
$tmp['size'] = $files['size'];
|
||||
$tmp['mime'] = $files['file']['mimeType'];
|
||||
$tmp['url'] = $files['download_url'];
|
||||
$tmp['content'] = $files['content'];
|
||||
if (isset($files['exist'])) $tmp['exist'] = $files['exist'];
|
||||
if (isset($files['rapid_upload'])) $tmp['rapid_upload'] = $files['rapid_upload'];
|
||||
} elseif ($files['type']=='folder'||isset($files['items'])) {
|
||||
$tmp['type'] = 'folder';
|
||||
$tmp['id'] = $files['file_id'];
|
||||
if (isset($files['name'])) $tmp['name'] = $files['name'];
|
||||
elseif (isset($files['file_name'])) $tmp['name'] = $files['file_name'];
|
||||
$tmp['time'] = $files['updated_at'];
|
||||
$tmp['size'] = $files['size'];
|
||||
//$tmp['page'] = $files['folder']['page'];
|
||||
foreach ($files['items'] as $file) {
|
||||
$filename = strtolower($file['name']);
|
||||
if ($file['type']=='file') {
|
||||
$tmp['list'][$filename]['type'] = 'file';
|
||||
$tmp['list'][$filename]['url'] = $file['download_url'];
|
||||
$tmp['list'][$filename]['mime'] = $file['file']['content_type'];
|
||||
} elseif ($file['type']=='folder') {
|
||||
$tmp['list'][$filename]['type'] = 'folder';
|
||||
}
|
||||
//$tmp['id'] = $file['parent_file_id'];
|
||||
$tmp['list'][$filename]['id'] = $file['file_id'];
|
||||
$tmp['list'][$filename]['name'] = $file['name'];
|
||||
$tmp['list'][$filename]['time'] = $file['updated_at'];
|
||||
$tmp['list'][$filename]['size'] = $file['size'];
|
||||
$tmp['childcount']++;
|
||||
}
|
||||
} elseif (isset($files['code'])||isset($files['error'])) {
|
||||
return $files;
|
||||
}
|
||||
//error_log1(json_encode($tmp));
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function list_path($path = '/')
|
||||
{
|
||||
global $exts;
|
||||
while (substr($path, -1)=='/') $path = substr($path, 0, -1);
|
||||
if ($path == '') $path = '/';
|
||||
//$files = getcache('path_' . $path, $this->disktag);
|
||||
//if (!$files) {
|
||||
if (!($files = getcache('path_' . $path, $this->disktag))) {
|
||||
if ($path == '/' || $path == '') {
|
||||
$files = $this->fileList('root');
|
||||
//error_log1('root_id' . $files['id']);
|
||||
$files['file_id'] = 'root';
|
||||
$files['type'] = 'folder';
|
||||
} else {
|
||||
$tmp = splitlast($path, '/');
|
||||
$parent_path = $tmp[0];
|
||||
$filename = urldecode($tmp[1]);
|
||||
$parent_folder = $this->list_path($parent_path);
|
||||
foreach ($parent_folder['items'] as $item) {
|
||||
if ($item['name']==$filename) {
|
||||
if ($item['type']=='folder') {
|
||||
$files = $this->fileList($item['file_id']);
|
||||
$files['type'] = 'folder';
|
||||
$files['file_id'] = $item['file_id'];
|
||||
$files['name'] = $item['name'];
|
||||
$files['time'] = $item['updated_at'];
|
||||
$files['size'] = $item['size'];
|
||||
} else $files = $item;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//echo $files['name'];
|
||||
}
|
||||
if ($files['type']=='file') {
|
||||
if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) {
|
||||
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
|
||||
$header['Referer'] = 'https://www.aliyundrive.com/';
|
||||
$header['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36';
|
||||
$content1 = curl('GET', $files['download_url'], '', $header);
|
||||
$files['content'] = $content1;
|
||||
savecache('path_' . $path, $files, $this->disktag);
|
||||
}
|
||||
error_log1($files['name'] . ' : ' . json_encode($files['content']) . PHP_EOL);
|
||||
}
|
||||
}
|
||||
if (!$files) {
|
||||
$files['error']['code'] = 'Not Found';
|
||||
$files['error']['message'] = $path . ' Not Found';
|
||||
$files['error']['stat'] = 404;
|
||||
} elseif (isset($files['stat'])) {
|
||||
$files['error']['stat'] = $files['stat'];
|
||||
$files['error']['code'] = 'Error';
|
||||
$files['error']['message'] = $files['body'];
|
||||
unset($files['file_id']);
|
||||
unset($files['type']);
|
||||
} elseif (isset($files['code'])) {
|
||||
$files['error']['stat'] = 500;
|
||||
$files['error']['code'] = $files['code'];
|
||||
$files['error']['message'] = $files['message'];
|
||||
unset($files['file_id']);
|
||||
unset($files['type']);
|
||||
} else {
|
||||
savecache('path_' . $path, $files, $this->disktag, 600);
|
||||
}
|
||||
}
|
||||
//error_log1('path:' . $path . ', files:' . substr(json_encode($files), 0, 150));
|
||||
//error_log1('path:' . $path . ', files:' . json_encode($files));
|
||||
return $files;
|
||||
}
|
||||
|
||||
protected function fileGet($file_id)
|
||||
{
|
||||
$url = $this->api_url . '/file/get';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['file_id'] = $file_id;
|
||||
|
||||
$res = curl('POST', $url, json_encode($data), $header);
|
||||
if ($res['stat']==200) return json_decode($res['body'], true);
|
||||
else return $res;
|
||||
}
|
||||
protected function fileList($parent_file_id)
|
||||
{
|
||||
$url = $this->api_url . '/file/list';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['limit'] = 50;
|
||||
$data['marker'] = NULL;
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['parent_file_id'] = $parent_file_id;
|
||||
$data['image_thumbnail_process'] = 'image/resize,w_160/format,jpeg';
|
||||
$data['image_url_process'] = 'image/resize,w_1920/format,jpeg';
|
||||
$data['video_thumbnail_process'] = 'video/snapshot,t_0,f_jpg,w_300';
|
||||
$data['fields'] = '*';
|
||||
$data['order_by'] = 'updated_at';
|
||||
$data['order_direction'] = 'DESC';
|
||||
|
||||
$res = curl('POST', $url, json_encode($data), $header);
|
||||
//error_log1($res['stat'] . $res['body']);
|
||||
if ($res['stat']==200) return json_decode($res['body'], true);
|
||||
else return $res;
|
||||
}
|
||||
|
||||
public function Rename($file, $newname) {
|
||||
$url = $this->api_url . '/file/update';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['check_name_mode'] = 'refuse';
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['file_id'] = $file['id'];
|
||||
$data['name'] = $newname;
|
||||
//$data['parent_file_id'] = 'root';
|
||||
|
||||
$result = curl('POST', $url, json_encode($data), $header);
|
||||
//savecache('path_' . $file['path'], json_decode('{}',true), $this->disktag, 1);
|
||||
//error_log1('decode:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
//return output($result['body'], $result['stat']);
|
||||
}
|
||||
public function Delete($file) {
|
||||
$url = $this->api_url . '/batch';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['resource'] = 'file';
|
||||
$data['requests'][0]['url'] = '/file/delete';
|
||||
$data['requests'][0]['method'] = 'DELETE';
|
||||
$data['requests'][0]['id'] = $file['id'];
|
||||
$data['requests'][0]['headers']['Content-Type'] = 'application/json';
|
||||
$data['requests'][0]['body']['drive_id'] = $this->driveId;
|
||||
$data['requests'][0]['body']['file_id'] = $file['id'];
|
||||
|
||||
$result = curl('POST', $url, json_encode($data), $header);
|
||||
//savecache('path_' . $file['path'], json_decode('{}',true), $this->disktag, 1);
|
||||
//error_log1('result:' . json_encode($result));
|
||||
//return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
$res = json_decode($result['body'], true)['responses'][0];
|
||||
if (isset($res['status'])) return output($res['id'], $res['status']);
|
||||
else return output($result['body'], $result['stat']);
|
||||
}
|
||||
public function Encrypt($folder, $passfilename, $pass) {
|
||||
$existfile = $this->list_path($folder['path'] . '/' . $passfilename);
|
||||
if (isset($existfile['type'])) { // 删掉原文件
|
||||
$this->Delete(['id'=>$existfile['file_id']]);
|
||||
}
|
||||
if ($pass==='') {
|
||||
// 如果为空,上面已经删除了
|
||||
return output('Success', 200);
|
||||
}
|
||||
if (!$folder['id']) {
|
||||
$res = $this->list_path($folder['path']);
|
||||
//error_log1('res:' . json_encode($res));
|
||||
$folder['id'] = $res['file_id'];
|
||||
}
|
||||
$tmp = '/tmp/' . $passfilename;
|
||||
file_put_contents($tmp, $pass);
|
||||
|
||||
$result = $this->tmpfileCreate($folder['id'], $tmp, $passfilename);
|
||||
|
||||
if ($result['stat']==201) {
|
||||
//error_log1('1,url:' . $url .' res:' . json_encode($result));
|
||||
$res = json_decode($result['body'], true);
|
||||
$url = $res['part_info_list'][0]['upload_url'];
|
||||
if (!$url) { // 无url,应该算秒传
|
||||
return output('no up url', 200);
|
||||
}
|
||||
$file_id = $res['file_id'];
|
||||
$upload_id = $res['upload_id'];
|
||||
$result = curl('PUT', $url, $pass, [], 1);
|
||||
if ($result['stat']==200) { // 块1传好
|
||||
$result = $this->fileComplete($file_id, $upload_id, [ $result['returnhead']['ETag'] ]);
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
}
|
||||
//error_log1('2,url:' . $url .' res:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Move($file, $folder) {
|
||||
if (!$folder['id']) {
|
||||
$res = $this->list_path($folder['path']);
|
||||
//error_log1('res:' . json_encode($res));
|
||||
$folder['id'] = $res['file_id'];
|
||||
}
|
||||
|
||||
$url = $this->api_url . '/batch';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['resource'] = 'file';
|
||||
$data['requests'][0]['url'] = '/file/move';
|
||||
$data['requests'][0]['method'] = 'POST';
|
||||
$data['requests'][0]['id'] = $file['id'];
|
||||
$data['requests'][0]['headers']['Content-Type'] = 'application/json';
|
||||
$data['requests'][0]['body']['drive_id'] = $this->driveId;
|
||||
$data['requests'][0]['body']['file_id'] = $file['id'];
|
||||
$data['requests'][0]['body']['auto_rename'] = true;
|
||||
$data['requests'][0]['body']['to_parent_file_id'] = $folder['id'];
|
||||
|
||||
$result = curl('POST', $url, json_encode($data), $header);
|
||||
//savecache('path_' . $file['path'], json_decode('{}',true), $this->disktag, 1);
|
||||
//error_log1('result:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Copy($file) {
|
||||
if (!$file['id']) {
|
||||
$oldfile = $this->list_path($file['path'] . '/' . $file['name']);
|
||||
//error_log1('res:' . json_encode($res));
|
||||
//$file['id'] = $res['file_id'];
|
||||
} else {
|
||||
$oldfile = $this->fileGet($file['id']);
|
||||
}
|
||||
|
||||
$url = $this->api_url . '/file/create';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['check_name_mode'] = 'auto_rename'; // ignore, auto_rename, refuse.
|
||||
$data['content_hash'] = $oldfile['content_hash'];
|
||||
$data['content_hash_name'] = 'sha1';
|
||||
$data['content_type'] = $oldfile['content_type'];
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['ignoreError'] = false;
|
||||
$data['name'] = $oldfile['name'];
|
||||
$data['parent_file_id'] = $oldfile['parent_file_id'];
|
||||
$data['part_info_list'][0]['part_number'] = 1;
|
||||
$data['size'] = $oldfile['size'];
|
||||
$data['type'] = 'file';
|
||||
|
||||
$result = curl('POST', $url, json_encode($data), $header);
|
||||
|
||||
if ($result['stat']==201) {
|
||||
//error_log1('1,url:' . $url .' res:' . json_encode($result));
|
||||
$res = json_decode($result['body'], true);
|
||||
$url = $res['part_info_list'][0]['upload_url'];
|
||||
if (!$url) { // 无url,应该算秒传
|
||||
return output('no up url', 200);
|
||||
} else {
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
/*$file_id = $res['file_id'];
|
||||
$upload_id = $res['upload_id'];
|
||||
$result = curl('PUT', $url, $content, [], 1);
|
||||
if ($result['stat']==200) { // 块1传好
|
||||
$etag = $result['returnhead']['ETag'];
|
||||
$result = $this->fileComplete($file_id, $upload_id, [ $etag ]);
|
||||
if ($result['stat']!=200) return output($result['body'], $result['stat']);
|
||||
else return output('success', 0);
|
||||
}*/
|
||||
}
|
||||
//error_log1('2,url:' . $url .' res:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Edit($file, $content) {
|
||||
$tmp = splitlast($file['path'], '/');
|
||||
$folderpath = $tmp[0];
|
||||
$filename = $tmp[1];
|
||||
$existfile = $this->list_path($file['path']);
|
||||
if (isset($existfile['type'])) { // 删掉原文件
|
||||
$this->Delete(['id'=>$existfile['file_id']]);
|
||||
}
|
||||
$tmp1 = '/tmp/' . $filename;
|
||||
file_put_contents($tmp1, $content);
|
||||
|
||||
$result = $this->tmpfileCreate($this->list_path($folderpath)['file_id'], $tmp1, $filename);
|
||||
|
||||
if ($result['stat']==201) {
|
||||
//error_log1('1,url:' . $url .' res:' . json_encode($result));
|
||||
$res = json_decode($result['body'], true);
|
||||
$url = $res['part_info_list'][0]['upload_url'];
|
||||
if (!$url) { // 无url,应该算秒传
|
||||
return output('no up url', 0);
|
||||
}
|
||||
$file_id = $res['file_id'];
|
||||
$upload_id = $res['upload_id'];
|
||||
$result = curl('PUT', $url, $content, [], 1);
|
||||
if ($result['stat']==200) { // 块1传好
|
||||
$result = $this->fileComplete($file_id, $upload_id, [ $result['returnhead']['ETag'] ]);
|
||||
if ($result['stat']!=200) return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
else return output('success', 0);
|
||||
}
|
||||
}
|
||||
//error_log1('2,url:' . $url .' res:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Create($folder, $type, $name, $content = '') {
|
||||
if (!$folder['id']) {
|
||||
$res = $this->list_path($folder['path']);
|
||||
//error_log1('res:' . json_encode($res));
|
||||
$folder['id'] = $res['file_id'];
|
||||
}
|
||||
if ($type=='folder') {
|
||||
$result = $this->folderCreate($folder['id'], $name);
|
||||
//error_log1('res:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
if ($type=='file') {
|
||||
$tmp = '/tmp/' . $name;
|
||||
file_put_contents($tmp, $content);
|
||||
|
||||
$result = $this->tmpfileCreate($folder['id'], $tmp, $name);
|
||||
|
||||
if ($result['stat']==201) {
|
||||
//error_log1('1,url:' . $url .' res:' . json_encode($result));
|
||||
$res = json_decode($result['body'], true);
|
||||
if (isset($res['exist'])&&$res['exist']!=false) {
|
||||
// 已经有
|
||||
//error_log1('exist:' . json_encode($res));
|
||||
return output('{"type":"file","name":"' . $name . '", "exist":true}', 200);
|
||||
}
|
||||
if (isset($res['rapid_upload'])&&$res['rapid_upload']!=false) {
|
||||
// 秒传
|
||||
//error_log1('rapid up:' . json_encode($res));
|
||||
return output('{"type":"file","name":"' . $name . '", "rapid_upload":true}', 200);
|
||||
}
|
||||
$url = $res['part_info_list'][0]['upload_url'];
|
||||
$file_id = $res['file_id'];
|
||||
$upload_id = $res['upload_id'];
|
||||
$result = curl('PUT', $url, $content, [], 1);
|
||||
//error_log1('2,url:' . $url .' res:' . json_encode($result));
|
||||
if ($result['stat']==200) { // 块1传好
|
||||
$result = $this->fileComplete($file_id, $upload_id, [ $result['returnhead']['ETag'] ]);
|
||||
//error_log1('3,url:' . $url .' res:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
}
|
||||
//error_log1('4,url:' . $url .' res:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
return output('Type not folder or file.', 500);
|
||||
}
|
||||
|
||||
protected function folderCreate($parentId, $folderName) {
|
||||
if (strrpos($folderName, '/')) {
|
||||
$tmp = splitlast($folderName, '/');
|
||||
$parentId = json_decode($this->folderCreate($parentId, $tmp[0])['body'], true)['file_id'];
|
||||
$folderName = $tmp[1];
|
||||
}
|
||||
$url = $this->api_url . '/file/create';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['check_name_mode'] = 'refuse'; // ignore, auto_rename, refuse.
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['name'] = $folderName;
|
||||
$data['parent_file_id'] = $parentId;
|
||||
$data['type'] = 'folder';
|
||||
|
||||
return curl('POST', $url, json_encode($data), $header);
|
||||
}
|
||||
protected function fileCreate($parentId, $fileName, $sha1, $size, $part_number) {
|
||||
$url = $this->api_url . '/file/create';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['check_name_mode'] = 'refuse'; // ignore, auto_rename, refuse.
|
||||
$data['content_hash'] = $sha1;
|
||||
$data['content_hash_name'] = 'sha1';
|
||||
$data['content_type'] = '';
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['ignoreError'] = false;
|
||||
$data['name'] = $fileName;
|
||||
$data['parent_file_id'] = $parentId;
|
||||
for ($i=0;$i<$part_number;$i++) {
|
||||
$data['part_info_list'][$i]['part_number'] = $i+1;
|
||||
}
|
||||
$data['size'] = (int)$size;
|
||||
$data['type'] = 'file';
|
||||
|
||||
return curl('POST', $url, json_encode($data), $header);
|
||||
}
|
||||
protected function tmpfileCreate($parentId, $tmpFilePath, $tofileName = '') {
|
||||
$sha1 = sha1_file($tmpFilePath);
|
||||
if ($tofileName == '') $tofileName = splitlast($tmpFilePath, '/')[1];
|
||||
$url = $this->api_url . '/file/create';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['check_name_mode'] = 'refuse'; // ignore, auto_rename, refuse.
|
||||
$data['content_hash'] = $sha1;
|
||||
$data['content_hash_name'] = 'sha1';
|
||||
$data['content_type'] = 'text/plain'; // now only txt
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['ignoreError'] = false;
|
||||
$data['name'] = $tofileName;
|
||||
$data['parent_file_id'] = $parentId;
|
||||
$data['part_info_list'][0]['part_number'] = 1; // now only txt
|
||||
$data['size'] = filesize($tmpFilePath);
|
||||
$data['type'] = 'file';
|
||||
|
||||
return curl('POST', $url, json_encode($data), $header);
|
||||
}
|
||||
protected function fileComplete($file_id, $upload_id, $etags) {
|
||||
$url = $this->api_url . '/file/complete';
|
||||
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$data['drive_id'] = $this->driveId;
|
||||
$data['file_id'] = $file_id;
|
||||
$data['ignoreError'] = false;
|
||||
$i = 0;
|
||||
foreach ($etags as $etag) {
|
||||
$data['part_info_list'][$i]['part_number'] = $i + 1;
|
||||
$data['part_info_list'][$i]['etag'] = $etag;
|
||||
$i++;
|
||||
}
|
||||
$data['upload_id'] = $upload_id;
|
||||
|
||||
return curl('POST', $url, json_encode($data), $header);
|
||||
}
|
||||
|
||||
public function get_thumbnails_url($path = '/')
|
||||
{
|
||||
$res = $this->list_path($path);
|
||||
$thumb_url = $res['thumbnail'];
|
||||
return $thumb_url;
|
||||
}
|
||||
public function bigfileupload($path)
|
||||
{
|
||||
if (isset($_POST['uploadid'])) {
|
||||
// Complete
|
||||
$result = $this->fileComplete($_POST['fileid'], $_POST['uploadid'], json_decode($_POST['etag'], true));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
} else {
|
||||
if ($_POST['upbigfilename']=='') return output('error: no file name', 400);
|
||||
if (!is_numeric($_POST['filesize'])) return output('error: no file size', 400);
|
||||
if (!isset($_POST['filesha1'])) return output('error: no file sha1', 400);
|
||||
|
||||
$tmp = splitlast($_POST['upbigfilename'], '/');
|
||||
if ($tmp[1]!='') {
|
||||
$fileinfo['name'] = $tmp[1];
|
||||
if ($_SERVER['admin']) $fileinfo['path'] = $tmp[0];
|
||||
} else {
|
||||
$fileinfo['name'] = $_POST['upbigfilename'];
|
||||
}
|
||||
$fileinfo['size'] = $_POST['filesize'];
|
||||
$fileinfo['filelastModified'] = $_POST['filelastModified'];
|
||||
if ($_SERVER['admin']) {
|
||||
$filename = $fileinfo['name'];
|
||||
} else {
|
||||
$tmp1 = splitlast($fileinfo['name'], '.');
|
||||
if ($tmp1[0]==''||$tmp1[1]=='') $filename = $_POST['filesha1'];
|
||||
else $filename = $_POST['filesha1'] . '.' . $tmp1[1];
|
||||
}
|
||||
|
||||
$parent = $this->list_path($path . '/' . $fileinfo['path']);
|
||||
if (isset($parent['file_id'])) {
|
||||
$parent_file_id = $parent['file_id'];
|
||||
} else {
|
||||
$res = $this->folderCreate($this->list_path($path)['file_id'], $fileinfo['path']);
|
||||
//error_log1($res['body']);
|
||||
$parent_file_id = json_decode($res['body'], true)['file_id'];
|
||||
}
|
||||
$response = $this->fileCreate($parent_file_id, $filename, $_POST['filesha1'], $fileinfo['size'], ceil($fileinfo['size']/$_POST['chunksize']));
|
||||
$res = json_decode($response['body'], true);
|
||||
if (isset($res['exist'])) {
|
||||
// 已经有
|
||||
//error_log1('exist:' . json_encode($res));
|
||||
return output(json_encode($this->files_format(json_decode($response['body'], true))), $response['stat']);
|
||||
//return output('{"type":"file","name":"' . $_POST['upbigfilename'] . '", "exist":true}', 200);
|
||||
}
|
||||
if (isset($res['rapid_upload'])&&$res['rapid_upload']!=false) {
|
||||
// 秒传
|
||||
//error_log1('rapid up:' . json_encode($res));
|
||||
return output(json_encode($this->files_format(json_decode($response['body'], true))), $response['stat']);
|
||||
//return output('{"type":"file","name":"' . $_POST['upbigfilename'] . '", "rapid upload":true}', 200);
|
||||
}
|
||||
//if ($response['stat']<500) {
|
||||
// $responsearry = json_decode($response['body'], true);
|
||||
// if (isset($responsearry['error'])) return output($response['body'], $response['stat']);
|
||||
// $fileinfo['uploadUrl'] = $responsearry['uploadUrl'];
|
||||
// if ($fileinfo['size']>10*1024*1024) $this->MSAPI('PUT', path_format($path . '/' . $cachefilename), json_encode($fileinfo, JSON_PRETTY_PRINT), $this->access_token);
|
||||
//}
|
||||
return output($response['body'], $response['stat']);
|
||||
}
|
||||
}
|
||||
|
||||
public function AddDisk() {
|
||||
global $constStr;
|
||||
global $EnvConfigs;
|
||||
|
||||
$envs = '';
|
||||
foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
|
||||
if (isset($_GET['Finish'])) {
|
||||
if ($this->access_token == '') {
|
||||
$refresh_token = getConfig('refresh_token', $this->disktag);
|
||||
if (!$refresh_token) {
|
||||
$html = 'No refresh_token config, please AddDisk again or wait minutes.<br>' . $this->disktag;
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$response = $this->get_access_token($refresh_token);
|
||||
if (!$response) return message($this->error['body'], 'Error', $this->error['stat']);
|
||||
}
|
||||
$tmp = null;
|
||||
if ($_POST['driveId']!='') {
|
||||
$tmp['driveId'] = $_POST['driveId'];
|
||||
} else {
|
||||
return message('no driveId', 'Error', 201);
|
||||
}
|
||||
|
||||
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
$str .= '<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
||||
return message($str, getconstStr('WaitJumpIndex'), 201);
|
||||
}
|
||||
}
|
||||
if (isset($_GET['SelectDrive'])) {
|
||||
if ($this->access_token == '') {
|
||||
if (isset($_POST['refresh_token'])) {
|
||||
$res = curl('POST', $this->auth_url, json_encode([ 'refresh_token' => $_POST['refresh_token'], 'grant_type' => 'refresh_token' ]), ["content-type"=>"application/json; charset=utf-8"]);
|
||||
//return output($res['body']);
|
||||
if ($res['stat']!=200) {
|
||||
return message($res['body'], $res['stat'], $res['stat']);
|
||||
}
|
||||
//var_dump($res['body']);
|
||||
$result = json_decode($res['body'], true);
|
||||
|
||||
$tmp = null;
|
||||
$tmp['refresh_token'] = $result['refresh_token'];
|
||||
$tmp['token_expires'] = time()+3*24*60*60;
|
||||
$tmp['Driver'] = 'Aliyundrive';
|
||||
//error_log(json_encode($tmp));
|
||||
|
||||
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
savecache('access_token', $result['access_token'], $this->disktag, $result['expires_in'] - 60);
|
||||
} else {
|
||||
$refresh_token = getConfig('refresh_token', $this->disktag);
|
||||
if (!$refresh_token) {
|
||||
$html = 'No refresh_token config, please AddDisk again or wait minutes.<br>' . $this->disktag;
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$response = $this->get_access_token($refresh_token);
|
||||
if (!$response) return message($this->error['body'], 'Error', $this->error['stat']);
|
||||
}
|
||||
}
|
||||
if (!isset($result['default_drive_id'])) {
|
||||
$res = curl('POST', $this->auth_url, json_encode([ 'refresh_token' => getConfig('refresh_token', $this->disktag), 'grant_type' => 'refresh_token' ]), ["content-type"=>"application/json; charset=utf-8"]);
|
||||
//return output($res['body']);
|
||||
if ($res['stat']!=200) {
|
||||
return message($res['body'], $res['stat'], $res['stat']);
|
||||
}
|
||||
//var_dump($res['body']);
|
||||
$result = json_decode($res['body'], true);
|
||||
}
|
||||
|
||||
//$tmp = null;
|
||||
//$tmp['driveId'] = $result['default_drive_id'];
|
||||
//$tmp['default_sbox_drive_id'] = $result['default_sbox_drive_id'];
|
||||
$title = 'Select Driver';
|
||||
$html = '
|
||||
<div>
|
||||
<form action="?Finish&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);">
|
||||
<label><input type="radio" name="driveId" value="' . $result['default_drive_id'] . '"' . ($result['default_drive_id']==$this->driveId?' checked':'') . '>' . '用普通空间 ' . getconstStr(' ') . '</label><br>
|
||||
<label><input type="radio" name="driveId" value="' . $result['default_sbox_drive_id'] . '"' . ($result['default_sbox_drive_id']==$this->driveId?' checked':'') . '>' . '用虎符文件保险箱 </label><br>
|
||||
<input type="submit" value="' . getconstStr('Submit') . '">
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.driveId.value==\'\') {
|
||||
alert(\'Select a Disk\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (isset($_GET['install0']) && $_POST['disktag_add']!='') {
|
||||
$_POST['disktag_add'] = preg_replace('/[^0-9a-zA-Z|_]/i', '', $_POST['disktag_add']);
|
||||
$f = substr($_POST['disktag_add'], 0, 1);
|
||||
if (strlen($_POST['disktag_add'])==1) $_POST['disktag_add'] .= '_';
|
||||
if (isCommonEnv($_POST['disktag_add'])) {
|
||||
return message('Do not input ' . $envs . '<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+1);
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'disktag=; path=/; \'+expires;
|
||||
</script>', 'Error', 201);
|
||||
} elseif (!(('a'<=$f && $f<='z') || ('A'<=$f && $f<='Z'))) {
|
||||
return message('Please start with letters<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+1);
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'disktag=; path=/; \'+expires;
|
||||
</script>', 'Error', 201);
|
||||
}
|
||||
|
||||
$tmp = null;
|
||||
foreach ($EnvConfigs as $env => $v) if (isInnerEnv($env)) $tmp[$env] = '';
|
||||
|
||||
$tmp['Driver'] = 'Aliyundrive';
|
||||
$tmp['disktag_add'] = $_POST['disktag_add'];
|
||||
$tmp['diskname'] = $_POST['diskname'];
|
||||
//error_log(json_encode($tmp));
|
||||
|
||||
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
$title = 'Refresh token';
|
||||
$html = '
|
||||
<form action="?SelectDrive&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);">
|
||||
<div>填入refresh_token:
|
||||
<input type="text" name="refresh_token" placeholder="自行百度如何获取' . getconstStr(' ') . '" style="width:100%"><br>
|
||||
</div><br>
|
||||
<input type="submit" value="' . getconstStr('Submit') . '">
|
||||
<form>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.refresh_token.value==\'\') {
|
||||
alert(\'Input refresh_token\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
|
||||
$html = '
|
||||
<div>
|
||||
<form id="form1" action="" method="post" onsubmit="return notnull(this);">
|
||||
' . getconstStr('DiskTag') . ': (' . getConfig('disktag') . ')
|
||||
<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
|
||||
' . getconstStr('DiskName') . ':
|
||||
<input type="text" name="diskname" placeholder="' . getconstStr('EnvironmentsDescription')['diskname'] . '" style="width:100%"><br>
|
||||
<br>
|
||||
|
||||
<input type="submit" value="' . getconstStr('Submit') . '">
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.disktag_add.value==\'\') {
|
||||
alert(\'' . getconstStr('DiskTag') . '\');
|
||||
return false;
|
||||
}
|
||||
envs = [' . $envs . '];
|
||||
if (envs.indexOf(t.disktag_add.value)>-1) {
|
||||
alert("Do not input ' . $envs . '");
|
||||
return false;
|
||||
}
|
||||
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
|
||||
if (!reg.test(t.disktag_add.value)) {
|
||||
alert(\'' . getconstStr('TagFormatAlert') . '\');
|
||||
return false;
|
||||
}
|
||||
|
||||
document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=Aliyundrive";
|
||||
//var expd = new Date();
|
||||
//expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
//var expires = "expires="+expd.toGMTString();
|
||||
//document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/; \'+expires;
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = 'Select Account Type';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
protected function get_access_token($refresh_token) {
|
||||
if (!$refresh_token) {
|
||||
$tmp['stat'] = 0;
|
||||
$tmp['body'] = 'No refresh_token';
|
||||
$this->error = $tmp;
|
||||
return false;
|
||||
}
|
||||
if (!($this->access_token = getcache('access_token', $this->disktag))) {
|
||||
$p=0;
|
||||
$tmp1['refresh_token'] = $refresh_token;
|
||||
$tmp1['grant_type'] = 'refresh_token';
|
||||
while ($response['stat']==0&&$p<3) {
|
||||
$response = curl('POST', $this->auth_url, json_encode($tmp1), ["content-type"=>"application/json; charset=utf-8"]);
|
||||
$p++;
|
||||
}
|
||||
//error_log1(json_encode($response));
|
||||
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
||||
if (!isset($ret['access_token'])) {
|
||||
error_log1('failed to get [' . $this->disktag . '] access_token. response: ' . $response['stat'] . $response['body']);
|
||||
//$response['body'] = json_encode(json_decode($response['body']), JSON_PRETTY_PRINT);
|
||||
$response['body'] .= 'failed to get [' . $this->disktag . '] access_token.';
|
||||
$this->error = $response;
|
||||
return false;
|
||||
}
|
||||
$tmp = $ret;
|
||||
$tmp['access_token'] = substr($tmp['access_token'], 0, 10) . '******';
|
||||
$tmp['refresh_token'] = substr($tmp['refresh_token'], 0, 10) . '******';
|
||||
error_log1('[' . $this->disktag . '] Get access token:' . json_encode($tmp, JSON_PRETTY_PRINT));
|
||||
$this->access_token = $ret['access_token'];
|
||||
savecache('access_token', $this->access_token, $this->disktag, $ret['expires_in'] - 300);
|
||||
if (time()>getConfig('token_expires', $this->disktag)) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+3*24*60*60 ], $this->disktag);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function getDiskSpace() {
|
||||
if (!($diskSpace = getcache('diskSpace', $this->disktag))) {
|
||||
$url = $this->api_url . '/databox/get_personal_info';
|
||||
$header["content-type"] = "application/json; charset=utf-8";
|
||||
$header['authorization'] = 'Bearer ' . $this->access_token;
|
||||
$response = curl('POST', $url, '', $header);
|
||||
//error_log1(json_encode($response));
|
||||
$res = json_decode($response['body'], true)['personal_space_info'];
|
||||
$used = size_format($res['used_size']);
|
||||
$total = size_format($res['total_size']);
|
||||
$diskSpace = $used . ' / ' . $total;
|
||||
savecache('diskSpace', $diskSpace, $this->disktag);
|
||||
}
|
||||
return $diskSpace;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,853 @@
|
||||
<?php
|
||||
|
||||
class Googledrive {
|
||||
protected $access_token;
|
||||
protected $disktag;
|
||||
|
||||
function __construct($tag) {
|
||||
$this->disktag = $tag;
|
||||
$this->redirect_uri = 'https://scfonedrive.github.io';
|
||||
if (getConfig('client_id', $tag) && getConfig('client_secret', $tag)) {
|
||||
$this->client_id = getConfig('client_id', $tag);
|
||||
$this->client_secret = getConfig('client_secret', $tag);
|
||||
} else {
|
||||
$this->client_id = '106151778902-ajieetaab5ondhbvia97n4tr5k0cg8eo.apps.googleusercontent.com';
|
||||
$this->client_secret = 'LlCV-rQClzYIKCEqiVddh68G';
|
||||
}
|
||||
//$this->oauth_url = 'https://www.googleapis.com/oauth2/v4/';
|
||||
$this->oauth_url = 'https://accounts.google.com/o/oauth2/';
|
||||
$this->api_url = 'https://www.googleapis.com/drive/v3';
|
||||
$this->scope = 'https://www.googleapis.com/auth/drive';
|
||||
|
||||
$this->client_secret = urlencode($this->client_secret);
|
||||
$this->scope = urlencode($this->scope);
|
||||
//$this->DownurlStrName = '@microsoft.graph.downloadUrl';
|
||||
//$this->ext_api_url = '/me/drive/root';
|
||||
$this->driveId = getConfig('driveId', $tag);
|
||||
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
||||
}
|
||||
|
||||
public function isfine()
|
||||
{
|
||||
if (!$this->access_token) return false;
|
||||
else return true;
|
||||
}
|
||||
public function show_base_class()
|
||||
{
|
||||
return get_class();
|
||||
//$tmp[0] = get_class();
|
||||
//$tmp[1] = get_class($this);
|
||||
//return $tmp;
|
||||
}
|
||||
|
||||
public function ext_show_innerenv()
|
||||
{
|
||||
return ['driveId'];
|
||||
}
|
||||
|
||||
public function list_files($path = '/')
|
||||
{
|
||||
$files = $this->list_path($path);
|
||||
|
||||
return $this->files_format($files);
|
||||
}
|
||||
|
||||
protected function files_format($files)
|
||||
{
|
||||
if (isset($files['files']) || (isset($files['mimeType'])&&$files['mimeType']=='application/vnd.google-apps.folder') ) {
|
||||
$tmp['type'] = 'folder';
|
||||
$tmp['id'] = $files['id'];
|
||||
$tmp['name'] = $files['name'];
|
||||
$tmp['time'] = $files['modifiedTime'];
|
||||
$tmp['size'] = $files['size'];
|
||||
$tmp['childcount'] = $files['folder']['childCount'];
|
||||
$tmp['page'] = $files['folder']['page'];
|
||||
foreach ($files['files'] as $file) {
|
||||
$filename = strtolower($file['name']);
|
||||
if ($file['mimeType']=='application/vnd.google-apps.folder') {
|
||||
$tmp['list'][$filename]['type'] = 'folder';
|
||||
} else {
|
||||
$tmp['list'][$filename]['type'] = 'file';
|
||||
//var_dump($file);
|
||||
//echo $file['name'] . ':' . $this->DownurlStrName . ':' . $file[$this->DownurlStrName] . PHP_EOL;
|
||||
$tmp['list'][$filename]['url'] = ($file['downUrl']?$file['downUrl']:$file['webContentLink']);
|
||||
$tmp['list'][$filename]['mime'] = $file['mimeType'];
|
||||
}
|
||||
$tmp['list'][$filename]['id'] = $file['id'];
|
||||
$tmp['list'][$filename]['name'] = $file['name'];
|
||||
$tmp['list'][$filename]['time'] = $file['modifiedTime'];
|
||||
$tmp['list'][$filename]['size'] = $file['size'];
|
||||
}
|
||||
} elseif (isset($files['mimeType'])) {
|
||||
$tmp['type'] = 'file';
|
||||
$tmp['id'] = $files['id'];
|
||||
$tmp['name'] = $files['name'];
|
||||
$tmp['time'] = $files['modifiedTime'];
|
||||
$tmp['size'] = $files['size'];
|
||||
$tmp['mime'] = $files['mimeType'];
|
||||
$tmp['url'] = ($files['downUrl']?$files['downUrl']:$files['webContentLink']);
|
||||
$tmp['content'] = $files['content'];
|
||||
} else/*if (isset($files['error']))*/ {
|
||||
return $files;
|
||||
}
|
||||
//error_log1(json_encode($tmp));
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function list_path($path = '/')
|
||||
{
|
||||
global $exts;
|
||||
while (substr($path, -1)=='/') $path = substr($path, 0, -1);
|
||||
if ($path == '') $path = '/';
|
||||
|
||||
if (!($files = getcache('path_' . $path, $this->disktag))) {
|
||||
//$response = curl('GET', $this->api_url . '/drives', '', ['Authorization' => 'Bearer ' . $this->access_token]);
|
||||
//$response = curl('GET', $this->api_url . '/files?fields=*,files(id,name,mimeType,size,modifiedTime,parents,webContentLink,thumbnailLink),nextPageToken' . (($this->driveId!='')?'&driveId=' . $this->driveId . '&corpora=teamDrive&includeItemsFromAllDrives=true&supportsAllDrives=true':''), '', ['Authorization' => 'Bearer ' . $this->access_token]);
|
||||
if ($path == '/' || $path == '') {
|
||||
$files = $this->fileList();
|
||||
//error_log1('root_id' . $files['id']);
|
||||
//$files['id'] = 'root';
|
||||
//$files['type'] = 'folder';
|
||||
} else {
|
||||
$tmp = splitlast($path, '/');
|
||||
$parent_path = $tmp[0];
|
||||
$filename = urldecode($tmp[1]);
|
||||
$parent_folder = $this->list_path($parent_path);
|
||||
$i = 0;
|
||||
foreach ($parent_folder['files'] as $item) {
|
||||
if ($item['name']==$filename) {
|
||||
if ($item['mimeType']=='application/vnd.google-apps.folder') {
|
||||
$files = $this->fileList($item['id']);
|
||||
$files['type'] = 'folder';
|
||||
$files['id'] = $item['id'];
|
||||
$files['name'] = $item['name'];
|
||||
$files['time'] = $item['modifiedTime'];
|
||||
$files['size'] = $item['size'];
|
||||
} else {
|
||||
if (isset($item['id'])&&$item['shared']!==true) $this->permission('create', $item['id']);
|
||||
//$this->permission('delete', $files['id']);
|
||||
|
||||
//if (isset($item['mimeType']) && $item['mimeType']!='application/vnd.google-apps.folder') {
|
||||
if (in_array(splitlast($item['name'],'.')[1], $exts['txt'])) {
|
||||
if (!(isset($item['content'])&&$item['content']['stat']==200)) {
|
||||
//if (!isset($item['downUrl'])) {
|
||||
$res = curl('GET', $item['webContentLink'], '', [], 1);
|
||||
$weblink = $res['returnhead']['Location'];
|
||||
//if ($weblink!==null) $item['downUrl'] = $weblink;
|
||||
//else error_log1('Cant get link:' . json_encode($res, JSON_PRETTY_PRINT));
|
||||
//}
|
||||
if ($res['stat']==302) {
|
||||
$content1 = curl('GET', $weblink, '', ["User-Agent"=>"qkqpttgf/OneManager 3.0.0", "Accept"=>"*/*"]);
|
||||
$item['content'] = $content1;
|
||||
}// else $content1 = $res;
|
||||
//error_log1($item['name'] . '~' . json_encode($content1, JSON_PRETTY_PRINT) . PHP_EOL);
|
||||
$parent_folder['files'][$i] = $item;
|
||||
savecache('path_' . $path, $parent_folder, $this->disktag);
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
//error_log1(json_encode($item, JSON_PRETTY_PRINT));
|
||||
$files = $item;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
//echo $files['name'];
|
||||
}
|
||||
|
||||
if (!$files) {
|
||||
$files['error']['code'] = 'Not Found';
|
||||
$files['error']['message'] = 'Not Found';
|
||||
$files['error']['stat'] = 404;
|
||||
} elseif (isset($files['stat'])) {
|
||||
$files['error']['stat'] = $files['stat'];
|
||||
$files['error']['code'] = 'Error';
|
||||
$files['error']['message'] = $files['body'];
|
||||
} else {
|
||||
savecache('path_' . $path, $files, $this->disktag, 600);
|
||||
}
|
||||
}
|
||||
//error_log1('path:' . $path . ', files:' . json_encode($files, JSON_PRETTY_PRINT));
|
||||
//error_log1('path:' . $path . ', files:' . substr(json_encode($files), 0, 150));
|
||||
return $files;
|
||||
}
|
||||
protected function fileList($parent_file_id = '')
|
||||
{
|
||||
$url = $this->api_url . '/files';
|
||||
|
||||
$url .= '?fields=files(id,name,mimeType,size,modifiedTime,parents,webContentLink,thumbnailLink,shared,permissions,permissionIds),nextPageToken';
|
||||
//$url .= '?fields=files(*),nextPageToken';
|
||||
//$url .= '?q=mimeType=\'application/vnd.google-apps.folder\'';
|
||||
if ($parent_file_id!='') {
|
||||
$q = $parent_file_id;
|
||||
} else {
|
||||
$q = $this->driveId;
|
||||
}
|
||||
$q = '\'' . $q . '\' in parents and trashed = false';
|
||||
$q = urlencode($q);
|
||||
$url .= '&q=' . $q;
|
||||
if ($this->driveId!='root') $url .= '&driveId=' . $this->driveId . '&corpora=teamDrive&includeItemsFromAllDrives=true&supportsAllDrives=true';
|
||||
|
||||
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$res = curl('GET', $url, '', $header);
|
||||
if ($res['stat']==200) return json_decode($res['body'], true);
|
||||
else return $res;
|
||||
}
|
||||
protected function permission($op, $fileId)
|
||||
{
|
||||
$url = $this->api_url . '/files/' . $fileId . '/permissions';
|
||||
if ($op=='create') {
|
||||
$method = 'POST';
|
||||
$header['Content-Type'] = 'application/json';
|
||||
$tmp['role'] = 'reader';
|
||||
$tmp['type'] = 'anyone';
|
||||
$data = json_encode($tmp);
|
||||
} elseif ($op=='delete') {
|
||||
$url .= '/anyoneWithLink';
|
||||
$method = 'DELETE';
|
||||
$data = '';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$url .= '?supportsAllDrives=true';
|
||||
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$res = curl($method, $url, $data, $header);
|
||||
//error_log1('Set Share' . json_encode($res, JSON_PRETTY_PRINT));
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function Rename($file, $newname) {
|
||||
$url = $this->api_url . '/files/' . $file['id'] . '?supportsAllDrives=true';
|
||||
$tmp['name'] = $newname;
|
||||
$result = $this->GDAPI('PATCH', $url, json_encode($tmp));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Delete($file) {
|
||||
$url = $this->api_url . '/files/' . $file['id'] . '?supportsAllDrives=true';
|
||||
$result = $this->GDAPI('DELETE', $url);
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Encrypt($folder, $passfilename, $pass) {
|
||||
$existfile = $this->list_path($folder['path'] . '/' . $passfilename);
|
||||
if (isset($existfile['name'])) {
|
||||
if ($pass==='') {
|
||||
// 如果为空,删除
|
||||
$this->Delete(['id'=>$existfile['id']]);
|
||||
return output('Success', 200);
|
||||
} else {
|
||||
$result = $this->editFile($existfile['id'], $pass);
|
||||
}
|
||||
} else {
|
||||
if (!$folder['id']) {
|
||||
$res = $this->list_path($folder['path']);
|
||||
//error_log1('res:' . json_encode($res));
|
||||
$folder['id'] = $res['id'];
|
||||
}
|
||||
if (!$folder['id']) {
|
||||
$folder['id'] = $this->driveId;
|
||||
}
|
||||
$result = $this->createFile_c($folder['id'], $passfilename, $pass);
|
||||
}
|
||||
|
||||
//error_log1('2,url:' . $url .' res:' . json_encode($result));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Move($file, $folder) {
|
||||
$nowParentId = $this->list_path($file['path'])['id'];
|
||||
if (!$nowParentId) {
|
||||
$nowParentId = $this->driveId;
|
||||
}
|
||||
if (!$folder['id']) {
|
||||
$res = $this->list_path($folder['path']);
|
||||
//error_log1('res:' . json_encode($res));
|
||||
$folder['id'] = $res['id'];
|
||||
}
|
||||
if (!$folder['id']) {
|
||||
$folder['id'] = $this->driveId;
|
||||
}
|
||||
$url = $this->api_url . '/files/' . $file['id'] . '?removeParents=' . $nowParentId . '&addParents=' . $folder['id'] . '&supportsAllDrives=true';
|
||||
//$tmp['name'] = $newname;
|
||||
$result = $this->GDAPI('PATCH', $url);
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Copy($file) {
|
||||
$url = $this->api_url . '/files/' . $file['id'] . '/copy?supportsAllDrives=true';
|
||||
$namearr = splitlast($file['name'], '.');
|
||||
date_default_timezone_set('UTC');
|
||||
if ($namearr[0]!='') {
|
||||
$newname = $namearr[0] . '_' . date("Ymd\_His");
|
||||
if ($namearr[1]!='') $newname .= '.' . $namearr[1];
|
||||
} else {
|
||||
$newname = '.' . $namearr[1] . '_' . date("Ymd\_His");
|
||||
}
|
||||
$tmp['name'] = $newname;
|
||||
$result = $this->GDAPI('POST', $url, json_encode($tmp));
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Edit($file, $content) {
|
||||
$tmp = splitlast($file['path'], '/');
|
||||
$folderpath = $tmp[0];
|
||||
$filename = $tmp[1];
|
||||
$existfile = $this->list_path($file['path']);
|
||||
if (isset($existfile['name'])) {
|
||||
$result = $this->editFile($existfile['id'], $content);
|
||||
} else {
|
||||
$result = $this->createFile_c($this->list_path($folderpath)['id'], $filename, $content);
|
||||
}
|
||||
//error_log1('edit: ' . json_encode($result, JSON_PRETTY_PRINT));
|
||||
if ($result['stat']==200) return output('success', 0);
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function Create($parent, $type, $name, $content = '') {
|
||||
$filename = spurlencode($name);
|
||||
$filename = path_format($parent['path'] . '/' . $filename);
|
||||
$res = $this->list_path($filename);
|
||||
//error_log1($filename . '查重:' . json_encode($res, JSON_PRETTY_PRINT) . PHP_EOL);
|
||||
if (isset($res['name'])) {
|
||||
$tmp['error']['code'] = 'File exist';
|
||||
$tmp['error']['message'] = $res;
|
||||
$tmp['error']['stat'] = 409;
|
||||
return output(json_encode($this->files_format($tmp), JSON_PRETTY_PRINT), $tmp['error']['stat']);
|
||||
}
|
||||
if (!$parent['id']) {
|
||||
$res = $this->list_path($parent['path']);
|
||||
//error_log1('找ID:' . json_encode($res));
|
||||
$parent['id'] = $res['id'];
|
||||
}
|
||||
if (!$parent['id']) {
|
||||
$parent['id'] = $this->driveId;
|
||||
}
|
||||
|
||||
if ($type=='file') {
|
||||
$result = $this->createFile_c($parent['id'], $name, $content);
|
||||
}
|
||||
if ($type=='folder') {
|
||||
$result = $this->createFolder($parent['id'], $name);
|
||||
}
|
||||
//error_log1('data:' . $data . ' res:' . json_encode($result, JSON_PRETTY_PRINT));
|
||||
//savecache('path_' . $path1, json_decode('{}',true), $_SERVER['disktag'], 1);
|
||||
return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
|
||||
}
|
||||
public function get_thumbnails_url($path = '/') {
|
||||
$res = $this->list_path($path);
|
||||
$thumb_url = $res['thumbnailLink'];
|
||||
return $thumb_url;
|
||||
}
|
||||
public function bigfileupload($path) {
|
||||
return output('Stop!\nCan not upload form explorer without token.', 403);
|
||||
|
||||
// https://developers.google.com/drive/api/v3/manage-uploads#http---multiple-requests
|
||||
|
||||
if ($_POST['upbigfilename']=='') return output('error: no file name', 400);
|
||||
if (!is_numeric($_POST['filesize'])) return output('error: no file size', 400);
|
||||
if (!$_SERVER['admin']) if (!isset($_POST['filemd5'])) return output('error: no file md5', 400);
|
||||
$filename = $_POST['upbigfilename'];
|
||||
$filename = path_format($path . '/' . $filename);
|
||||
$res = $this->list_path($filename);
|
||||
//error_log1($filename . '查重:' . json_encode($res, JSON_PRETTY_PRINT) . PHP_EOL);
|
||||
if (isset($res['name'])) {
|
||||
$tmp['error']['code'] = 'File exist';
|
||||
$tmp['error']['message'] = json_encode($res);
|
||||
$tmp['error']['stat'] = 409;
|
||||
return output(json_encode($this->files_format($tmp), JSON_PRETTY_PRINT), $tmp['error']['stat']);
|
||||
}
|
||||
$tmp = splitlast($_POST['upbigfilename'], '/');
|
||||
if ($tmp[1]!='') {
|
||||
$fileinfo['name'] = $tmp[1];
|
||||
if ($_SERVER['admin']) $fileinfo['path'] = $tmp[0];
|
||||
} else {
|
||||
$fileinfo['name'] = $_POST['upbigfilename'];
|
||||
}
|
||||
$fileinfo['size'] = $_POST['filesize'];
|
||||
$fileinfo['filelastModified'] = $_POST['filelastModified'];
|
||||
if ($_SERVER['admin']) {
|
||||
$filename = $fileinfo['name'];
|
||||
} else {
|
||||
$tmp1 = splitlast($fileinfo['name'], '.');
|
||||
if ($tmp1[0]==''||$tmp1[1]=='') $filename = $_POST['filemd5'];
|
||||
else $filename = $_POST['filemd5'] . '.' . $tmp1[1];
|
||||
}
|
||||
$parent = $this->list_path($path . '/' . $fileinfo['path']);
|
||||
if (isset($parent['id'])) {
|
||||
$parent_file_id = $parent['id'];
|
||||
} else {
|
||||
$res = $this->createFolder($this->list_path($path)['id'], $fileinfo['path']);
|
||||
//error_log1($res['body']);
|
||||
$parent_file_id = json_decode($res['body'], true)['id'];
|
||||
}
|
||||
$url = 'https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable';
|
||||
$res = $this->list_path($path);
|
||||
//error_log1('找ID:' . json_encode($res));
|
||||
$parentId = $res['id'];
|
||||
if (!$parentId) {
|
||||
$parentId = $this->driveId;
|
||||
}
|
||||
$tmp['name'] = $_POST['upbigfilename'];
|
||||
$tmp['parents'][0] = $parentId;
|
||||
|
||||
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
||||
$header['Content-Type'] = 'application/json; charset=UTF-8';
|
||||
//$header['Content-Length'] = '';
|
||||
//$header['X-Upload-Content-Type'] = '';
|
||||
//$header['X-Upload-Content-Length'] = $_POST['filesize'];
|
||||
|
||||
$response = curl('POST', $url, json_encode($tmp), $header, 1);
|
||||
return output($response['returnhead']['Location'], $response['stat']);
|
||||
}
|
||||
|
||||
protected function editFile($id, $content) {
|
||||
$url = 'https://www.googleapis.com/upload/drive/v3/files/' . $id . '?uploadType=multipart&supportsAllDrives=true';
|
||||
|
||||
$boundary = md5($id . date());
|
||||
$header['Content-Type'] = 'multipart/related; boundary=' . $boundary;
|
||||
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
||||
$data = '--' . $boundary . "\r\n";
|
||||
$data .= 'Content-Type: application/json; charset=UTF-8' . "\r\n";
|
||||
$data .= "\r\n";
|
||||
$data .= "\r\n";
|
||||
$data .= "\r\n";
|
||||
$data .= '--' . $boundary . "\r\n";
|
||||
$data .= 'Content-Type: text/plain' . "\r\n";
|
||||
$data .= "\r\n";
|
||||
$data .= $content . "\r\n";
|
||||
$data .= '--' . $boundary . "--";
|
||||
|
||||
$result = curl('PATCH', $url, $data, $header);
|
||||
//error_log1('url: ' . $url . ' data: ' . $data . ' result: ' . json_encode($result, JSON_PRETTY_PRINT));
|
||||
return $result;
|
||||
}
|
||||
protected function createFile_c($parentId, $name, $content) {
|
||||
while (substr($name, 0, 1)=='/') $name = substr($name, 1);
|
||||
while (substr($name, -1)=='/') $name = substr($name, 0, -1);
|
||||
if (strpos($name, '/')>0) {
|
||||
$p = splitlast($name, '/');
|
||||
$res = $this->createFolder($parentId, $p[0]);
|
||||
$parentId = json_decode($res['body'], true)['id'];
|
||||
$name = $p[1];
|
||||
}
|
||||
|
||||
$url = 'https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&supportsAllDrives=true';
|
||||
$tmp['name'] = $name;
|
||||
$tmp['parents'][0] = $parentId;
|
||||
|
||||
$boundary = md5($name . date());
|
||||
$header['Content-Type'] = 'multipart/related; boundary=' . $boundary;
|
||||
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
||||
$data = '--' . $boundary . "\r\n";
|
||||
$data .= 'Content-Type: application/json; charset=UTF-8' . "\r\n";
|
||||
$data .= "\r\n";
|
||||
$data .= json_encode($tmp, JSON_PRETTY_PRINT) . "\r\n";
|
||||
$data .= "\r\n";
|
||||
$data .= '--' . $boundary . "\r\n";
|
||||
$data .= 'Content-Type: text/plain' . "\r\n";
|
||||
$data .= "\r\n";
|
||||
$data .= $content . "\r\n";
|
||||
$data .= '--' . $boundary . "--";
|
||||
|
||||
$result = curl('POST', $url, $data, $header);
|
||||
return $result;
|
||||
}
|
||||
protected function createFolder($parentId, $name) {
|
||||
while (substr($name, 0, 1)=='/') $name = substr($name, 1);
|
||||
while (substr($name, -1)=='/') $name = substr($name, 0, -1);
|
||||
if (strpos($name, '/')>0) {
|
||||
$p = splitlast($name, '/');
|
||||
$res = $this->createFolder($parentId, $p[0]);
|
||||
$parentId = json_decode($res['body'], true)['id'];
|
||||
$name = $p[1];
|
||||
}
|
||||
|
||||
$url = $this->api_url . '/files?&supportsAllDrives=true';
|
||||
|
||||
$tmp['name'] = $name;
|
||||
$tmp['parents'][0] = $parentId;
|
||||
$tmp['mimeType'] = 'application/vnd.google-apps.folder';
|
||||
$data = json_encode($tmp);
|
||||
|
||||
$header['Content-Type'] = 'application/json; charset=UTF-8';
|
||||
$header['Authorization'] = 'Bearer ' . $this->access_token;
|
||||
|
||||
$result = curl('POST', $url, $data, $header);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function AddDisk() {
|
||||
global $constStr;
|
||||
global $EnvConfigs;
|
||||
|
||||
$envs = '';
|
||||
foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
|
||||
if (isset($_GET['Finish'])) {
|
||||
if ($this->access_token == '') {
|
||||
$refresh_token = getConfig('refresh_token', $this->disktag);
|
||||
if (!$refresh_token) {
|
||||
$html = 'No refresh_token config, please AddDisk again or wait minutes.<br>' . $this->disktag;
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$response = $this->get_access_token($refresh_token);
|
||||
if (!$response) return message($this->error['body'], 'Error', $this->error['stat']);
|
||||
}
|
||||
|
||||
$tmp = null;
|
||||
if ($_POST['DriveType']=='Googledrive') {
|
||||
$tmp['driveId'] = 'root';
|
||||
} else {
|
||||
// 直接是id
|
||||
$tmp['driveId'] = $_POST['DriveType'];
|
||||
}
|
||||
|
||||
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
$str .= '<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
||||
return message($str, getconstStr('WaitJumpIndex'), 201);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['SelectDrive'])) {
|
||||
if ($this->access_token == '') {
|
||||
$refresh_token = getConfig('refresh_token', $this->disktag);
|
||||
if (!$refresh_token) {
|
||||
$html = 'No refresh_token config, please AddDisk again or wait minutes.<br>' . $this->disktag;
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$response = $this->get_access_token($refresh_token);
|
||||
if (!$response) return message($this->error['body'], 'Error', $this->error['stat']);
|
||||
}
|
||||
|
||||
$api = $this->api_url . '/drives';
|
||||
$arr = curl('GET', $api, '', [ 'Authorization' => 'Bearer ' . $this->access_token ]);
|
||||
//if (!($arr['stat']==200||$arr['stat']==403||$arr['stat']==400||$arr['stat']==404))
|
||||
if ($arr['stat']!=200) return message($arr['stat'] . json_encode(json_decode($arr['body']), JSON_PRETTY_PRINT), 'Get followedSites', $arr['stat']);
|
||||
error_log1($arr['body']);
|
||||
$drives = json_decode($arr['body'], true)['drives'];
|
||||
|
||||
$title = 'Select Driver';
|
||||
$html = '
|
||||
<div>
|
||||
<form action="?Finish&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);">
|
||||
<label><input type="radio" name="DriveType" value="Googledrive" checked>' . 'Use Googledrive ' . getconstStr(' ') . '</label><br>';
|
||||
if ($drives[0]!='') foreach ($drives as $k => $v) {
|
||||
$html .= '
|
||||
<label>
|
||||
<input type="radio" name="DriveType" value="' . $v['id'] . '" onclick="document.getElementById(\'sharepointSiteUrl\').value=\'' . $v['webUrl'] . '\';">' . 'Use Google share drive: <br><div style="width:100%;margin:0px 35px">: ' . $v['name'] . '<br>siteid: ' . $v['id'] . '</div>
|
||||
</label>';
|
||||
}
|
||||
$html .= '
|
||||
<input type="submit" value="' . getconstStr('Submit') . '">
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.DriveType.value==\'\') {
|
||||
alert(\'Select a Disk\');
|
||||
return false;
|
||||
}
|
||||
if (t.DriveType.value==\'Custom\') {
|
||||
if (t.sharepointSite.value==\'\') {
|
||||
alert(\'sharepoint Site Address\');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
if (isset($_GET['install2']) && isset($_GET['code'])) {
|
||||
$data['client_id'] = $this->client_id;
|
||||
$data['client_secret'] = $this->client_secret;
|
||||
$data['grant_type'] = 'authorization_code';
|
||||
$data['redirect_uri'] = $this->redirect_uri;
|
||||
$data['code'] = $_GET['code'];
|
||||
$api = $this->oauth_url . 'token';
|
||||
//$api = 'https://www.googleapis.com/oauth2/v4/token';
|
||||
$tmp = curl('POST',
|
||||
$api,
|
||||
json_encode($data)
|
||||
);
|
||||
if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true);
|
||||
if (isset($ret['refresh_token'])) {
|
||||
$refresh_token = $ret['refresh_token'];
|
||||
$str = '
|
||||
refresh_token :<br>';
|
||||
$str .= '
|
||||
<textarea readonly style="width: 95%">' . $refresh_token . '</textarea><br><br>
|
||||
' . getconstStr('SavingToken') . '
|
||||
<script>
|
||||
var texta=document.getElementsByTagName(\'textarea\');
|
||||
for(i=0;i<texta.length;i++) {
|
||||
texta[i].style.height = texta[i].scrollHeight + \'px\';
|
||||
}
|
||||
</script>';
|
||||
$tmptoken['refresh_token'] = $refresh_token;
|
||||
//$tmptoken['token_expires'] = time()+7*24*60*60;
|
||||
$response = setConfigResponse( setConfig($tmptoken, $this->disktag) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60);
|
||||
$str .= '
|
||||
<meta http-equiv="refresh" content="3;URL=' . $url . '?AddDisk=' . get_class($this) . '&disktag=' . $_GET['disktag'] . '&SelectDrive">';
|
||||
return message($str, getconstStr('Wait') . ' 3s', 201);
|
||||
}
|
||||
}
|
||||
return message('<pre>' . $tmp['body'] . '</pre>', $tmp['stat']);
|
||||
//return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
|
||||
}
|
||||
|
||||
if (isset($_GET['install1'])) {
|
||||
if (get_class($this)=='Googledrive') {
|
||||
return message('
|
||||
<a href="" id="a1">' . getconstStr('JumptoOffice') . '</a>
|
||||
<script>
|
||||
url=location.protocol + "//" + location.host + "' . $url . '?install2&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '";
|
||||
url="' . $this->oauth_url . 'auth?scope=' . $this->scope . '&response_type=code&client_id=' . $this->client_id . '&redirect_uri=' . $this->redirect_uri . '&access_type=offline&state=' . '"+encodeURIComponent(url);
|
||||
document.getElementById(\'a1\').href=url;
|
||||
//window.open(url,"_blank");
|
||||
location.href = url;
|
||||
</script>
|
||||
', getconstStr('Wait') . ' 1s', 201);
|
||||
} else {
|
||||
return message('Something error, retry after a few seconds.', 'Retry', 201);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['install0'])) {
|
||||
if ($_POST['disktag_add']!='') {
|
||||
$_POST['disktag_add'] = preg_replace('/[^0-9a-zA-Z|_]/i', '', $_POST['disktag_add']);
|
||||
$f = substr($_POST['disktag_add'], 0, 1);
|
||||
if (strlen($_POST['disktag_add'])==1) $_POST['disktag_add'] .= '_';
|
||||
if (isCommonEnv($_POST['disktag_add'])) {
|
||||
return message('Do not input ' . $envs . '<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>', 'Error', 201);
|
||||
} elseif (!(('a'<=$f && $f<='z') || ('A'<=$f && $f<='Z'))) {
|
||||
return message('Please start with letters<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+1);
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'disktag=; path=/; \'+expires;
|
||||
</script>', 'Error', 201);
|
||||
}
|
||||
|
||||
$tmp = null;
|
||||
// clear envs
|
||||
foreach ($EnvConfigs as $env => $v) if (isInnerEnv($env)) $tmp[$env] = '';
|
||||
|
||||
//$this->disktag = $_POST['disktag_add'];
|
||||
$tmp['disktag_add'] = $_POST['disktag_add'];
|
||||
$tmp['diskname'] = $_POST['diskname'];
|
||||
$tmp['Driver'] = 'Googledrive';
|
||||
|
||||
if ($_POST['NT_Drive_custom']=='on') {
|
||||
$tmp['client_id'] = $_POST['NT_client_id'];
|
||||
$tmp['client_secret'] = $_POST['NT_client_secret'];
|
||||
}
|
||||
|
||||
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
} else {
|
||||
$title = getconstStr('MayinEnv');
|
||||
$html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=Googledrive">';
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
|
||||
$html = '
|
||||
<div>
|
||||
<form id="form1" action="" method="post" onsubmit="return notnull(this);">
|
||||
' . getconstStr('DiskTag') . ': (' . getConfig('disktag') . ')
|
||||
<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
|
||||
' . getconstStr('DiskName') . ':
|
||||
<input type="text" name="diskname" placeholder="' . getconstStr('EnvironmentsDescription')['diskname'] . '" style="width:100%"><br>
|
||||
<br>
|
||||
<div>
|
||||
<label><input type="checkbox" name="NT_Drive_custom" onclick="document.getElementById(\'NT_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br>
|
||||
<div id="NT_secret" style="display:none;margin:10px 35px">
|
||||
<a href="https://console.cloud.google.com/apis" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br>
|
||||
return_uri(Reply URL):<br>https://scfonedrive.github.io<br>
|
||||
client_id:<input type="text" name="NT_client_id" style="width:100%" placeholder="123456789-abcdefghijklmno.apps.googleusercontent.com"><br>
|
||||
client_secret:<input type="text" name="NT_client_secret" style="width:100%"><br>
|
||||
</div>
|
||||
</div>
|
||||
<br>';
|
||||
if ($_SERVER['language']=='zh-cn') $html .= '你要理解 scfonedrive.github.io 是github上的静态网站,<br><font color="red">除非github真的挂掉</font>了,<br>不然,稍后你如果连不上,请检查你的运营商或其它“你懂的”问题!<br>';
|
||||
$html .='
|
||||
<input type="submit" value="' . getconstStr('Submit') . '">
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.disktag_add.value==\'\') {
|
||||
alert(\'' . getconstStr('DiskTag') . '\');
|
||||
return false;
|
||||
}
|
||||
envs = [' . $envs . '];
|
||||
if (envs.indexOf(t.disktag_add.value)>-1) {
|
||||
alert("Do not input ' . $envs . '");
|
||||
return false;
|
||||
}
|
||||
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
|
||||
if (!reg.test(t.disktag_add.value)) {
|
||||
alert(\'' . getconstStr('TagFormatAlert') . '\');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (t.NT_Drive_custom.checked==true) {
|
||||
if (t.NT_client_secret.value==\'\'||t.NT_client_id.value==\'\') {
|
||||
alert(\'client_id & client_secret\');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=Googledrive";
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = 'Select Account Type';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
protected function get_access_token($refresh_token) {
|
||||
if (!$refresh_token) {
|
||||
$tmp['stat'] = 0;
|
||||
$tmp['body'] = 'No refresh_token';
|
||||
$this->error = $tmp;
|
||||
return false;
|
||||
}
|
||||
if (!($this->access_token = getcache('access_token', $this->disktag))) {
|
||||
$p=0;
|
||||
$data['client_id'] = $this->client_id;
|
||||
$data['client_secret'] = $this->client_secret;
|
||||
$data['grant_type'] = 'refresh_token';
|
||||
//$data['redirect_uri'] = $this->redirect_uri;
|
||||
$data['refresh_token'] = $refresh_token;
|
||||
while ($response['stat']==0&&$p<3) {
|
||||
//$response = curl('POST', 'https://www.googleapis.com/oauth2/v4/token', json_encode($data));
|
||||
$response = curl('POST', $this->oauth_url . 'token', json_encode($data));
|
||||
$p++;
|
||||
}
|
||||
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
||||
if (!isset($ret['access_token'])) {
|
||||
error_log1($this->oauth_url . 'token' . '?client_id=' . $this->client_id . '&client_secret=' . $this->client_secret . '&grant_type=refresh_token&refresh_token=' . substr($refresh_token, 0, 20) . '******' . substr($refresh_token, -20));
|
||||
error_log1('failed to get [' . $this->disktag . '] access_token. response: ' . $response['body']);
|
||||
$response['body'] = json_encode(json_decode($response['body']), JSON_PRETTY_PRINT);
|
||||
$response['body'] .= '\nfailed to get [' . $this->disktag . '] access_token.';
|
||||
$this->error = $response;
|
||||
return false;
|
||||
//throw new Exception($response['stat'].', failed to get ['.$this->disktag.'] access_token.'.$response['body']);
|
||||
}
|
||||
$tmp = $ret;
|
||||
$tmp['access_token'] = substr($tmp['access_token'], 0, 10) . '******';
|
||||
//$tmp['refresh_token'] = substr($tmp['refresh_token'], 0, 10) . '******';
|
||||
error_log1('[' . $this->disktag . '] Get access token:' . json_encode($tmp, JSON_PRETTY_PRINT));
|
||||
$this->access_token = $ret['access_token'];
|
||||
savecache('access_token', $this->access_token, $this->disktag, $ret['expires_in'] - 300);
|
||||
//if (time()>getConfig('token_expires', $this->disktag)) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ], $this->disktag);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function getDiskSpace() {
|
||||
if ($this->driveId!='root') return '0 / 0';
|
||||
if (!($diskSpace = getcache('diskSpace', $this->disktag))) {
|
||||
$url = $this->api_url . '/about?fields=storageQuota';
|
||||
$response = $this->GDAPI('GET', $url);
|
||||
if ($response['stat']==200) {
|
||||
$res = json_decode($response['body'], true)['storageQuota'];
|
||||
$used = size_format($res['usage']);
|
||||
$total = size_format($res['limit']);
|
||||
$diskSpace = $used . ' / ' . $total;
|
||||
savecache('diskSpace', $diskSpace, $this->disktag);
|
||||
} else return json_encode($response);
|
||||
}
|
||||
return $diskSpace;
|
||||
}
|
||||
|
||||
protected function GDAPI($method, $url, $data = '')
|
||||
{
|
||||
/*if (substr($path,0,7) == 'http://' or substr($path,0,8) == 'https://') {
|
||||
$url = $path;
|
||||
} else {
|
||||
$url = $this->api_url;
|
||||
if ($path=='' or $path=='/') {
|
||||
$url .= '/';
|
||||
} else {
|
||||
$url .= ':' . $path;
|
||||
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
||||
}
|
||||
if ($method=='PUT') {
|
||||
if ($path=='' or $path=='/') {
|
||||
$url .= 'content';
|
||||
} else {
|
||||
$url .= ':/content';
|
||||
}
|
||||
$headers['Content-Type'] = 'text/plain';
|
||||
} elseif ($method=='PATCH') {
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
} elseif ($method=='POST') {
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
} elseif ($method=='DELETE') {
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
} else {
|
||||
if ($path=='' or $path=='/') {
|
||||
$url .= $method;
|
||||
} else {
|
||||
$url .= ':/' . $method;
|
||||
}
|
||||
$method='POST';
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
}*/
|
||||
$headers['Authorization'] = 'Bearer ' . $this->access_token;
|
||||
if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;*
|
||||
$sendHeaders = array();
|
||||
foreach ($headers as $headerName => $headerVal) {
|
||||
$sendHeaders[] = $headerName . ': ' . $headerVal;
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
||||
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);
|
||||
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
|
||||
$response['body'] = curl_exec($ch);
|
||||
$response['stat'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
//$response['Location'] = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
/*error_log1($response['stat'].'
|
||||
' . $response['body'].'
|
||||
' . $url.'
|
||||
' . $data);*/
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
+1007
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
if (!class_exists('Onedrive')) require 'Onedrive.php';
|
||||
|
||||
class OnedriveCN extends Onedrive {
|
||||
|
||||
function __construct($tag) {
|
||||
$this->disktag = $tag;
|
||||
$this->redirect_uri = 'https://scfonedrive.github.io';
|
||||
if (getConfig('client_id', $tag) && getConfig('client_secret', $tag)) {
|
||||
$this->client_id = getConfig('client_id', $tag);
|
||||
$this->client_secret = getConfig('client_secret', $tag);
|
||||
} else {
|
||||
$this->client_id = '31f3bed5-b9d9-4173-86a4-72c73d278617';
|
||||
$this->client_secret = 'P5-ZNtFK-tT90J.We_-DcsuB8uV7AfjL8Y';
|
||||
}
|
||||
$this->oauth_url = 'https://login.partner.microsoftonline.cn/common/oauth2/v2.0/';
|
||||
$this->api_url = 'https://microsoftgraph.chinacloudapi.cn/v1.0';
|
||||
$this->scope = 'https://microsoftgraph.chinacloudapi.cn/Files.ReadWrite.All https://microsoftgraph.chinacloudapi.cn/Sites.ReadWrite.All offline_access';
|
||||
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
||||
|
||||
$this->client_secret = urlencode($this->client_secret);
|
||||
$this->scope = urlencode($this->scope);
|
||||
$this->DownurlStrName = '@microsoft.graph.downloadUrl';
|
||||
$this->ext_api_url = '/me/drive/root';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
if (!class_exists('Onedrive')) require 'Onedrive.php';
|
||||
|
||||
class Sharelink extends Onedrive {
|
||||
|
||||
function __construct($tag) {
|
||||
$this->disktag = $tag;
|
||||
$this->redirect_uri = 'https://scfonedrive.github.io';
|
||||
$this->api_url = getConfig('shareapiurl', $tag);
|
||||
$res = $this->get_access_token(1);
|
||||
//$this->ext_api_url = '/me/drive/root';
|
||||
$this->DownurlStrName = '@content.downloadUrl';
|
||||
}
|
||||
|
||||
public function ext_show_innerenv()
|
||||
{
|
||||
return [ 'shareurl' ];
|
||||
}
|
||||
|
||||
protected function get_access_token($refresh_token) {
|
||||
if (!($this->access_token = getcache('access_token', $this->disktag))) {
|
||||
$shareurl = getConfig('shareurl', $this->disktag);
|
||||
if (!($this->sharecookie = getcache('sharecookie', $this->disktag))) {
|
||||
$res = curl('GET', $shareurl, '', [], 1);
|
||||
error_log1(json_encode($res, JSON_PRETTY_PRINT));
|
||||
if (isset($res['returnhead']['Set-Cookie'])) $this->sharecookie = $res['returnhead']['Set-Cookie'];
|
||||
if (isset($res['returnhead']['set-cookie'])) $this->sharecookie = $res['returnhead']['set-cookie'];
|
||||
if ($this->sharecookie=='') {
|
||||
$this->error = $res;
|
||||
return false;
|
||||
}
|
||||
savecache('sharecookie', $this->sharecookie, $this->disktag);
|
||||
}
|
||||
$tmp1 = splitlast($shareurl, '/')[0];
|
||||
$account = splitlast($tmp1, '/')[1];
|
||||
$domain = splitlast($shareurl, '/:')[0];
|
||||
$response = curl('POST',
|
||||
$domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE",
|
||||
'{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"RenderOptions":136967,"AllowMultipleValueFilterForTaxonomyFields":true,"AddRequiredFields":true}}',
|
||||
[ 'Accept' => 'application/json;odata=verbose', 'Content-Type' => 'application/json;odata=verbose', 'origin' => $domain, 'Cookie' => $this->sharecookie ]
|
||||
);
|
||||
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
||||
$this->access_token = splitlast($ret['ListSchema']['.driveAccessToken'],'=')[1];
|
||||
$this->api_url = $ret['ListSchema']['.driveUrl'].'/root';
|
||||
if (!$this->access_token) {
|
||||
error_log1($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
|
||||
error_log1('failed to get share access_token. response' . json_encode($ret));
|
||||
//$response['body'] = json_encode(json_decode($response['body']), JSON_PRETTY_PRINT);
|
||||
$response['body'] .= '<br>' .json_decode($response['body'], true)['error']['message']['value'];
|
||||
$response['body'] .= '<br>failed to get shareurl access_token.';
|
||||
$this->error = $response;
|
||||
return false;
|
||||
//throw new Exception($response['stat'].', failed to get share access_token.'.$response['body']);
|
||||
}
|
||||
//$tmp = $ret;
|
||||
//$tmp['access_token'] = '******';
|
||||
//error_log1('['.$this->disktag.'] Get access token:'.json_encode($tmp, JSON_PRETTY_PRINT));
|
||||
savecache('access_token', $this->access_token, $this->disktag);
|
||||
$tmp1 = null;
|
||||
if (getConfig('shareapiurl', $this->disktag)!=$this->api_url) $tmp1['shareapiurl'] = $this->api_url;
|
||||
//if (getConfig('sharecookie', $this->disktag)!=$this->sharecookie) $tmp1['sharecookie'] = $this->sharecookie;
|
||||
if (!!$tmp1) setConfig($tmp1, $this->disktag);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
if (!class_exists('Onedrive')) require 'Onedrive.php';
|
||||
|
||||
class Sharepoint extends Onedrive {
|
||||
|
||||
function __construct($tag) {
|
||||
$this->disktag = $tag;
|
||||
$this->redirect_uri = 'https://scfonedrive.github.io';
|
||||
if (getConfig('client_id', $tag) && getConfig('client_secret', $tag)) {
|
||||
$this->client_id = getConfig('client_id', $tag);
|
||||
$this->client_secret = getConfig('client_secret', $tag);
|
||||
} else {
|
||||
$this->client_id = '734ef928-d74c-4555-8d1b-d942fa0a1a41';
|
||||
$this->client_secret = '_I5gOpmG5vTC2Ts_K._wCW4nN1km~4Pk52';
|
||||
}
|
||||
$this->oauth_url = 'https://login.microsoftonline.com/common/oauth2/v2.0/';
|
||||
$this->api_url = 'https://graph.microsoft.com/v1.0';
|
||||
$this->scope = 'https://graph.microsoft.com/Files.ReadWrite.All https://graph.microsoft.com/Sites.ReadWrite.All offline_access';
|
||||
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
||||
|
||||
$this->client_secret = urlencode($this->client_secret);
|
||||
$this->scope = urlencode($this->scope);
|
||||
$this->DownurlStrName = '@microsoft.graph.downloadUrl';
|
||||
$this->ext_api_url = '/sites/' . getConfig('siteid', $tag) . '/drive/root';
|
||||
}
|
||||
|
||||
public function ext_show_innerenv()
|
||||
{
|
||||
return [ 'sharepointSite', 'siteid' ];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
if (!class_exists('Onedrive')) require 'Onedrive.php';
|
||||
|
||||
class SharepointCN extends Onedrive {
|
||||
|
||||
function __construct($tag) {
|
||||
$this->disktag = $tag;
|
||||
$this->redirect_uri = 'https://scfonedrive.github.io';
|
||||
if (getConfig('client_id', $tag) && getConfig('client_secret', $tag)) {
|
||||
$this->client_id = getConfig('client_id', $tag);
|
||||
$this->client_secret = getConfig('client_secret', $tag);
|
||||
} else {
|
||||
$this->client_id = '31f3bed5-b9d9-4173-86a4-72c73d278617';
|
||||
$this->client_secret = 'P5-ZNtFK-tT90J.We_-DcsuB8uV7AfjL8Y';
|
||||
}
|
||||
$this->oauth_url = 'https://login.partner.microsoftonline.cn/common/oauth2/v2.0/';
|
||||
$this->api_url = 'https://microsoftgraph.chinacloudapi.cn/v1.0';
|
||||
$this->scope = 'https://microsoftgraph.chinacloudapi.cn/Files.ReadWrite.All https://microsoftgraph.chinacloudapi.cn/Sites.ReadWrite.All offline_access';
|
||||
$res = $this->get_access_token(getConfig('refresh_token', $tag));
|
||||
|
||||
$this->client_secret = urlencode($this->client_secret);
|
||||
$this->scope = urlencode($this->scope);
|
||||
$this->DownurlStrName = '@microsoft.graph.downloadUrl';
|
||||
$this->ext_api_url = '/sites/' . getConfig('siteid', $tag) . '/drive/root';
|
||||
}
|
||||
|
||||
public function ext_show_innerenv()
|
||||
{
|
||||
return [ 'sharepointSite', 'siteid' ];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
//error_reporting(E_ALL & ~E_NOTICE);
|
||||
error_reporting(0);
|
||||
include 'vendor/autoload.php';
|
||||
include 'conststr.php';
|
||||
include 'common.php';
|
||||
@@ -15,8 +16,6 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
||||
//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') {
|
||||
include 'platform/Heroku.php';
|
||||
@@ -136,28 +135,3 @@ function handler($event, $context)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
+72
-23
@@ -28,7 +28,6 @@ function GetGlobalVariable($event)
|
||||
$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)
|
||||
@@ -52,22 +51,31 @@ function GetPathSetting($event, $context)
|
||||
$_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];
|
||||
if (isset($event['headers']['Authorization'])) {
|
||||
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['Authorization'][0], 'Basic ')[1]), ':');
|
||||
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
|
||||
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
|
||||
}
|
||||
$_SERVER['HTTP_HOST'] = $event['headers']['Host'][0];
|
||||
$_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto'][0];
|
||||
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
//if ($_SERVER['HTTP_REFERER']!='')
|
||||
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2];
|
||||
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if (isInnerEnv($str)) {
|
||||
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]);
|
||||
if (isBase64Env($str)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
if (isBase64Env($str)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
@@ -75,29 +83,36 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$disktags = explode("|", getConfig('disktag'));
|
||||
$diskconfig = json_decode(getenv($disktag), true);
|
||||
$tmp = [];
|
||||
$indisk = 0;
|
||||
$oparetdisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$tmp[$newtag] = getConfig($v);
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
$tmp[$k] = json_encode($v);
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -105,11 +120,22 @@ function setConfig($arr, $disktag = '')
|
||||
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'] = '';
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$tmp['disktag'] = implode('|', $tags);
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
@@ -237,7 +263,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -313,7 +339,8 @@ function updateEnvironment($Envs, $accountId, $region, $service_name, $function_
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
//ksort($tmp_env);
|
||||
sortConfig($tmp_env);
|
||||
|
||||
$tmpdata['environmentVariables'] = $tmp_env;
|
||||
return FCAPI2016($config, 'PUT', json_encode($tmpdata));
|
||||
@@ -449,3 +476,25 @@ function addFileToZip($zip, $rootpath, $path = '')
|
||||
}
|
||||
@closedir($path);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
+51
-24
@@ -26,9 +26,6 @@ function GetGlobalVariable($event)
|
||||
$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)
|
||||
@@ -42,22 +39,33 @@ function GetPathSetting($event, $context)
|
||||
$_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'];
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['User-Agent'];
|
||||
if (isset($event['headers']['authorization'])) {
|
||||
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['authorization'], 'Basic ')[1]), ':');
|
||||
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
|
||||
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
|
||||
}
|
||||
$_SERVER['HTTP_HOST'] = $event['headers']['Host'];
|
||||
$_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto'];
|
||||
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
//if ($_SERVER['HTTP_REFERER']!='')
|
||||
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'])[2];
|
||||
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||
$_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if (isInnerEnv($str)) {
|
||||
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]);
|
||||
if (isBase64Env($str)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
if (isBase64Env($str)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
@@ -65,29 +73,36 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
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;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$tmp[$newtag] = getConfig($v);
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
$tmp[$k] = json_encode($v);
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -95,11 +110,22 @@ function setConfig($arr, $disktag = '')
|
||||
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'] = '';
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$tmp['disktag'] = implode('|', $tags);
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
@@ -224,7 +250,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -294,7 +320,8 @@ function updateEnvironment($Envs, $SecretId, $SecretKey)
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
//ksort($tmp_env);
|
||||
sortConfig($tmp_env);
|
||||
|
||||
$tmp['Environment']['Variables'] = $tmp_env;
|
||||
$data = json_encode($tmp);
|
||||
|
||||
+113
-42
@@ -2,8 +2,35 @@
|
||||
|
||||
function getpath()
|
||||
{
|
||||
if (getConfig('function_name') && getConfig('APIKey')) {
|
||||
$APIKey = getConfig('APIKey');
|
||||
$res = HerokuAPI('GET', 'https://api.heroku.com/apps/' . getConfig('function_name'), '', $APIKey);
|
||||
$response = json_decode($res['body'], true);
|
||||
if (isset($response['build_stack'])) {
|
||||
$tmp['HerokuappId'] = $response['id'];
|
||||
$tmp['function_name'] = null;
|
||||
} else {
|
||||
error_log1('Something error' . 'Get Heroku app id: ' . json_encode($res, JSON_PRETTY_PRINT));
|
||||
//return message('Get Heroku app id: ' . json_encode($res, JSON_PRETTY_PRINT), 'Something error', 500);
|
||||
}
|
||||
$response = json_decode(setHerokuConfig($tmp, $tmp['HerokuappId'], $APIKey)['body'], true);
|
||||
$title = 'Change function_name to HerokuappId';
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$stat = 500;
|
||||
error_log1('Change function_name to HerokuappId' . $html);
|
||||
} else {
|
||||
$html = getconstStr('Wait') . ' 5s, jump to index.
|
||||
<meta http-equiv="refresh" content="5;URL=/">';
|
||||
$stat = 201;
|
||||
}
|
||||
//return message($html, $title, $stat);
|
||||
}
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
$_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_X_FORWARDED_PROTO'];
|
||||
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
|
||||
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||
@@ -15,6 +42,24 @@ function getpath()
|
||||
|
||||
function getGET()
|
||||
{
|
||||
//error_log1('POST:' . json_encode($_POST));
|
||||
if (!$_POST) {
|
||||
if (!!$HTTP_RAW_POST_DATA) {
|
||||
$tmpdata = $HTTP_RAW_POST_DATA;
|
||||
//error_log1('RAW:' . $tmpdata);
|
||||
} else {
|
||||
$tmpdata = file_get_contents('php://input');
|
||||
//error_log1('PHPINPUT:' . $tmpdata);
|
||||
}
|
||||
if (!!$tmpdata) {
|
||||
$postbody = explode("&", $tmpdata);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
//error_log1('POSTformPHPINPUT:' . json_encode($_POST));
|
||||
}
|
||||
}
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) {
|
||||
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
|
||||
@@ -40,17 +85,15 @@ function getGET()
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if (isInnerEnv($str)) {
|
||||
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]);
|
||||
if (isBase64Env($str)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
if (isBase64Env($str)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
@@ -58,29 +101,36 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
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;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$tmp[$newtag] = getConfig($v);
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
$tmp[$k] = json_encode($v);
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -88,16 +138,27 @@ function setConfig($arr, $disktag = '')
|
||||
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'] = '';
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$tmp['disktag'] = implode('|', $tags);
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = null;
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = null;
|
||||
}
|
||||
}
|
||||
foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey'));
|
||||
|
||||
return setHerokuConfig($tmp, getConfig('HerokuappId'), getConfig('APIKey'));
|
||||
error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($tmp, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
function install()
|
||||
@@ -113,15 +174,25 @@ function install()
|
||||
$APIKey = $_POST['APIKey'];
|
||||
$tmp['APIKey'] = $APIKey;
|
||||
}
|
||||
$function_name = getConfig('function_name');
|
||||
if ($function_name=='') {
|
||||
$tmp1 = substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], '.'));
|
||||
$maindomain = substr($tmp1, strrpos($tmp1, '.')+1);
|
||||
if ($maindomain=='herokuapp') $function_name = substr($tmp1, 0, strrpos($tmp1, '.'));
|
||||
else $function_name = 'visit from xxxx.herokuapp.com';
|
||||
$tmp['function_name'] = $function_name;
|
||||
}
|
||||
$response = json_decode(setHerokuConfig($tmp, $function_name, $APIKey)['body'], true);
|
||||
$HerokuappId = getConfig('HerokuappId');
|
||||
if ($HerokuappId=='') {
|
||||
$function_name = getConfig('function_name');
|
||||
if ($function_name=='') {
|
||||
$tmp1 = substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], '.'));
|
||||
$maindomain = substr($tmp1, strrpos($tmp1, '.')+1);
|
||||
if ($maindomain=='herokuapp') $function_name = substr($tmp1, 0, strrpos($tmp1, '.'));
|
||||
else return message('Please visit from xxxx.herokuapp.com', '', 500);
|
||||
$res = HerokuAPI('GET', 'https://api.heroku.com/apps/' . $function_name, '', $APIKey);
|
||||
$response = json_decode($res['body'], true);
|
||||
if (isset($response['build_stack'])) {
|
||||
$HerokuappId = $response['id'];
|
||||
} else {
|
||||
return message('Get Heroku app id: ' . json_encode($res, JSON_PRETTY_PRINT), 'Something error', 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
$tmp['HerokuappId'] = $HerokuappId;
|
||||
$response = json_decode(setHerokuConfig($tmp, $HerokuappId, $APIKey)['body'], true);
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
@@ -129,7 +200,7 @@ function install()
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
expd.setTime(expd.getTime()+1000);
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
@@ -188,7 +259,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -205,7 +276,7 @@ function HerokuAPI($method, $url, $data = '', $apikey)
|
||||
foreach ($headers as $headerName => $headerVal) {
|
||||
$sendHeaders[] = $headerName . ': ' . $headerVal;
|
||||
}
|
||||
error_log($method . $url . $data . $apikey);
|
||||
error_log1($method . $url . $data . $apikey);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
|
||||
@@ -220,28 +291,28 @@ function HerokuAPI($method, $url, $data = '', $apikey)
|
||||
$response['body'] = curl_exec($ch);
|
||||
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
error_log($response['stat'].'
|
||||
error_log1($response['stat'].'
|
||||
'.$response['body'].'
|
||||
');
|
||||
return $response;
|
||||
}
|
||||
|
||||
function getHerokuConfig($function_name, $apikey)
|
||||
function getHerokuConfig($HerokuappId, $apikey)
|
||||
{
|
||||
return HerokuAPI('GET', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', '', $apikey);
|
||||
return HerokuAPI('GET', 'https://api.heroku.com/apps/' . $HerokuappId . '/config-vars', '', $apikey);
|
||||
}
|
||||
|
||||
function setHerokuConfig($env, $function_name, $apikey)
|
||||
function setHerokuConfig($env, $HerokuappId, $apikey)
|
||||
{
|
||||
$data = json_encode($env);
|
||||
return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
|
||||
if (substr($data, 0, 1)=='{') return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $HerokuappId . '/config-vars', $data, $apikey);
|
||||
}
|
||||
|
||||
function updateHerokuapp($function_name, $apikey, $source)
|
||||
function updateHerokuapp($HerokuappId, $apikey, $source)
|
||||
{
|
||||
$tmp['source_blob']['url'] = $source;
|
||||
$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/' . $HerokuappId . '/builds', $data, $apikey);
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
@@ -261,7 +332,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
|
||||
{
|
||||
//'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);
|
||||
return updateHerokuapp(getConfig('HerokuappId'), getConfig('APIKey'), $source);
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
|
||||
+50
-24
@@ -39,9 +39,6 @@ function GetGlobalVariable($event)
|
||||
$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)
|
||||
@@ -64,23 +61,33 @@ function GetPathSetting($event, $context)
|
||||
$_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'];
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
if (isset($event['headers']['authorization'])) {
|
||||
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['authorization'], 'Basic ')[1]), ':');
|
||||
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
|
||||
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
|
||||
}
|
||||
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
|
||||
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
//if ($_SERVER['HTTP_REFERER']!='')
|
||||
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
|
||||
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
global $contextUserData;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if (isInnerEnv($str)) {
|
||||
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]);
|
||||
if (isBase64Env($str)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($contextUserData->getUserData($str));
|
||||
if (isBase64Env($str)) return base64y_decode($contextUserData->getUserData($str));
|
||||
else return $contextUserData->getUserData($str);
|
||||
}
|
||||
return '';
|
||||
@@ -88,30 +95,37 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
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;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$tmp[$newtag] = getConfig($v);
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
$tmp[$k] = json_encode($v);
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -119,11 +133,22 @@ function setConfig($arr, $disktag = '')
|
||||
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'] = '';
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$tmp['disktag'] = implode('|', $tags);
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
@@ -270,7 +295,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -349,7 +374,8 @@ function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
//ksort($tmp_env);
|
||||
sortConfig($tmp_env);
|
||||
|
||||
$tmpdata['handler'] = 'index.handler';
|
||||
$tmpdata['memory_size'] = $contextUserData->getMemorySize()+1-1;
|
||||
|
||||
+65
-34
@@ -39,9 +39,6 @@ function GetGlobalVariable($event)
|
||||
$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)
|
||||
@@ -64,28 +61,40 @@ function GetPathSetting($event, $context)
|
||||
$_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'];
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
if (isset($event['headers']['authorization'])) {
|
||||
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['authorization'], 'Basic ')[1]), ':');
|
||||
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
|
||||
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
|
||||
}
|
||||
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
|
||||
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
//if ($_SERVER['HTTP_REFERER']!='')
|
||||
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
|
||||
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
|
||||
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);
|
||||
|
||||
global $slash;
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
||||
$s = file_get_contents($configPath);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') {
|
||||
$envs = json_decode($configs, true);
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if (isInnerEnv($str)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
if (isset($envs[$disktag][$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||
if (isBase64Env($str)) 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]);
|
||||
if (isBase64Env($str)) return base64y_decode($envs[$str]);
|
||||
else return $envs[$str];
|
||||
}
|
||||
}
|
||||
@@ -95,20 +104,23 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
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);
|
||||
global $slash;
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
||||
$s = file_get_contents($configPath);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
|
||||
else $envs[$disktag][$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
@@ -118,9 +130,15 @@ function setConfig($arr, $disktag = '')
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$envs[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$envs[$newtag] = $envs[$v];
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
$envs[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -130,13 +148,24 @@ function setConfig($arr, $disktag = '')
|
||||
$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'] = '';
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$envs['disktag'] = implode('|', $tags);
|
||||
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
|
||||
$envs[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
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);
|
||||
//ksort($envs);
|
||||
$response = updateEnvironment($envs, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
|
||||
return $response;
|
||||
}
|
||||
@@ -280,7 +309,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -340,7 +369,7 @@ function getfunctioncode($HW_urn, $HW_key, $HW_secret)
|
||||
' . '/' . $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' => '' ]);
|
||||
$response = curl('GET', $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'];
|
||||
@@ -369,9 +398,8 @@ function copyFolder($from, $to)
|
||||
|
||||
function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
|
||||
sortConfig($Envs);
|
||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||
global $contextUserData;
|
||||
$source = '/tmp/code.zip';
|
||||
$outPath = '/tmp/code/';
|
||||
$oldcode = '/tmp/oldcode.zip';
|
||||
@@ -384,7 +412,7 @@ function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
// 将配置写入
|
||||
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||
$aftstr = PHP_EOL . '\';';
|
||||
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
file_put_contents($outPath . '.data/config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
@@ -399,6 +427,7 @@ function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
|
||||
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
global $slash;
|
||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||
else {
|
||||
@@ -440,15 +469,17 @@ function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
if (api_error(setConfigResponse($response))) {
|
||||
return $response;
|
||||
}
|
||||
$s = file_get_contents(__DIR__ . '/../config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
||||
$s = file_get_contents($configPath);
|
||||
$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);
|
||||
//ksort($tmp_env);
|
||||
$response = updateEnvironment($tmp_env, $HW_urn, $HW_key, $HW_secret);
|
||||
return $response;
|
||||
}
|
||||
@@ -530,7 +561,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
|
||||
}
|
||||
|
||||
// 放入配置文件
|
||||
file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
|
||||
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
|
||||
+70
-39
@@ -4,6 +4,9 @@ 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['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
//if ($_SERVER['HTTP_REFERER']!='')
|
||||
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
|
||||
if (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/app') $_SERVER['base_path'] = '/';
|
||||
else $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||
@@ -18,6 +21,20 @@ function getpath()
|
||||
|
||||
function getGET()
|
||||
{
|
||||
if (!$_POST) {
|
||||
if (!!$HTTP_RAW_POST_DATA) {
|
||||
$tmpdata = $HTTP_RAW_POST_DATA;
|
||||
} else {
|
||||
$tmpdata = file_get_contents('php://input');
|
||||
}
|
||||
if (!!$tmpdata) {
|
||||
$postbody = explode("&", $tmpdata);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) {
|
||||
@@ -44,23 +61,22 @@ function getGET()
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
//include 'config.php';
|
||||
$s = file_get_contents('.data/config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
global $slash;
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
||||
$s = file_get_contents($configPath);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') {
|
||||
$envs = json_decode($configs, true);
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if (isInnerEnv($str)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
if (isset($envs[$disktag][$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||
if (isBase64Env($str)) 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]);
|
||||
if (isBase64Env($str)) return base64y_decode($envs[$str]);
|
||||
else return $envs[$str];
|
||||
}
|
||||
}
|
||||
@@ -70,20 +86,22 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
global $slash;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
//include 'config.php';
|
||||
$s = file_get_contents('.data/config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
||||
$s = file_get_contents($configPath);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$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);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
|
||||
else $envs[$disktag][$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
@@ -93,9 +111,20 @@ function setConfig($arr, $disktag = '')
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$envs[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$envs[$newtag] = $envs[$v];
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
//$tmpdisk = json_decode($v, true);
|
||||
//var_dump($tmpdisk);
|
||||
//error_log(json_encode($tmpdisk));
|
||||
//if ($tmpdisk===null)
|
||||
$envs[$k] = $v;
|
||||
//else $envs[$k] = $tmpdisk;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -105,17 +134,30 @@ function setConfig($arr, $disktag = '')
|
||||
$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'] = '';
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$envs['disktag'] = implode('|', $tags);
|
||||
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
|
||||
unset($envs[$arr['disktag_rename']]);
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $envs['disktag'] = '';
|
||||
}
|
||||
}
|
||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||
ksort($envs);
|
||||
//ksort($envs);
|
||||
sortConfig($envs);
|
||||
|
||||
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
|
||||
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||
$aftstr = PHP_EOL . '\';';
|
||||
$response = file_put_contents('.data/config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
$response = file_put_contents($configPath, $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
if ($response>0) return json_encode( [ 'response' => 'success' ] );
|
||||
return json_encode( [ 'message' => 'Failed to write config.', 'code' => 'failed' ] );
|
||||
}
|
||||
@@ -230,7 +272,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -245,17 +287,6 @@ function ConfigWriteable()
|
||||
return false;
|
||||
}
|
||||
|
||||
function RewriteEngineOn()
|
||||
{
|
||||
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
|
||||
$tmpurl = $http_type . $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'];
|
||||
$tmpurl .= path_format($_SERVER['base_path'] . '/.data/config.php');
|
||||
$tmp = curl_request($tmpurl);
|
||||
if ($tmp['stat']==200) return false;
|
||||
if ($tmp['stat']==201) return true; //when install return 201, after installed return 404 or 200;
|
||||
return false;
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['message']);
|
||||
@@ -286,8 +317,8 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
|
||||
$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
|
||||
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
|
||||
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
||||
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
|
||||
} else {
|
||||
ob_start();
|
||||
@@ -305,7 +336,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
|
||||
break;
|
||||
}
|
||||
}
|
||||
//error_log($outPath);
|
||||
//error_log1($outPath);
|
||||
if ($outPath=='') return 0;
|
||||
|
||||
//unlink($outPath.'/config.php');
|
||||
|
||||
+50
-25
@@ -23,9 +23,6 @@ function GetGlobalVariable($event)
|
||||
$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)
|
||||
@@ -33,7 +30,7 @@ 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');
|
||||
$_SERVER['Region'] = $context['tencentcloud_region'];
|
||||
$host_name = $event['headers']['host'];
|
||||
$_SERVER['HTTP_HOST'] = $host_name;
|
||||
$serviceId = $event['requestContext']['serviceId'];
|
||||
@@ -49,22 +46,31 @@ function GetPathSetting($event, $context)
|
||||
$_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'];
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
if (isset($event['headers']['authorization'])) {
|
||||
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['authorization'], 'Basic ')[1]), ':');
|
||||
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
|
||||
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
|
||||
}
|
||||
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
|
||||
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
|
||||
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
|
||||
$_SERVER['USER'] = 'qcloud';
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if (isInnerEnv($str)) {
|
||||
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]);
|
||||
if (isBase64Env($str)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
if (isBase64Env($str)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
@@ -72,29 +78,36 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
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;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$oparetdisk = 1;
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$tmp[$newtag] = getConfig($v);
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
$tmp[$k] = json_encode($v);
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -102,11 +115,22 @@ function setConfig($arr, $disktag = '')
|
||||
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'] = '';
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$tmp['disktag'] = implode('|', $tags);
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
@@ -248,7 +272,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -316,7 +340,8 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
//$tmp_env['Region'] = $Region;
|
||||
ksort($tmp_env);
|
||||
//ksort($tmp_env);
|
||||
sortConfig($tmp_env);
|
||||
|
||||
$i = 0;
|
||||
foreach ($tmp_env as $key1 => $value1) {
|
||||
|
||||
@@ -23,9 +23,6 @@ function GetGlobalVariable($event)
|
||||
$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)
|
||||
@@ -33,7 +30,7 @@ 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');
|
||||
$_SERVER['Region'] = $context['tencentcloud_region'];
|
||||
$host_name = $event['headers']['host'];
|
||||
$_SERVER['HTTP_HOST'] = $host_name;
|
||||
$serviceId = $event['requestContext']['serviceId'];
|
||||
@@ -49,28 +46,37 @@ function GetPathSetting($event, $context)
|
||||
$_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'];
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
if (isset($event['headers']['authorization'])) {
|
||||
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['authorization'], 'Basic ')[1]), ':');
|
||||
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
|
||||
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
|
||||
}
|
||||
$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
|
||||
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
|
||||
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
|
||||
$_SERVER['USER'] = 'qcloud';
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
//include 'config.php';
|
||||
$s = file_get_contents('config.php');
|
||||
$s = file_get_contents('.data/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 (isInnerEnv($str)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
if (isset($envs[$disktag][$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||
if (isBase64Env($str)) 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]);
|
||||
if (isBase64Env($str)) return base64y_decode($envs[$str]);
|
||||
else return $envs[$str];
|
||||
}
|
||||
}
|
||||
@@ -80,11 +86,9 @@ function getConfig($str, $disktag = '')
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
//include 'config.php';
|
||||
$s = file_get_contents('config.php');
|
||||
$s = file_get_contents('.data/config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
@@ -92,8 +96,11 @@ function setConfig($arr, $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);
|
||||
if (isCommonEnv($k)) {
|
||||
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
} elseif (isInnerEnv($k)) {
|
||||
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
|
||||
else $envs[$disktag][$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
@@ -103,9 +110,15 @@ function setConfig($arr, $disktag = '')
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$envs[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_copy') {
|
||||
$newtag = $v . '_' . date("Ymd_His");
|
||||
$envs[$newtag] = $envs[$v];
|
||||
array_push($disktags, $newtag);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
$envs[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
@@ -115,13 +128,24 @@ function setConfig($arr, $disktag = '')
|
||||
$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'] = '';
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tags = [];
|
||||
foreach ($disktags as $tag) {
|
||||
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||
else array_push($tags, $tag);
|
||||
}
|
||||
$envs['disktag'] = implode('|', $tags);
|
||||
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
|
||||
$envs[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
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);
|
||||
//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;
|
||||
@@ -260,7 +284,7 @@ language:<br>';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
$title = 'Install';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
@@ -358,6 +382,7 @@ function copyFolder($from, $to)
|
||||
|
||||
function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
sortConfig($Envs);
|
||||
// 获取当前代码并解压
|
||||
//$codeurl = json_decode(getfunctioncodeurl($function_name, $Region, $Namespace, $SecretId, $SecretKey), true)['Response']['Url'];
|
||||
//$codezip = '/tmp/oldcode.zip';
|
||||
@@ -374,7 +399,7 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
|
||||
// 将配置写入
|
||||
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||
$aftstr = PHP_EOL . '\';';
|
||||
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
file_put_contents($outPath . '.data/config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
$source = '/tmp/code.zip';
|
||||
@@ -387,7 +412,7 @@ function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId
|
||||
|
||||
return updateProgram($function_name, $Region, $namespace, $SecretId, $SecretKey, $source);
|
||||
$tmp1['Response']['Error']['Message'] = $codeurl;
|
||||
error_log($tmp1['Response']['Error']['Message']);
|
||||
error_log1($tmp1['Response']['Error']['Message']);
|
||||
return json_encode($tmp1);
|
||||
}
|
||||
|
||||
@@ -443,7 +468,7 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
|
||||
}
|
||||
WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey);
|
||||
|
||||
$s = file_get_contents('config.php');
|
||||
$s = file_get_contents('.data/config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
@@ -451,7 +476,7 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
|
||||
$envs[$k] = $v;
|
||||
}
|
||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||
ksort($envs);
|
||||
//ksort($envs);
|
||||
$response = updateEnvironment($envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey);
|
||||
return $response;
|
||||
}
|
||||
@@ -530,7 +555,7 @@ function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKe
|
||||
// .' -H "X-TC-Version: '.$version.'"'
|
||||
// .' -H "X-TC-Region: '.$region.'"'
|
||||
// ." -d '".$payload."'";
|
||||
//error_log( $curl.PHP_EOL );
|
||||
//error_log1( $curl.PHP_EOL );
|
||||
//return '{"response": {"Error": {"Message":"' . $curl . '"}}}';
|
||||
$headers['Authorization'] = $authorization;
|
||||
$headers['Content-Type'] = 'application/json; charset=utf-8';
|
||||
@@ -539,7 +564,7 @@ function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKe
|
||||
$headers['X-TC-Timestamp'] = $timestamp;
|
||||
$headers['X-TC-Version'] = $version;
|
||||
$headers['X-TC-Region'] = $region;
|
||||
return curl_request('https://'.$host, $payload, $headers)['body'];
|
||||
return curl('POST', 'https://'.$host, $payload, $headers)['body'];
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
@@ -585,7 +610,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
|
||||
}
|
||||
}
|
||||
// 放入配置文件
|
||||
file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
|
||||
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
|
||||
@@ -40,8 +40,8 @@ How to Install:
|
||||
开启伪静态(重写)功能,规则在.htaccess文件中,ngnix从里面复制,我们的目的是不管访问什么都让index.php来处理。
|
||||
3.Upload code.
|
||||
上传好代码。
|
||||
4.Change the file config.php can be read&write (666 is suggested).
|
||||
让代码中的config.php文件程序可读写,推荐chmod 666 config.php。
|
||||
4.Change the file .data/config.php can be read&write (666 is suggested).
|
||||
使web身份可读写代码中的.data/config.php文件,推荐chmod 666 .data/config.php。
|
||||
5.View the website in chrome or other.
|
||||
在浏览器中访问。
|
||||
|
||||
@@ -104,5 +104,14 @@ 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.
|
||||
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
|
||||
|
||||
QQ Group: 943919989 (请看完上面的中英双语再加群,谢谢!)
|
||||
# Functional files 功能性文件
|
||||
### favicon.ico
|
||||
put it in the showing home folder of FIRST disk (maybe not root of onedrive). 放在第一个盘的显示目录(不一定是onedrive根目录)。
|
||||
### index.html
|
||||
show content of index.html as html. 将index.html以静态网页显示出来。
|
||||
### head.md readme.md
|
||||
it will showed at top or bottom as markdown. 以MD语法显示在顶部或底部。
|
||||
### head.omf foot.omf
|
||||
it will showed at top or bottom as html (javascript works!). 以html显示在顶部或底部(可以跑js)。
|
||||
|
||||
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
|
||||
|
||||
+456
-87
@@ -179,11 +179,11 @@
|
||||
<div style="margin: 12px 4px 4px; text-align: center">
|
||||
<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>
|
||||
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
||||
</div>
|
||||
<div style="margin: 24px">
|
||||
<!--IsimgFileStart-->
|
||||
<img src="<!--FileDownUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';" />
|
||||
<img src="<!--FileEncodeUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';" />
|
||||
<!--IsimgFileEnd-->
|
||||
<!--IsvideoFileStart-->
|
||||
<div id="video-a0"></div>
|
||||
@@ -249,7 +249,7 @@
|
||||
</li>
|
||||
<!--AdminEnd-->
|
||||
<ion-icon name="folder"></ion-icon>
|
||||
<a id="file_a<!--filenum-->" name="folderlist" href="<!--FileEncodeReplaceUrl-->/"><!--FileEncodeReplaceName--></a>
|
||||
<a id="file_a<!--filenum-->" name="folderlist" href="<!--FileEncodeReplaceUrl-->/" fileid="<!--FileId-->"><!--FileEncodeReplaceName--></a>
|
||||
</td>
|
||||
<td class="updated_at" id="folder_time<!--filenum-->"><!--lastModifiedDateTime--></td>
|
||||
<td class="size" id="folder_size<!--filenum-->"><!--size--></td>
|
||||
@@ -269,7 +269,7 @@
|
||||
</li>
|
||||
<!--AdminEnd-->
|
||||
<ion-icon name="<!--IconValue-->"></ion-icon>
|
||||
<a id="file_a<!--filenum-->" name="filelist" href="<!--FileEncodeReplaceUrl-->?preview" target=_blank><!--FileEncodeReplaceName--></a>
|
||||
<a id="file_a<!--filenum-->" name="filelist" href="<!--FileEncodeReplaceUrl-->?preview" fileid="<!--FileId-->" target=_blank><!--FileEncodeReplaceName--></a>
|
||||
<a class="download" href="<!--FileEncodeReplaceUrl-->"><ion-icon name="download"></ion-icon></a>
|
||||
</td>
|
||||
<td class="updated_at" id="file_time<!--filenum-->"><!--lastModifiedDateTime--></td>
|
||||
@@ -357,6 +357,7 @@
|
||||
<label id="rename_label"></label><br><br><a onclick="operatediv_close('rename')" class="operatediv_close"><!--constStr@Close--></a>
|
||||
<form id="rename_form" onsubmit="return submit_operate('rename');">
|
||||
<input id="rename_sid" name="rename_sid" type="hidden" value="">
|
||||
<input id="rename_fileid" name="rename_fileid" type="hidden" value="">
|
||||
<input id="rename_hidden" name="rename_oldname" type="hidden" value="">
|
||||
<input id="rename_input" name="rename_newname" type="text" value="">
|
||||
<input name="operate_action" type="submit" value="<!--constStr@Rename-->">
|
||||
@@ -370,6 +371,7 @@
|
||||
<form id="delete_form" onsubmit="return submit_operate('delete');">
|
||||
<label id="delete_input"><!--constStr@Delete-->?</label>
|
||||
<input id="delete_sid" name="delete_sid" type="hidden" value="">
|
||||
<input id="delete_fileid" name="delete_fileid" type="hidden" value="">
|
||||
<input id="delete_hidden" name="delete_name" type="hidden" value="">
|
||||
<input name="operate_action" type="submit" value="<!--constStr@Submit-->">
|
||||
</form>
|
||||
@@ -380,6 +382,7 @@
|
||||
<label id="encrypt_label"></label><br><br><a onclick="operatediv_close('encrypt')" class="operatediv_close"><!--constStr@Close--></a>
|
||||
<form id="encrypt_form" onsubmit="return submit_operate('encrypt');">
|
||||
<input id="encrypt_sid" name="encrypt_sid" type="hidden" value="">
|
||||
<input id="encrypt_fileid" name="encrypt_fileid" type="hidden" value="">
|
||||
<input id="encrypt_hidden" name="encrypt_folder" type="hidden" value="">
|
||||
<input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<!--constStr@InputPasswordUWant-->">
|
||||
<!--EncryptBtnStart--><input name="operate_action" type="submit" value="<!--constStr@Encrypt-->"><!--EncryptBtnEnd--><!--EncryptAlertStart--><br><label><!--constStr@SetpassfileBfEncrypt--></label><!--EncryptAlertEnd-->
|
||||
@@ -391,6 +394,7 @@
|
||||
<label id="copy_label"></label><br><br><a onclick="operatediv_close('copy')" class="operatediv_close"><!--constStr@Close--></a>
|
||||
<form id="copy_form" onsubmit="return submit_operate('copy');">
|
||||
<input id="copy_sid" name="copy_sid" type="hidden" value="">
|
||||
<input id="copy_fileid" name="copy_fileid" type="hidden" value="">
|
||||
<input id="copy_hidden" name="copy_name" type="hidden" value="">
|
||||
<input id="copy_input" name="copy_input" type="hidden" value="">
|
||||
<input name="operate_action" type="submit" value="<!--constStr@Copy-->">
|
||||
@@ -402,6 +406,7 @@
|
||||
<label id="move_label"></label><br><br><a onclick="operatediv_close('move')" class="operatediv_close"><!--constStr@Close--></a>
|
||||
<form id="move_form" onsubmit="return submit_operate('move');">
|
||||
<input id="move_sid" name="move_sid" type="hidden" value="">
|
||||
<input id="move_fileid" name="move_fileid" type="hidden" value="">
|
||||
<input id="move_hidden" name="move_name" type="hidden" value="">
|
||||
<select id="move_input" name="move_folder">
|
||||
<!--MoveRootStart-->
|
||||
@@ -420,6 +425,7 @@
|
||||
<a onclick="operatediv_close('create')" class="operatediv_close"><!--constStr@Close--></a>
|
||||
<form id="create_form" onsubmit="return submit_operate('create');">
|
||||
<input id="create_sid" name="create_sid" type="hidden" value="">
|
||||
<input id="create_fileid" name="create_fileid" type="hidden" value="">
|
||||
<input id="create_hidden" type="hidden" value="">
|
||||
<table>
|
||||
<tr>
|
||||
@@ -456,14 +462,15 @@
|
||||
<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>
|
||||
<form action="<!--IsPreview?-->admin" method="post" onsubmit="return sha1loginpass(this);">
|
||||
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
|
||||
<input name="timestamp" type="hidden" value="">
|
||||
<input type="submit" value="<!--constStr@Login-->">
|
||||
</form>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--LoginEnd-->
|
||||
<div style="color: rgba(247,247,249,0);"><!--FootStr--></div>
|
||||
</body>
|
||||
@@ -472,6 +479,7 @@
|
||||
<!--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-->
|
||||
<!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
||||
<!--AliyundriveUploadJsStart--><script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
|
||||
<!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
||||
<!--ListEnd-->
|
||||
<script type="text/javascript">
|
||||
@@ -484,28 +492,32 @@
|
||||
document.cookie='language='+str+'; path=/; '+expires;
|
||||
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
|
||||
<!--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();
|
||||
}
|
||||
document.querySelectorAll('.table-header').forEach(function (e) {
|
||||
var path = e.innerText;
|
||||
if (path.substr(path.length-1)=='/') path = path.substr(0, path.length-1);
|
||||
var paths = path.split('/');
|
||||
e.innerHTML = '/ ';
|
||||
if (paths <= 2) return;
|
||||
for (var i = 1; i < paths.length - 1; i++) {
|
||||
var to = path_format(root + paths.slice(0, i + 1).join('/'));
|
||||
e.innerHTML += '<a href="' + to + '">' + paths[i] + '</a> / '
|
||||
function sha1loginpass(f) {
|
||||
if (f.password1.value=="") return false;
|
||||
try {
|
||||
timestamp = new Date().getTime() + "";
|
||||
timestamp = timestamp.substr(0, timestamp.length-3);
|
||||
f.timestamp.value = timestamp;
|
||||
f.password1.value = sha1(timestamp + "" + f.password1.value);
|
||||
return true;
|
||||
} catch {
|
||||
alert("sha1.js not loaded.");
|
||||
return false;
|
||||
}
|
||||
e.innerHTML += paths[paths.length - 1];
|
||||
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
|
||||
});*/
|
||||
}
|
||||
<!--LoginEnd-->
|
||||
<!--ListStart-->
|
||||
|
||||
<!--IsFileStart-->
|
||||
var $url = document.getElementById('url');
|
||||
if ($url) {
|
||||
@@ -633,7 +645,6 @@
|
||||
if ($head) {
|
||||
//document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div'));
|
||||
$head.innerHTML = marked(document.getElementById('head-md').innerText);
|
||||
|
||||
}
|
||||
<!--HeadmdEnd-->
|
||||
<!--ReadmemdStart-->
|
||||
@@ -796,6 +807,40 @@
|
||||
alert(tmptextarea.innerHTML+"<!--constStr@Success-->");
|
||||
}
|
||||
<!--UploadJsStart-->
|
||||
function size_format(num) {
|
||||
if (num>1024) {
|
||||
num=num/1024;
|
||||
} else {
|
||||
return num.toFixed(2) + ' B';
|
||||
}
|
||||
if (num>1024) {
|
||||
num=num/1024;
|
||||
} else {
|
||||
return num.toFixed(2) + ' KB';
|
||||
}
|
||||
if (num>1024) {
|
||||
num=num/1024;
|
||||
} else {
|
||||
return num.toFixed(2) + ' MB';
|
||||
}
|
||||
return num.toFixed(2) + ' GB';
|
||||
}
|
||||
function seconds2hour(seconds) {
|
||||
let h, m, s;
|
||||
if (parseFloat(seconds)<60) {
|
||||
return seconds + 's';
|
||||
} else {
|
||||
s = (seconds % 60).toFixed(0);
|
||||
m = parseInt(seconds / 60);
|
||||
if (parseInt(m)<60) {
|
||||
return m + 'm' + s + 's';
|
||||
} else {
|
||||
h = parseInt(m / 60);
|
||||
m = m % 60;
|
||||
return h + 'h' + m + 'm' + s + 's';
|
||||
}
|
||||
}
|
||||
}
|
||||
function uploadbuttonhide() {
|
||||
document.getElementById('upload_btns').style.display='none';
|
||||
/*document.getElementById('upload_submit').disabled='disabled';
|
||||
@@ -810,6 +855,9 @@
|
||||
document.getElementById('upload_submit').style.display='';
|
||||
document.getElementById('upload_file').style.display='';*/
|
||||
}
|
||||
var uploading = new Object();
|
||||
<!--UploadJsEnd-->
|
||||
<!--OnedriveUploadJsStart-->
|
||||
function preup() {
|
||||
uploadbuttonhide();
|
||||
var files=document.getElementById('upload_file').files;
|
||||
@@ -822,7 +870,15 @@
|
||||
table1.setAttribute('class','list-table');
|
||||
var timea=new Date().getTime();
|
||||
var i=0;
|
||||
getuplink(i);
|
||||
var uploadList = setInterval(function(){
|
||||
if (i<files.length) {
|
||||
if (Object.keys(uploading).length<5) {
|
||||
getuplink(i);
|
||||
i++;
|
||||
}// else console.log(Object.keys(uploading).length);
|
||||
} else clearInterval(uploadList);
|
||||
}, 1000);
|
||||
//getuplink(i);
|
||||
function getuplink(i, r=0) {
|
||||
var file=files[i];
|
||||
var td1;
|
||||
@@ -835,7 +891,7 @@
|
||||
tr1.appendChild(td1);
|
||||
td1.setAttribute('style','width:30%;word-break:break-word;');
|
||||
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
|
||||
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size);
|
||||
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size)+' ('+(i+1)+'/'+files.length+')';
|
||||
td2=document.createElement('td');
|
||||
tr1.appendChild(td2);
|
||||
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
|
||||
@@ -848,7 +904,9 @@
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
}
|
||||
upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
|
||||
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
|
||||
uploading[upbigfilename] = i;
|
||||
var filemd5='';
|
||||
<!--GuestStart-->
|
||||
function getext(str) {
|
||||
strarry=str.split('.');
|
||||
@@ -880,13 +938,14 @@
|
||||
if (asize < file.size) {
|
||||
readblob(asize);
|
||||
} else {
|
||||
var filemd5 = spark.end();
|
||||
filemd5 = spark.end();
|
||||
td2.innerHTML='md5: '+filemd5;
|
||||
upbigfilename = filemd5+ext;
|
||||
<!--GuestEnd-->
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onprogress = function(e){
|
||||
td2.innerHTML+='.';
|
||||
@@ -894,15 +953,6 @@
|
||||
xhr1.onload = function(e){
|
||||
//console.log(xhr1.status+xhr1.responseText);
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>';
|
||||
if (xhr1.status==409) {
|
||||
// td2.innerHTML='nameAlreadyExists';
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
td2.innerHTML=html['error']['code']+': '+html['error']['message'];
|
||||
<!--GuestStart-->
|
||||
td2.innerHTML='md5: '+filemd5;
|
||||
<!--GuestEnd-->
|
||||
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
}
|
||||
if (xhr1.status==200) {
|
||||
if (xhr1.responseText=='') {
|
||||
getuplink(i,1);
|
||||
@@ -915,13 +965,27 @@
|
||||
td2.innerHTML='<!--constStr@UploadStart--> ...';
|
||||
binupfile(file,html['uploadUrl'],timea+'_'+i, upbigfilename);
|
||||
}
|
||||
}
|
||||
if (i<files.length-1) {
|
||||
} else {
|
||||
if (xhr1.status==409) {
|
||||
// td2.innerHTML='nameAlreadyExists';
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
td2.innerHTML=html['error']['code']+': '+html['error']['message'];
|
||||
<!--GuestStart-->
|
||||
td2.innerHTML='md5: '+filemd5;
|
||||
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'"><!--constStr@CopyUrl--></button></div>';
|
||||
<!--GuestEnd-->
|
||||
<!--AdminStart-->
|
||||
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" style="display:none"><!--constStr@CopyUrl--></button></div>';
|
||||
<!--AdminEnd-->
|
||||
}
|
||||
/*if (i<files.length-1) {
|
||||
i++;
|
||||
getuplink(i);
|
||||
}*/
|
||||
delete uploading[upbigfilename];
|
||||
}
|
||||
}
|
||||
xhr1.send(null);
|
||||
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5);
|
||||
<!--GuestStart-->
|
||||
}
|
||||
}
|
||||
@@ -929,24 +993,7 @@
|
||||
}
|
||||
uploadbuttonshow();
|
||||
}
|
||||
function size_format(num) {
|
||||
if (num>1024) {
|
||||
num=num/1024;
|
||||
} else {
|
||||
return num.toFixed(2) + ' B';
|
||||
}
|
||||
if (num>1024) {
|
||||
num=num/1024;
|
||||
} else {
|
||||
return num.toFixed(2) + ' KB';
|
||||
}
|
||||
if (num>1024) {
|
||||
num=num/1024;
|
||||
} else {
|
||||
return num.toFixed(2) + ' MB';
|
||||
}
|
||||
return num.toFixed(2) + ' GB';
|
||||
}
|
||||
|
||||
function binupfile(file,url,tdnum,filename){
|
||||
var label=document.getElementById('upfile_td2_'+tdnum);
|
||||
var reader = new FileReader();
|
||||
@@ -995,7 +1042,7 @@
|
||||
var tmptime = new Date();
|
||||
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
|
||||
var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
|
||||
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+remaintime.toFixed(1)+'s';
|
||||
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
|
||||
}
|
||||
}
|
||||
var C_starttime = new Date();
|
||||
@@ -1020,10 +1067,12 @@
|
||||
} else {
|
||||
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
}
|
||||
delete uploading[filename];
|
||||
while (filename.indexOf('%2F')>0) filename = filename.replace('%2F', '/');
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
label.innerHTML=StartStr+MiddleStr;
|
||||
label.style.color='green';
|
||||
|
||||
// uploadbuttonshow();
|
||||
<!--AdminStart-->
|
||||
response.name=file.webkitRelativePath||response.name;
|
||||
@@ -1032,6 +1081,7 @@
|
||||
} else {
|
||||
if (!response['nextExpectedRanges']) {
|
||||
label.innerHTML='<font color="red">'+xhr.responseText+'</font><br>';
|
||||
delete uploading[filename];
|
||||
} else {
|
||||
var a=response['nextExpectedRanges'][0];
|
||||
asize=Number( a.slice(0,a.indexOf("-")) );
|
||||
@@ -1047,12 +1097,332 @@
|
||||
} else {
|
||||
label.innerHTML='<font color="red">'+xhr2.responseText+'</font>';
|
||||
}
|
||||
delete uploading[filename];
|
||||
// uploadbuttonshow();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<!--UploadJsEnd-->
|
||||
<!--OnedriveUploadJsEnd-->
|
||||
<!--AliyundriveUploadJsStart-->
|
||||
function preup() {
|
||||
uploadbuttonhide();
|
||||
var files=document.getElementById('upload_file').files;
|
||||
if (files.length<1) {
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
};
|
||||
var table1=document.createElement('table');
|
||||
document.getElementById('upload_div').appendChild(table1);
|
||||
table1.setAttribute('class','list-table');
|
||||
var timea=new Date().getTime();
|
||||
var i=0;
|
||||
var uploadList = setInterval(function(){
|
||||
if (i<files.length) {
|
||||
if (Object.keys(uploading).length<5) {
|
||||
getuplink(i);
|
||||
i++;
|
||||
}// else console.log(Object.keys(uploading).length);
|
||||
} else clearInterval(uploadList);
|
||||
}, 1000);
|
||||
//getuplink(i);
|
||||
function getuplink(i, r=0) {
|
||||
var file=files[i];
|
||||
var td1;
|
||||
var td2;
|
||||
if (r==0) {
|
||||
var tr1=document.createElement('tr');
|
||||
table1.appendChild(tr1);
|
||||
tr1.setAttribute('data-to',1);
|
||||
td1=document.createElement('td');
|
||||
tr1.appendChild(td1);
|
||||
td1.setAttribute('style','width:30%;word-break:break-word;');
|
||||
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
|
||||
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size)+' ('+(i+1)+'/'+files.length+')';
|
||||
td2=document.createElement('td');
|
||||
tr1.appendChild(td2);
|
||||
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
|
||||
}
|
||||
var tdnum = timea+'_'+i;
|
||||
td1=document.getElementById('upfile_td1_'+tdnum);
|
||||
td2=document.getElementById('upfile_td2_'+tdnum);
|
||||
var chunksize=10*1024*1024; // 分块大小
|
||||
//var chunksize=100*1024; // 测试小块
|
||||
/*if (file.size>100*1024*1024*1024) {
|
||||
td2.innerHTML='<font color="red"><!--constStr@UpFileTooLarge--></font>';
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
}*/
|
||||
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
|
||||
uploading[upbigfilename] = [i];
|
||||
var spark = sha1.create();
|
||||
var reader = new FileReader();
|
||||
var chunksize=10*1024*1024;
|
||||
var asize = 0;
|
||||
var filesha1;
|
||||
function readblob(start) {
|
||||
var end=start+chunksize;
|
||||
var blob = file.slice(start,end);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
}
|
||||
readblob(asize);
|
||||
|
||||
reader.onload = function(e){
|
||||
td2.innerHTML='<!--constStr@Calculate--> SHA1: '+(asize*100/file.size).toFixed(2)+'%';
|
||||
var binary = this.result;
|
||||
spark.update(binary);
|
||||
asize += chunksize;
|
||||
if (asize < file.size) {
|
||||
readblob(asize);
|
||||
} else {
|
||||
filesha1 = spark.hex();
|
||||
td2.innerHTML='SHA1: ' + filesha1;
|
||||
<!--GuestStart-->
|
||||
function getext(str) {
|
||||
let p = str.lastIndexOf('.');
|
||||
if (p===-1) return '';
|
||||
if (p===0) return '';
|
||||
return str.substr(p);
|
||||
}
|
||||
var ext = getext(file.webkitRelativePath||file.name);
|
||||
upbigfilename = filesha1 + ext;
|
||||
<!--GuestEnd-->
|
||||
//while (upbigfilename.indexOf('%2F')>0) upbigfilename = upbigfilename.replace('%2F', '/');
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
var html = JSON.parse(localStorage.getItem(filesha1));
|
||||
//console.log(html);
|
||||
if (html!==null && ('part_info_list' in html)) {
|
||||
td2.innerHTML='<!--constStr@UploadStart--> ...';
|
||||
binupfile(file, html, timea+'_'+i, upbigfilename, filesha1, chunksize);
|
||||
} else {
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onload = function(e){
|
||||
//console.log(xhr1.status+xhr1.responseText);
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>';
|
||||
if (xhr1.status==201) {
|
||||
if (xhr1.responseText=='') {
|
||||
getuplink(i,1);
|
||||
return;
|
||||
}
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
//console.log(html);
|
||||
if (!html['part_info_list']) {
|
||||
if (html.name!='') {
|
||||
if (html.exist==true) td2.innerHTML=html.name+' 文件名已有';
|
||||
else if (html.rapid_upload==true) td2.innerHTML=html.name+' 秒传';
|
||||
else td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
|
||||
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
} else {
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
|
||||
}
|
||||
delete uploading[upbigfilename];
|
||||
} else {
|
||||
td2.innerHTML='<!--constStr@UploadStart--> ...';
|
||||
//console.log(html);
|
||||
localStorage.setItem(filesha1, JSON.stringify(html));
|
||||
binupfile(file, html, timea+'_'+i, upbigfilename, filesha1, chunksize);
|
||||
}
|
||||
} else {
|
||||
delete uploading[upbigfilename];
|
||||
}
|
||||
/*if (i<files.length-1) {
|
||||
i++;
|
||||
getuplink(i);
|
||||
}*/
|
||||
}
|
||||
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&filesha1=' + filesha1 + '&chunksize=' + chunksize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
uploadbuttonshow();
|
||||
}
|
||||
function binupfile(file, res, tdnum, filename, filesha1, chunksize) {
|
||||
// xhr.getResponseHeader
|
||||
if (!('ETag' in res)) res['ETag'] = new Array();
|
||||
var fileid = res['file_id'];
|
||||
var uploadid = res['upload_id'];
|
||||
var label=document.getElementById('upfile_td2_'+tdnum);
|
||||
var reader = new FileReader();
|
||||
var StartStr='';
|
||||
var MiddleStr='';
|
||||
var StartTime;
|
||||
var EndTime;
|
||||
var newstartsize = 0;
|
||||
if(!!file){
|
||||
var chunknum = 0;
|
||||
var chunknumtotal = res['part_info_list'].length;
|
||||
var asize=0;
|
||||
var totalsize=file.size;
|
||||
var newstartsize=0;
|
||||
while (res['ETag'][chunknum]!=null) {
|
||||
chunknum++;
|
||||
newstartsize += chunksize;
|
||||
}
|
||||
StartTime = new Date();
|
||||
asize = newstartsize;
|
||||
if (newstartsize==0) {
|
||||
StartStr='<!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
|
||||
} else {
|
||||
StartStr='<!--constStr@LastUpload-->'+size_format(newstartsize)+ '<br><!--constStr@ThisTime--><!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
|
||||
}
|
||||
//var chunksize=5*1024*1024; // chunk size, max 60M. 每小块上传大小
|
||||
//if (totalsize>200*1024*1024) chunksize=10*1024*1024;
|
||||
function readblob(start) {
|
||||
var end=start+chunksize;
|
||||
var blob = file.slice(start,end);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
//reader.readAsArrayBuffer(file);
|
||||
}
|
||||
readblob(asize);
|
||||
|
||||
reader.onload = function(e){
|
||||
if (asize>totalsize) {
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onload = function(e){
|
||||
console.log(xhr1.responseText+','+xhr1.status);
|
||||
if (xhr1.status==200) {
|
||||
localStorage.removeItem(filesha1);
|
||||
<!--AdminStart-->
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
//response.name=file.webkitRelativePath||response.name;
|
||||
addelement(html);
|
||||
<!--AdminEnd-->
|
||||
/*if (totalsize>10*1024*1024) {
|
||||
var xhr3 = new XMLHttpRequest();
|
||||
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
|
||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr3.send(null);
|
||||
xhr3.onload = function(e){
|
||||
console.log(xhr3.responseText+','+xhr3.status);
|
||||
}
|
||||
}*/
|
||||
EndTime=new Date();
|
||||
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
|
||||
if (newstartsize==0) {
|
||||
MiddleStr += '<!--constStr@AverageSpeed-->:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
} else {
|
||||
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
}
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
label.innerHTML=StartStr+MiddleStr;
|
||||
label.style.color='green';
|
||||
} else {
|
||||
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
|
||||
localStorage.removeItem(filesha1);
|
||||
}
|
||||
delete uploading[filename];
|
||||
}
|
||||
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
|
||||
} else {
|
||||
var binary = this.result;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("PUT", res['part_info_list'][chunknum]['upload_url'], true);
|
||||
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
bsize=asize+e.loaded-1;
|
||||
xhr.setRequestHeader('Content-Range', 'bytes ' + asize + '-' + bsize +'/'+ totalsize);
|
||||
xhr.upload.onprogress = function(e){
|
||||
if (e.lengthComputable) {
|
||||
var tmptime = new Date();
|
||||
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
|
||||
var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
|
||||
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
|
||||
}
|
||||
}
|
||||
var C_starttime = new Date();
|
||||
xhr.onload = function(e){
|
||||
if (xhr.status<500) {
|
||||
//console.log(xhr.responseText);
|
||||
//console.log(xhr.getResponseHeader('ETag'));
|
||||
//var response=JSON.parse(xhr.responseText);
|
||||
if (xhr.responseText==''&&xhr.getResponseHeader('ETag')!='') {
|
||||
// 有ETag说明本段上传成功
|
||||
let etag = xhr.getResponseHeader('ETag');
|
||||
//if (etag.substr(0,1)=='"') etag = etag.substr(1);还就要引号!
|
||||
//if (etag.substr(-1)=='"') etag = etag.substr(0, etag.length-1);
|
||||
res['ETag'][chunknum] = etag;
|
||||
localStorage.setItem(filesha1, JSON.stringify(res));
|
||||
chunknum++;
|
||||
asize = bsize + 1;
|
||||
if (chunknum==chunknumtotal) {
|
||||
// 上传结束
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
//xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onload = function(e){
|
||||
console.log(xhr1.responseText+','+xhr1.status);
|
||||
if (xhr1.status==200) {
|
||||
localStorage.removeItem(filesha1);
|
||||
<!--AdminStart-->
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
//response.name=file.webkitRelativePath||response.name;
|
||||
addelement(html);
|
||||
<!--AdminEnd-->
|
||||
/*if (totalsize>10*1024*1024) {
|
||||
var xhr3 = new XMLHttpRequest();
|
||||
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
|
||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr3.send(null);
|
||||
xhr3.onload = function(e){
|
||||
console.log(xhr3.responseText+','+xhr3.status);
|
||||
}
|
||||
}*/
|
||||
EndTime=new Date();
|
||||
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
|
||||
if (newstartsize==0) {
|
||||
MiddleStr += '<!--constStr@AverageSpeed-->:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
} else {
|
||||
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
}
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
label.innerHTML=StartStr+MiddleStr;
|
||||
label.style.color='green';
|
||||
} else {
|
||||
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
|
||||
localStorage.removeItem(filesha1);
|
||||
}
|
||||
delete uploading[filename];
|
||||
}
|
||||
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
|
||||
// uploadbuttonshow();
|
||||
} else {
|
||||
readblob(asize);
|
||||
}
|
||||
} else {
|
||||
console.log(xhr.status+xhr.responseText);//<PartEtag>
|
||||
if (xhr.status==409) {
|
||||
let str = xhr.responseText;
|
||||
str = str.substr(str.indexOf('<PartEtag>')+10);
|
||||
str = str.substr(0, str.indexOf('</PartEtag>'));
|
||||
res['ETag'][chunknum] = str;
|
||||
localStorage.setItem(filesha1, JSON.stringify(res));
|
||||
chunknum++;
|
||||
asize += chunksize;
|
||||
readblob(asize);
|
||||
} else {
|
||||
delete uploading[filename];
|
||||
}
|
||||
//label.innerHTML='<font color="red">'+xhr.responseText+'</font><br>';
|
||||
} } else readblob(asize);
|
||||
}
|
||||
xhr.send(binary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<!--AliyundriveUploadJsEnd-->
|
||||
<!--GoogledriveUploadJsStart-->
|
||||
function preup() {
|
||||
alert("Stop!\nCan not upload form explorer without token.");
|
||||
}
|
||||
<!--GoogledriveUploadJsEnd-->
|
||||
<!--ListEnd-->
|
||||
function operatediv_close(operate) {
|
||||
document.getElementById(operate+'_div').style.display='none';
|
||||
@@ -1060,7 +1430,10 @@
|
||||
}
|
||||
<!--AdminStart-->
|
||||
function logout() {
|
||||
document.cookie = "admin=; path=/";
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+1000);
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie = "admin=; path=/; "+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
<!--IsFolderStart-->
|
||||
@@ -1074,16 +1447,19 @@
|
||||
document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px';
|
||||
if (num=='') {
|
||||
var str='';
|
||||
var fileid='';
|
||||
} else {
|
||||
var str=decodeURIComponent(document.getElementById('file_a'+num).href);
|
||||
if (str.substr(-1)==' ') str=str.substr(0, str.length-1);
|
||||
if (str.substr(-1)=='/') str=str.substr(0, str.length-1);
|
||||
if (str.substr(-8)=='?preview') str=str.substr(0, str.length-8);
|
||||
if (str.lastIndexOf('/')>-1) str=str.substr(str.lastIndexOf('/')+1);
|
||||
var fileid=document.getElementById('file_a'+num).attributes['fileid'].nodeValue;
|
||||
}
|
||||
document.getElementById(action + '_div').style.display='';
|
||||
document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&');
|
||||
document.getElementById(action + '_sid').value=num;
|
||||
document.getElementById(action + '_fileid').value=fileid;
|
||||
document.getElementById(action + '_hidden').value=str;
|
||||
if (action=='rename') document.getElementById(action + '_input').value=str;
|
||||
var $e = event || window.event;
|
||||
@@ -1112,9 +1488,9 @@
|
||||
function submit_operate(str) {
|
||||
var num=document.getElementById(str+'_sid').value;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", '?'+serializeForm(str+'_form'));
|
||||
xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr.send(null);
|
||||
xhr.open("POST", '');
|
||||
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr.setRequestHeader('x-requested-with', 'XMLHttpRequest');
|
||||
xhr.onload = function(e){
|
||||
var html;
|
||||
if (xhr.status<300) {
|
||||
@@ -1130,10 +1506,12 @@
|
||||
html=JSON.parse(xhr.responseText);
|
||||
addelement(html);
|
||||
}
|
||||
//alert('success');
|
||||
} else alert(xhr.status+'\n'+xhr.responseText);
|
||||
document.getElementById(str+'_div').style.display='none';
|
||||
document.getElementById('mask').style.display='none';
|
||||
}
|
||||
xhr.send(serializeForm(str+'_form'));
|
||||
return false;
|
||||
}
|
||||
function addelement(html) {
|
||||
@@ -1147,15 +1525,16 @@
|
||||
a1.target='_blank';
|
||||
var td2=document.createElement('td');
|
||||
td2.setAttribute('class','updated_at');
|
||||
td2.innerText=html.lastModifiedDateTime.replace(/T/,' ').replace(/Z/,'');
|
||||
if (!!html.time) td2.innerText=html.time.replace(/T/,' ').replace(/Z/,'');
|
||||
var td3=document.createElement('td');
|
||||
td3.setAttribute('class','size');
|
||||
td3.innerText=size_format(html.size);
|
||||
if (!!html.folder) {
|
||||
if (!!html.size) td3.innerText=size_format(html.size);
|
||||
else td3.innerText='0 B';
|
||||
if (html.type=='folder') {
|
||||
a1.href+='/';
|
||||
document.getElementById('tr0').parentNode.insertBefore(tr1,document.getElementById('tr0').nextSibling);
|
||||
}
|
||||
if (!!html.file) {
|
||||
if (html.type=='file') {
|
||||
a1.href+='?preview';
|
||||
a1.name='filelist';
|
||||
document.getElementById('tr0').parentNode.appendChild(tr1);
|
||||
@@ -1229,21 +1608,11 @@
|
||||
}
|
||||
<!--IsFolderEnd-->
|
||||
<!--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-->
|
||||
<!--EncryptedStart-->
|
||||
document.getElementById('password1').focus();
|
||||
<!--EncryptedEnd-->
|
||||
</script>
|
||||
<script src="//unpkg.zhimg.com/ionicons@4.4.4/dist/ionicons.js"></script>
|
||||
<!--LoginStart--><script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script><!--LoginEnd-->
|
||||
<!--customScript-->
|
||||
</html>
|
||||
|
||||
-1289
File diff suppressed because it is too large
Load Diff
-1283
File diff suppressed because it is too large
Load Diff
-1544
File diff suppressed because it is too large
Load Diff
+496
-155
@@ -45,7 +45,9 @@
|
||||
background-image: url('<!--BackgroundUrl-->');
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
height: 100%;
|
||||
background-attachment: fixed;
|
||||
background-position: center;
|
||||
height: 100vh;
|
||||
<!--BackgroundEnd-->
|
||||
}
|
||||
|
||||
@@ -677,13 +679,17 @@ return false;
|
||||
<!--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-->
|
||||
<!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
||||
<!--AliyundriveUploadJsStart--><script src="//cdn.bootcdn.net/ajax/libs/js-sha1/0.6.0/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
|
||||
<!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
||||
<!--ListEnd-->
|
||||
<script type="text/javascript">
|
||||
function changelanguage(str)
|
||||
{
|
||||
if (str=='Language') str = '';
|
||||
document.cookie='language='+str+'; path=/';
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie='language='+str+'; path=/; '+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
<!--ListStart-->
|
||||
@@ -790,14 +796,20 @@ return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
addVideos(['<!--FileDownUrl-->']);
|
||||
addVideos(['<!--FileEncodeUrl-->']);
|
||||
<!--IsvideoFileEnd-->
|
||||
<!--IspdfFileStart-->
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
|
||||
var loadingTask = pdfjsLib.getDocument({ url: '<!--FileDownUrl-->', });
|
||||
var loadingTask = pdfjsLib.getDocument({
|
||||
url: '<!--FileDownUrl-->',
|
||||
cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/",
|
||||
cMapPacked: true,
|
||||
rangeChunkSize: 65535
|
||||
});
|
||||
loadingTask.promise.then(function(pdf) {
|
||||
var pagenum = pdf.numPages;
|
||||
var pdfContainer = document.getElementById('pdf-d');
|
||||
pdfContainer.innerHTML = '';
|
||||
for (var i=1;i<=pagenum;i++) {
|
||||
var canvasNew = document.createElement('canvas');
|
||||
canvasNew.id = 'pdf-c'+i;
|
||||
@@ -829,7 +841,6 @@ return false;
|
||||
if ($head) {
|
||||
//document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div'));
|
||||
$head.innerHTML = marked(document.getElementById('head-md').innerText);
|
||||
|
||||
}
|
||||
<!--HeadmdEnd-->
|
||||
<!--ReadmemdStart-->
|
||||
@@ -840,29 +851,35 @@ return false;
|
||||
<!--ReadmemdEnd-->
|
||||
<!--ShowThumbnailsStart-->
|
||||
function showthumbnails(obj) {
|
||||
images = [<!--ImgExts-->];
|
||||
var files=document.getElementsByName('filelist');
|
||||
for ($i=0;$i<files.length;$i++) {
|
||||
str=files[$i].innerText;
|
||||
if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
|
||||
if (!str) return;
|
||||
if (!str) continue;
|
||||
strarry=str.split('.');
|
||||
ext=strarry[strarry.length-1].toLowerCase();
|
||||
images = [<!--ImgExts-->];
|
||||
if (images.indexOf(ext)>-1) get_thumbnails_url(str, files[$i]);
|
||||
if (images.indexOf(ext)>-1) {
|
||||
var url=files[$i].href;
|
||||
url=url.substr(0,url.length-8);
|
||||
if (document.getElementById('originalpic').checked==true) {
|
||||
files[$i].parentNode.parentNode.innerHTML='<td colspan="3"><img src="'+url+'" alt="'+str+'" onload="if (this.offsetWidth>document.getElementById(\'list-div\').offsetWidth) this.style.width=\'100%\';"></td>';
|
||||
$i--;
|
||||
} else {
|
||||
url+='?thumbnails';
|
||||
get_thumbnails_url(url, str, files[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
obj.disabled='disabled';
|
||||
}
|
||||
function get_thumbnails_url(str, filea) {
|
||||
if (!str) return;
|
||||
var nurl=window.location.href;
|
||||
if (nurl.substr(-1)!="/") nurl+="/";
|
||||
function get_thumbnails_url(url, name, filea) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", nurl+str+'?thumbnails', true);
|
||||
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr.open("GET", url, true);
|
||||
xhr.send('');
|
||||
xhr.onload = function(e){
|
||||
if (xhr.status==200) {
|
||||
if (xhr.responseText!='') filea.innerHTML='<img src="'+xhr.responseText+'" alt="'+str+'">';
|
||||
if (xhr.responseText!='') filea.innerHTML='<img src="'+xhr.responseText+'" alt="'+name+'">';
|
||||
} else console.log(xhr.status+'\n'+xhr.responseText);
|
||||
}
|
||||
}
|
||||
@@ -986,76 +1003,6 @@ return false;
|
||||
alert(tmptextarea.innerHTML+"<!--constStr@Success-->");
|
||||
}
|
||||
<!--UploadJsStart-->
|
||||
function uploadbuttonhide() {
|
||||
document.getElementById('upload_btns').style.display='none';
|
||||
/*document.getElementById('upload_submit').disabled='disabled';
|
||||
document.getElementById('upload_file').disabled='disabled';
|
||||
document.getElementById('upload_submit').style.display='none';
|
||||
document.getElementById('upload_file').style.display='none';*/
|
||||
}
|
||||
function uploadbuttonshow() {
|
||||
document.getElementById('upload_btns').style.display='';
|
||||
/*document.getElementById('upload_file').disabled='';
|
||||
document.getElementById('upload_submit').disabled='';
|
||||
document.getElementById('upload_submit').style.display='';
|
||||
document.getElementById('upload_file').style.display='';*/
|
||||
}
|
||||
function preup() {
|
||||
uploadbuttonhide();
|
||||
var files=document.getElementById('upload_file').files;
|
||||
if (files.length<1) {
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
};
|
||||
var table1=document.createElement('table');
|
||||
document.getElementById('uploading_div').appendChild(table1);
|
||||
table1.setAttribute('class','list-table');
|
||||
var timea=new Date().getTime();
|
||||
var i=0;
|
||||
getuplink(i);
|
||||
function getuplink(i) {
|
||||
var file=files[i];
|
||||
var tr1=document.createElement('tr');
|
||||
table1.appendChild(tr1);
|
||||
tr1.setAttribute('data-to',1);
|
||||
var td1=document.createElement('td');
|
||||
tr1.appendChild(td1);
|
||||
td1.setAttribute('style','width:30%');
|
||||
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
|
||||
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size);
|
||||
var td2=document.createElement('td');
|
||||
tr1.appendChild(td2);
|
||||
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
if (file.size>100*1024*1024*1024) {
|
||||
td2.innerHTML='<font color="red"><!--constStr@UpFileTooLarge--></font>';
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
}
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent((file.webkitRelativePath||file.name)) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.send(null);
|
||||
xhr1.onload = function(e){
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>';
|
||||
if (xhr1.status==200) {
|
||||
console.log(xhr1.responseText);
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
if (!html['uploadUrl']) {
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
|
||||
uploadbuttonshow();
|
||||
} else {
|
||||
td2.innerHTML='<!--constStr@UploadStart--> ...';
|
||||
binupfile(file,html['uploadUrl'],timea+'_'+i);
|
||||
}
|
||||
}
|
||||
if (i<files.length-1) {
|
||||
i++;
|
||||
getuplink(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function size_format(num) {
|
||||
if (num>1024) {
|
||||
num=num/1024;
|
||||
@@ -1074,7 +1021,145 @@ return false;
|
||||
}
|
||||
return num.toFixed(2) + ' GB';
|
||||
}
|
||||
function binupfile(file,url,tdnum){
|
||||
function uploadbuttonhide() {
|
||||
document.getElementById('upload_btns').style.display='none';
|
||||
/*document.getElementById('upload_submit').disabled='disabled';
|
||||
document.getElementById('upload_file').disabled='disabled';
|
||||
document.getElementById('upload_submit').style.display='none';
|
||||
document.getElementById('upload_file').style.display='none';*/
|
||||
}
|
||||
function uploadbuttonshow() {
|
||||
document.getElementById('upload_btns').style.display='';
|
||||
/*document.getElementById('upload_file').disabled='';
|
||||
document.getElementById('upload_submit').disabled='';
|
||||
document.getElementById('upload_submit').style.display='';
|
||||
document.getElementById('upload_file').style.display='';*/
|
||||
}
|
||||
<!--UploadJsEnd-->
|
||||
<!--OnedriveUploadJsStart-->
|
||||
function preup() {
|
||||
uploadbuttonhide();
|
||||
var files=document.getElementById('upload_file').files;
|
||||
if (files.length<1) {
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
};
|
||||
var table1=document.createElement('table');
|
||||
document.getElementById('upload_div').appendChild(table1);
|
||||
table1.setAttribute('class','list-table');
|
||||
var timea=new Date().getTime();
|
||||
var i=0;
|
||||
getuplink(i);
|
||||
function getuplink(i, r=0) {
|
||||
var file=files[i];
|
||||
var td1;
|
||||
var td2;
|
||||
if (r==0) {
|
||||
var tr1=document.createElement('tr');
|
||||
table1.appendChild(tr1);
|
||||
tr1.setAttribute('data-to',1);
|
||||
td1=document.createElement('td');
|
||||
tr1.appendChild(td1);
|
||||
td1.setAttribute('style','width:30%;word-break:break-word;');
|
||||
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
|
||||
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size);
|
||||
td2=document.createElement('td');
|
||||
tr1.appendChild(td2);
|
||||
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
|
||||
}
|
||||
var tdnum = timea+'_'+i;
|
||||
td1=document.getElementById('upfile_td1_'+tdnum);
|
||||
td2=document.getElementById('upfile_td2_'+tdnum);
|
||||
if (file.size>100*1024*1024*1024) {
|
||||
td2.innerHTML='<font color="red"><!--constStr@UpFileTooLarge--></font>';
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
}
|
||||
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
|
||||
var filemd5='';
|
||||
<!--GuestStart-->
|
||||
function getext(str) {
|
||||
strarry=str.split('.');
|
||||
if (strarry.length==1) return '';
|
||||
ext=strarry[strarry.length-1].toLowerCase();
|
||||
var reg = new RegExp(".","g");
|
||||
var a = str.replace(reg,"");
|
||||
if (a == ext) ext = "";
|
||||
else ext = "." + ext;
|
||||
return ext;
|
||||
}
|
||||
var ext = getext(file.webkitRelativePath||file.name);
|
||||
var spark = new SparkMD5.ArrayBuffer();
|
||||
var reader = new FileReader();
|
||||
var chunksize=10*1024*1024;
|
||||
var asize = 0;
|
||||
function readblob(start) {
|
||||
var end=start+chunksize;
|
||||
var blob = file.slice(start,end);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
}
|
||||
readblob(asize);
|
||||
|
||||
reader.onload = function(e){
|
||||
td2.innerHTML='<!--constStr@Calculate--> md5: '+(asize*100/file.size).toFixed(2)+'%';
|
||||
var binary = this.result;
|
||||
spark.append(binary);
|
||||
asize += chunksize;
|
||||
if (asize < file.size) {
|
||||
readblob(asize);
|
||||
} else {
|
||||
filemd5 = spark.end();
|
||||
td2.innerHTML='md5: '+filemd5;
|
||||
upbigfilename = filemd5+ext;
|
||||
<!--GuestEnd-->
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onprogress = function(e){
|
||||
td2.innerHTML+='.';
|
||||
}
|
||||
xhr1.onload = function(e){
|
||||
//console.log(xhr1.status+xhr1.responseText);
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>';
|
||||
if (xhr1.status==409) {
|
||||
// td2.innerHTML='nameAlreadyExists';
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
td2.innerHTML=html['error']['code']+': '+html['error']['message'];
|
||||
<!--GuestStart-->
|
||||
td2.innerHTML='md5: '+filemd5;
|
||||
<!--GuestEnd-->
|
||||
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||file.name)+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
}
|
||||
if (xhr1.status==200) {
|
||||
if (xhr1.responseText=='') {
|
||||
getuplink(i,1);
|
||||
return;
|
||||
}
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
if (!html['uploadUrl']) {
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
|
||||
} else {
|
||||
td2.innerHTML='<!--constStr@UploadStart--> ...';
|
||||
binupfile(file,html['uploadUrl'],timea+'_'+i, upbigfilename);
|
||||
}
|
||||
}
|
||||
if (i<files.length-1) {
|
||||
i++;
|
||||
getuplink(i);
|
||||
}
|
||||
}
|
||||
xhr1.send('upbigfilename='+ encodeURIComponent(upbigfilename) +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5);
|
||||
<!--GuestStart-->
|
||||
}
|
||||
}
|
||||
<!--GuestEnd-->
|
||||
}
|
||||
uploadbuttonshow();
|
||||
}
|
||||
|
||||
function binupfile(file,url,tdnum,filename){
|
||||
var label=document.getElementById('upfile_td2_'+tdnum);
|
||||
var reader = new FileReader();
|
||||
var StartStr='';
|
||||
@@ -1095,9 +1180,7 @@ return false;
|
||||
var a = html['nextExpectedRanges'][0];
|
||||
newstartsize = Number( a.slice(0,a.indexOf("-")) );
|
||||
StartTime = new Date();
|
||||
<!--AdminStart-->
|
||||
asize = newstartsize;
|
||||
<!--AdminEnd-->
|
||||
if (newstartsize==0) {
|
||||
StartStr='<!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
|
||||
} else {
|
||||
@@ -1111,19 +1194,9 @@ return false;
|
||||
reader.readAsArrayBuffer(blob);
|
||||
}
|
||||
readblob(asize);
|
||||
<!--LoginStart-->
|
||||
var spark = new SparkMD5.ArrayBuffer();
|
||||
<!--LoginEnd-->
|
||||
|
||||
reader.onload = function(e){
|
||||
var binary = this.result;
|
||||
<!--LoginStart-->
|
||||
spark.append(binary);
|
||||
if (asize < newstartsize) {
|
||||
asize += chunksize;
|
||||
readblob(asize);
|
||||
return;
|
||||
}
|
||||
<!--LoginEnd-->
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("PUT", url, true);
|
||||
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
@@ -1143,39 +1216,15 @@ return false;
|
||||
var response=JSON.parse(xhr.responseText);
|
||||
if (response['size']>0) {
|
||||
// contain size, upload finish. 有size说明是最终返回,上传结束
|
||||
var xhr3 = new XMLHttpRequest();
|
||||
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+encodeURIComponent((file.webkitRelativePath||file.name)));
|
||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr3.send(null);
|
||||
xhr3.onload = function(e){
|
||||
console.log(xhr3.responseText+','+xhr3.status);
|
||||
}
|
||||
<!--LoginStart-->
|
||||
var filemd5 = spark.end();
|
||||
var xhr4 = new XMLHttpRequest();
|
||||
xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent((file.webkitRelativePath||file.name))+'&filemd5='+filemd5);
|
||||
xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr4.send(null);
|
||||
xhr4.onload = function(e){
|
||||
console.log(xhr4.responseText+','+xhr4.status);
|
||||
var filename;
|
||||
//if (xhr4.status==200) filename = JSON.parse(xhr4.responseText)['name'];
|
||||
//if (xhr4.status==409) filename = filemd5 + (file.webkitRelativePath||file.name).substr((file.webkitRelativePath||file.name).indexOf('.'));
|
||||
filename = JSON.parse(xhr4.responseText)['name'];
|
||||
if (filename=='') {
|
||||
alert('<!--constStr@UploadErrorUpAgain-->');
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
if (totalsize>10*1024*1024) {
|
||||
var xhr3 = new XMLHttpRequest();
|
||||
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
|
||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr3.send(null);
|
||||
xhr3.onload = function(e){
|
||||
console.log(xhr3.responseText+','+xhr3.status);
|
||||
}
|
||||
var lasturl = location.href;
|
||||
if (lasturl.substr(lasturl.length-1)!='/') lasturl += '/';
|
||||
lasturl += filename + '?preview';
|
||||
//window.open(lasturl);
|
||||
document.getElementById('upfile_a_'+tdnum).href = lasturl;
|
||||
document.getElementById('upfile_a1_'+tdnum).href = filename;
|
||||
document.getElementById('upfile_cpbt_'+tdnum).style.display = "";
|
||||
}
|
||||
<!--LoginEnd-->
|
||||
EndTime=new Date();
|
||||
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
|
||||
if (newstartsize==0) {
|
||||
@@ -1183,10 +1232,13 @@ return false;
|
||||
} else {
|
||||
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
}
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path-->'+response.name+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path-->'+response.name+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
while (filename.indexOf('%2F')>0) filename = filename.replace('%2F', '/');
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
label.innerHTML=StartStr+MiddleStr;
|
||||
uploadbuttonshow();
|
||||
label.style.color='green';
|
||||
// uploadbuttonshow();
|
||||
<!--AdminStart-->
|
||||
response.name=file.webkitRelativePath||response.name;
|
||||
addelement(response);
|
||||
<!--AdminEnd-->
|
||||
} else {
|
||||
@@ -1202,17 +1254,299 @@ return false;
|
||||
xhr.send(binary);
|
||||
}
|
||||
} else {
|
||||
if (window.location.pathname.indexOf('%23')>0||(file.webkitRelativePath||file.name).indexOf('%23')>0) {
|
||||
if (window.location.pathname.indexOf('%23')>0||filename.indexOf('%23')>0) {
|
||||
label.innerHTML='<font color="red"><!--constStr@UploadFail23--></font>';
|
||||
} else {
|
||||
label.innerHTML='<font color="red">'+xhr2.responseText+'</font>';
|
||||
}
|
||||
uploadbuttonshow();
|
||||
// uploadbuttonshow();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<!--UploadJsEnd-->
|
||||
<!--OnedriveUploadJsEnd-->
|
||||
<!--AliyundriveUploadJsStart-->
|
||||
function preup() {
|
||||
uploadbuttonhide();
|
||||
var files=document.getElementById('upload_file').files;
|
||||
if (files.length<1) {
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
};
|
||||
var table1=document.createElement('table');
|
||||
document.getElementById('upload_div').appendChild(table1);
|
||||
table1.setAttribute('class','list-table');
|
||||
var timea=new Date().getTime();
|
||||
var i=0;
|
||||
getuplink(i);
|
||||
function getuplink(i, r=0) {
|
||||
var file=files[i];
|
||||
var td1;
|
||||
var td2;
|
||||
if (r==0) {
|
||||
var tr1=document.createElement('tr');
|
||||
table1.appendChild(tr1);
|
||||
tr1.setAttribute('data-to',1);
|
||||
td1=document.createElement('td');
|
||||
tr1.appendChild(td1);
|
||||
td1.setAttribute('style','width:30%;word-break:break-word;');
|
||||
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
|
||||
td1.innerHTML=(file.webkitRelativePath||file.name)+'<br>'+size_format(file.size);
|
||||
td2=document.createElement('td');
|
||||
tr1.appendChild(td2);
|
||||
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
|
||||
}
|
||||
var tdnum = timea+'_'+i;
|
||||
td1=document.getElementById('upfile_td1_'+tdnum);
|
||||
td2=document.getElementById('upfile_td2_'+tdnum);
|
||||
var chunksize=10*1024*1024; // 分块大小
|
||||
//var chunksize=100*1024; // 测试小块
|
||||
/*if (file.size>100*1024*1024*1024) {
|
||||
td2.innerHTML='<font color="red"><!--constStr@UpFileTooLarge--></font>';
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
}*/
|
||||
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
|
||||
var reader = new FileReader();
|
||||
reader.onprogress = function(e) {
|
||||
td2.innerText = '计算SHA1... ' + (e.loaded*100/file.size).toFixed(2) + " %";
|
||||
}
|
||||
reader.onload = function(e) {
|
||||
var filesha1 = sha1(this.result);
|
||||
<!--GuestStart-->
|
||||
function getext(str) {
|
||||
let p = str.lastIndexOf('.');
|
||||
if (p===-1) return '';
|
||||
if (p===0) return '';
|
||||
return str.substr(p);
|
||||
}
|
||||
var ext = getext(file.webkitRelativePath||file.name);
|
||||
upbigfilename = filesha1 + ext;
|
||||
<!--GuestEnd-->
|
||||
while (upbigfilename.indexOf('%2F')>0) upbigfilename = upbigfilename.replace('%2F', '/');
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
var html = JSON.parse(localStorage.getItem(filesha1));
|
||||
//console.log(html);
|
||||
if (html!==null && ('part_info_list' in html)) {
|
||||
td2.innerHTML='<!--constStr@UploadStart--> ...';
|
||||
binupfile(file, html, timea+'_'+i, upbigfilename, filesha1, chunksize);
|
||||
} else {
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onload = function(e){
|
||||
//console.log(xhr1.status+xhr1.responseText);
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font>';
|
||||
if (xhr1.status==201) {
|
||||
if (xhr1.responseText=='') {
|
||||
getuplink(i,1);
|
||||
return;
|
||||
}
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
//console.log(html);
|
||||
if (!html['part_info_list']) {
|
||||
if (html.name!='') {
|
||||
if (html.exist==true) td2.innerHTML=html.name+' 文件名已有';
|
||||
else if (html.rapid_upload==true) td2.innerHTML=html.name+' 秒传';
|
||||
else td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
|
||||
td1.innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+td1.innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+upbigfilename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
} else {
|
||||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
|
||||
}
|
||||
} else {
|
||||
td2.innerHTML='<!--constStr@UploadStart--> ...';
|
||||
//console.log(html);
|
||||
localStorage.setItem(filesha1, JSON.stringify(html));
|
||||
binupfile(file, html, timea+'_'+i, upbigfilename, filesha1, chunksize);
|
||||
}
|
||||
}
|
||||
if (i<files.length-1) {
|
||||
i++;
|
||||
getuplink(i);
|
||||
}
|
||||
}
|
||||
xhr1.send('upbigfilename='+ encodeURIComponent(upbigfilename) +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&filesha1=' + filesha1 + '&chunksize=' + chunksize);
|
||||
}
|
||||
}
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
uploadbuttonshow();
|
||||
}
|
||||
function binupfile(file, res, tdnum, filename, filesha1, chunksize) {
|
||||
// xhr.getResponseHeader
|
||||
if (!('ETag' in res)) res['ETag'] = new Array();
|
||||
var fileid = res['file_id'];
|
||||
var uploadid = res['upload_id'];
|
||||
var label=document.getElementById('upfile_td2_'+tdnum);
|
||||
var reader = new FileReader();
|
||||
var StartStr='';
|
||||
var MiddleStr='';
|
||||
var StartTime;
|
||||
var EndTime;
|
||||
var newstartsize = 0;
|
||||
if(!!file){
|
||||
var chunknum = 0;
|
||||
var chunknumtotal = res['part_info_list'].length;
|
||||
var asize=0;
|
||||
var totalsize=file.size;
|
||||
var newstartsize=0;
|
||||
while (res['ETag'][chunknum]!=null) {
|
||||
chunknum++;
|
||||
newstartsize += chunksize;
|
||||
}
|
||||
StartTime = new Date();
|
||||
asize = newstartsize;
|
||||
if (newstartsize==0) {
|
||||
StartStr='<!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
|
||||
} else {
|
||||
StartStr='<!--constStr@LastUpload-->'+size_format(newstartsize)+ '<br><!--constStr@ThisTime--><!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
|
||||
}
|
||||
//var chunksize=5*1024*1024; // chunk size, max 60M. 每小块上传大小
|
||||
//if (totalsize>200*1024*1024) chunksize=10*1024*1024;
|
||||
function readblob(start) {
|
||||
var end=start+chunksize;
|
||||
var blob = file.slice(start,end);
|
||||
reader.readAsArrayBuffer(blob);
|
||||
//reader.readAsArrayBuffer(file);
|
||||
}
|
||||
readblob(asize);
|
||||
|
||||
reader.onload = function(e){
|
||||
if (asize>totalsize) {
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onload = function(e){
|
||||
console.log(xhr1.responseText+','+xhr1.status);
|
||||
if (xhr1.status==200) {
|
||||
localStorage.removeItem(filesha1);
|
||||
<!--AdminStart-->
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
//response.name=file.webkitRelativePath||response.name;
|
||||
addelement(html);
|
||||
<!--AdminEnd-->
|
||||
/*if (totalsize>10*1024*1024) {
|
||||
var xhr3 = new XMLHttpRequest();
|
||||
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
|
||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr3.send(null);
|
||||
xhr3.onload = function(e){
|
||||
console.log(xhr3.responseText+','+xhr3.status);
|
||||
}
|
||||
}*/
|
||||
EndTime=new Date();
|
||||
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
|
||||
if (newstartsize==0) {
|
||||
MiddleStr += '<!--constStr@AverageSpeed-->:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
} else {
|
||||
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
}
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
label.innerHTML=StartStr+MiddleStr;
|
||||
label.style.color='green';
|
||||
} else {
|
||||
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
|
||||
localStorage.removeItem(filesha1);
|
||||
}
|
||||
}
|
||||
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
|
||||
} else {
|
||||
var binary = this.result;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("PUT", res['part_info_list'][chunknum]['upload_url'], true);
|
||||
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
bsize=asize+e.loaded-1;
|
||||
xhr.setRequestHeader('Content-Range', 'bytes ' + asize + '-' + bsize +'/'+ totalsize);
|
||||
xhr.upload.onprogress = function(e){
|
||||
if (e.lengthComputable) {
|
||||
var tmptime = new Date();
|
||||
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
|
||||
var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
|
||||
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+remaintime.toFixed(1)+'s';
|
||||
}
|
||||
}
|
||||
var C_starttime = new Date();
|
||||
xhr.onload = function(e){
|
||||
if (xhr.status<500) {
|
||||
//console.log(xhr.responseText);
|
||||
//console.log(xhr.getResponseHeader('ETag'));
|
||||
//var response=JSON.parse(xhr.responseText);
|
||||
if (xhr.responseText==''&&xhr.getResponseHeader('ETag')!='') {
|
||||
// 有ETag说明本段上传成功
|
||||
let etag = xhr.getResponseHeader('ETag');
|
||||
//if (etag.substr(0,1)=='"') etag = etag.substr(1);还就要引号!
|
||||
//if (etag.substr(-1)=='"') etag = etag.substr(0, etag.length-1);
|
||||
res['ETag'][chunknum] = etag;
|
||||
localStorage.setItem(filesha1, JSON.stringify(res));
|
||||
chunknum++;
|
||||
asize = bsize + 1;
|
||||
if (chunknum==chunknumtotal) {
|
||||
// 上传结束
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
xhr1.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onload = function(e){
|
||||
console.log(xhr1.responseText+','+xhr1.status);
|
||||
if (xhr1.status==200) {
|
||||
localStorage.removeItem(filesha1);
|
||||
<!--AdminStart-->
|
||||
var html=JSON.parse(xhr1.responseText);
|
||||
//response.name=file.webkitRelativePath||response.name;
|
||||
addelement(html);
|
||||
<!--AdminEnd-->
|
||||
/*if (totalsize>10*1024*1024) {
|
||||
var xhr3 = new XMLHttpRequest();
|
||||
xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
|
||||
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr3.send(null);
|
||||
xhr3.onload = function(e){
|
||||
console.log(xhr3.responseText+','+xhr3.status);
|
||||
}
|
||||
}*/
|
||||
EndTime=new Date();
|
||||
MiddleStr = '<!--constStr@EndAt-->:'+EndTime.toLocaleString()+'<br>';
|
||||
if (newstartsize==0) {
|
||||
MiddleStr += '<!--constStr@AverageSpeed-->:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
} else {
|
||||
MiddleStr += '<!--constStr@ThisTime--><!--constStr@AverageSpeed-->:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
}
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
|
||||
label.innerHTML=StartStr+MiddleStr;
|
||||
label.style.color='green';
|
||||
} else {
|
||||
label.innerHTML= '<font color="red">' + xhr1.status + ',' + xhr1.responseText + '</font>';
|
||||
localStorage.removeItem(filesha1);
|
||||
}
|
||||
}
|
||||
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']));
|
||||
// uploadbuttonshow();
|
||||
} else {
|
||||
readblob(asize);
|
||||
}
|
||||
} else {
|
||||
console.log(xhr.status+xhr.responseText);//<PartEtag>
|
||||
if (xhr.status==409) {
|
||||
let str = xhr.responseText;
|
||||
str = str.substr(str.indexOf('<PartEtag>')+10);
|
||||
str = str.substr(0, str.indexOf('</PartEtag>'));
|
||||
res['ETag'][chunknum] = str;
|
||||
localStorage.setItem(filesha1, JSON.stringify(res));
|
||||
chunknum++;
|
||||
asize += chunksize;
|
||||
readblob(asize);
|
||||
}
|
||||
//label.innerHTML='<font color="red">'+xhr.responseText+'</font><br>';
|
||||
} } else readblob(asize);
|
||||
}
|
||||
xhr.send(binary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
<!--AliyundriveUploadJsEnd-->
|
||||
<!--ListEnd-->
|
||||
function operatediv_close(operate) {
|
||||
document.getElementById(operate+'_div').style.display='none';
|
||||
@@ -1220,7 +1554,10 @@ return false;
|
||||
}
|
||||
<!--AdminStart-->
|
||||
function logout() {
|
||||
document.cookie = "admin=; path=/";
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+1000);
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie = "admin=; path=/; "+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
<!--IsFolderStart-->
|
||||
@@ -1229,26 +1566,24 @@ return false;
|
||||
for ($i=0;$i<$operatediv.length;$i++) {
|
||||
$operatediv[$i].style.display='none';
|
||||
}
|
||||
document.getElementById('mask').style.display='none';
|
||||
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';
|
||||
if (num=='') {
|
||||
var str='';
|
||||
var fileid='';
|
||||
} else {
|
||||
var str=document.getElementById('file_a'+num).innerText;
|
||||
if (str=='') {
|
||||
str=document.getElementById('file_a'+num).getElementsByTagName("img")[0].alt;
|
||||
if (str=='') {
|
||||
alert('<!--constStr@GetFileNameFail-->');
|
||||
operatediv_close(action);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
|
||||
var str=decodeURIComponent(document.getElementById('file_a'+num).href);
|
||||
if (str.substr(-1)==' ') str=str.substr(0, str.length-1);
|
||||
if (str.substr(-1)=='/') str=str.substr(0, str.length-1);
|
||||
if (str.substr(-8)=='?preview') str=str.substr(0, str.length-8);
|
||||
if (str.lastIndexOf('/')>-1) str=str.substr(str.lastIndexOf('/')+1);
|
||||
var fileid=document.getElementById('file_a'+num).attributes['fileid'].nodeValue;
|
||||
}
|
||||
document.getElementById(action + '_div').style.display='';
|
||||
document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&');
|
||||
document.getElementById(action + '_sid').value=num;
|
||||
document.getElementById(action + '_fileid').value=fileid;
|
||||
document.getElementById(action + '_hidden').value=str;
|
||||
if (action=='rename') document.getElementById(action + '_input').value=str;
|
||||
var $e = event || window.event;
|
||||
@@ -1277,9 +1612,9 @@ return false;
|
||||
function submit_operate(str) {
|
||||
var num=document.getElementById(str+'_sid').value;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", '?'+serializeForm(str+'_form'));
|
||||
xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr.send(null);
|
||||
xhr.open("POST", '');
|
||||
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
|
||||
xhr.setRequestHeader('x-requested-with', 'XMLHttpRequest');
|
||||
xhr.onload = function(e){
|
||||
var html;
|
||||
if (xhr.status<300) {
|
||||
@@ -1295,10 +1630,12 @@ return false;
|
||||
html=JSON.parse(xhr.responseText);
|
||||
addelement(html);
|
||||
}
|
||||
//alert('success');
|
||||
} else alert(xhr.status+'\n'+xhr.responseText);
|
||||
document.getElementById(str+'_div').style.display='none';
|
||||
document.getElementById('mask').style.display='none';
|
||||
}
|
||||
xhr.send(serializeForm(str+'_form'));
|
||||
return false;
|
||||
}
|
||||
function addelement(html) {
|
||||
@@ -1312,15 +1649,16 @@ return false;
|
||||
a1.target='_blank';
|
||||
var td2=document.createElement('td');
|
||||
td2.setAttribute('class','updated_at');
|
||||
td2.innerText=html.lastModifiedDateTime.replace(/T/,' ').replace(/Z/,'');
|
||||
if (!!html.time) td2.innerText=html.time.replace(/T/,' ').replace(/Z/,'');
|
||||
var td3=document.createElement('td');
|
||||
td3.setAttribute('class','size');
|
||||
td3.innerText=size_format(html.size);
|
||||
if (!!html.folder) {
|
||||
if (!!html.size) td3.innerText=size_format(html.size);
|
||||
else td3.innerText='0 B';
|
||||
if (html.type=='folder') {
|
||||
a1.href+='/';
|
||||
document.getElementById('tr0').parentNode.insertBefore(tr1,document.getElementById('tr0').nextSibling);
|
||||
}
|
||||
if (!!html.file) {
|
||||
if (html.type=='file') {
|
||||
a1.href+='?preview';
|
||||
a1.name='filelist';
|
||||
document.getElementById('tr0').parentNode.appendChild(tr1);
|
||||
@@ -1396,7 +1734,7 @@ return false;
|
||||
<!--AdminEnd-->
|
||||
<!--LoginStart-->
|
||||
function login() {
|
||||
document.getElementById('mask').style.display='none';
|
||||
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='';
|
||||
@@ -1405,6 +1743,9 @@ return false;
|
||||
document.getElementById('login_input').focus();
|
||||
}
|
||||
<!--LoginEnd-->
|
||||
<!--EncryptedStart-->
|
||||
document.getElementById('password1').focus();
|
||||
<!--EncryptedEnd-->
|
||||
</script>
|
||||
<script src="//unpkg.zhimg.com/ionicons@4.4.4/dist/ionicons.js"></script>
|
||||
<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
|
||||
+3
-2
@@ -807,6 +807,7 @@
|
||||
return;
|
||||
}
|
||||
upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
|
||||
var filemd5='';
|
||||
<!--GuestStart-->
|
||||
function getext(str) {
|
||||
strarry=str.split('.');
|
||||
@@ -843,7 +844,7 @@
|
||||
<!--GuestEnd-->
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onprogress = function(e){
|
||||
td2.innerHTML+='.';
|
||||
@@ -878,7 +879,7 @@
|
||||
getuplink(i);
|
||||
}
|
||||
}
|
||||
xhr1.send(null);
|
||||
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5);
|
||||
<!--GuestStart-->
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -849,6 +849,7 @@
|
||||
return;
|
||||
}
|
||||
upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
|
||||
var filemd5='';
|
||||
<!--GuestStart-->
|
||||
function getext(str) {
|
||||
strarry=str.split('.');
|
||||
@@ -885,7 +886,7 @@
|
||||
<!--GuestEnd-->
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
xhr1.open("GET", '?action=upbigfile&upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
|
||||
xhr1.open("POST", '?action=upbigfile');
|
||||
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
xhr1.onprogress = function(e){
|
||||
td2.innerHTML+='.';
|
||||
@@ -920,7 +921,7 @@
|
||||
getuplink(i);
|
||||
}
|
||||
}
|
||||
xhr1.send(null);
|
||||
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5);
|
||||
<!--GuestStart-->
|
||||
}
|
||||
}
|
||||
|
||||
-1272
File diff suppressed because it is too large
Load Diff
+519
-1
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1657
File diff suppressed because it is too large
Load Diff
-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,7 +1,34 @@
|
||||
20210331-1530.36
|
||||
admin can only use classic theme after admin login, and guest can not change theme now. fix: Sharelink can not work in php8. show disk space. limit 5 files in uploading. do with activityLimitReached. fix some bugs.
|
||||
暂时解决昨天阿里云盘最新防盗链。管理登录后只能用classic主题,游客不能再切换主题了。修复Sharelink在php8下不能正常工作。显示盘空间。同时上传文件数限制5个。对activityLimitReached稍微处理。修复一些bug。
|
||||
|
||||
20210313-1352.35
|
||||
use driveId, after update, <font color="red">Aliyundrive and Googledrive please click the Change link after Driver type</font>. try fix: php8 will run error 500. change layout in settup. fix: uploading non-englist file name. try fix: sha1 a big file.
|
||||
换用driveId,更新后<font color="red">Aliyundrive与Googledrive请点一下那个切换链接</font>。尝试修复php8的500 ERROR。改变设置页面的布局。修复上传中文名文件时最终文件以url代码命名。阿里云盘上传时可以sha1大文件了。
|
||||
20210311-2004.34
|
||||
try fix: can not login, sha1.js not loaded(changed a cdn), show error log.
|
||||
尝试修复登录不了的情况:可能sha1.js没有载入(换了源),在登录页显示出错信息。
|
||||
20210309-1718.33
|
||||
Googledrive can operate now, but the uploading can not done on explorer without token. Onedrive try deal with activeLimit. Can change admin password now. Admin password will sha1 when submitting. Fix some bugs.
|
||||
Googledrive可以管理操作了,但因为没法在浏览器端不带token上传,所以上传操作作罢。Onedrive尝试处理activeLimit。可以修改admin密码了。登录等提交admin密码时,会sha1加密再提交。修复一些bug。
|
||||
20210301-1745.32
|
||||
Onedrive client secret extend. export&import config. adding Googledrive. add reffer: only listing domains can refer. add diskDescription: tips of disk. Heroku change function_name to HerokuappId. try fix domainforproxy. fix create in Aliyundrive. fix other bugs.
|
||||
Onedrive 的client延期。可以导入导出配置了。初步添加Googledrive。添加reffer:只有指定域名能引用。添加diskDescription:可以对盘备注了。Heroku中将function_name改为使用HerokuappId。尝试修复domainforproxy在个人帐号时的问题。修复阿里云盘不能新建与加密。修复其它bug。
|
||||
20210118-1600.31
|
||||
can change Ondrive to Sharepoint, can copy a disk. fix a bug that 500 error in setup.
|
||||
Onedrive跟Sharepoint可以切换了,可以复制一个盘。修复bug。
|
||||
20210115-1111.30
|
||||
<font color=red>v3, after update, please AddDisk again, please set passfile again.</font> themes of php deleted, or you can use branch v2_last.
|
||||
<font color=red>v3,一键升级后请重新添加盘,passfile失效,重新设置。</font>php主题删掉了,要么就用v2_last分支。
|
||||
20201229.29
|
||||
Modify tags, change sequence of disk.
|
||||
可以修改标签,移动标签顺序。
|
||||
20201215-1400.28
|
||||
fix: hackers can upload files to ANY folder (or create a new folder) in your Onedrive. add language zh-tw. now, on heroku, xhr can post. fix: 2 or more space in file name cause bugs.
|
||||
修复:构造代码后可以上传文件到你Onedrive的任意目录(甚至创建新目录)。新增zh-tw语言。xhr的post在heroku会接收了,改回post。修复:文件名有多个空格相连时造成bug。
|
||||
20201106-1730.27
|
||||
Add theme. A code used in CloudFlare Workers. Admin not need password in folder. Add caddy2 rewrite rule. Add new platform Glitch. <font color=red>web hosting and VPS user should backup your config.php, after update, copy it to .data foloder.</font>
|
||||
添加主题。添加一段用于CF workers的代码。加密目录管理员不需要密码了。添加caddy2伪静态。新增Glitch平台。<font color=red>虚拟主机与VPS用户请备份config.php,升级后,手动将它覆盖到.data目录。</font>
|
||||
|
||||
20200828-1420.26
|
||||
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.
|
||||
nginx的伪静态中排除.well-known目录,方便自动SSL。添加IIS的伪静态。与linux不同,处理windows下目录用\分隔。FC、FG中使用自己代码对接平台。<font color=red>世纪互联旧API即将过期失效,升级后世纪互联的盘需要删除重新添加。</font>更新说明只显示部分。
|
||||
|
||||
Reference in New Issue
Block a user