329 Commits
Author SHA1 Message Date
qkqpttgfandGitHub 646c963eba Update version 2021-12-01 16:12:57 +08:00
qkqpttgfandGitHub ae757bef84 add setup=auth, check if another building 2021-12-01 14:55:41 +08:00
qkqpttgfandGitHub 21c1120867 add setup=auth, check if another building 2021-12-01 14:54:29 +08:00
qkqpttgfandGitHub 05531b5fe1 add setup=auth 2021-12-01 14:51:43 +08:00
qkqpttgfandGitHub 8c270bb7eb add setup=auth 2021-12-01 14:50:41 +08:00
qkqpttgfandGitHub f439497c6a add setup=auth 2021-12-01 14:39:21 +08:00
qkqpttgfandGitHub 717b454256 add setup=auth 2021-12-01 14:38:07 +08:00
qkqpttgfandGitHub eee1c5511a add setup=auth 2021-12-01 14:36:52 +08:00
qkqpttgfandGitHub 92d4401070 add setup=auth 2021-12-01 14:30:36 +08:00
qkqpttgfandGitHub 7d56bde181 add setup=auth 2021-12-01 14:29:16 +08:00
qkqpttgfandGitHub 7fbc9c8285 add setup=auth 2021-12-01 14:26:01 +08:00
qkqpttgfandGitHub 41ca3bc56f try fix no driver in config sometime 2021-12-01 14:24:38 +08:00
qkqpttgfandGitHub 42e06e647d mv waitfunction before install, add setp=auth 2021-12-01 14:23:18 +08:00
qkqpttgfandGitHub 9fdd9227a5 remove ts, add 3gp 2021-11-27 12:38:49 +08:00
qkqpttgfandGitHub 6383864bb6 short fix back link when spacialChar 2021-11-26 14:54:39 +08:00
qkqpttgfandGitHub e6abbc6086 fix back link with spacialChar 2021-11-26 09:46:25 +08:00
qkqpttgfandGitHub 340c84ef76 try clear cache after upload done 2021-11-25 15:46:06 +08:00
qkqpttgfandGitHub a44ca9f83c login by jump not dialog 2021-11-25 14:06:13 +08:00
qkqpttgfandGitHub 78c616b52d fix sort when size is TB
#470 ,
2021-11-23 20:07:55 +08:00
qkqpttgfandGitHub e0d7bba0fb Redirect when folder not end with / (fix disktag with no /) 2021-11-23 19:59:41 +08:00
qkqpttgfandGitHub 51d7e13ca5 sort config in vercel file 2021-11-16 13:35:03 +08:00
qkqpttgfandGitHub af90ff91f7 fix ' in path cause js error 2021-11-16 11:24:28 +08:00
qkqpttgfandGitHub 06988494b3 order_by name asc 2021-11-14 17:17:17 +08:00
root 9d677c8aee fix: too many redirect in SCF/FC/FG/CFC 2021-11-10 11:42:19 +00:00
qkqpttgfandGitHub 724f357fc4 fix: too many redirect in SCF long link 2021-11-10 18:40:24 +08:00
qkqpttgfandGitHub 2f48674ef8 Update readme_cn.md 2021-11-08 18:56:39 +08:00
qkqpttgfandGitHub e34cfb173c Update readme.md 2021-11-08 18:55:59 +08:00
qkqpttgfandGitHub 7627fd78eb Update readme_cn.md 2021-11-08 18:48:53 +08:00
qkqpttgfandGitHub 83ee24fc90 check if exist curl in vps at php start, not install 2021-11-04 10:41:25 +08:00
qkqpttgfandGitHub 2dfd11c8d1 check if exist curl in vps at begin
#462 check curl mod
2021-11-04 10:39:57 +08:00
qkqpttgfandGitHub 4577a35b83 Redirect when folder not end with /
#465 fix
2021-11-04 10:36:28 +08:00
qkqpttgfandGitHub 880f90b026 try fix encrypt current directory at left-top 2021-11-01 18:50:13 +08:00
qkqpttgfandGitHub 51cc75c0f5 try fix encrypt current directory at left-top 2021-11-01 18:49:35 +08:00
qkqpttgfandGitHub 457e2cee18 try to check exist curl before install 2021-11-01 18:45:49 +08:00
qkqpttgfandGitHub 0d2f38af37 Create CFWorkers_rand.js 2021-10-28 10:56:24 +08:00
qkqpttgfandGitHub 0683524cd3 try fix + in FG 2021-10-25 10:58:10 +08:00
qkqpttgfandGitHub 22fb9dd669 try fix + in FG 2021-10-25 10:57:24 +08:00
qkqpttgfandGitHub 621aadecdf fix export&import with no localstorage 2021-10-22 13:36:26 +08:00
qkqpttgfandGitHub 330ec7680d fix fix a bug 2021-10-21 17:08:12 +08:00
qkqpttgfandGitHub d8a1832c01 fix a bug
#448 .
2021-10-21 16:43:52 +08:00
qkqpttgfandGitHub 89e4fa6f42 try fix login in specialChar folder will jump to error 2021-10-21 16:20:01 +08:00
qkqpttgfandGitHub 13e72665ac fix & in title 2021-10-21 12:49:24 +08:00
qkqpttgfandGitHub d02c9beb53 encrypt via fileID 2021-10-21 11:40:55 +08:00
qkqpttgfandGitHub 07664407c6 encrypt via fileID, try fix get pass from specialchars folder 2021-10-21 11:39:09 +08:00
qkqpttgfandGitHub 9623e03c3f try fix index.html in specialchars folder 2021-10-20 17:11:09 +08:00
qkqpttgfandGitHub b737194bea try fix readme in specialchars folder 2021-10-20 17:01:09 +08:00
qkqpttgfandGitHub a3108ad6e9 fix show special chars in url textarea 2021-10-20 11:34:14 +08:00
qkqpttgfandGitHub 239ddea6f3 try fix specialchars 2021-10-20 11:33:09 +08:00
qkqpttgfandGitHub d4adc8233e fix: AddDisk with no driver name
#449 .
2021-10-20 09:49:55 +08:00
qkqpttgfandGitHub 04721295fa fix random on a file cause error in php8
#446 fix
2021-10-19 14:36:15 +08:00
qkqpttgfandGitHub 5b232b3ef5 fix cant change disk order 2021-10-18 10:34:54 +08:00
qkqpttgfandGitHub 9381bcaab3 try fix & in base_path in FC 2021-10-15 17:26:29 +08:00
qkqpttgfandGitHub bab19ae9d3 try fix PathArray with & , last not preview 2021-10-15 16:54:54 +08:00
qkqpttgfandGitHub 07c715c7e0 try fix # in title 2021-10-15 13:44:06 +08:00
qkqpttgfandGitHub 37993f0113 try fix # 2021-10-15 13:26:57 +08:00
qkqpttgfandGitHub bec4e3c91f Create readme_cn.md 2021-10-15 10:57:23 +08:00
qkqpttgfandGitHub 44b8738b0c separate en/cn 2021-10-15 10:56:32 +08:00
qkqpttgfandGitHub 978c7722e4 fix too many redirect when adddisk with no admin
#259 thx
2021-10-14 10:00:43 +08:00
qkqpttgfandGitHub 212a7008dd focus at last, in cmd 2021-10-13 18:08:52 +08:00
qkqpttgfandGitHub f924b116db fix XSS in random file 2021-10-07 14:32:22 +08:00
qkqpttgfandGitHub 0220c29dbf fix cant upload 2021-10-07 12:39:49 +08:00
qkqpttgfandGitHub cb478ccf66 operate by id 2021-10-06 19:28:05 +08:00
qkqpttgfandGitHub 0a0162abe2 fix & 2021-10-06 16:32:23 +08:00
root 9205015782 fix CSRF, try fix %20 2021-10-06 08:01:31 +00:00
qkqpttgfandGitHub 76249edf4d Merge pull request #436 from ifwlzs/master
Update readme.md
2021-10-04 19:05:42 +08:00
ifwlzsandGitHub 5eb8fc8172 Update readme.md 2021-10-04 18:57:06 +08:00
qkqpttgfandGitHub 45a7b1e303 try fix filename have () or other in FC 2021-09-28 12:47:06 +08:00
qkqpttgfandGitHub d2fd1f3a05 try fix filename have [] in FC 2021-09-28 11:01:44 +08:00
qkqpttgfandGitHub bb31dee01d Merge pull request #427 from Sansui233/master
Update theme flatcard
2021-09-22 09:07:20 +08:00
Sansui233 8e53c2883d fix vertical align 2021-09-21 20:37:52 +08:00
Sansui233 a167ce1376 add responsive grid-view when thumbnails 2021-09-21 20:03:34 +08:00
Sansui233 4c14349c76 add grid-view 2021-09-21 20:03:34 +08:00
Sansui233 cec9cfd800 save 2021-09-21 20:03:33 +08:00
qkqpttgfandGitHub 76524fbced video add ts
#388
2021-09-10 09:21:31 +08:00
qkqpttgfandGitHub 369e5c3394 fileConduit 2021-09-08 18:07:03 +08:00
qkqpttgfandGitHub d2909b85bc fileConduit 2021-09-08 18:06:53 +08:00
root 8dea16da78 add littleFileCacheTime 2021-09-08 05:03:36 +00:00
qkqpttgfandGitHub ee23cd636f chang ' to "
#418 ,
2021-09-06 20:21:18 +08:00
qkqpttgfandGitHub c7f4089b2a add Hidden function "cmd" 2021-09-03 09:04:56 +08:00
root bdfee2c81b fix error in wait function 2021-08-26 10:09:57 +00:00
qkqpttgfandGitHub b6860e373a move BackHome up Title 2021-08-24 03:31:59 +00:00
qkqpttgfandGitHub f81284b3f9 wait app build in heroku 2021-08-23 13:18:54 +08:00
qkqpttgfandGitHub 8a4341cbd2 fix : cant find lower readme.md in Aliyundrive 2021-08-23 10:40:00 +08:00
qkqpttgfandGitHub 45648eb676 translate "change password" & "export, import"
#359
2021-08-21 12:07:25 +00:00
qkqpttgfandGitHub f3668b79e9 translate "change password" & "export, import" 2021-08-21 12:03:40 +00:00
qkqpttgfandGitHub 3aecc1ddf5 Update readme.md 2021-08-20 18:56:14 +08:00
qkqpttgfandGitHub 4f6241d445 fix: not put config when update 2021-08-20 10:51:14 +00:00
qkqpttgfandGitHub 5cdf343415 Update version 2021-08-20 10:35:01 +00:00
qkqpttgfandGitHub 24def8d1ab config save in file default in Vercel 2021-08-20 10:09:16 +00:00
qkqpttgfandGitHub d61ed7a03c Create Vercel.php 2021-08-20 10:07:33 +00:00
qkqpttgfandGitHub 536a8e60da Rename Vercel.php to Vercel_env.php 2021-08-20 10:06:58 +00:00
qkqpttgfandGitHub dc58b15913 fix bug, cant save config 2021-08-19 01:27:03 +00:00
qkqpttgfandGitHub 3d67d57ded show Environment<4K error 2021-08-18 05:14:16 +00:00
qkqpttgfandGitHub 7e5fc7c502 Update version 2021-08-17 20:34:16 +08:00
root f2ee21b683 add WaitFunction in operate 2021-08-17 11:51:17 +00:00
qkqpttgfandGitHub 729e1e1176 chang SCF update 2021-08-17 19:37:00 +08:00
qkqpttgfandGitHub 12494b62ed change dontBasicAuth to useBasicAuth 2021-08-09 04:27:25 +00:00
qkqpttgfandGitHub 54e38b5f67 change dontBasicAuth to useBasicAuth 2021-08-09 04:25:18 +00:00
qkqpttgfandGitHub b079891a1e try2 fix [500 Parse Error: Expected HTTP/] in Vercel 2021-08-07 20:56:41 +08:00
qkqpttgfandGitHub ee33e30cbf try fix [500 Parse Error: Expected HTTP/] in Vercel 2021-08-07 20:30:45 +08:00
qkqpttgfandGitHub c862409072 pay me 2021-08-06 18:29:33 +08:00
qkqpttgfandGitHub 0a20505798 add How to deploy to Vercel 2021-08-05 18:14:47 +08:00
qkqpttgfandGitHub 29e9fea562 try fix bug 2021-08-05 18:13:37 +08:00
qkqpttgfandGitHub 80d93cb852 temp fix add driver error 2021-08-05 18:11:46 +08:00
qkqpttgfandGitHub b2b5703977 fix: base_path error, read {} as object 2021-08-05 16:05:37 +08:00
qkqpttgfandGitHub 21d7d5d007 Update version 2021-08-04 15:46:16 +08:00
qkqpttgfandGitHub e06065a95c add platform Vercel 2021-08-04 15:30:19 +08:00
qkqpttgfandGitHub e58502f0be add platform Vercel 2021-08-04 15:28:58 +08:00
qkqpttgfandGitHub 9ff6e6bfe4 add platform Vercel 2021-08-04 15:26:13 +08:00
qkqpttgfandGitHub 52de7975c4 background (or other) based on width/height not only width 2021-08-04 15:19:50 +08:00
qkqpttgfandGitHub 638d8b09e3 fix bug 2021-08-04 15:17:17 +08:00
qkqpttgfandGitHub 244fbf747c rename use file id 2021-08-04 15:16:08 +08:00
qkqpttgfandGitHub 47bf9705bb Merge pull request #392 from yareiy/yareiy-patch-1
fix: ionicons svg 404 error and Cannot read property 'focus' of null
2021-08-04 09:09:50 +08:00
夜棂依andGitHub 23bf6fa38f fix: Cannot read property 'focus' of null 2021-08-03 21:42:07 +08:00
夜棂依andGitHub e2494ff385 fix: ionicons svg 404 error 2021-08-03 21:37:34 +08:00
夜棂依andGitHub 353222fc47 fix: ionicons svg 404 error 2021-08-03 21:34:14 +08:00
qkqpttgfandGitHub ba6aa0e9a1 Merge pull request #391 from yareiy/yareiy-patch-1
fix svg 404
2021-08-03 09:11:57 +08:00
夜棂依andGitHub 00422380d4 fix svg 404 2021-08-03 02:27:12 +08:00
qkqpttgfandGitHub 82f4d1b247 Merge pull request #383 from wendaleruan/patch-1
fix svg 404
2021-07-26 11:08:24 +08:00
wendaleandGitHub 21d96bb838 fix svg 404 2021-07-26 10:41:37 +08:00
qkqpttgfandGitHub 31b64cf4ba try fix: ionicons svg 404 error 2021-07-26 10:23:03 +08:00
qkqpttgfandGitHub fc5cdab36b try fix: custom domain in glitch, force https 2021-07-16 13:57:52 +08:00
qkqpttgfandGitHub c0d3afcaa4 Merge pull request #368 from BingoKingo/patch-1
tfo theme 20210711
2021-07-12 08:53:13 +08:00
BingoKingoandGitHub 1a5a6ee0e8 tfo theme 20210711 2021-07-11 19:47:54 +08:00
qkqpttgfandGitHub bc4a300cf7 Update readme.md 2021-07-06 20:41:16 +08:00
qkqpttgfandGitHub 8732de4047 Heroku Policy 2021-07-01 16:23:45 +08:00
qkqpttgfandGitHub 3249934f36 MSAPI, headers 2021-06-24 15:55:24 +08:00
qkqpttgfandGitHub c6e93168af fix: readme hidden 2021-06-23 16:11:13 +08:00
qkqpttgfandGitHub 74bb87ef15 fix: get hidden filename via json 2021-06-20 17:57:08 +08:00
qkqpttgfandGitHub 86ba05b5be MSAPI, GET 2021-06-17 17:18:44 +08:00
qkqpttgfandGitHub 7e4bf448e3 fix: guest upload >5 files. change: chunk size change with speed, operate box in middle. 2021-06-03 14:28:00 +08:00
qkqpttgfandGitHub 1737477aed Update readme.md 2021-05-28 15:55:30 +08:00
qkqpttgfandGitHub 33e464f991 try fix: image too long 2021-05-28 13:27:13 +08:00
qkqpttgfandGitHub dec313c0c7 fix: dont load disk cache in check rewrite 2021-05-25 18:25:29 +08:00
qkqpttgfandGitHub 0adcec4cf4 Update readme.md 2021-05-25 09:29:23 +08:00
qkqpttgfandGitHub 4de09d0a15 add nginx rewrite when used in Subdirectory 2021-05-24 17:55:28 +08:00
qkqpttgfandGitHub 5d7b4deeb7 dont load disk cache in check rewrite 2021-05-24 17:29:49 +08:00
qkqpttgfandGitHub 3498d8862e Merge pull request #327 from Sansui233/master
add theme flatcard
2021-05-18 19:35:35 +08:00
Sansui233 e9c3125194 add theme flatcard 2021-05-18 18:40:30 +08:00
qkqpttgfandGitHub 6030c320c5 Merge pull request #324 from kizx/onemoeTheme
更新onemoe主题
2021-05-17 10:43:05 +08:00
qkqpttgfandGitHub dd1250b0f0 try fix & and &amp; in path 2021-05-16 20:12:17 +08:00
kizx d03423bb5f 更新onemoe主题 2021-05-16 17:47:47 +08:00
qkqpttgfandGitHub 77d8147405 try fix & in path 2021-05-16 12:50:39 +08:00
qkqpttgfandGitHub 52d765a27f margin in foot of preview 2021-05-14 14:41:16 +08:00
qkqpttgfandGitHub 41d37f6bb4 Merge pull request #321 from qkqpttgf/GBKpreview
GBKpreview
2021-05-14 14:28:56 +08:00
qkqpttgfandGitHub 57fc272939 more files 2021-05-13 15:13:08 +08:00
qkqpttgfandGitHub fa7b27a878 try fix GBK txt preview 2021-05-13 13:59:36 +08:00
qkqpttgfandGitHub 279055b3bb try fix GBK txt preview 2021-05-13 13:58:43 +08:00
qkqpttgfandGitHub 741044e5ea try fix GBK txt preview 2021-05-13 13:57:24 +08:00
qkqpttgfandGitHub 13b70a4252 fix the last folder name is the number it in list 2021-05-13 09:54:52 +08:00
qkqpttgfandGitHub 57f5a1cdd2 try Aliyundrive norefer in output 2021-05-13 09:43:57 +08:00
qkqpttgfandGitHub 3b084f9544 Update version 2021-05-12 16:55:17 +08:00
qkqpttgfandGitHub 72e08c886a hide "login" 2021-05-12 16:39:19 +08:00
root e131588680 forceHttps 2021-05-12 08:35:34 +00:00
qkqpttgfandGitHub d33578ad57 fix: continue upload after stop 2021-04-25 11:07:55 +08:00
qkqpttgfandGitHub 388f08a9b0 Merge pull request #303 from jssycszyj/master
修复文件夹名包含%导致文件夹下文件400错误
2021-04-22 14:04:16 +08:00
jssycszyj 398fa02063 Update common.php 2021-04-21 23:45:18 +08:00
jssycszyj a630f9cbe7 Update common.php 2021-04-21 23:36:14 +08:00
jssycszyj 04908da5a4 Update common.php 2021-04-21 22:46:07 +08:00
qkqpttgfandGitHub 1da82abb95 fix: can not edit disk when disktag is 'home' 2021-04-20 19:11:38 +08:00
qkqpttgfandGitHub b545056787 theme only for guest 2021-04-19 20:46:30 +08:00
qkqpttgfandGitHub f33564258d fix: back color of container 2021-04-19 19:42:27 +08:00
qkqpttgfandGitHub a4fe802689 fix: radius 2021-04-19 19:35:54 +08:00
qkqpttgfandGitHub 98d5b4d63f mv TagSort to top 2021-04-19 19:03:52 +08:00
qkqpttgfandGitHub bd682db3b9 try fix: delete button hidden at last line 2021-04-19 18:23:04 +08:00
qkqpttgfandGitHub f993264e91 fix: sharepoint change to another sharepoint 2021-04-11 22:15:01 +08:00
qkqpttgfandGitHub a8e3d2ad15 Merge pull request #294 from qkqpttgf/qkqpttgf-patch-1
try fix: can not click operate in Safari
2021-04-11 21:46:07 +08:00
qkqpttgfandGitHub ef1748ba15 Update classic.html 2021-04-11 21:33:35 +08:00
qkqpttgfandGitHub e116b1224e try fix: preview office files 2021-04-09 10:44:56 +08:00
qkqpttgfandGitHub 55c9805cc0 try fix some error in import 2021-04-07 21:16:37 +08:00
qkqpttgfandGitHub 99d3d4c2ee fix: 500 error in setting new app 2021-04-07 20:07:30 +08:00
qkqpttgfandGitHub ea278dc2b3 Update version 2021-03-31 15:43:52 +08:00
qkqpttgfandGitHub ca4ec6f497 fix: Aliyun download need header
改用手机token
2021-03-31 15:30:07 +08:00
qkqpttgfandGitHub 671481c284 use content cache in TXT 2021-03-31 15:28:00 +08:00
qkqpttgfandGitHub 449ead425a try fix: ShareLink get cookie in php8(Set-Cookie/set-cookie) 2021-03-30 16:16:07 +08:00
qkqpttgfandGitHub c0852bc979 Merge pull request #274 from 186526/patch-22
[UPDATE] renexmoe v1.3
2021-03-28 17:32:36 +08:00
qkqpttgfandGitHub 8a5d22f699 add change description 2021-03-28 17:18:48 +08:00
186526andGitHub ff74c9b50c [UPDATE] renexmoe v1.3
更新详情见 https://github.com/186526/onemanager-theme-renexmoe
2021-03-28 17:10:55 +08:00
qkqpttgfandGitHub d9d34d32c9 fix: guest upload exist file, get local name not md5 2021-03-28 17:01:15 +08:00
qkqpttgfandGitHub d591812c7f fix: need Sites scope 2021-03-28 16:42:23 +08:00
qkqpttgfandGitHub 599b937f99 fix: need Sites scope 2021-03-28 16:42:19 +08:00
qkqpttgfandGitHub 7ea726c9c7 fix: need Sites scope 2021-03-28 16:39:06 +08:00
qkqpttgfandGitHub 1295ad92ef fix: need Sites scope 2021-03-28 16:38:37 +08:00
qkqpttgfandGitHub 32649ccc62 fix: reading base64 config in SCF_file 2021-03-28 16:24:25 +08:00
qkqpttgfandGitHub e83648a332 admin fix classic theme, remove disableChangeTheme 2021-03-27 14:55:09 +08:00
qkqpttgfandGitHub ec6e9d50ce show hour&minute when uploading 2021-03-27 14:34:58 +08:00
qkqpttgfandGitHub 58482e88c5 fix: SCF Region 2021-03-22 22:46:14 +08:00
qkqpttgfandGitHub d377410b19 fix: SCF Region 2021-03-22 22:45:33 +08:00
qkqpttgfandGitHub 75710ec7e9 try limit 5 uploading at same time 2021-03-16 14:17:37 +08:00
qkqpttgfandGitHub 43b1046aba fix bug 2021-03-15 21:28:53 +08:00
qkqpttgfandGitHub 0f5c7587d5 get personal drive space size 2021-03-15 21:16:21 +08:00
qkqpttgfandGitHub d5c456bc0b try fix activityLimitReached 2021-03-14 17:34:18 +08:00
qkqpttgfandGitHub 7b51e773f3 get disk space size 2021-03-14 17:00:39 +08:00
qkqpttgfandGitHub 82e8d5d0e7 wait to get disk space size 2021-03-14 17:00:01 +08:00
qkqpttgfandGitHub 06db4a70f6 get disk space size 2021-03-14 16:59:07 +08:00
qkqpttgfandGitHub 3118222734 get disk space size 2021-03-14 16:58:30 +08:00
qkqpttgfandGitHub 2850db0699 try fix: can not update in php8 2021-03-14 16:42:31 +08:00
qkqpttgfandGitHub 273f41d90b away tabs 2021-03-13 14:55:26 +08:00
qkqpttgfandGitHub fab8a996e3 open github in new tab 2021-03-13 14:16:17 +08:00
qkqpttgfandGitHub 5543c0314e Update version 2021-03-13 14:01:40 +08:00
qkqpttgfandGitHub 19549e0612 use driveId, select secret drive. 2021-03-13 13:51:41 +08:00
qkqpttgfandGitHub 6f2a4c4a40 use driveId 2021-03-13 13:50:37 +08:00
qkqpttgfandGitHub 9717e32254 change layout in setup 2021-03-13 13:49:46 +08:00
qkqpttgfandGitHub 377a9f8aaa fix: not encode file name. fix: sha1 big file. 2021-03-13 13:47:46 +08:00
qkqpttgfandGitHub 119ac5280d fix: 500 error in php8 2021-03-12 17:38:47 +08:00
qkqpttgfandGitHub 6230773e52 fix: 500 error in php8 2021-03-12 17:37:26 +08:00
qkqpttgfandGitHub bc66f43bea Update version 2021-03-11 20:07:00 +08:00
qkqpttgfandGitHub 0649f19e21 QQ Group is dead 2021-03-11 20:03:35 +08:00
qkqpttgfandGitHub 8ef5e3d4a6 fix: load sha1.js 2021-03-11 20:01:49 +08:00
qkqpttgfandGitHub 4c0daaca80 fix: load sha1.js 2021-03-11 19:59:58 +08:00
qkqpttgfandGitHub ab49796661 Show error in login 2021-03-11 18:48:43 +08:00
qkqpttgfandGitHub 5c29afd5fe Merge pull request #242 from Nchyn/patch-1
Update nchyn_grey.html
2021-03-09 21:00:27 +08:00
qkqpttgfandGitHub 4cecf6f5af Update version 2021-03-09 20:59:22 +08:00
qkqpttgfandGitHub 6e66ec05d8 Can change admin password now 2021-03-09 17:18:59 +08:00
qkqpttgfandGitHub 6949fae7eb sha1 admin pass in submit 2021-03-09 16:04:19 +08:00
qkqpttgfandGitHub 928d028d7f sha1 admin pass in submit 2021-03-09 15:51:23 +08:00
NchynandGitHub 55e7a840d2 Update nchyn_grey.html
Fix Background-image layout
2021-03-09 13:25:59 +08:00
qkqpttgfandGitHub dd4dde83f3 undo form urlencode 2021-03-08 13:14:02 +08:00
qkqpttgfandGitHub 2aec731ab1 try fix #% in file name 2021-03-07 23:07:54 +08:00
qkqpttgfandGitHub d42547bdfb try fix #% in file name 2021-03-07 23:07:12 +08:00
qkqpttgfandGitHub 07edb1aadf show each upload js 2021-03-07 22:43:38 +08:00
qkqpttgfandGitHub cee88dba69 GD Can not upload form explorer without token 2021-03-07 22:37:12 +08:00
qkqpttgfandGitHub c06b8c0992 rm not use param 2021-03-07 22:35:33 +08:00
qkqpttgfandGitHub 77198ddf8b rm not use code 2021-03-07 22:31:58 +08:00
qkqpttgfandGitHub 4e008e0b2f create file/folder with /. stop upload 2021-03-07 22:29:23 +08:00
qkqpttgfandGitHub 1af93af86f Rename,Move,Copy,Delete,Encrypt,Edit,Thumb in GD 2021-03-07 17:14:15 +08:00
qkqpttgfandGitHub 6f9235bc33 use urlencode form 2021-03-06 16:05:17 +08:00
qkqpttgfandGitHub 8c5c61508c try to stop when activeLimit 2021-03-06 15:59:18 +08:00
qkqpttgfandGitHub dad086da6b add a prama activeLimit 2021-03-06 15:51:04 +08:00
qkqpttgfandGitHub 86ddf9e388 fix: url 403 soon 2021-03-04 22:08:16 +08:00
qkqpttgfandGitHub e07e036fb6 fix: 非zh-cn的zh语系将默认显示zh-tw 2021-03-04 17:40:48 +08:00
qkqpttgfandGitHub ae14fd6ca8 fix: list all files (include trashed) 2021-03-04 15:56:35 +08:00
qkqpttgfandGitHub cba994cf41 fix guest upload non-name file 2021-03-04 15:15:34 +08:00
qkqpttgfandGitHub 36048cd773 Merge pull request #234 from 186526/patch-21
Update Renexmoe 1.2
2021-03-04 09:24:13 +08:00
186526andGitHub cb69900c32 Update Renexmoe 1.2 2021-03-03 23:03:07 +08:00
qkqpttgfandGitHub 61811b60ac remove / in return_uri 2021-03-02 11:14:11 +08:00
qkqpttgfandGitHub fb6306c316 Update version 2021-03-01 17:53:46 +08:00
qkqpttgfandGitHub 5d524529b4 Create Googledrive.php 2021-03-01 17:46:01 +08:00
root e9ed4dc7f1 export&import config 2021-03-01 04:38:15 -05:00
qkqpttgfandGitHub c234dd62d1 Merge pull request #229 from BingoKingo/patch-1
tfo theme 20210224
2021-02-26 21:46:01 +08:00
qkqpttgfandGitHub 3aaa18ee59 progress in Calculate sha1 2021-02-25 18:33:26 +08:00
qkqpttgfandGitHub 366a477ae2 fix: cache 2021-02-25 18:30:44 +08:00
qkqpttgfandGitHub a05ba3ed44 remove surplus backhome 2021-02-25 18:29:13 +08:00
BingoKingoandGitHub 46b9fb9296 tfo theme 20210224
repush.
2021-02-25 15:07:50 +08:00
qkqpttgfandGitHub 7c23cdfba1 use this->error 2021-02-23 17:40:39 +08:00
qkqpttgfandGitHub c610eb6a85 Merge pull request #226 from qkqpttgf/refer
only designated referrer
2021-02-23 17:27:53 +08:00
root 8254f279ef refer 2021-02-23 17:20:19 +08:00
qkqpttgfandGitHub a9be0e3fbf tfo theme
tfo theme.
2021-02-08 20:24:06 +08:00
BingoKingoandGitHub 57e6c481d3 tfo theme 20210205 2021-02-08 19:44:38 +08:00
qkqpttgfandGitHub d613780312 fix: link in rapid 2021-02-07 19:38:05 +08:00
qkqpttgfandGitHub cce6e32b61 fix: got a wrong link after guest uploaded in Aliyundrive 2021-02-07 19:01:04 +08:00
qkqpttgfandGitHub 2b5bb6d3b5 aliyundrive uploading can split chunk 2021-02-07 11:58:17 +08:00
qkqpttgfandGitHub c09453080c split chunk to upload, token try 3days 2021-02-07 11:55:24 +08:00
qkqpttgfandGitHub 71675b58b7 extend secret 2021-02-06 16:43:02 +08:00
qkqpttgfandGitHub f8e3db2e37 extend secret 2021-02-06 16:42:15 +08:00
qkqpttgfandGitHub ba471ab650 try fix: office file can not preview 2021-02-01 18:17:43 +08:00
qkqpttgfandGitHub c186cee4d3 try fix siit 404 2021-01-28 23:29:40 +08:00
qkqpttgfandGitHub bb9b76a427 try fix upload 2021-01-26 09:19:54 +08:00
qkqpttgfandGitHub 9987651af9 try fix upload 2021-01-26 09:17:47 +08:00
qkqpttgfandGitHub 38bd4e4041 try fix upload 2021-01-26 09:14:58 +08:00
qkqpttgfandGitHub 558d34c9e3 try preview&download aliyundrive 2021-01-25 12:26:10 +08:00
qkqpttgfandGitHub 79b7357b70 description of config.php 2021-01-24 23:25:30 +08:00
qkqpttgfandGitHub 12ff9da6f4 fix: only lower letter readme.md can display. 2021-01-24 17:47:51 +08:00
qkqpttgfandGitHub 0b6adc077c try fix: add Aliyundrive will instead current disk 2021-01-24 16:51:33 +08:00
qkqpttgfandGitHub bdedf7a4b0 fix: only lower letter readme.md can display. 2021-01-24 16:14:17 +08:00
qkqpttgfandGitHub bde862ffb5 Merge pull request #198 from 186526/patch-20
Update renexmoe v1.1.5
2021-01-24 15:54:19 +08:00
186526andGitHub 0521bc08c0 Update renexmoe v1.1.5 2021-01-23 22:48:44 +08:00
qkqpttgfandGitHub 89de647c2f try fix more page not show (just for page<50) 2021-01-23 22:40:07 +08:00
qkqpttgfandGitHub ee6f9c9761 Merge pull request #195 from 186526/patch-18
Update renexmoe to v1.1.4.1-lts
2021-01-23 08:15:37 +08:00
186526andGitHub fbfc683c1b Update renexmoe to v1.1.4.1-lts 2021-01-22 15:03:34 +08:00
qkqpttgfandGitHub 2d18450872 try preview&download aliyundrive 2021-01-20 18:59:55 +08:00
qkqpttgfandGitHub 6b08d8edf2 fix bug: in encrypted but downloadable folder, can list by json 2021-01-19 18:05:58 +08:00
qkqpttgfandGitHub 1251195b8f fix: rename to an exist tag 2021-01-18 16:36:45 +08:00
qkqpttgfandGitHub 71d57052da Update version 2021-01-18 16:06:24 +08:00
root 11e87f9ea8 copy disk, change onedrive/sharepoint. 2021-01-18 15:59:39 +08:00
qkqpttgfandGitHub 85cdc6b211 fix bug: error drive will 500 2021-01-18 15:04:42 +08:00
root 8e3a165d60 try fix: tag with same string replaced in renaming tag 2021-01-17 22:05:49 +08:00
qkqpttgfandGitHub 562cd246c4 ext show 2021-01-17 19:02:13 +08:00
qkqpttgfandGitHub d8c1cd619b ext show 2021-01-17 19:01:47 +08:00
qkqpttgfandGitHub 1b8d29354d ext show 2021-01-17 19:01:07 +08:00
qkqpttgfandGitHub c4fcd55669 try to change onedrive to sharepoint 2021-01-17 19:00:05 +08:00
qkqpttgfandGitHub ff85f901f8 ext show 2021-01-17 18:58:25 +08:00
qkqpttgfandGitHub 4ea8cb5bef try to change onedrive to sharepoint 2021-01-17 18:57:26 +08:00
qkqpttgfandGitHub ec9ba6c20e Update version 2021-01-17 14:55:30 +08:00
qkqpttgfandGitHub 0617d258d5 try fix: some php host show Warning 2021-01-17 14:53:16 +08:00
qkqpttgfandGitHub ecb2aad3bb set empty pass will delete passfile 2021-01-17 13:33:33 +08:00
qkqpttgfandGitHub 49e602e7e6 set empty pass will delete passfile 2021-01-17 13:32:33 +08:00
qkqpttgfandGitHub 96ce1a91d3 try fix: password is '' 2021-01-17 13:13:37 +08:00
qkqpttgfandGitHub fe876dd87c use Basic Auth or not 2021-01-17 11:33:05 +08:00
qkqpttgfandGitHub c36621b400 use Basic Auth or not 2021-01-17 11:31:48 +08:00
qkqpttgfandGitHub 1367dd72fb Update conststr.php 2021-01-16 20:28:30 +08:00
root 34599a6e71 use BasicAuth in encrypted folder. fix: error_log in SCF 2021-01-16 17:12:03 +08:00
qkqpttgfandGitHub 5e49a44ec1 add ar-sa 2021-01-16 16:11:12 +08:00
qkqpttgfandGitHub 01e094d95d return json with content-type 2021-01-16 12:27:41 +08:00
qkqpttgfandGitHub 66238a6d54 fix: del upload cache 2021-01-16 12:18:19 +08:00
qkqpttgfandGitHub be96d3aa8b fix: del upload cache 2021-01-16 12:17:06 +08:00
root b44f15f141 fix bug: access token be 1 2021-01-16 11:28:19 +08:00
qkqpttgfandGitHub 15a7ea192a Merge pull request #187 from 186526/patch-16
Update renexmoe to Version 1.1.3
2021-01-16 08:53:55 +08:00
186526andGitHub 0535fcc709 Update renexmoe to Version 1.1.3 2021-01-15 22:55:02 +08:00
qkqpttgfandGitHub 4d83358ee1 fix: access_token be an Array 2021-01-15 19:27:36 +08:00
qkqpttgfandGitHub 27ec89e172 fix: access_token be an Array 2021-01-15 19:26:39 +08:00
qkqpttgfandGitHub 0b0f80c135 fix: access_token be an Array 2021-01-15 19:26:01 +08:00
qkqpttgfandGitHub d5120aa390 the $drive not new twice 2021-01-15 19:24:14 +08:00
qkqpttgfandGitHub 1102d4234f try fix: sharepoint name is non english 2021-01-15 18:32:32 +08:00
qkqpttgfandGitHub 894121d0c6 try fix: empty array to json, heroku error. 2021-01-15 17:43:00 +08:00
qkqpttgfandGitHub 399fb38fd4 fix: empty files cause 500 error in heroku 2021-01-15 16:28:53 +08:00
qkqpttgfandGitHub 661a6f89fe -DriveId 2021-01-15 12:48:13 +08:00
qkqpttgfandGitHub 0169c5bb9a fix bug 2021-01-15 12:08:20 +08:00
qkqpttgfandGitHub 3f63374740 Update version 2021-01-15 11:21:01 +08:00
qkqpttgfandGitHub 404ee22905 v3 2021-01-15 11:19:03 +08:00
qkqpttgfandGitHub 4c836880a1 now admin not base64 2021-01-15 11:18:42 +08:00
root e8f1fd7175 v3 2021-01-15 11:10:08 +08:00
qkqpttgfandGitHub 372a42bc05 curl_req->curl 2021-01-11 10:04:56 +08:00
qkqpttgfandGitHub b8c4cc1312 curl_re->curl 2021-01-11 10:03:54 +08:00
qkqpttgfandGitHub 4e434ede6b Merge pull request #186 from 186526/patch-15
Update renexmoe.html
2021-01-10 19:37:54 +08:00
186526andGitHub 086ac6d3e0 Update renexmoe.html 2021-01-09 19:34:52 +08:00
qkqpttgfandGitHub 26b49c7a69 Merge pull request #185 from 186526/patch-14
Update renexmoe
2021-01-09 14:43:25 +08:00
186526andGitHub 10a071df64 Update renexmoe 2021-01-08 18:46:49 +08:00
root 352a078829 fix: fix bug 2021-01-03 17:10:20 +08:00
root de5ccd74cb fix: modify tag 2021-01-03 16:29:33 +08:00
qkqpttgfandGitHub 218e7e5230 Merge pull request #181 from david082321/patch-2
Update zh-tw language
2021-01-02 21:48:27 +08:00
david082321andGitHub 40eca60aba Update zh-tw language 2021-01-02 20:22:48 +08:00
qkqpttgfandGitHub 67da665f11 only 1 disk will not display drag to sort table 2020-12-29 19:07:17 +08:00
root 6b5c26b897 Modify tags, change sequence of disk 2020-12-27 14:22:18 +08:00
qkqpttgfandGitHub 4d48228d8a Merge pull request #177 from 186526/patch-13
Fix PJAX bug && login bug
2020-12-27 14:11:16 +08:00
186526andGitHub 20d210945e Fix PJAX bug && login bug 2020-12-27 00:00:52 +08:00
qkqpttgfandGitHub 95a62a9d81 Update readme.md 2020-12-22 11:31:59 +08:00
qkqpttgfandGitHub 6ed09dde72 Merge pull request #172 from 186526/patch-12
Update renexmoe.html
2020-12-17 20:22:31 +08:00
186526andGitHub bc38d419e0 Update renexmoe.html 2020-12-17 19:41:53 +08:00
42 changed files with 12828 additions and 14277 deletions
+5
View File
@@ -9,6 +9,11 @@ RewriteRule ^(.*) index.php?/$1 [L]
### nginx
# rewrite ^/(?!.well-known)(.*)$ /index.php?/$1 last;
#
### nginx Subdirectory 在子目录中使用
# location /OneManager2/ {
# rewrite ^/(.*)$ /OneManager2/index.php?/$1 last;
# }
#
### caddy
# rewrite {
# to index.php?/$1
+113
View File
@@ -0,0 +1,113 @@
// Hosts Array
// 服务器数组
const H = [
'https://herooneindex.herokuapp.com/',
'https://onemanager.glitch.me/',
'https://onemanager-php.vercel.app/'
]
// View Type
// 1 , only first host,
// 只第一条Host记录有用
// 2 , view top 2 host as odd/even days,
// 只有前两条记录有效,分别单双日运行
// 3 , view random host
// 所有记录随机访问
const T = 1
// CF proxy all, true/false
// 一切给CF代理,true或false
const CFproxy = true
// Used in cloudflare workers
// // // // // //
addEventListener('fetch', event => {
let url=new URL(event.request.url);
if (url.protocol == 'http:') {
// force HTTPS
url.protocol = 'https:'
event.respondWith( Response.redirect(url.href) )
} else {
let host = null;
if (T===1) {
host = H[0];
}
if (T===2) {
host = H[new Date().getDate()%2];
}
if (T===3) {
let n = H.length;
host = H[Math.round(Math.random()*n*10)%n];
}
//console.log(host)
if (host.substr(0, 7)!='http://'&&host.substr(0, 8)!='https://') host = 'http://' + host;
let response = fetchAndApply(host, event.request);
event.respondWith( response );
}
})
async function fetchAndApply(host, request) {
let f_url = new URL(request.url);
let a_url = new URL(host);
let replace_path = a_url.pathname;
if (replace_path.substr(replace_path.length-1)!='/') replace_path += '/';
let replaced_path = '/';
let query = f_url.search;
let path = f_url.pathname;
if (host.substr(host.length-1)=='/') path = path.substr(1);
f_url.href = host + path + query;
let response = null;
if (!CFproxy) {
response = await fetch(f_url, request);
} else {
let method = request.method;
let body = request.body;
let request_headers = request.headers;
let new_request_headers = new Headers(request_headers);
new_request_headers.set('Host', f_url.host);
new_request_headers.set('Referer', request.url);
response = await fetch(f_url.href, {
/*cf: {
cacheEverything: true,
cacheTtl: 1000,
mirage: true,
polish: "on",
minify: {
javascript: true,
css: true,
html: true,
}
},*/
method: method,
body: body,
headers: new_request_headers
});
}
let out_headers = new Headers(response.headers);
if (out_headers.get('Content-Disposition')=='attachment') out_headers.delete('Content-Disposition');
let out_body = null;
let contentType = out_headers.get('Content-Type');
if (contentType.includes("application/text")) {
out_body = await response.text();
while (replace_path!='/'&&out_body.includes(replace_path)) out_body = out_body.replace(replace_path, replaced_path);
} else if (contentType.includes("text/html")) {
//f_url.href +
out_body = await response.text();
while (replace_path!='/'&&out_body.includes(replace_path)) out_body = out_body.replace(replace_path, replaced_path);
} else {
out_body = await response.body;
}
let out_response = new Response(out_body, {
status: response.status,
headers: out_headers
})
return out_response;
}
+1435 -1417
View File
File diff suppressed because it is too large Load Diff
+323 -68
View File
File diff suppressed because it is too large Load Diff
+869
View File
@@ -0,0 +1,869 @@
<?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 = '/';
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(strtolower(splitlast($files['name'],'.')[1]), $exts['txt'])) {
if ($files['size']<1024*1024) {
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);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
}
//error_log1('body : ' . $content1['body'] . PHP_EOL);
$files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag);
}
} else {
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
//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'] = 200;
$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'] = 'name'; //updated_at
$data['order_direction'] = 'ASC'; //DESC
$res = curl('POST', $url, json_encode($data), $header);
//error_log1($res['stat'] . $res['body']);
if ($res['stat']==200) {
$body = json_decode($res['body'], true);
$body1 = $body;
while ($body1['next_marker']!='') {
$data['marker'] = $body1['next_marker'];
$res1 = null;
$res1 = curl('POST', $url, json_encode($data), $header);
$body1 = json_decode($res1['body'], true);
$body['items'] = array_merge($body['items'], $body1['items']);
}
return $body;
//return json_decode($res['body'], true);
}
else return $res;
}
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 .= '
<script>
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(min++);
} else {
clearInterval(uploadList);
location.href = "' . $url . '";
}
}, 1000);
</script>';
return message($str, getconstStr('WaitJumpIndex'), 201, 1);
}
}
if (isset($_GET['SelectDrive'])) {
if ($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>
var status = "' . $response['DplStatus'] . '";
function notnull(t)
{
if (t.driveId.value==\'\') {
alert(\'Select a Disk\');
return false;
}
return true;
}
</script>
';
return message($html, $title, 201, 1);
}
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, 400);
} 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;
}
var status = "' . $response['DplStatus'] . '";
</script>
';
return message($html, $title, 201, 1);
}
}
$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;
}
}
+865
View File
@@ -0,0 +1,865 @@
<?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(strtolower(splitlast($item['name'],'.')[1]), $exts['txt'])) {
if ($files['size']<1024*1024) {
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"=>"*/*"]);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
}
$item['content'] = $content1;
}// 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);
}
} else {
$files['content']['stat'] = 202;
$files['content']['body'] = 'File too large.';
}
}
//}
//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;
}
}
+1068
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -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';
}
}
+67
View File
@@ -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;
}
}
+31
View File
@@ -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' ];
}
}
+31
View File
@@ -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' ];
}
}
+26 -31
View File
@@ -1,10 +1,12 @@
<?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';
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
//echo '<pre>'. json_encode($_ENV, JSON_PRETTY_PRINT).'</pre>';
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/TencentSCF_file.php';
else include 'platform/TencentSCF_env.php';
@@ -15,8 +17,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';
@@ -30,9 +30,28 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
header($headerName . ': ' . $headerVal, true);
}
http_response_code($re['statusCode']);
echo $re['body'];
if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} elseif (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/var/task/user') {
if (getenv('ONEMANAGER_CONFIG_SAVE')=='env') include 'platform/Vercel_env.php';
else include 'platform/Vercel.php';
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
$re = main($path);
$sendHeaders = array();
foreach ($re['headers'] as $headerName => $headerVal) {
header($headerName . ': ' . $headerVal, true);
}
http_response_code($re['statusCode']);
if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} else {
include 'platform/Normal.php';
if (!function_exists('curl_init')) {
return message('<font color="red">Need curl</font>, please install php-curl.', 'Error', 500);
}
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
@@ -44,7 +63,8 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
header($headerName . ': ' . $headerVal, true);
}
http_response_code($re['statusCode']);
echo $re['body'];
if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
}
// Tencent SCF
@@ -91,7 +111,7 @@ function handler($event, $context)
$re = main($path);
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['body']);
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['isBase64Encoded']?base64_decode($re['body']):$re['body']);
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
// Huawei FG
@@ -136,28 +156,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;
}
+154 -43
View File
@@ -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)
@@ -38,36 +37,52 @@ function GetPathSetting($event, $context)
$_SERVER['region'] = $context['region'];
$_SERVER['service_name'] = $context['service']['name'];
$_SERVER['function_name'] = $context['function']['name'];
$path = $event['path'];
$tmp = $event['requestURI'];
//$path = str_replace('%5D', ']', str_replace('%5B', '[', $event['path']));//%5B
//$path = $event['path'];
$path = $event['requestURI'];
if (strpos($path, '?')) $path = substr($path, 0, strpos($path, '?'));
$tmp = urldecode($event['requestURI']);
if (strpos($tmp, '?')) $tmp = substr($tmp, 0, strpos($tmp, '?'));
if ($path=='/'||$path=='') {
$_SERVER['base_path'] = $tmp;
} else {
$_SERVER['base_path'] = substr($tmp, 0, -strlen($path)+1);
$tmp = str_replace('&amp;', '&', $tmp);
while ($tmp!=urldecode($tmp)) $tmp = urldecode($tmp);
$tmp1 = urldecode($event['path']);
while ($tmp1!=urldecode($tmp1)) $tmp1 = urldecode($tmp1);
$_SERVER['base_path'] = substr($tmp, 0, strlen($tmp)-strlen($tmp1)+1);
//$_SERVER['base_path'] = substr($tmp, 0, strlen(urldecode($event['path'])));
}
if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['base_path'] = spurlencode($_SERVER['base_path'], '/');
//$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['clientIP'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'][0];
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'];
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2];
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'][0];
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
return $path;
//return spurlencode($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 +90,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 +127,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).'
//';
@@ -152,16 +185,16 @@ function install()
if ($_GET['install1']) {
//if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone'];
$AccessKeyID = getConfig('AccessKeyID');
if ($AccessKeyID=='') {
//$AccessKeyID = getConfig('AccessKeyID');
//if ($AccessKeyID=='') {
$AccessKeyID = $_POST['AccessKeyID'];
$tmp['AccessKeyID'] = $AccessKeyID;
}
$AccessKeySecret = getConfig('AccessKeySecret');
if ($AccessKeySecret=='') {
//}
//$AccessKeySecret = getConfig('AccessKeySecret');
//if ($AccessKeySecret=='') {
$AccessKeySecret = $_POST['AccessKeySecret'];
$tmp['AccessKeySecret'] = $AccessKeySecret;
}
//}
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) );
if (api_error($response)) {
$html = api_error_msg($response);
@@ -196,12 +229,13 @@ language:<br>';
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
<a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">'.getconstStr('Create').' AccessKeyID & AccessKeySecret</a><br>
<label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br>
<label>AccessKeySecret:<input name="AccessKeySecret" type="text" placeholder="" size=""></label><br>';
//if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='')
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
<a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">' . getconstStr('Create') . ' AccessKeyID & AccessKeySecret</a><br>
<label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br>
<label>AccessKeySecret:<input name="AccessKeySecret" type="password" placeholder="" size=""></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
var nowtime= new Date();
@@ -220,7 +254,8 @@ language:<br>';
}
function notnull(t)
{';
if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
//if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='')
$html .= '
if (t.AccessKeyID.value==\'\') {
alert(\'input AccessKeyID\');
return false;
@@ -236,8 +271,8 @@ language:<br>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
$title = 'Error';
$html .= '<a href="?install0">' . getconstStr('ClickInstall').'</a>, ' . getconstStr('LogintoBind');
$title = 'Install';
return message($html, $title, 201);
}
@@ -313,7 +348,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 +485,78 @@ 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;
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['AccessKeyID']!=''&&$_POST['AccessKeySecret']!='') {
$tmp['AccessKeyID'] = $_POST['AccessKeyID'];
$tmp['AccessKeySecret'] = $_POST['AccessKeySecret'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $tmp['AccessKeyID'], $tmp['AccessKeySecret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">' . getconstStr('Create') . ' AccessKeyID & AccessKeySecret</a><br>
<label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br>
<label>AccessKeySecret:<input name="AccessKeySecret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.AccessKeyID.value==\'\') {
alert(\'input AccessKeyID\');
return false;
}
if (t.AccessKeySecret.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+124 -40
View File
@@ -1,4 +1,6 @@
<?php
// https://cloud.baidu.com/doc/CFC/s/jjwvz45ex
// https://cloud.baidu.com/doc/CFC/s/2jwvz44ns
function printInput($event, $context)
{
@@ -26,9 +28,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)
@@ -37,27 +36,36 @@ function GetPathSetting($event, $context)
$_SERVER['functionBrn'] = $context['functionBrn'];
$_SERVER['base_path'] = '/';
$path = $event['path'];
if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
//$_SERVER['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'];
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'];
$_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).'
//';
@@ -140,16 +166,16 @@ function install()
}
if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone'];
$SecretId = getConfig('SecretId');
if ($SecretId=='') {
//$SecretId = getConfig('SecretId');
//if ($SecretId=='') {
$SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId;
}
$SecretKey = getConfig('SecretKey');
if ($SecretKey=='') {
//}
//$SecretKey = getConfig('SecretKey');
//if ($SecretKey=='') {
$SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey;
}
//}
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
if (api_error($response)) {
$html = api_error_msg($response);
@@ -183,12 +209,13 @@ language:<br>';
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
<a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">'.getconstStr('Create').' Access Key & Secret Key</a><br>
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>Secret Key:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
<a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">' . getconstStr('Create') . ' Access Key & Secret Key</a><br>
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>Secret Key:<input name="SecretKey" type="password" placeholder="" size=""></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
var nowtime= new Date();
@@ -207,7 +234,8 @@ language:<br>';
}
function notnull(t)
{';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
if (t.SecretId.value==\'\') {
alert(\'input Access Key\');
return false;
@@ -224,7 +252,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 +322,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);
@@ -337,7 +366,7 @@ function api_error_msg($response)
{
if (isset($response['code'])) $html = $response['code'] . '<br>
' . $response['message'];
else $html = var_dump($response);
else $html = json_encode($response, JSON_PRETTY_PRINT);
return $html . '<br><br>
BRN: ' . $_SERVER['functionBrn'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
@@ -405,3 +434,58 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@closedir($path);
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretKey']!='') {
$SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId;
$SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey;
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">' . getconstStr('Create') . ' Access Key & Secret Key</a><br>
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>Secret Key:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input Access Key\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input Secret Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+183 -59
View File
@@ -1,9 +1,37 @@
<?php
// https://devcenter.heroku.com/articles/platform-api-reference#build-create
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,14 +43,14 @@ function getpath()
function getGET()
{
//error_log('POST' . json_encode($_POST));
//error_log1('POST' . json_encode($_POST));
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
//error_log('RAW' . $tmpdata);
//error_log1('RAW' . $tmpdata);
} else {
$tmpdata = file_get_contents('php://input');
//error_log('PHPINPUT' . $tmpdata);
//error_log1('PHPINPUT' . $tmpdata);
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
@@ -30,7 +58,7 @@ function getGET()
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
//error_log('POSTformPHPINPUT' . json_encode($_POST));
//error_log1('POSTformPHPINPUT' . json_encode($_POST));
}
}
$p = strpos($_SERVER['REQUEST_URI'],'?');
@@ -58,17 +86,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 '';
@@ -76,29 +102,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);
if ($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) {
@@ -106,16 +139,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()
@@ -126,34 +170,51 @@ function install()
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = getConfig('APIKey');
if ($APIKey=='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$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);
}
}
}
$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);
$tmp['HerokuappId'] = $HerokuappId;
$response = json_decode(setHerokuConfig($tmp, $HerokuappId, $APIKey)['body'], true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
return output('Jump
$html = getconstStr('Success') . '
<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>
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
return message($html, $title, 201);
}
}
if ($_GET['install0']) {
@@ -164,9 +225,9 @@ language:<br>';
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
if (getConfig('APIKey')=='') $html .= '
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br>
<label>API Key:<input name="APIKey" type="text" placeholder="" size=""></label><br>';
$html .= '
<a href="https://dashboard.heroku.com/account" target="_blank">' . getconstStr('Create') . ' API Key</a><br>
<label>API Key:<input name="APIKey" type="password" placeholder="" size=""></label><br>';
$html .= '
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= '
@@ -193,7 +254,7 @@ language:<br>';
alert(\'input admin\');
return false;
}';
if (getConfig('APIKey')=='') $html .= '
$html .= '
if (t.APIKey.value==\'\') {
alert(\'input API Key\');
return false;
@@ -206,7 +267,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);
}
@@ -223,7 +284,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);
@@ -238,28 +299,32 @@ 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);
$response = HerokuAPI('POST', 'https://api.heroku.com/apps/' . $HerokuappId . '/builds', $data, $apikey);
$result = json_decode( $response['body'], true );
$result['DplStatus'] = $result['id'];
$response['body'] = json_encode($result);
return $response;
}
function api_error($response)
@@ -279,10 +344,69 @@ 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)
{
return json_decode( $response['body'], true );
}
function WaitFunction($buildId = '') {
// GET /apps/{app_id_or_name}/builds/{build_id}
if ($buildId=='1') return true;
$response = HerokuAPI('GET', 'https://api.heroku.com/apps/' . getConfig('HerokuappId') . '/builds/' . $buildId, '', getConfig('APIKey'));
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['status']=="succeeded") return true;
else return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = setConfigResponse( setHerokuConfig($tmp, getConfig('HerokuappId'), $APIKey) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br>
<label>API Key:<input name="APIKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'input API Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+118 -42
View File
@@ -1,4 +1,7 @@
<?php
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0110.html
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0111.html
global $contextUserData;
function printInput($event, $context)
@@ -39,9 +42,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)
@@ -52,6 +52,7 @@ function GetPathSetting($event, $context)
$host_name = $event['headers']['host'];
$_SERVER['HTTP_HOST'] = $host_name;
$path = path_format($event['pathParameters'][''].'/');
$path = str_replace('+', '%2B', $path);
$_SERVER['base_path'] = path_format($event['path'].'/');
if ( $_SERVER['base_path'] == $path ) {
$_SERVER['base_path'] = '/';
@@ -59,28 +60,36 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
}
if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
//$_SERVER['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'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
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 +97,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 +135,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).'
//';
@@ -166,18 +193,9 @@ function install()
if ($_GET['install1']) {
//if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = getConfig('HW_urn');
if ($tmp['HW_urn']=='') {
$tmp['HW_urn'] = $_POST['HW_urn'];
}
$tmp['HW_key'] = getConfig('HW_key');
if ($tmp['HW_key']=='') {
$tmp['HW_key'] = $_POST['HW_key'];
}
$tmp['HW_secret'] = getConfig('HW_secret');
if ($tmp['HW_secret']=='') {
$tmp['HW_secret'] = $_POST['HW_secret'];
}
$tmp['HW_urn'] = $_POST['HW_urn'];
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response'];
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
@@ -219,13 +237,14 @@ language:<br>';
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br>
<label>URN:<input name="HW_urn" type="text" placeholder="" size=""></label><br>
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="text" placeholder="" size=""></label><br>';
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>';
$html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -249,7 +268,8 @@ language:<br>';
}
function notnull(t)
{';
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
if (t.HW_urn.value==\'\') {
alert(\'input URN\');
return false;
@@ -270,7 +290,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 +369,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;
@@ -462,3 +483,58 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@closedir($path);
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+135 -54
View File
@@ -1,4 +1,7 @@
<?php
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0110.html
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0111.html
global $contextUserData;
function printInput($event, $context)
@@ -39,9 +42,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)
@@ -52,6 +52,7 @@ function GetPathSetting($event, $context)
$host_name = $event['headers']['host'];
$_SERVER['HTTP_HOST'] = $host_name;
$path = path_format($event['pathParameters'][''].'/');
$path = str_replace('+', '%2B', $path);
$_SERVER['base_path'] = path_format($event['path'].'/');
if ( $_SERVER['base_path'] == $path ) {
$_SERVER['base_path'] = '/';
@@ -59,33 +60,43 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
}
if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
//$_SERVER['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'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
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 +106,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 +132,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 +150,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;
}
@@ -176,18 +207,9 @@ function install()
if ($_GET['install1']) {
//if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = getConfig('HW_urn');
if ($tmp['HW_urn']=='') {
$tmp['HW_urn'] = $_POST['HW_urn'];
}
$tmp['HW_key'] = getConfig('HW_key');
if ($tmp['HW_key']=='') {
$tmp['HW_key'] = $_POST['HW_key'];
}
$tmp['HW_secret'] = getConfig('HW_secret');
if ($tmp['HW_secret']=='') {
$tmp['HW_secret'] = $_POST['HW_secret'];
}
$tmp['HW_urn'] = $_POST['HW_urn'];
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//return message($html, $title, 201);
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
@@ -229,13 +251,14 @@ language:<br>';
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br>
<label>URN:<input name="HW_urn" type="text" placeholder="urn:fss:ap-XXXXXXXX:XXXXXXXXXXXXXXXXXXXXc01a1e9caXXX:function:default:XXXXX:latest" size=""></label><br>
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="text" placeholder="" size=""></label><br>';
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>';
$html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -259,17 +282,18 @@ language:<br>';
}
function notnull(t)
{';
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
//if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
if (t.HW_urn.value==\'\') {
alert(\'input URN\');
return false;
}
if (t.HW_key.value==\'\') {
alert(\'input name\');
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input pwd\');
alert(\'input Secret Access Key\');
return false;
}';
$html .= '
@@ -280,7 +304,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 +364,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 +393,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 +407,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 +422,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 +464,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 +556,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();
@@ -838,3 +864,58 @@ class Signer
return $curl;
}
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+68 -31
View File
@@ -4,6 +4,16 @@ function getpath()
{
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (isset($_SERVER['HTTP_FLY_CLIENT_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_FLY_CLIENT_IP'];
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
}
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
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'];
@@ -58,27 +68,22 @@ function getGET()
function getConfig($str, $disktag = '')
{
global $InnerEnv;
global $Base64Env;
$slash = '/';
if (strpos(__DIR__, ':')) $slash = '\\';
global $slash;
$projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$s = file_get_contents($configPath);
//$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];
}
}
@@ -88,23 +93,22 @@ function getConfig($str, $disktag = '')
function setConfig($arr, $disktag = '')
{
global $InnerEnv;
global $Base64Env;
global $slash;
if ($disktag=='') $disktag = $_SERVER['disktag'];
$slash = '/';
if (strpos(__DIR__, ':')) $slash = '\\';
$projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$s = file_get_contents($configPath);
//$configs = substr($s, 18, -2);
$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') {
@@ -114,9 +118,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) {
@@ -126,13 +141,26 @@ 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 . '\';';
@@ -206,7 +234,7 @@ function install()
url += location.pathname;
if (url.substr(-1)!="/") url += "/";
url += "app.json";
//alert(url);
url += "?" + Date.now();
var xhr4 = new XMLHttpRequest();
xhr4.open("GET", url);
xhr4.setRequestHeader("x-requested-with","XMLHttpRequest");
@@ -218,7 +246,7 @@ function install()
document.getElementById("submitbtn").disabled = false;
document.getElementById("formdiv").style.display = "";
} else {
alert("Url: " + url + "\nExpect http code 201, but received " + xhr4.status);
alert("' . getconstStr('MakesuerRewriteOn') . '?\nfalse\n\nUrl: " + url + "\nExpect http code 201, but received " + xhr4.status);
}
}
}
@@ -250,8 +278,9 @@ language:<br>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
$title = 'Error';
$title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201);
}
@@ -296,8 +325,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();
@@ -315,7 +344,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
break;
}
}
//error_log($outPath);
//error_log1($outPath);
if ($outPath=='') return 0;
//unlink($outPath.'/config.php');
@@ -357,3 +386,11 @@ function moveFolder($from, $to, $slash)
rmdir($from);
return json_encode( [ 'response' => 'success' ] );
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
return message("Not need.", 'Change platform Auth token or key', 404);
}
+277 -48
View File
@@ -1,4 +1,7 @@
<?php
// https://cloud.tencent.com/document/product/583/33846
// https://cloud.tencent.com/document/product/583/18581
// https://cloud.tencent.com/document/product/583/18580
function printInput($event, $context)
{
@@ -23,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['USER'] = 'qcloud';
}
function GetPathSetting($event, $context)
@@ -33,7 +33,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'];
@@ -44,27 +44,36 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = $event['requestContext']['path'];
$path = substr($event['path'], strlen($event['requestContext']['path']));
}
if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
//$_SERVER['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-api-scheme'];
//$_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['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_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 +81,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 +118,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).'
//';
@@ -142,16 +169,24 @@ function install()
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201, 1);
}
return output('Jump
return message(getconstStr('Success') . '
<script>
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>', 201, 1);
}
if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone'];
@@ -175,7 +210,7 @@ function install()
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
$title = 'Reinstall';
return message($html, $title, 201);
return message($html, $title, 201, 1);
}
$html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);">
@@ -193,7 +228,7 @@ function install()
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
return message($html, $title, 201, 1);
}
}
if ($_GET['install0']) {
@@ -204,10 +239,11 @@ language:<br>';
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>';
$html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -231,7 +267,8 @@ language:<br>';
}
function notnull(t)
{';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
@@ -248,7 +285,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 +353,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) {
@@ -345,9 +383,6 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
{
//echo json_encode($Envs,JSON_PRETTY_PRINT);
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
/*$trynum = 0;
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;*/
//json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
foreach ($tmp as $tmp1) {
@@ -387,7 +422,7 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
}
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
function updateProgram_OLD($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
{
WaitSCFStat();
$meth = 'POST';
@@ -426,14 +461,208 @@ namespace:' . $_SERVER['namespace'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source['url'] = 'https://github.com/' . $auth . '/' . $project;
$source['branch'] = $branch;
return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source);
}
function setConfigResponse($response)
{
return json_decode( $response, true )['Response'];
}
function WaitFunction() {
//$trynum = 0;
//while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
//'.++$trynum;
if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true;
else return false;
}
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
{
$secretId = $SecretId;
$secretKey = $SecretKey;
$host = 'scf.tencentcloudapi.com';
$service = "scf";
$version = "2018-04-16";
$action = "UpdateFunctionCode";
$region = $Region;
$timestamp = time();
$algorithm = "TC3-HMAC-SHA256";
// step 1: build canonical request string
$httpRequestMethod = "POST";
$canonicalUri = "/";
$canonicalQueryString = "";
$canonicalHeaders = "content-type:application/json; charset=utf-8\n"."host:".$host."\n";
$signedHeaders = "content-type;host";
//$tmpdata['Action'] = 'UpdateFunctionCode';
$tmpdata['Code']['ZipFile'] = base64_encode( file_get_contents($source) );
$tmpdata['CodeSource'] = 'ZipFile';
$tmpdata['FunctionName'] = $function_name;
$tmpdata['Handler'] = 'index.main_handler';
//$tmpdata['Namespace'] = $Namespace;
//$tmpdata['Nonce'] = time();
//$tmpdata['Region'] = $Region;
//$tmpdata['SecretId'] = $SecretId;
//$tmpdata['Timestamp'] = time();
//$tmpdata['Token'] = '';
//$tmpdata['Version'] = '2018-04-16';
$payload = json_encode($tmpdata);
//$payload = '{"Limit": 1, "Filters": [{"Values": ["\u672a\u547d\u540d"], "Name": "instance-name"}]}';
$hashedRequestPayload = hash("SHA256", $payload);
$canonicalRequest = $httpRequestMethod."\n"
.$canonicalUri."\n"
.$canonicalQueryString."\n"
.$canonicalHeaders."\n"
.$signedHeaders."\n"
.$hashedRequestPayload;
//echo $canonicalRequest.PHP_EOL;
// step 2: build string to sign
$date = gmdate("Y-m-d", $timestamp);
$credentialScope = $date."/".$service."/tc3_request";
$hashedCanonicalRequest = hash("SHA256", $canonicalRequest);
$stringToSign = $algorithm."\n"
.$timestamp."\n"
.$credentialScope."\n"
.$hashedCanonicalRequest;
//echo $stringToSign.PHP_EOL;
// step 3: sign string
$secretDate = hash_hmac("SHA256", $date, "TC3".$secretKey, true);
$secretService = hash_hmac("SHA256", $service, $secretDate, true);
$secretSigning = hash_hmac("SHA256", "tc3_request", $secretService, true);
$signature = hash_hmac("SHA256", $stringToSign, $secretSigning);
//echo $signature.PHP_EOL;
// step 4: build authorization
$authorization = $algorithm
." Credential=".$secretId."/".$credentialScope
.", SignedHeaders=content-type;host, Signature=".$signature;
//echo $authorization.PHP_EOL;
//$curl = "curl -X POST https://".$host
// .' -H "Authorization: '.$authorization.'"'
// .' -H "Content-Type: application/json; charset=utf-8"'
// .' -H "Host: '.$host.'"'
// .' -H "X-TC-Action: '.$action.'"'
// .' -H "X-TC-Timestamp: '.$timestamp.'"'
// .' -H "X-TC-Version: '.$version.'"'
// .' -H "X-TC-Region: '.$region.'"'
// ." -d '".$payload."'";
//error_log1( $curl.PHP_EOL );
//return '{"response": {"Error": {"Message":"' . $curl . '"}}}';
$headers['Authorization'] = $authorization;
$headers['Content-Type'] = 'application/json; charset=utf-8';
$headers['Host'] = $host;
$headers['X-TC-Action'] = $action;
$headers['X-TC-Timestamp'] = $timestamp;
$headers['X-TC-Version'] = $version;
$headers['X-TC-Region'] = $region;
return curl('POST', 'https://'.$host, $payload, $headers)['body'];
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取包中目录名
$tmp = scandir('phar://'.$tarfile);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
// 放入配置文件
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
// 将目录中文件打包成zip
//$zip=new ZipArchive();
$zip=new PharData($source);
//if($zip->open($source, ZipArchive::CREATE)){
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
// $zip->close(); //关闭处理的zip文件
//}
return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source);
}
function addFileToZip($zip, $rootpath, $path = '')
{
if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
if (substr($path,0,1)=='/') $path = substr($path, 1);
$handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
while($filename=readdir($handler)){
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
$nowname = path_format($rootpath.'/'.$path."/".$filename);
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
$zip->addEmptyDir($path."/".$filename);
addFileToZip($zip, $rootpath, $path."/".$filename);
}else{ //将文件加入zip对象
$newname = $path."/".$filename;
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
$zip->addFile($nowname, $newname);
//$zip->renameName($nowname, $newname);
}
}
}
@closedir($path);
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+139 -52
View File
@@ -1,4 +1,7 @@
<?php
// https://cloud.tencent.com/document/product/583/33846
// https://cloud.tencent.com/document/product/583/18581
// https://cloud.tencent.com/document/product/583/18580
function printInput($event, $context)
{
@@ -23,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['USER'] = 'qcloud';
}
function GetPathSetting($event, $context)
@@ -33,7 +33,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'];
@@ -44,33 +44,42 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = $event['requestContext']['path'];
$path = substr($event['path'], strlen($event['requestContext']['path']));
}
if (substr($path,-1)=='/') $path=substr($path,0,-1);
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
//$_SERVER['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-api-scheme'];
//$_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['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_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 +89,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 +99,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 +113,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 +131,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;
@@ -154,29 +181,31 @@ function install()
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201, 1);
}
return output('Jump
return message(getconstStr('Success') . '
<script>
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>', 201, 1);
}
if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone'];
$SecretId = getConfig('SecretId');
if ($SecretId=='') {
$SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId;
}
$SecretKey = getConfig('SecretKey');
if ($SecretKey=='') {
$SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey;
}
$SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId;
$SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey;
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
$response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
if (api_error($response)) {
@@ -187,7 +216,7 @@ function install()
if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
$title = 'Reinstall';
return message($html, $title, 201);
return message($html, $title, 201, 1);
}
$html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);">
@@ -205,7 +234,7 @@ function install()
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
return message($html, $title, 201, 1);
}
}
if ($_GET['install0']) {
@@ -216,10 +245,11 @@ language:<br>';
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">'.getconstStr('Create').' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>';
$html .= '
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -243,7 +273,8 @@ language:<br>';
}
function notnull(t)
{';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
//if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
@@ -260,7 +291,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 +389,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 +406,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 +419,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 +475,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 +483,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 +562,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 +571,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 +617,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();
@@ -619,3 +651,58 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@closedir($path);
}
function WaitFunction() {
if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true;
else return false;
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+492
View File
@@ -0,0 +1,492 @@
<?php
// https://vercel.com/docs/api#endpoints/deployments/create-a-new-deployment
function getpath()
{
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (isset($_SERVER['HTTP_FLY_CLIENT_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_FLY_CLIENT_IP'];
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
}
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = "/";
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
$_SERVER['DOCUMENT_ROOT'] = '/var/task/user';
return $path;
}
function getGET()
{
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
$getstrarr = explode("&",$getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function getConfig($str, $disktag = '')
{
$projectPath = splitlast(__DIR__, '/')[0];
$configPath = $projectPath . '/.data/config.php';
$s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') {
$envs = json_decode($configs, true);
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
if (isset($envs[$disktag][$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$disktag][$str]);
else return $envs[$disktag][$str];
}
} else {
if (isset($envs[$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$str]);
else return $envs[$str];
}
}
}
return '';
}
function setConfig($arr, $disktag = '')
{
if ($disktag=='') $disktag = $_SERVER['disktag'];
$projectPath = splitlast(__DIR__, '/')[0];
$configPath = $projectPath . '/.data/config.php';
$s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') $envs = json_decode($configs, true);
$disktags = explode("|",getConfig('disktag'));
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
else $envs[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
else $envs[$disktag][$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$envs[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$envs[$newtag] = $envs[$v];
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$envs[$k] = $v;
}
}
if ($indisk) {
$diskconfig = $envs[$disktag];
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$envs[$disktag] = $diskconfig;
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$envs['disktag'] = implode('|', $tags);
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
$envs[$arr['disktag_rename']] = '';
} else {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
else $envs['disktag'] = '';
}
}
$envs = array_filter($envs, 'array_value_isnot_null');
//ksort($envs);
//sortConfig($envs);
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT));
//echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT);
return setVercelConfig($envs, getConfig('HerokuappId'), getConfig('APIKey'));
}
function install()
{
global $constStr;
if ($_GET['install1']) {
if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = $_POST['APIKey'];
//if ($APIKey=='') {
// $APIKey = getConfig('APIKey');
//}
$tmp['APIKey'] = $APIKey;
$token = $APIKey;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$aliases = json_decode(curl("GET", "https://api.vercel.com/v3/now/aliases", "", $header)['body'], true);
$host = splitfirst($_SERVER["host"], "//")[1];
foreach ($aliases["aliases"] as $key => $aliase) {
if ($host==$aliase["alias"]) $projectId = $aliase["projectId"];
}
$tmp['HerokuappId'] = $projectId;
$response = json_decode(setVercelConfig($tmp, $projectId, $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var expd = new Date();
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
}
if ($_GET['install0']) {
$html .= '
<form action="?install1" method="post" onsubmit="return notnull(this);">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
$html .= '<br>
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>';
$html .= '<br>
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<div id="showerror"></div>
<script>
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
var errordiv = document.getElementById("showerror");
function changelanguage(str)
{
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
location.href = location.href;
}
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\'input admin\');
return false;
}
if (t.APIKey.value==\'\') {
alert(\'input Token\');
return false;
}
return true;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
if (substr($_SERVER["host"], -10)=="vercel.app") {
$html .= '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
$html .= "<br>Remember: you MUST wait 30-60s after each operate / do some change, that make sure Vercel has done the building<br>" ;
} else {
$html.= "Please visit form *.vercel.app";
}
$title = 'Install';
return message($html, $title, 201);
}
function copyFolder($from, $to)
{
if (substr($from, -1)=='/') $from = substr($from, 0, -1);
if (substr($to, -1)=='/') $to = substr($to, 0, -1);
if (!file_exists($to)) mkdir($to, 0777, 1);
$handler=opendir($from);
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..'){
$fromfile = $from.'/'.$filename;
$tofile = $to.'/'.$filename;
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
copyFolder($fromfile, $tofile);
}else{
copy($fromfile, $tofile);
}
}
}
closedir($handler);
return 1;
}
function setVercelConfig($envs, $appId, $token)
{
sortConfig($envs);
$outPath = '/tmp/code/';
$outPath_Api = $outPath . 'api/';
$coderoot = __DIR__;
$coderoot = splitlast($coderoot, '/')[0] . '/';
//echo $outPath_Api . '<br>' . $coderoot . '<br>';
copyFolder($coderoot, $outPath_Api);
$prestr = '<?php $configs = \'' . PHP_EOL;
$aftstr = PHP_EOL . '\';';
file_put_contents($outPath_Api . '.data/config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
return VercelUpdate($appId, $token, $outPath);
}
function VercelUpdate($appId, $token, $sourcePath = "")
{
if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}';
$url = "https://api.vercel.com/v13/deployments";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$data["name"] = "OneManager";
$data["project"] = $appId;
$data["target"] = "production";
$data["routes"][0]["src"] = "/(.*)";
$data["routes"][0]["dest"] = "/api/index.php";
$data["functions"]["api/index.php"]["runtime"] = "vercel-php@0.4.0";
if ($sourcePath=="") $sourcePath = splitlast(splitlast(__DIR__, "/")[0], "/")[0];
//echo $sourcePath . "<br>";
getEachFiles($file, $sourcePath);
$data["files"] = $file;
//echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>";
$response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
$result['DplStatus'] = $result['id'];
return json_encode($result);
}
function checkBuilding($projectId, $token)
{
$r = 0;
$url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, '', $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
foreach ( $result['deployments'] as $deployment ) {
if ($deployment['state']!=="READY") $r++;
}
return $r;
//if ($r===0) return true;
//else return false;
}
function getEachFiles(&$file, $base, $path = "")
{
//if (substr($base, -1)=="/") $base = substr($base, 0, -1);
//if (substr($path, -1)=="/") $path = substr($path, 0, -1);
$handler=opendir(path_format($base . "/" . $path));
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..' && $filename != '.git'){
$fromfile = path_format($base . "/" . $path . "/" . $filename);
//echo $fromfile . "<br>";
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = getEachFiles($file, $base, path_format($path . "/" . $filename));
if (api_error(setConfigResponse($response))) return $response;
}else{
$tmp['file'] = path_format($path . "/" . $filename);
$tmp['data'] = file_get_contents($fromfile);
$file[] = $tmp;
}
}
}
closedir($handler);
return json_encode( [ 'response' => 'success' ] );
}
function api_error($response)
{
return isset($response['error']);
}
function api_error_msg($response)
{
return $response['error']['code'] . '<br>
' . $response['error']['message'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function setConfigResponse($response)
{
return json_decode($response, true);
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$tmppath = '/tmp';
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
$tarfile = $tmppath . '/github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return '{"error":{"message":"fail to download from github"}}';
file_put_contents($tarfile, $githubfile);
$phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
unlink($tarfile);
$outPath = '';
$tmp = scandir($tmppath);
$name = $auth . '-' . $project;
mkdir($tmppath . "/" . $name, 0777, 1);
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
$outPath = $tmppath . "/" . $name;
break;
}
}
//echo $outPath . "<br>";
//error_log1($outPath);
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
// put in config
$coderoot = __DIR__;
$coderoot = splitlast($coderoot, '/')[0] . '/';
copy($coderoot . '.data/config.php', $outPath . '/api/.data/config.php');
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
}
function WaitFunction($deployid = '') {
if ($buildId=='1') {
$tmp['stat'] = 400;
$tmp['body'] = 'id must provided.';
return $tmp;
}
$header["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/deployments/" . $deployid;
$response = curl("GET", $url, "", $header);
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['readyState']=="READY") return true;
if ($result['readyState']=="ERROR") return $response;
return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = setConfigResponse( setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'Input Token\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+474
View File
@@ -0,0 +1,474 @@
<?php
// https://vercel.com/docs/api#endpoints/deployments/create-a-new-deployment
function getpath()
{
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (isset($_SERVER['HTTP_FLY_CLIENT_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_FLY_CLIENT_IP'];
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
}
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = "/";
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
$_SERVER['DOCUMENT_ROOT'] = '/var/task/user';
return $path;
}
function getGET()
{
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
$getstrarr = explode("&",$getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function getConfig($str, $disktag = '')
{
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$tmp = getenv($disktag);
if (is_array($tmp)) $env = $tmp;
else $env = json_decode($tmp, true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(getenv($str));
else return getenv($str);
}
return '';
}
function setConfig($arr, $disktag = '')
{
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getenv('disktag'));
if ($disktag!='') {
$tmp = getenv($disktag);
if (is_array($tmp)) $diskconfig = $tmp;
else $diskconfig = json_decode($tmp, true);
}
$tmp = [];
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
else $tmp[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
else $diskconfig[$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$tmp[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$tagvalue = getenv($v);
if (is_array($tagvalue)) $tmp[$newtag] = json_encode($tagvalue);
else $tmp[$newtag] = $tagvalue;
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$tmp[$k] = json_encode($v);
}
}
if ($indisk) {
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig);
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$tmp['disktag'] = implode('|', $tags);
$tagvalue = getenv($arr['disktag_rename']);
if (is_array($tagvalue)) $tmp[$arr['disktag_newname']] = json_encode($tagvalue);
else $tmp[$arr['disktag_newname']] = $tagvalue;
$tmp[$arr['disktag_rename']] = null;
} else {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = null;
}
}
foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT));
//echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT);
return setVercelConfig($tmp, getConfig('HerokuappId'), getConfig('APIKey'));
}
function install()
{
global $constStr;
if ($_GET['install1']) {
if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$token = $APIKey;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$aliases = json_decode(curl("GET", "https://api.vercel.com/v3/now/aliases", "", $header)['body'], true);
$host = splitfirst($_SERVER["host"], "//")[1];
foreach ($aliases["aliases"] as $key => $aliase) {
if ($host==$aliase["alias"]) $projectId = $aliase["projectId"];
}
$tmp['HerokuappId'] = $projectId;
$response = json_decode(setVercelConfig($tmp, $projectId, $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var expd = new Date();
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
}
if ($_GET['install0']) {
$html .= '
<form action="?install1" method="post" onsubmit="return notnull(this);">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
$html .= '<br>
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>';
$html .= '<br>
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<div id="showerror"></div>
<script>
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
var errordiv = document.getElementById("showerror");
function changelanguage(str)
{
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
location.href = location.href;
}
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\'input admin\');
return false;
}
if (t.APIKey.value==\'\') {
alert(\'input Token\');
return false;
}
return true;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
if (substr($_SERVER["host"], -10)=="vercel.app") {
$html .= '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
$html .= "<br>Remember: you MUST wait 30-60s after each operate / do some change, that make sure Vercel has done the building<br>" ;
} else {
$html.= "Please visit form *.vercel.app";
}
$title = 'Install';
return message($html, $title, 201);
}
// POST /v8/projects/:id/env
function setVercelConfig($envs, $appId, $token)
{
$url = "https://api.vercel.com/v8/projects/" . $appId . "/env";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, "", $header);
$result = json_decode($response['body'], true);
foreach ($result["envs"] as $key => $value) {
$existEnvs[$value["key"]] = $value["id"];
}
foreach ($envs as $key => $value) {
$response = null;
$tmp = null;
$tmp["type"] = "encrypted";
$tmp["key"] = $key;
$tmp["value"] = $value;
$tmp["target"] = [ "development", "production", "preview" ];
if (isset($existEnvs[$key])) {
if ($value) $response = curl("PATCH", $url . "/" . $existEnvs[$key], json_encode($tmp), $header);
else $response = curl("DELETE", $url . "/" . $existEnvs[$key], "", $header);
} else {
if ($value) $response = curl("POST", $url, json_encode($tmp), $header);
}
//echo $key . " = " . $value . ", <br>" . $response . json_encode($response, JSON_PRETTY_PRINT) . "<br>";
if (!!$response && $response['stat']!=200) return $response['body'];
}
return VercelUpdate($appId, $token);
}
function VercelUpdate($appId, $token, $sourcePath = "")
{
if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}';
$url = "https://api.vercel.com/v13/deployments";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$data["name"] = "OneManager";
$data["project"] = $appId;
$data["target"] = "production";
$data["routes"][0]["src"] = "/(.*)";
$data["routes"][0]["dest"] = "/api/index.php";
$data["functions"]["api/index.php"]["runtime"] = "vercel-php@0.4.0";
if ($sourcePath=="") $sourcePath = splitlast(splitlast(__DIR__, "/")[0], "/")[0];
//echo $sourcePath . "<br>";
getEachFiles($file, $sourcePath);
$data["files"] = $file;
//echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>";
$response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
$result['DplStatus'] = $result['id'];
return json_encode($result);
}
function checkBuilding($projectId, $token)
{
$r = 0;
$url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, '', $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
foreach ( $result['deployments'] as $deployment ) {
if ($deployment['state']!=="READY") $r++;
}
return $r;
//if ($r===0) return true;
//else return false;
}
function getEachFiles(&$file, $base, $path = "")
{
//if (substr($base, -1)=="/") $base = substr($base, 0, -1);
//if (substr($path, -1)=="/") $path = substr($path, 0, -1);
$handler=opendir(path_format($base . "/" . $path));
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..' && $filename != '.git'){
$fromfile = path_format($base . "/" . $path . "/" . $filename);
//echo $fromfile . "<br>";
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = getEachFiles($file, $base, path_format($path . "/" . $filename));
if (api_error(setConfigResponse($response))) return $response;
}else{
$tmp['file'] = path_format($path . "/" . $filename);
$tmp['data'] = file_get_contents($fromfile);
$file[] = $tmp;
}
}
}
closedir($handler);
return json_encode( [ 'response' => 'success' ] );
}
function api_error($response)
{
return isset($response['error']);
}
function api_error_msg($response)
{
return $response['error']['code'] . '<br>
' . $response['error']['message'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function setConfigResponse($response)
{
return json_decode($response, true);
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$tmppath = '/tmp';
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
$tarfile = $tmppath . '/github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return '{"error":{"message":"fail to download from github"}}';
file_put_contents($tarfile, $githubfile);
$phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
unlink($tarfile);
$outPath = '';
$tmp = scandir($tmppath);
$name = $auth . '-' . $project;
mkdir($tmppath . "/" . $name, 0777);
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
$outPath = $tmppath . "/" . $name;
break;
}
}
//echo $outPath . "<br>";
//error_log1($outPath);
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
}
function WaitFunction($deployid) {
if ($buildId=='1') {
$tmp['stat'] = 400;
$tmp['body'] = 'id must provided.';
return $tmp;
}
$header["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/deployments/" . $deployid;
$response = curl("GET", $url, "", $header);
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['readyState']=="READY") return true;
if ($result['readyState']=="ERROR") return $response;
return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = json_decode(setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'Input Token\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+181 -83
View File
@@ -1,108 +1,206 @@
Install program first, then add onedrive in setup after login.
先安装程序,登录后在设置中添加onedrive。
[中文readme](readme_cn.md)
# NOTICE:
The Releases is used as archive, not newest code.
Please read the descriptions of settings before raising an issue.
---
# Deploy to Heroku
Official: https://heroku.com
Demo: https://herooneindex.herokuapp.com/
How to Install: Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/qkqpttgf/OneManager-php) to Deploy a new app, or create an app then deploy via connect to your github fork.
### Official
https://heroku.com
### Demo
https://herooneindex.herokuapp.com/
### How to Install
> ~~Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
>
> Star this project, then Fork, create a app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork.
---
# Deploy to Glitch
Official: https://glitch.com/
Demo: https://onemanager.glitch.me/
How to Install: New Project -> Import form Github -> paste "https://github.com/qkqpttgf/OneManager-php", after done, Show -> In a New Window.
### Official
https://glitch.com/
### Demo
https://onemanager.glitch.me/
### How to Install
[New Project] -> [Import form Github] -> paste "https://github.com/qkqpttgf/OneManager-php" , after done, [Show] -> [In a New Window].
---
# Deploy to Vercel
### Official
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### Notice
> 1. you must wait 30-50s to make sure deploy READY after change config;
>
> 2. Vercel limit 100 deploy every day.
### How to Install
https://scfonedrive.github.io/Vercel/Deploy.html .
---
# Deploy to Tencent Serverless Cloud Function (SCF)
### Official
https://cloud.tencent.com/product/scf
### DEMO
null
### How to Install
see CN readme.
----
# Deploy to Tencent Serverless Cloud Function (SCF 腾讯无服务器云函数)
Official: https://cloud.tencent.com/product/scf
DEMO: 无
注意:SCF新增限制,环境变量整体最大4KB,所以最多添加4个盘。
# Deploy to Huawei cloud Function Graph (FG)
How to Install:
1,进入函数服务,上方选择地区,然后点击新建。
2,输入函数名称,选择模板函数,在模糊搜索中输入onedrive,大小写随意,选择那个【获取onedrive信息.....】,点下一步,在代码界面不用动,直接点完成。
3,点击触发管理,创建触发器,触发方式改成API网关触发,底下勾选启用集成响应,提交。
4,在触发管理中可以看到一个 访问路径,访问它,开始安装。
### Official
(重点:勾选集成响应)
添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。
https://console.huaweicloud.com/functiongraph/
### DEMO
# Deploy to Virtual Private Server (VPS 或空间)
DEMO: 无
How to Install:
1.Start web service on your server (httpd or other), make sure you can visit it.
启动web服务器,确保你能访问到。
2.Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php.
开启伪静态(重写)功能,规则在.htaccess文件中,ngnix从里面复制,我们的目的是不管访问什么都让index.php来处理。
3.Upload code.
上传好代码。
4.Change the file config.php can be read&write (666 is suggested).
让代码中的config.php文件程序可读写,推荐chmod 666 config.php。
5.View the website in chrome or other.
在浏览器中访问。
null
### How to Install
# Deploy to Huawei cloud Function Graph (FG 华为云函数工作流)
Official: https://console.huaweicloud.com/functiongraph/
DEMO: 无
注意:FG中,环境变量整体大小为2KB,所以最多添加2个盘。
see CN readme.
How to Install:
1,在函数列表,点右边创建函数
2,输入名称,选择运行时语言为PHP7.3,点上传ZIP文件,选择文件,然后点右边的创建函数(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。)
3,创建触发器:选API网关,安全认证选None,后端超时(毫秒)将5000改成30000,上面创建分组一下,其它的点点点
4,访问触发器给的url,开始安装
5,在触发器界面点触发器名称,跳到API网关管理,右边更多URL,可以添加自定义域名,自定义域名后发现还是要 xxxx.com/函数名 来访问,点上方的编辑,第1页不用改,点下一步,请求Path改成/,注意匹配模式是前缀匹配,Method为ANY,然后不用点下一步了,点立即完成,然后去发布生效
----
# Deploy to Aliyun Function Compute (FC)
# Deploy to Aliyun Function Compute (FC 阿里云函数计算)
Official: https://fc.console.aliyun.com/
DEMO: 无
### Official:
How to Install:
1,新建函数 -- HTTP函数
2,运行环境选择php7.2
3,触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
4,上传代码
5,触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
6,访问你的域名,开始安装
https://fc.console.aliyun.com/
### DEMO
# Deploy to Baidu Cloud Function Compute (CFC 百度云函数计算)
Official: https://console.bce.baidu.com/cfc/#/cfc/functions
DEMO: 无
自定义域名需要另外使用API网关,并备案。
null
How to Install:
1,在函数列表,点创建函数
2,创建方式改为空白函数,点下一步
3,输入名称,选择运行时为PHP7.2,点下一步
4,触发器:下拉选择HTTP触发器,URL路径填 /{filepath+} ,HTTP方法全选,身份验证:不验证,点提交
5,进入代码编辑页,编辑类型改上传函数ZIP包,选择文件(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。),开始上传
6,点击右边触发器,复制并访问提供的url,开始安装
### How to Install
see CN readme.
# Features 特性
When downloading files, the program produce a direct url, visitor download files from MS OFFICE via the direct url, the server expend a few bandwidth in produce.
下载时,由程序解析出直链,浏览器直接从微软Onedrive服务器下载文件,服务器只消耗与微软通信的少量流量。
When uploading files, the program produce a direct url, visitor upload files to MS OFFICE via the direct url, the server expend a few bandwidth in produce.
上传时,由程序生成上传url,浏览器直接向微软Onedrive的这个url上传文件,服务器只消耗与微软通信的少量流量。
The XXX_path in setting is the path in Onedrive, not in url, program will find the path in Onedrive.
设置中的 XXX_path 是Onedrive里面的路径,并不是你url里面的,程序会去你Onedrive里面找这个路径。
LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited.
网站图标:将favicon.ico文件放在你要展示的目录中,确保 xxxxx.com/favicon.ico 可以访问到。
Program will show content of 'readme.md' & 'head.md'.
可以在文件列表显示head.md跟readme.md文件的内容。
guest up path, is a folder that the guest can upload files, but can not be list (exclude admin).
游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。
If there is 'index.html' file, program will only show the content of 'index.html', not list the files.
如果目录中有index.html文件,只会输出显示html文件,不显示程序框架。
Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
---
QQ Group: 943919989 (请看完上面的中英双语再加群,谢谢!)
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
# Deploy to Baidu Cloud Function Compute (CFC)
### Official
https://console.bce.baidu.com/cfc/#/cfc/functions
### DEMO
null
### How to Install
see CN readme.
---
# Deploy to Virtual Private Server (VPS) or php host
### DEMO
null
### How to Install
1. Start web service on your server (httpd or other), make sure you can visit it.
2. Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php.
3. Upload code.
4. Change the file .data/config.php can be read&write (666 is suggested).
5. View the website in chrome or other.
----
# Features
When downloading files, the program produce a direct url, visitor download files from MS OFFICE via the direct url, the server expend a few bandwidth in produce.
When uploading files, the program produce a direct url, visitor upload files to MS OFFICE via the direct url, the server expend a few bandwidth in produce.
The XXX_path in setting is the path in Onedrive, not in url, program will find the path in Onedrive.
LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited.
Program will show content of 'readme.md' & 'head.md'.
guest upload path, is a folder that the guest can upload files, but can not be list (exclude admin).
If there is 'index.html' file, program will only show the content of 'index.html', not list the files.
Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
----
# Functional files
### favicon.ico
put it in the showing home folder of FIRST disk (maybe not root of onedrive).
### index.html
show content of index.html as html.
### head.md
### readme.md
it will showed at top or bottom as markdown.
### head.omf
### foot.omf
it will showed at top or bottom as html (javascript works!).
----
# A cup of coffee
https://paypal.me/qkqpttgf
-----
# Chat
### Telegram Group
https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
+246
View File
@@ -0,0 +1,246 @@
[Readme EN](readme.md)
# 注意:
Releases只是当存档在用的,并不是最新代码。
请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。
---
# 部署到 Heroku
### 官网
https://heroku.com
### Demo
https://herooneindex.herokuapp.com/
### 安装
> 给这个项目点star,然后fork,在Heroku创建一个app,然后点进Deploy页,在"Deployment method"处点"Connect GitHub",选择你的fork。
---
# 部署到 Glitch
### 官网
https://glitch.com/
### Demo
https://onemanager.glitch.me/
### 安装
点 [New Project] -> 点 [Import form Github] -> 粘贴 "https://github.com/qkqpttgf/OneManager-php" ,结束后,左上角点 [Show] -> [In a New Window]。
---
# 部署到 Vercel
### 官网
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### 注意
> 1. 每次更改配置后都要等 30-50s 来确保部署成功;
>
> 2. Vercel 每天限制 100 次部署。
### 安装(英文)
https://scfonedrive.github.io/Vercel/Deploy.html
---
# 部署到腾讯无服务器云函数 Serverless Cloud Function (SCF)
### 官网
https://cloud.tencent.com/product/scf
### DEMO
暂无
### 注意事项
SCF新增限制,环境变量整体最大4KB,所以最多添加4个盘(可以在安装时选择将配置保存在文件来避开限制)。
### 安装
1. 进入函数服务,上方选择地区,然后点击新建。
2. 输入函数名称,选择模板函数,在模糊搜索中输入onedrive,大小写随意,选择那个【获取onedrive信息.....】,点下一步,在代码界面不用动,直接点完成。
3. 点击触发管理,创建触发器,触发方式改成API网关触发,底下勾选启用集成响应,提交。
4. 在触发管理中可以看到一个 访问路径,访问它,开始安装。
(重点:**勾选集成响应**)
> **添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。**
----
# 部署到华为云函数工作流 Function Graph (FG)
### 官网
https://console.huaweicloud.com/functiongraph/
### DEMO
暂无
### 注意事项
FG中,环境变量整体大小为2KB,所以最多添加2个盘(一个onedrive一个aliyundrive)(可以在安装时选择将配置保存在文件来避开限制)。
### 安装
1. 在函数列表,点右边创建函数
2. 输入名称,选择运行时语言为PHP7.3,点上传ZIP文件,选择文件,然后点右边的创建函数(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。)
3. 创建触发器:选API网关,安全认证选None,后端超时(毫秒)将5000改成30000,上面创建分组一下,其它的点点点
4. 访问触发器给的url,开始安装
5. 在【触发器界面】点【触发器名称】,跳到API网关管理,右边【更多URL】,可以添加自定义域名,自定义域名后发现还是要 xxxx.com/函数名 来访问,点上方的【编辑】,第1页不用改,点【下一步】,**请求Path改成/**,注意匹配模式是前缀匹配,Method为ANY,然后不用点下一步了,点【立即完成】,然后去【发布】生效
----
# 部署到阿里云函数计算 Function Compute (FC)
### 官网
https://fc.console.aliyun.com/
### DEMO
### 安装
1. 新建函数 -- HTTP函数
2. 运行环境选择php7.2
3. 触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
4. 上传代码(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。)
5. 触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
6. 访问你的域名,开始安装
---
# 部署到百度云函数计算 Cloud Function Compute (CFC)
### 官网
https://console.bce.baidu.com/cfc/#/cfc/functions
### DEMO
暂无
### 注意事项
**自定义域名需要另外使用API网关,并备案。**
### 安装
1. 在函数列表,点创建函数
2. 创建方式改为空白函数,点下一步
3. 输入名称,选择运行时为PHP7.2,点下一步
4. 触发器:下拉选择HTTP触发器,URL路径填 /{filepath+} ,HTTP方法全选,身份验证:不验证,点提交
5. 进入代码编辑页,编辑类型改上传函数ZIP包,选择文件(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。),开始上传
6. 点击右边触发器,复制并访问提供的url,开始安装
---
# 部署到VPS (Virtual Private Server) 或 空间
### DEMO
暂无
### 安装
1. 启动web服务器,确保你能访问到。
2. 开启伪静态(重写)功能,规则在.htaccess文件中,ngnix从里面复制,我们的目的是不管访问什么都让index.php来处理。
3. 上传好代码。
4. 使web身份可读写代码中的.data/config.php文件,推荐chmod 666 .data/config.php。
5. 在浏览器中访问。
----
# 特性
下载时,由程序解析出直链,浏览器直接从微软Onedrive服务器下载文件,服务器只消耗与微软通信的少量流量。
上传时,由程序生成上传url,浏览器直接向微软Onedrive的这个url上传文件,服务器只消耗与微软通信的少量流量。
设置中的 XXX_path 是Onedrive里面的路径,并不是你url里面的,程序会去你Onedrive里面找这个路径。
网站图标:将favicon.ico文件放在你要展示的目录中,确保 xxxxx.com/favicon.ico 可以访问到。
可以在文件列表显示head.md跟readme.md文件的内容。
游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。
如果目录中有index.html文件,只会输出显示html文件,不显示程序框架。
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
----
# 功能性文件
### favicon.ico
放在第一个盘的显示目录(不一定是onedrive根目录)。
### index.html
将index.html以静态网页显示出来。
### head.md
### readme.md
以MD语法显示在顶部或底部。
### head.omf
### foot.omf
以html显示在顶部或底部(可以跑js)。
----
# 捐赠
https://paypal.me/qkqpttgf
-----
# 群聊
**请看完上面的中英双语再加群,谢谢!**
### QQ 群:
212088653
### Telegram Group
https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
+2 -2
View File
@@ -254,14 +254,14 @@
<div class="title pull-left">
<a href="<!--base_path-->"><!--Sitename--></a>
</div>
<div class="pull-right">
<div class="pull-right"><!--
<!--LoginStart-->
<a class="pull-left" onclick="/*login();*/"><!--constStr@Login--></a>
<!--LoginEnd-->
<!--AdminStart-->
<a class="pull-left" onclick="logout();"><!--constStr@Logout--></a>
<!--AdminEnd-->
&nbsp;|
&nbsp;| -->
<div class="pull-right lang">
<select name="language" id="language" class="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
<option value="">Language</option>
+522 -119
View File
File diff suppressed because it is too large Load Diff
+1701
View File
File diff suppressed because it is too large Load Diff
-1289
View File
File diff suppressed because it is too large Load Diff
-1283
View File
File diff suppressed because it is too large Load Diff
-1544
View File
File diff suppressed because it is too large Load Diff
+502 -161
View File
@@ -3,9 +3,9 @@
"music":"musical-notes",
"video":"logo-youtube",
"img":"image",
"office":"paper",
"office":"newspaper",
"txt":"clipboard",
"zip":"filing",
"zip":"file-tray-full",
"iso":"disc",
"apk":"logo-android",
"exe":"logo-windows",
@@ -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-->
}
@@ -107,7 +109,7 @@
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<!--IsFolderStart-->
<a class="dropdown-item" data-toggle="modal" data-target="#NewFileModal"><ion-icon name="create"></ion-icon><!--constStr@Create--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value=''"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value=''"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a>
<a class="dropdown-item" href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a>
<!--IsFolderEnd-->
<a class="dropdown-item" href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a>
@@ -175,7 +177,7 @@
<div style="padding:20px">
<center>
<form action="" method="post">
<input name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input id="password1" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input type="submit" value="<!--constStr@Submit-->">
</form>
</center>
@@ -285,7 +287,7 @@
<ion-icon name="construct"></ion-icon>
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value='<!--FileEncodeReplaceName-->'"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#exampleencrypt" onclick="document.getElementById('encrypt_hidden').value='<!--FileEncodeReplaceName-->'"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#renameModal" onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#MoveModal" onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a>
<a class="dropdown-item" data-toggle="modal" data-target="#CopyModal" onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a>
@@ -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(/&/,'&amp;');
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,8 +1743,11 @@ 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="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="//cdn.bootcdn.net/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="//cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
+520 -132
View File
@@ -3,9 +3,9 @@
"music":"musical-notes",
"video":"logo-youtube",
"img":"image",
"office":"paper",
"office":"newspaper",
"txt":"clipboard",
"zip":"filing",
"zip":"file-tray-full",
"iso":"disc",
"apk":"logo-android",
"exe":"logo-windows",
@@ -24,9 +24,12 @@
<link rel="icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kizx/onemoe-theme/onemoe.min.css" type="text/css" />
<!--BackgroundStart-->
<!--BackgroundStart-->
<style>body{background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-position-x:center;background-image:url("<!--BackgroundUrl-->")}</style>
<!--BackgroundEnd-->
<!--BackgroundEnd-->
<!--BackgroundMStart-->
<style>@media screen and (orientation:portrait){body{background-image:url("<!--BackgroundMUrl-->");}}</style>
<!--BackgroundMEnd-->
<script type="text/javascript">if(window.console&&window.console.log){console.log("%c Onemoe Theme %c https://github.com/kizx/onemoe-theme ","color: #fff; margin: 1em 0; padding: 5px 0; background: #673ab7;","margin: 1em 0; padding: 5px 0; background: #efefef;")}</script>
<!--customCss-->
</head>
@@ -40,7 +43,7 @@
<li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul>
<!--IsFolderStart-->
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li>
<!--IsFolderEnd-->
<li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li>
@@ -104,42 +107,41 @@
<div class="list-wrapper" id="list-div">
<div class="list-container">
<div class="list-header-container">
<!--BackArrowStart-->
<a href="<!--BackArrowUrl-->" class="back-link">
<ion-icon name="arrow-back"></ion-icon>
</a>
<!--BackArrowEnd-->
<h3 class="table-header"><!--PathArrayStart--> / <a href="<!--PathArrayLink-->"><!--PathArrayName--></a><!--PathArrayEnd--></h3>
<h3 class="table-header"><a href="<!--base_path-->"><!--constStr@Home--></a><!--DiskPathArrayStart--> / <a href="<!--PathArrayLink-->"><!--PathArrayName--></a><!--DiskPathArrayEnd--></h3>
</div>
<div class="list-body-container">
<!--EncryptedStart-->
<div style="padding:20px">
<center>
<form action="" method="post">
<input name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input id="password1" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input type="submit" value="<!--constStr@Submit-->">
</form>
</center>
</div>
<!--EncryptedEnd-->
<!--GuestUploadStart-->
<div id="upload_div" style="margin:10px">
<div id="upload_btns" align="center">
<input id="upload_file" type="file" name="upload_filename">
<div id="upload_div" style="padding:0 0 16px 0">
<div id="upload_btns" align="center">
<select onchange="document.getElementById('upload_file').webkitdirectory=this.value;">
<option value=""><!--constStr@UploadFile--></option>
<option value="1"><!--constStr@UploadFolder--></option>
</select>
<input id="upload_file" type="file" name="upload_filename" multiple="multiple">
<input id="upload_submit" onclick="preup();" value="<!--constStr@Upload-->" type="button">
</div>
</div>
</div>
<!--GuestUploadEnd-->
<!--IsFileStart-->
<div style="margin: 12px 4px 4px; text-align: center">
<div style="padding: 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>&nbsp;<!--constStr@Download--></a>
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
</div>
<div 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>
@@ -196,7 +198,7 @@
<!--AdminStart-->
<li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a>
<ul>
<li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li>
<li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li>
<li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li>
@@ -205,7 +207,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>
@@ -225,7 +227,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>
@@ -261,7 +263,7 @@
</form>
<!--MorePageEnd-->
<!--AdminStart-->
<div id="upload_div" style="margin:0 0 16px 0">
<div id="upload_div" style="padding:0 0 16px 0">
<div id="upload_btns" align="center">
<select onchange="document.getElementById('upload_file').webkitdirectory=this.value;">
<option value=""><!--constStr@UploadFile--></option>
@@ -273,10 +275,10 @@
</div>
<!--AdminEnd-->
<!--IsFolderEnd-->
<!--ListEnd-->
</div>
</div>
</div>
<!--ListEnd-->
<!--ReadmemdStart-->
<div class="list-wrapper" id="readme-div">
<div class="list-container">
@@ -313,6 +315,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-->">
@@ -326,6 +329,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>
@@ -336,6 +340,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-->
@@ -347,6 +352,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-->">
@@ -358,6 +364,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-->
@@ -376,6 +383,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>
@@ -412,14 +420,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>
@@ -428,6 +437,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">
@@ -440,28 +450,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) {
@@ -544,7 +558,7 @@
});
}
}
addVideos(['<!--FileDownUrl-->']);
addVideos(['<!--FileEncodeUrl-->']);
<!--IsvideoFileEnd-->
<!--IspdfFileStart-->
pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
@@ -589,7 +603,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-->
@@ -609,15 +622,13 @@
strarry=str.split('.');
ext=strarry[strarry.length-1].toLowerCase();
if (images.indexOf(ext)>-1) {
var url=files[$i].href;
url=url.substr(0,url.length-8);
if (document.getElementById('originalpic').checked==true) {
var url=files[$i].href;
url=url.substr(0,url.length-8);
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 {
var nurl=window.location.href;
if (nurl.substr(-1)!="/") nurl+="/";
var url=nurl+str+'?thumbnails';
url+='?thumbnails';
get_thumbnails_url(url, str, files[$i]);
}
}
@@ -754,6 +765,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';
@@ -768,6 +813,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;
@@ -780,7 +828,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;
@@ -793,7 +849,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);
@@ -806,10 +862,13 @@
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('.');
if (strarry.length==1) return '';
ext=strarry[strarry.length-1].toLowerCase();
var reg = new RegExp(".","g");
var a = str.replace(reg,"");
@@ -837,29 +896,21 @@
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+='.';
}
xhr1.onload = function(e){
console.log(xhr1.status+xhr1.responseText);
//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);
@@ -872,13 +923,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-->
}
}
@@ -886,24 +951,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();
@@ -952,7 +1000,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();
@@ -961,12 +1009,14 @@
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='+filename);
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr3.send(null);
xhr3.onload = function(e){
console.log(xhr3.responseText+','+xhr3.status);
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>';
@@ -975,8 +1025,12 @@
} 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-->'+(file.webkitRelativePath||response.name)+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+(file.webkitRelativePath||response.name)+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
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;
@@ -985,6 +1039,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("-")) );
@@ -1000,12 +1055,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';
@@ -1013,9 +1388,28 @@
}
<!--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;
}
/*for some mobile browser*/
function menu_click(e){
var ee=document.getElementsByClassName("active");
for(var i=0;i<ee.length;i++){
ee[i].classList.remove("active");
}
if(e.type!="mouseout")this.classList.add("active");
}
(function(){
var e=document.getElementsByClassName("operate");
document.body.addEventListener("touchstart", menu_click);
for(var i=0;i<e.length;i++){
e[i].addEventListener("touchstart", menu_click);
e[i].addEventListener("mouseout", menu_click);
}
})();
<!--IsFolderStart-->
function showdiv(event,action,num) {
var $operatediv=document.getElementsByName('operatediv');
@@ -1027,21 +1421,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=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(/&/,'&amp;');
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;
@@ -1070,9 +1462,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) {
@@ -1088,10 +1480,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) {
@@ -1105,15 +1499,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);
@@ -1187,18 +1582,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>
<script src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<!--LoginStart--><script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script><!--LoginEnd-->
<!--customScript-->
</html>
+8 -7
View File
@@ -3,9 +3,9 @@
"music":"musical-notes",
"video":"logo-youtube",
"img":"image",
"office":"paper",
"office":"newspaper",
"txt":"clipboard",
"zip":"filing",
"zip":"file-tray-full",
"iso":"disc",
"apk":"logo-android",
"exe":"logo-windows",
@@ -89,7 +89,7 @@
<li class="operate"><ion-icon name="construct"></ion-icon><!--constStr@Operate--><ul>
<!--IsFolderStart-->
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><!--constStr@Create--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><!--constStr@RefreshCache--></a></li>
<!--IsFolderEnd-->
<li><a href="<!--IsPreview?-->setup"><ion-icon name="settings"></ion-icon><!--constStr@Setup--></a></li>
@@ -240,7 +240,7 @@
<!--AdminStart-->
<li class="operate"><ion-icon name="construct"></ion-icon><a><!--constStr@Operate--></a>
<ul>
<li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event,'encrypt',<!--filenum-->);"><ion-icon name="lock-closed"></ion-icon><!--constStr@Encrypt--></a></li>
<li><a onclick="showdiv(event, 'rename',<!--filenum-->);"><ion-icon name="create"></ion-icon><!--constStr@Rename--></a></li>
<li><a onclick="showdiv(event, 'move',<!--filenum-->);"><ion-icon name="move"></ion-icon><!--constStr@Move--></a></li>
<li><a onclick="showdiv(event, 'copy',<!--filenum-->);"><ion-icon name="copy"></ion-icon><!--constStr@Copy--></a></li>
@@ -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-->
}
}
@@ -1247,6 +1248,6 @@
document.getElementById('password1').focus();
<!--EncryptedEnd-->
</script>
<script src="//unpkg.zhimg.com/ionicons@4.4.4/dist/ionicons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<!--customScript-->
</html>
-1272
View File
File diff suppressed because it is too large Load Diff
+253 -111
View File
@@ -1,34 +1,59 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<link rel="preconnect" href="https://cdn.jsdelivr.net">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="preconnect" href="https://renexmoe.vercel.app">
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<meta charset="utf-8" />
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no" />
<title>
<!--Title-->
</title>
<meta name="description" content="A Onemanager-PHP site with Theme-renexmoe">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v0.5/css/app.css"><meta name="theme-color" content="#fff" />
<link
rel="shortcut icon"
href="<!--base_path-->favicon.ico"
type="image/x-icon"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"
/>
<title><!--Title--></title>
<meta name="description" content="A Onemanager-PHP site with Theme-renexmoe" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/css/app.css"><meta name="theme-color" content="#fff" />
<!--BackgroundStart-->
<style>
body {
--bg: url("<!--BackgroundUrl-->");
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-image: var(--bg)
}
body {
--bg: url("<!--BackgroundUrl-->");
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-image: var(--bg);
}
.mdui-shadow-3 {
background: rgba(255, 255, 255, 0.5)
}
.mdui-shadow-3 {
background: rgba(255, 255, 255, 0.5);
}
</style>
<script>window.disableddarkmode = true;</script>
<script>
window.disableddarkmode = true;
</script>
<!--BackgroundEnd-->
<!--BackgroundMStart-->
<style>
body {
--bg: url("<!--BackgroundMUrl-->");
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-image: var(--bg);
}
.mdui-shadow-3 {
background: rgba(255, 255, 255, 0.5);
}
</style>
<script>
window.disableddarkmode = true;
</script>
<!--BackgroundMEnd-->
</head>
<body
class="mdui-appbar-with-toolbar mdui-theme-layout-auto mdui-loaded mdui-theme-accent-pink"
@@ -39,13 +64,11 @@
<div class="mdui-toolbar">
<span
class="mdui-btn mdui-btn-icon mdui-ripple mdui-ripple-white"
mdui-tooltip="{content: '菜单'}"
onclick='mdui.$("body").toggleClass("mdui-drawer-body-left");'
id="toggle-drawer"
><i class="mdui-icon material-icons">menu</i></span
>
<a
mdui-tooltip="{content: '返回'}"
class="mdui-btn mdui-btn-icon mdui-ripple mdui-ripple-white mdui-hidden-sm-up"
onclick="window.history.back()"
>
@@ -65,7 +88,6 @@
<!--AdminStart--><a
href="javascript:;"
class="mdui-btn mdui-btn-icon mdui-ripple mdui-hidden-sm-up refresh"
mdui-tooltip="{content: '刷新缓存'}"
><i class="mdui-icon material-icons">refresh</i></a
>
<!--AdminEnd-->
@@ -76,19 +98,32 @@
<div class="mdui-drawer mdui-drawer-close" id="main-drawer">
<div class="mdui-list" mdui-collapse="{accordion: true}">
<!--LoginStart-->
<li class="mdui-list-item mdui-ripple" href="javascript:void(0);" mdui-dialog="{target: '#login_input'}"><a
class="mdui-list-item-icon mdui-icon material-icons">account_circle</a><a
class="mdui-list-item-content">登录</a></li>
<li class="mdui-list-item mdui-ripple" href="?admin" >
<a class="mdui-list-item-icon mdui-icon material-icons">account_circle</a>
<a class="mdui-list-item-content" href="?admin">登录</a>
</li>
<!--LoginEnd-->
<!--AdminStart-->
<li class="mdui-list-item mdui-ripple" href="?setup"><a class="mdui-list-item-icon mdui-icon material-icons"
href="?setup">account_circle</a><a class="mdui-list-item-content" href="?setup">管理</a></li>
<li class="mdui-list-item mdui-ripple" onclick='document.cookie=null;window.location.reload();'><i
class="mdui-icon material-icons mdui-list-item-icon">exit_to_app</i>
<div class="mdui-list-item-content">退出登陆</div>
<li class="mdui-list-item mdui-ripple" href="?setup">
<a class="mdui-list-item-icon mdui-icon material-icons" href="?setup"
>account_circle</a
><a class="mdui-list-item-content" href="?setup">管理</a>
</li>
<li
class="mdui-list-item mdui-ripple"
onclick="document.cookie=``;window.location.reload();"
id="logout"
>
<i class="mdui-icon material-icons mdui-list-item-icon">exit_to_app</i>
<div class="mdui-list-item-content">退出登陆</div>
</li>
<li class="mdui-list-item mdui-ripple" id="checkupdate">
<i class="mdui-icon material-icons mdui-list-item-icon">update</i>
<div class="mdui-list-item-content">检查主题更新</div>
</li>
<div class="mdui-divider"></div>
<!--AdminEnd-->
<div class="mdui-divider"></div>
<li
class="mdui-list-item mdui-ripple"
href="javascript:void(0);"
@@ -102,29 +137,33 @@
href="<!--base_path-->"
class="mdui-list-item-icon mdui-icon material-icons"
>home</a
><a href="<!--base_path-->" class="mdui-list-item-content">
><a href="<!--base_path-->" class="mdui-list-item-content" id="home">
<!--constStr@Home--></a
>
</li>
<!--MultiDiskAreaStart-->
<div class="mdui-divider"></div>
<!--MultiDisksStart--><a
href="<!--MultiDisksUrl-->"
class="mdui-list-item mdui-ripple"
<!--MultiDisksNow--
>
><i class="mdui-list-item-icon mdui-icon material-icons">cloud</i>
<div class="mdui-list-item-content">
<!--MultiDisksStart-->
<li class="mdui-list-item mdui-ripple">
<a
href="<!--MultiDisksUrl-->"
class="mdui-list-item-icon mdui-icon material-icons"
>cloud</a
>
<a
href="<!--MultiDisksUrl-->"
class="mdui-list-item-content mdui-text-truncate disk_name"
>
<!--MultiDisksName-->
</div>
</a>
</a>
</li>
<!--MultiDisksEnd-->
<div class="mdui-divider"></div>
<!--MultiDiskAreaEnd-->
<a
href="https://github.com/qkqpttgf/OneManager-php"
class="mdui-list-item mdui-ripple mdui-hidden-sm-up"
class="mdui-list-item mdui-ripple"
><i class="mdui-list-item-icon mdui-icon material-icons">code</i>
<div class="mdui-list-item-content">Github</div>
</a>
@@ -141,46 +180,97 @@
<div class="mdui-container">
<ul class="mdui-menu" id="admin-menu">
<li class="mdui-menu-item"><a href="javascript:;" class="mdui-ripple back"><i
class="mdui-menu-item-icon mdui-icon material-icons">arrow_back</i>返回上一页</a></li>
<!--AdminStart-->
<li class="mdui-menu-item"><a href="javascript:;" class="mdui-ripple refresh"><i
class="mdui-menu-item-icon mdui-icon material-icons">refresh</i>刷新缓存</a></li>
<!--AdminEnd-->
<li class="mdui-menu-item">
<a href="javascript:;" class="mdui-ripple back"
><i class="mdui-menu-item-icon mdui-icon material-icons">arrow_back</i
>返回上一页</a
>
</li>
<!--AdminStart-->
<li class="mdui-menu-item">
<a href="javascript:;" class="mdui-ripple refresh"
><i class="mdui-menu-item-icon mdui-icon material-icons">refresh</i
>刷新缓存</a
>
</li>
<!--AdminEnd-->
</ul>
<i id="mouseplace" style="position: absolute;"></i> <!--EncryptedStart-->
<div class="mdui-col-md-6 mdui-col-offset-md-3"><br>
<center>
<div class="mdui-typo-title">这是一个受保护的文件夹,您需要提供访问密码才能查看。</div>
</center>
<form action="" method="post">
<div class="mdui-textfield mdui-textfield-floating-label"><i
class="mdui-icon material-icons">https</i><label class="mdui-textfield-label">
<!--constStr@InputPassword--></label><input name="password1" class="mdui-textfield-input"
type="password" /></div><br><button type="submit"
class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme"><i
class="mdui-icon material-icons">fingerprint</i>
<!--constStr@Submit--></button>
</form>
<i id="mouseplace" style="position: absolute"></i>
<div class="mdui-dialog" id="login_input">
<div class="mdui-dialog-title">登录</div>
<div class="mdui-dialog-content" style="height: 108px">
<div class="mdui-textfield mdui-textfield-floating-label">
<i class="mdui-icon material-icons">lock</i
><label class="mdui-textfield-label">密码</label
><input
class="mdui-textfield-input"
name="password1"
type="password"
onkeydown="if(event.keyCode==13) document.querySelector('#login_btn').click();"
/>
</div>
</div>
<div class="mdui-dialog-actions">
<button class="mdui-btn mdui-ripple" mdui-dialog-close="" id="login_close">取消</button
><button
id="login_btn"
class="mdui-btn mdui-ripple"
type="submit"
value="登录"
>
登录
</button>
</div>
</div>
<!--EncryptedStart-->
<div class="mdui-col-md-6 mdui-col-offset-md-3">
<br />
<center>
<div class="mdui-typo-title">
这是一个受保护的文件夹,您需要提供访问密码才能查看。
</div>
</center>
<form action="" method="post">
<div class="mdui-textfield mdui-textfield-floating-label">
<i class="mdui-icon material-icons">https</i
><label class="mdui-textfield-label"> <!--constStr@InputPassword--></label
><input name="password1" class="mdui-textfield-input" type="password" />
</div>
<br /><button
type="submit"
class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme"
>
<i class="mdui-icon material-icons">fingerprint</i>
<!--constStr@Submit-->
</button>
</form>
</div>
<!--EncryptedEnd-->
<!--IsFolderStart-->
<!--HeadomfStart-->
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
<!--HeadomfContent-->
<div class="mdui-typo mdui-shadow-3" style="padding: 20px; margin: 20px 0">
<!--HeadomfContent-->
</div>
<!--HeadomfEnd-->
<!--HeadmdStart-->
<div class="mdui-chip mdui-ripple mdui-hidden-xs"><span class="mdui-chip-icon"><i
class="mdui-icon material-icons">face</i></span><span class="mdui-chip-title">HEAD.md</span></div>
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0" id="head"><textarea
id="head-md"><!--HeadmdContent--></textarea></div>
<!--HeadmdEnd-->
<div class="mdui-chip mdui-ripple mdui-hidden-xs">
<span class="mdui-chip-icon"
><i class="mdui-icon material-icons">face</i></span
><span class="mdui-chip-title">HEAD.md</span>
</div>
<div
class="mdui-row mdui-shadow-3"
style="padding: 5px; margin: 20px 0; border-radius: 8px"
class="mdui-typo mdui-shadow-3 markdown"
style="padding: 20px; margin: 20px 0; overflow-x: scroll"
id="head"
>
<ul class="mdui-list">
<pre><code id="head-md"><!--HeadmdContent--></code></pre>
</div>
<!--HeadmdEnd-->
<div class="mdui-row mdui-shadow-3" style="margin: 20px 0; border-radius: 8px">
<ul class="mdui-list" id="file-list">
<li class="mdui-list-item mdui-ripple">
<div class="mdui-row mdui-col-xs-12">
<div class="mdui-col-xs-12 mdui-col-sm-7">
@@ -210,7 +300,7 @@
</div>
</li>
<!--BackArrowStart-->
<li class="mdui-list-item mdui-ripple">
<li class="mdui-list-item mdui-ripple back-page">
<div class="mdui-row mdui-col-sm-12">
<a href="<!--BackArrowUrl-->">
<div class="mdui-col-xs-7">
@@ -292,35 +382,71 @@
</ul>
</div>
<!--ReadmemdStart-->
<div class="mdui-chip mdui-ripple mdui-hidden-xs"><span class="mdui-chip-icon"><i
class="mdui-icon material-icons">face</i></span><span class="mdui-chip-title">README.md</span></div>
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0" id="readme"><textarea
id="readme-md"><!--ReadmemdContent--></textarea></div>
<div class="mdui-chip mdui-ripple mdui-hidden-xs">
<span class="mdui-chip-icon"
><i class="mdui-icon material-icons">face</i></span
><span class="mdui-chip-title">README.md</span>
</div>
<div
class="mdui-typo mdui-shadow-3 markdown"
style="padding: 20px; margin: 20px 0; overflow-x: scroll"
id="readme"
>
<pre><code id="readme-md"><!--ReadmemdContent--></code></pre>
</div>
<!--ReadmemdEnd-->
<!--FootomfStart-->
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
<!--FootomfContent-->
<div class="mdui-typo mdui-shadow-3" style="padding: 20px; margin: 20px 0">
<!--FootomfContent-->
</div>
<!--FootomfEnd-->
<script>
document.querySelector("#admin-menu").innerHTML +=
'<li class="mdui-menu-item"><a href="javascript:void(0);"class="mdui-ripple getalllink"><i class="mdui-menu-item-icon mdui-icon material-icons">link</i>批量链接</a></li>';
</script>
<script>
window.MorePage = undefined;
</script>
<!--MorePageStart-->
<script>
window.MorePage = [
<!--MorePageListNowStart-->
<!--PageNum-->,
<!--MorePageListNowEnd-->
<!--MorePageListStart-->
<!--PageNum-->,
<!--MorePageListEnd-->
];
</script>
<!--MorePageEnd-->
<!--IsFolderEnd-->
<!--IsFileStart-->
<div id="file">
<!--IsimgFileStart-->
<div
id="file"
class="mdui-shadow-3"
style="padding: 5px; margin: 20px 0px; padding: 20px; border-radius: 8px"
>
<!--IsimgFileStart-->
<img class="mdui-img-fluid mdui-center mdui-m-t-5" src="<!--FileDownUrl-->" />
<!--IsimgFileEnd-->
<!--IsmusicFileStart-->
<!--IsmusicFileStart-->
<audio
class="mdui-center"
src="<!--FileDownUrl-->"
controls
autoplay
style="width: 100%; margin-top: 10%"
style="width: 100%; margin-top: 10%; margin-bottom: 10%"
></audio>
<!--IsmusicFileEnd-->
<!--IsvideoFileStart-->
<video class="mdui-video-fluid" controls style="margin-top: 20px">
<!--IsvideoFileStart-->
<video
class="mdui-video-fluid"
controls
style="margin-top: 20px; margin-bottom: 20px"
>
<source src="<!--FileDownUrl-->" />
<p>
Your browser doesn't support HTML5 video. Here is a
@@ -328,39 +454,56 @@ id="readme-md"><!--ReadmemdContent--></textarea></div>
</p>
</video>
<!--IsvideoFileEnd-->
<!--IsofficeFileStart-->
<iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->"
style="width: 100%;height: 800px" frameborder="0"></iframe>
<!--IsofficeFileStart-->
<iframe
id="office-a"
src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->"
style="width: 100%; height: 800px"
frameborder="0"
></iframe>
<!--IsofficeFileEnd-->
<!--IspdfFileStart-->
<pre id="editor"
style="white-space: pre-wrap;font-family: JetBrains Mono,Fira Code,Sarasa Mono SC,Cascadia Code,Menlo,Consolas,monaco,monospace;">
PDF暂不支持 懂?
</pre>
<!--IspdfFileStart-->
<embed src="<!--FileEncodeReplaceUrl-->" type="application/pdf" />
<!--IspdfFileEnd-->
<!--IstxtFileStart-->
<!--IstxtFileStart-->
<pre
id="editor"
style="
white-space: pre-wrap;
font-family: JetBrains Mono, Fira Code, Sarasa Mono SC, Cascadia Code, Menlo,
Consolas, monaco, monospace;
Consolas, monaco, Noto Sans SC;
"
><!--TxtContent--></pre>
><code id="code"><!--TxtContent--></code></pre>
<script>
document.querySelector("#admin-menu").innerHTML +=
'<li class="mdui-menu-item"><a href="javascript:void(0);"class="mdui-ripple highlight"><i class="mdui-menu-item-icon mdui-icon material-icons">style</i>markdown解析</a></li>';
document.querySelector(
".mdui-toolbar"
).innerHTML += `<a href="javascript:;" class="mdui-btn mdui-btn-icon mdui-ripple mdui-hidden-sm-up highlight"><i class="mdui-icon material-icons">style</i></a>`;
</script>
<!--IstxtFileEnd-->
<!--IsOtherFileStart-->
<!--constStr@FileNotSupport-->
<!--IsOtherFileEnd-->
</div><a href="<!--FileEncodeReplaceUrl-->" target="_blank"
class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i
class="mdui-icon material-icons">file_download</i></a>
<!--IsOtherFileStart-->
<!--constStr@FileNotSupport-->
<!--IsOtherFileEnd-->
</div>
<a
href="<!--FileEncodeReplaceUrl-->"
target="_blank"
class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"
><i class="mdui-icon material-icons">file_download</i></a
>
<script>
document.querySelector("#admin-menu").innerHTML += '<li class="mdui-menu-item"><a href="javascript:void(0);"class="mdui-ripple downloadurl"><i class="mdui-menu-item-icon mdui-icon material-icons">cloud_download</i>下载链接</a></li>';
document.querySelector('.mdui-toolbar').innerHTML += `<a href="javascript:;" class="mdui-btn mdui-btn-icon mdui-ripple mdui-hidden-sm-up downloadurl" mdui-tooltip="{content: '下载链接'}"><i class="mdui-icon material-icons">cloud_download</i></a>`;
document.querySelector("#admin-menu").innerHTML +=
'<li class="mdui-menu-item"><a href="javascript:void(0);"class="mdui-ripple downloadurl"><i class="mdui-menu-item-icon mdui-icon material-icons">cloud_download</i>下载链接</a></li>';
document.querySelector(
".mdui-toolbar"
).innerHTML += `<a href="javascript:;" class="mdui-btn mdui-btn-icon mdui-ripple mdui-hidden-sm-up downloadurl"><i class="mdui-icon material-icons">cloud_download</i></a>`;
</script>
<!--IsFileEnd-->
</div>
</body>
@@ -368,6 +511,5 @@ id="readme-md"><!--ReadmemdContent--></textarea></div>
{ "music":"audiotrack", "video":"ondemand_video", "img":"image",
"pdf":"picture_as_pdf", "default":"insert_drive_file"}
<!--IconValuesEnd-->
<script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v0.5/js/webpack-runtime.379a2fcc01ccf12b5342.js"></script>
<script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v0.5/js/app.0a2b4a0f9fd0828393f6.js"></script>
<script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@1b381f3c.a4f2dc4618121eac37e2.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@28a13772.98a11cc0c1cf2495c3d8.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@34e3d95a.2f8dbf552095a86a7f1b.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@798ab416.9ed46bb752b71a3c13a4.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@9c50beac.30955a99f08c9574cd14.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@f0256996.956ea71aa357ba3fdc28.js"></script><script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/webpack-runtime.93708ab3e9cb84dcc01a.js"></script>
</html>
-1240
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1812
View File
File diff suppressed because one or more lines are too long
-1296
View File
File diff suppressed because it is too large Load Diff
-1296
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+58 -1
View File
@@ -1,7 +1,64 @@
20211201-1602.41
add a latent function, you can edit platform token(or API key) via '?setup=auth' when the token invalid, not need edit it in Environment(or Config Var) manually, (even in Vercel, config saved in file, and can't modiy it manually).
新增隐藏功能,在平台操作代码的token或API key失效时,可以在 '?setup=auth' 修改它,不用去环境变量修改了(特别地,Vercel保存在代码中时都改不到)。
20211129
check if there is another deployment building when start deploy.
Vercel部署时检测是否有另一个部署。
20211104
check if exist php-curl or not in php host and VPS.
在VPS中检测是否有php-curl。
20211021
specialchars, fix: list folder, encrypt folder, preview files, rename, show in title, error on back link after login at specialchars folder, etc.
针对特殊字符,解决目录的列表,目录的加密,文件的预览,目录与文件重命名,在网页标题的显示,在特殊字符处登录后跳转出错等问题。
20211006
oprate files by fileID, write a localStorage when login to anti CSRF.
管理时对文件id操作,管理登录时写入一个localStorage预防CSRF。
20210908
add fileConduitSize&fileConduitCacheTime, little files can stream from program, better to show html/js as local file.
增加fileConduitSizefileConduitCacheTime,小文件可以从服务器中转,以对html/js本地化更好的支持。
20210903
add a latent function, you can run some command by '?setup=cmd', be care, please dont try "top", and set times by "ping -c 4".
新增隐藏功能,你可以通过'?setup=cmd'来跑一些命令,注意不要试图跑top,另外ping请-c设置次数。
20210820-1810.40
because Vercel must redeploy after change Environment Variables, and it must <4k, so decide that, save config in code file. <font color=red>in Vercel, after update, please install again. if you want continue use Environment, please add a ( name: "ONEMANAGER_CONFIG_SAVE", value: "env" ) in Environment Variables in Project Settings before update.</font>
因为Vercel修改环境变量也必须重新部署才生效,而且环境变量只能小于4k,所以决定将配置保存在代码文件中。<font color=red>升级更新后,用Vercel的请重新安装。如果还想继续使用环境变量,请在更新前,在Project Settings的Environment Variables中,新增一个( name: "ONEMANAGER_CONFIG_SAVE", value: "env" )的环境变量。</font>
20210817-2030.39
fix bugs in Vercel. add wait function in operating. change update method in SCF. add payme in readme.
修复一些Vercel上的bug。在操作完后添加等待功能,确认平台已经准备好。SCF的更新方式改变。在readme中添加讨饭链接。
20210804-1535.38
try fix "&"/"&amp;" in filename. try show an img too height. change upload chunk size when upload speed>10M/s. fix forceHttps when custom domain in Glitch. fix ionicons svg lost.try use file id when rename. background (or other) based on width/height not only width. fix some bugs. Pre-Add platform Vercel, just wait bugs fixed.
尝试修复文件名含 "&"/"&amp;"。尝试在一屏内显示过长的图片。上传时分割的块大小随着上传速度改变。修复Glitch中使用自定义域名时forceHttps问题。修复ionicons图标失踪。尝试在重命名时使用file id来操作。背景(或其它)基于长宽来看是竖屏还是横屏,不再只看宽度。修复其它bug。预加入Vercel平台,等修复bugs。
20210512-1648.37
add setting "forceHttps", can force 302 jump to https. fix preview office files. fix manage in safari.fix disktag can be "home". fix some bugs.
新增一个设置,可以强制跳转https。修复office文档预览。修复safari上点不了管理。盘的标签可以是home了,随便命名了。修复一些其它问题。
20210331-1530.36
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>