214 Commits
Author SHA1 Message Date
qkqpttgfandGitHub d21abf12df Update common.php 2022-05-29 12:22:00 +08:00
qkqpttgfandGitHub 94f780963b Merge pull request #594 from hmsjy2017/patch-2
Use Fastly CDN for renexmoe theme
2022-05-28 08:33:34 +08:00
TonyandGitHub b7595eee71 Use Fastly CDN for renexmoe theme 2022-05-28 00:16:54 +08:00
qkqpttgfandGitHub be07cced24 fix: if no php-curl, can show error message now 2022-05-15 16:04:04 +08:00
qkqpttgfandGitHub 326e7ba0e5 show " in cmd 2022-05-15 14:39:05 +08:00
qkqpttgfandGitHub ce0d34084d vercel update version 2022-05-15 11:00:38 +08:00
qkqpttgfandGitHub a81c94bad3 add diskDisplay
a disk display to guest or hide, or disable for guest, only admin can visit
2022-05-04 17:19:34 +08:00
qkqpttgfandGitHub f276a60a1d add smallfileupload, fix title in encrypted folder
#576 ,
2022-04-16 10:54:15 +08:00
qkqpttgfandGitHub a4d0d8dfff try, try nothing 2022-04-16 10:51:43 +08:00
qkqpttgfandGitHub 9c8c739a9c add smallfileupload 2022-04-16 10:49:52 +08:00
qkqpttgfandGitHub 00dcccee9c add smallfileupload 2022-04-16 10:49:08 +08:00
qkqpttgfandGitHub 09c276f33a add smallfileupload 2022-04-16 10:48:22 +08:00
qkqpttgfandGitHub 134e9c29cf add smallfileupload 2022-04-16 10:47:32 +08:00
qkqpttgfandGitHub 6dc5d60649 add smallfileupload 2022-04-16 10:46:42 +08:00
qkqpttgfandGitHub 38d64b2d00 add smallfileupload 2022-04-16 10:45:30 +08:00
qkqpttgfandGitHub 27b7aa1619 add smallfileupload 2022-04-16 10:44:43 +08:00
qkqpttgfandGitHub 179641a403 add smallfileupload 2022-04-16 10:43:39 +08:00
qkqpttgfandGitHub c24a6fd37e add smallfileupload 2022-04-16 10:42:42 +08:00
qkqpttgfandGitHub 97d2bce570 add smallfileupload 2022-04-16 10:41:31 +08:00
qkqpttgfandGitHub 0793caec0f add smalfileupload 2022-04-16 10:38:01 +08:00
qkqpttgfandGitHub e87b00a242 add rapid copy, add smallfileupload 2022-04-16 10:36:52 +08:00
qkqpttgfandGitHub 54a997acbb simplify code 2022-03-19 11:48:41 +08:00
qkqpttgfandGitHub 3e3141be80 render pdf by page, not download all file 2022-03-18 21:21:30 +08:00
qkqpttgfandGitHub 2b5a3e89d7 return md5 to browser to Calc bignumber 2022-03-16 22:40:49 +08:00
qkqpttgfandGitHub 1b57164db5 Calc bignumber in browser 2022-03-16 22:25:44 +08:00
qkqpttgfandGitHub 7c6daaddbb fix: cant copy url in guestupload 2022-03-09 16:03:04 +08:00
qkqpttgfandGitHub e16a7012ef fix check bcmath, fix error proof when no bcmath 2022-03-09 15:11:08 +08:00
qkqpttgfandGitHub ed631d958d rapid upload (need bcmath) 2022-03-09 14:11:41 +08:00
qkqpttgfandGitHub 64096211e2 rapid upload for aliyundrive (need bcmath) 2022-03-09 14:03:23 +08:00
qkqpttgfandGitHub 5a0d6d990f add bchexdec 2022-03-09 13:59:36 +08:00
qkqpttgfandGitHub 6eb6a826cf change sortablejs to unpkg 2022-02-22 10:38:40 +08:00
qkqpttgfandGitHub cfdebf35b7 change sha1.js&ionicons.js from jsdelivr to unpkg 2022-02-22 10:26:57 +08:00
qkqpttgfandGitHub a7acdaeb7c change sha1.js from jsdelivr to unpkg 2022-02-22 10:25:45 +08:00
qkqpttgfandGitHub c48ebba178 fix $$ bug 2022-02-19 13:41:00 +08:00
qkqpttgfandGitHub 8d6864f145 fix: can read js in ../ 2022-02-18 18:24:13 +08:00
qkqpttgfandGitHub 5433fe0522 add log in txt 2022-02-18 16:15:12 +08:00
qkqpttgfandGitHub e209d98ad8 check txtfile charset 2022-02-18 16:13:38 +08:00
qkqpttgfandGitHub eb1319119a check txtfile charset 2022-02-18 16:11:23 +08:00
qkqpttgfandGitHub 46fb778cb5 Create sha1.min.js 2022-02-17 18:14:04 +08:00
qkqpttgfandGitHub 0271dc5b9f load sha1.js from program when login 2022-02-17 18:08:37 +08:00
qkqpttgfandGitHub 4a866c8aa2 load sha1.js from program 2022-02-17 18:05:13 +08:00
qkqpttgfandGitHub 7329e51368 show md when no file listing 2022-02-17 16:05:10 +08:00
qkqpttgfandGitHub a259f9e5ee try fix: force https in azurewebsite 2022-02-17 16:00:41 +08:00
qkqpttgfandGitHub e8b89d3296 show MD in preview 2022-02-10 11:10:57 +08:00
qkqpttgfandGitHub d2a31efb43 MultiDiskArea add back 2022-02-10 10:37:38 +08:00
qkqpttgfandGitHub 93569049ea autoJumpFirstDisk function add back 2022-02-10 10:36:46 +08:00
qkqpttgfandGitHub 816513cde7 fix: login page 2022-01-30 16:17:41 +08:00
qkqpttgfandGitHub 3e8919b642 Update renexmoe.html 2022-01-30 16:16:51 +08:00
qkqpttgfandGitHub 1ba3f28226 fix: login page 2022-01-30 16:16:06 +08:00
qkqpttgfandGitHub 2570bad78b fix: login page 2022-01-30 16:15:22 +08:00
qkqpttgfandGitHub bb291b7ae8 fix: login page 2022-01-30 16:14:29 +08:00
qkqpttgfandGitHub b9953586c8 fix: login page 2022-01-30 16:13:42 +08:00
qkqpttgfandGitHub 2d192e5623 fix: login page 2022-01-30 16:12:48 +08:00
qkqpttgfandGitHub 4073323d7c fix: ?login can return loginpage 2022-01-30 15:55:54 +08:00
root 29840c8b26 rm disktag length limit 2022-01-29 14:02:04 +00:00
qkqpttgfandGitHub 9fa89acb5b log the install 2022-01-29 20:40:40 +08:00
qkqpttgfandGitHub 3cf47c7c94 fix : can not sort disks 2022-01-29 20:24:53 +08:00
qkqpttgfandGitHub c0fdfd341a fix : getenv(null)
be58a17328
2022-01-27 22:06:26 +08:00
qkqpttgfandGitHub c6f8c1cd5c Merge pull request #525 from VBill/update-aliyun-fc-check
fix: check aliyun fc with official env var
2022-01-27 15:03:40 +08:00
Menu Yang 79c35daca0 fix: check aliyun fc with official env var
Check aliyun fc with official env var.
    see example code in: https://help.aliyun.com/document_detail/89032.html
    use of FC_SERVER_PATH with fixed path php7.2 may not compatible with higher php version
2022-01-27 15:00:30 +08:00
qkqpttgfandGitHub 95c6657dc1 fix aliyun FC platform 2022-01-27 14:50:09 +08:00
qkqpttgfandGitHub dc462d8e64 Update version 2022-01-27 12:36:39 +08:00
qkqpttgfandGitHub e2df7c19c6 rm multiDiskArea, change login page 2022-01-27 12:00:19 +08:00
qkqpttgfandGitHub 5274405e7a get method 2022-01-27 11:57:30 +08:00
qkqpttgfandGitHub 4d6cecd11c Update TencentSCF_env.php 2022-01-27 11:56:39 +08:00
qkqpttgfandGitHub a8ba8b3157 get method 2022-01-27 11:55:24 +08:00
qkqpttgfandGitHub 38165fa25d get method 2022-01-27 11:54:29 +08:00
qkqpttgfandGitHub 1a8f1cb962 get method 2022-01-27 11:53:33 +08:00
qkqpttgfandGitHub 011471289b get method 2022-01-27 11:52:24 +08:00
qkqpttgfandGitHub 51a85ae30e set default timezone 2022-01-27 11:51:04 +08:00
qkqpttgfandGitHub 083443a4b5 change login page, add global md config 2022-01-27 11:49:41 +08:00
qkqpttgfandGitHub bc86e38c71 change login page, rm JumpFirstDisk, 403 in operating root, change sorting disk, remake disktags tab, add global md config
change login page, rm JumpFirstDisk, 403 in operating root, change sorting disk, remake disktags tab, add global md config
2022-01-27 11:48:01 +08:00
qkqpttgfandGitHub be58a17328 try fix : getenv(null) 2022-01-20 22:08:04 +08:00
qkqpttgfandGitHub c5e7cabe09 can not copy file by rapid_upload, so return 415 2022-01-18 13:08:48 +08:00
qkqpttgfandGitHub 08c12518a7 show upload progress in table background 2022-01-18 13:04:46 +08:00
qkqpttgfandGitHub 9572b68be9 fix bug: turn index when adding disk 2022-01-16 15:58:42 +08:00
qkqpttgfandGitHub 38799d427e fix bug: turn index when adding disk 2022-01-16 15:57:25 +08:00
qkqpttgfandGitHub 1b8287062d more smoothly in Adding Onedrive disk 2022-01-14 10:29:29 +08:00
qkqpttgfandGitHub f2d53d45af Allow Preview when enable downloadencrypt
#506 ,
2022-01-09 16:07:59 +08:00
qkqpttgfandGitHub c8adcbbd7a add / at last, via SCF default link. 2022-01-09 14:05:25 +08:00
qkqpttgfandGitHub ac4defe663 add 'current folder' in 'refresh cache' 2022-01-06 09:31:03 +08:00
qkqpttgfandGitHub 8cf8c11cde fix bug: visit file in encrypted folder will add / at last 2022-01-01 11:45:23 +00:00
qkqpttgfandGitHub d99ee1dadc rm rewrite check 2021-12-24 09:13:32 +08:00
qkqpttgfandGitHub 544035b07a fix: url in preview 2021-12-22 20:50:54 +08:00
qkqpttgfandGitHub 4db307d6fe fix: url in preview 2021-12-22 20:47:50 +08:00
qkqpttgfandGitHub 8c70f8ad91 fix: url in preview 2021-12-22 20:46:47 +08:00
qkqpttgfandGitHub e828fe0a2b fix: url in preview 2021-12-22 20:44:32 +08:00
qkqpttgfandGitHub 6cbeaa4a09 fix: url in preview 2021-12-22 20:43:00 +08:00
qkqpttgfandGitHub 0843eb7955 fix: url in preview 2021-12-22 20:41:48 +08:00
qkqpttgfandGitHub 36d493a1d2 time error tip 2021-12-20 12:36:55 +08:00
qkqpttgfandGitHub 50492f77e1 \n in ver 2021-12-20 11:09:51 +08:00
qkqpttgfandGitHub 606d2d2c05 Update version 2021-12-20 10:59:09 +08:00
qkqpttgfandGitHub 9139fbda53 add git source: HIT 2021-12-20 10:49:11 +08:00
qkqpttgfandGitHub 459b23b284 add git source: HIT 2021-12-20 10:48:25 +08:00
qkqpttgfandGitHub 4cfe38c388 add git source: HIT 2021-12-20 10:47:16 +08:00
qkqpttgfandGitHub 68c07943e6 add git source: HIT 2021-12-20 10:46:44 +08:00
qkqpttgfandGitHub e10a613044 add git source: HIT 2021-12-20 10:46:06 +08:00
qkqpttgfandGitHub b91245904c add git source: HIT 2021-12-20 10:44:51 +08:00
qkqpttgfandGitHub e9681f5595 add git source: HIT 2021-12-20 10:43:44 +08:00
qkqpttgfandGitHub eddc938bdd add git source: HIT 2021-12-20 10:42:55 +08:00
qkqpttgfandGitHub 5515b5bc9a add git source: HIT 2021-12-20 10:42:11 +08:00
qkqpttgfandGitHub 3504685172 add git source: HIT 2021-12-20 10:41:37 +08:00
qkqpttgfandGitHub 65d57a5d24 add git source: HIT 2021-12-20 10:40:33 +08:00
qkqpttgfandGitHub faf5027f04 add git source: HIT 2021-12-20 10:38:31 +08:00
qkqpttgfandGitHub 06c7efe513 change mv -b in deploy to replit 2021-12-18 20:45:23 +08:00
qkqpttgfandGitHub 16dec5d4cd change mv -b in deploy to replit 2021-12-18 20:43:41 +08:00
qkqpttgfandGitHub 341124e5b0 sort to easy reading config in shell 2021-12-15 09:47:34 +08:00
qkqpttgfandGitHub 270c73afb5 sha1.js use jsdelivr 2021-12-14 18:59:21 +08:00
qkqpttgfandGitHub f3391cd132 sha1.js use jsdelivr 2021-12-14 18:58:35 +08:00
qkqpttgfandGitHub c85898fd98 Update readme_cn.md 2021-12-14 18:31:48 +08:00
qkqpttgfandGitHub 801a9168e2 Update readme.md 2021-12-14 18:29:55 +08:00
qkqpttgfandGitHub 1580671b5e Update readme_cn.md 2021-12-13 19:11:03 +08:00
qkqpttgfandGitHub 0ab59926f6 Update readme.md 2021-12-13 19:08:09 +08:00
qkqpttgfandGitHub bdd76ca567 cache config for read 2021-12-13 14:53:35 +08:00
qkqpttgfandGitHub d10e99a8ff read config every time 2021-12-13 14:51:28 +08:00
qkqpttgfandGitHub 7f0e1d96ce fix error in editting config 2021-12-12 13:39:04 +00:00
qkqpttgfandGitHub dd8c56179f add platform replit 2021-12-12 18:47:17 +08:00
qkqpttgfandGitHub 6e76d23051 Update readme.md 2021-12-12 18:31:29 +08:00
qkqpttgfandGitHub 5281adca5b Create .replit 2021-12-12 18:15:22 +08:00
qkqpttgfandGitHub f909372a96 add platform replit 2021-12-12 17:22:28 +08:00
qkqpttgfandGitHub 2e9ce0bbb4 Create Replit.php
#413 try add replit
2021-12-12 14:24:57 +08:00
qkqpttgfandGitHub 108b14261c fix a new bug in tmp_dir 2021-12-06 10:39:45 +08:00
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
32 changed files with 4124 additions and 1035 deletions
+3
View File
@@ -0,0 +1,3 @@
language = "php74"
run = "php -S 0.0.0.0:8000 index.php"
entrypoint = "index.php"
+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;
}
+682 -221
View File
File diff suppressed because it is too large Load Diff
+77 -25
View File
@@ -6,8 +6,8 @@ global $constStr;
$exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff', 'png', 'heic', 'webp'];
$exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a'];
$exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
$exts['txt'] = ['txt', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf'];
$exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', 'rmvb'];
$exts['txt'] = ['txt', 'log', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf'];
$exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', '3gp', 'rmvb'];
$exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar'];
$constStr = [
@@ -88,8 +88,8 @@ $constStr = [
'EnvironmentsDescription' => [
'en-us' => [
'admin' => 'The admin password, Login button will not show when empty',
'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.',
'autoJumpFirstDisk' => 'used in multy disks, if 1, auto jump to first disk',
'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?login=admin\', it is \'?login={this value}\'.',
'autoJumpFirstDisk' => 'a switch used in multy disks, if 1, auto jump to first disk',
'customScript' => '<script> in all pages, e.g. http turn to https',
'customCss' => '<style> in <head>',
'customTheme' => 'an url of html',
@@ -98,17 +98,23 @@ $constStr = [
'diskname' => 'The disk name you want show.',
'diskDescription' => ' Some tips of this disk, not used in code.',
'disktag' => 'A tag used in store config and url.',
'disableShowThumb' => 'if 1, the ShowThumbnail button will not display',
'disableChangeTheme' => 'if 1, the Theme selection button will not display',
'downloadencrypt' => '0 or 1. if 1, the files in encrypt folder can be downloaded without password',
'useBasicAuth' => 'if 1, will popup user/pass windows in encrypted folder.',
'disableShowThumb' => 'a switch, if 1, the ShowThumbnail button will not display',
'disableChangeTheme' => 'a switch, if 1, the Theme selection button will not display',
'downloadencrypt' => 'a switch, 0 or 1. if 1, the files in encrypt folder can be downloaded without password',
'globalHeadOmfUrl' => 'get txt from url, show it as head.omf in every page.',
'globalHeadMdUrl' => 'get txt from url, show it as head.md in every page.',
'globalReadmeMdUrl' => 'get txt from url, show it as readme.md in every page.',
'globalFootOmfUrl' => 'get txt from url, show it as foot.omf in every page.',
'useBasicAuth' => 'a switch, if 1, will popup user/pass windows in encrypted folder.',
'background' => 'Set an url as background photo.',
'backgroundm' => 'Set an url as background in mobile phone.',
'forceHttps' => 'if 1, force to redirect to https when visit via http.',
'forceHttps' => 'a switch, if 1, force to redirect to https when visit via http.',
'fileConduitCacheTime' => 'Input number, unit is hour, if set this, little file<1M(or fileConduitSize) will through program and cache in explorer, otherwise, default 302 to Microsoft',
'fileConduitSize' => 'Input number, unit is M(suggest less than 4M), if set this, little file<this value will through program and cache in explorer, otherwise, default 302 to Microsoft',
'theme' => 'Select theme for guest.',
'timezone' => 'Set default timezone.',
'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.',
'hideFunctionalityFile' => '0 or 1. if 1, some file will not show in list to guest, like readme.md',
'hideFunctionalityFile' => 'a switch, 0 or 1. if 1, some file will not show in list to guest, like readme.md',
'passfile' => 'The password of folder(& its childrens) will save in this file.',
'domainforproxy' => 'Will replace the https://xxxxx-my.sharepoint.com with this value.Add &Origindomain=xxxxx-my.sharepoint.com at last',
'public_path' => 'Show this Onedrive dir when through the long url of API Gateway.',
@@ -116,8 +122,8 @@ $constStr = [
],
'zh-cn' => [
'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
'autoJumpFirstDisk' => '用于多个磁盘,如果为1,则自动跳转到第一个磁盘',
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?login=admin\',而是\'?login=此设置的值\'。',
'autoJumpFirstDisk' => '一个开关,用于多个磁盘,如果为1,则自动跳转到第一个磁盘',
'customScript' => '<script>,在所有页都会存在,例如放一个http跳转https',
'customCss' => '<style>,在<head>最后面',
'customTheme' => 'html格式的主题的url',
@@ -126,17 +132,23 @@ $constStr = [
'diskname' => '这个盘你想显示什么名称。',
'diskDescription' => '对这个盘的一些描述,随便写,代码不引用这个。',
'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。',
'disableShowThumb' => '如果填 1, ‘显示缩略’按钮将被隐藏。',
'disableChangeTheme' => '如果为 1,则不会显示主题选择按钮',
'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
'useBasicAuth' => '如果为 1,加密目录将弹出用户名密码窗口,不会显示主题自带的输入密码页面。',
'disableShowThumb' => '一个开关,如果填 1, ‘显示缩略’按钮将被隐藏。',
'disableChangeTheme' => '一个开关,如果为 1,则不会显示主题选择按钮',
'downloadencrypt' => '一个开关,0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
'globalHeadOmfUrl' => '从url获取文本,当成head.omf显示在每一页。',
'globalHeadMdUrl' => '从url获取文本,当成head.md显示在每一页。',
'globalReadmeMdUrl' => '从url获取文本,当成readme.md显示在每一页。',
'globalFootOmfUrl' => '从url获取文本,当成foot.omf显示在每一页。',
'useBasicAuth' => '一个开关,如果为 1,加密目录将弹出用户名密码窗口,不会显示主题自带的输入密码页面。',
'background' => '设置一个url作为背景。',
'backgroundm' => '设置一个url作为手机端用的背景。',
'forceHttps' => '0或1。如果设置为1,会强制跳https',
'forceHttps' => '一个开关,0或1。如果设置为1,会强制跳https',
'fileConduitCacheTime' => '填数字,单位是小时,如果设置,小于1M(或fileConduitSize)的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软',
'fileConduitSize' => '填数字,单位是M(建议4M以下),如果设置,小于这个值的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软',
'theme' => '为游客选择一个主题。',
'timezone' => '设置默认时区。',
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表给游客看,但它的功能正常,比如readme.md',
'hideFunctionalityFile' => '一个开关,0 或 1。如果 1, 功能文件不列表给游客看,但它的功能正常,比如readme.md',
'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;',
'domainforproxy' => '会将https://xxxxx-my.sharepoint.com替换成这个值,在目标需要自己设置反代。会加上&Origindomain=原域名',
'public_path' => '使用API长链接访问时,显示网盘文件的路径,不设置时默认为根目录。',
@@ -144,7 +156,7 @@ $constStr = [
],
'zh-tw' => [
'admin' => '管理密碼,不設定密碼將不顯示登入頁面且無法登入。',
'adminloginpage' => '如果設定,登入按鈕及頁面隱藏。管理登入的頁面不再是\'?admin\',而是\'?此設置的值\'。',
'adminloginpage' => '如果設定,登入按鈕及頁面隱藏。管理登入的頁面不再是\'?login=admin\',而是\'?login=此設置的值\'。',
'autoJumpFirstDisk' => '用於多盤,如果設1,將會自動跳到第一個盤。',
'customScript' => '<script>,在所有頁都會存在,例如放一個http跳轉https',
'customCss' => '<style>,在<head>最後面',
@@ -169,7 +181,7 @@ $constStr = [
],
'ja' => [
'admin' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。',
'adminloginpage' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?admin \'ではなく、\'?この設定の値\'。',
'adminloginpage' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?login=admin \'ではなく、\'?login=この設定の値\'。',
'autoJumpFirstDisk' => '複数のディスクを使って、1を設定すると、自動的に最初のディスクにジャンプします。',
'customScript' => '<script>は、すべてのページに存在します。例えば、httpを置いてhttpsをジャンプします。',
'customCss' => 'style>は、<head>の一番後ろにあります。',
@@ -194,7 +206,7 @@ $constStr = [
],
'ko-kr' => [
'admin' => '비밀번호를 관리하고 로그인 페이지를 표시하지 않으며 추가하지 않으면 로그인 할 수 없습니다.',
'adminloginpage' => '설정하면 로그인 버튼과 페이지가 숨겨집니다. 로그인 관리 페이지는 더 이상 \ ?Admin\'이 아니라 \ ?이 설정의 값 \'입니다.',
'adminloginpage' => '설정하면 로그인 버튼과 페이지가 숨겨집니다. 로그인 관리 페이지는 더 이상 \ ?login=admin\'이 아니라 \ ?login=이 설정의 값 \'입니다.',
'autoJumpFirstDisk' => '여러 개의 디스크 에 사용 되 며, 1 이 되면 첫 번 째 디스크 로 자동 으로 이동 합 니 다.',
'customScript' => '< script > 은 모든 페이지 에 존재 합 니 다. 예 를 들 어 http 을 하나 넣 고 https 로 이동 합 니 다.',
'customCss' => '< 스타일 >, < 헤드 > 맨 뒤에',
@@ -219,7 +231,7 @@ $constStr = [
],
'fa' => [
'admin' => 'رمز عبور ادمین، در صورت خالی بودن دکمه لاگین به نمایش در نمی‌آید',
'adminloginpage' => 'در صورت تنظیم ، دکمه ورود نمایش داده نمی شود و صفحه ورود دیگر \?admin\ نیست بلکه \?{مقدار ورودی شما}\ است.',
'adminloginpage' => 'در صورت تنظیم ، دکمه ورود نمایش داده نمی شود و صفحه ورود دیگر \?login=admin\ نیست بلکه \?login={مقدار ورودی شما}\ است.',
'referrer' => '',
'domain_path' => 'تنظیم دامنه سفارشی، به صورت a1.com:/dirto/path1|b2.com:/path2',
'diskname' => 'نام دیسک که می‌خواهید نشان دهید.',
@@ -1122,9 +1134,9 @@ $constStr = [
'ar-sa' => 'اختيار اللغة',
],
'RefreshCache' => [
'en-us' => 'RefreshCache',
'zh-cn' => '刷新缓存',
'zh-tw' => '重新整理快取',
'en-us' => 'Refresh Cache of Current Folder',
'zh-cn' => '刷新当前目录的缓存',
'zh-tw' => '重新整理当前資料夾快取',
'ja' => 'キャッシュを再構築',
'ko-kr' => '캐시 플러시',
'fa' => 'رفرش cache',
@@ -1140,6 +1152,46 @@ $constStr = [
'zh-cn' => '查询分支',
'zh-tw' => '查詢分支',
],
'OldPassword' => [
'en-us' => 'Old Password',
'zh-cn' => '旧密码',
'zh-tw' => '旧密碼',
],
'NewPassword' => [
'en-us' => 'New Password',
'zh-cn' => '新密码',
'zh-tw' => '新密碼',
],
'ReInput' => [
'en-us' => 'ReInput',
'zh-cn' => '再输入一次',
'zh-tw' => '再输入一次',
],
'ChangAdminPassword' => [
'en-us' => 'Chang Admin Password',
'zh-cn' => '修改管理密码',
'zh-tw' => '修改管理密碼',
],
'AdminPassword' => [
'en-us' => 'Admin Password',
'zh-cn' => '管理密码',
'zh-tw' => '管理密碼',
],
'export' => [
'en-us' => 'export',
'zh-cn' => '导出',
'zh-tw' => '导出',
],
'config' => [
'en-us' => 'config',
'zh-cn' => '配置',
'zh-tw' => '配置',
],
'import' => [
'en-us' => 'import',
'zh-cn' => '导入',
'zh-tw' => '导入',
],
'ONEMANAGER_CONFIG_SAVE_ENV' => [
'en-us' => 'Config save in Environments',
'zh-cn' => '配置保存在环境变量',
+138 -27
View File
@@ -93,9 +93,10 @@ class Aliyundrive {
if (!($files = getcache('path_' . $path, $this->disktag))) {
if ($path == '/' || $path == '') {
$files = $this->fileList('root');
//error_log1('root_id' . $files['id']);
//error_log1('root_id' . $files['file_id']);
$files['file_id'] = 'root';
$files['type'] = 'folder';
//error_log1(json_encode($files, JSON_PRETTY_PRINT));
} else {
$tmp = splitlast($path, '/');
$parent_path = $tmp[0];
@@ -194,8 +195,8 @@ class Aliyundrive {
$data['image_url_process'] = 'image/resize,w_1920/format,jpeg';
$data['video_thumbnail_process'] = 'video/snapshot,t_0,f_jpg,w_300';
$data['fields'] = '*';
$data['order_by'] = 'updated_at';
$data['order_direction'] = 'DESC';
$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']);
@@ -327,47 +328,60 @@ class Aliyundrive {
} else {
$oldfile = $this->fileGet($file['id']);
}
$url = $this->api_url . '/file/create';
if ($oldfile['type']=='folder') return output('Can not copy folder', 415);
if (!function_exists('bcadd')) {
// no php-bcmath
if ($bcmathurl = getConfig('bcmathUrl', $this->disktag)) {
if (strpos($bcmathurl, '?')) {
$bcmathurl .= '&dividend=0x' . substr(md5($this->access_token), 0, 16) . '&divisor=' . $oldfile['size'];
} else {
$bcmathurl .= '?dividend=0x' . substr(md5($this->access_token), 0, 16) . '&divisor=' . $oldfile['size'];
}
$o = curl('GET', $bcmathurl)['body'];
} else {
return output('No bcmath module, can not copy', 415);
}
} else {
$r = bchexdec( substr(md5($this->access_token), 0, 16) );
$o = bcmod($r, $oldfile['size']);
}
$res = curl('GET', $oldfile['download_url'], '', [
'Referer' => ''
, 'Range' => 'bytes=' . $o . '-' . ($o+7)
]);
if ($res['stat']==206) {
$proof_code = base64_encode($res['body']);
$url = 'https://api.aliyundrive.com/adrive/v2/file/createWithFolders';
$header["content-type"] = "application/json; charset=utf-8";
$header['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['proof_code'] = $proof_code;
$data['proof_version'] = 'v1';
$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));
/*if ($result['stat']==201) {
$res = json_decode($result['body'], true);
if ($res['rapid_upload']) return output('rapid upload', 200);
$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']);
} else {
return output("Get proof error\n" . json_encode($res), 415);
}
}
public function Edit($file, $content) {
$tmp = splitlast($file['path'], '/');
@@ -489,6 +503,31 @@ class Aliyundrive {
return curl('POST', $url, json_encode($data), $header);
}
protected function fileCreate1($parentId, $fileName, $sha1, $proof_code, $size, $part_number) {
//$url = $this->api_url . '/file/create';
$url = 'https://api.aliyundrive.com/adrive/v2/file/createWithFolders';
$header["content-type"] = "application/json; charset=utf-8";
$header['authorization'] = 'Bearer ' . $this->access_token;
$data['check_name_mode'] = 'refuse'; // ignore, auto_rename, refuse.
$data['content_hash'] = $sha1;
$data['content_hash_name'] = 'sha1';
//$data['content_type'] = '';
$data['drive_id'] = $this->driveId;
//$data['ignoreError'] = false;
$data['name'] = $fileName;
$data['parent_file_id'] = $parentId;
for ($i=0;$i<$part_number;$i++) {
$data['part_info_list'][$i]['part_number'] = $i+1;
}
$data['proof_code'] = $proof_code;
$data['proof_version'] = 'v1';
$data['size'] = (int)$size;
$data['type'] = 'file';
return curl('POST', $url, json_encode($data), $header);
}
protected function tmpfileCreate($parentId, $tmpFilePath, $tofileName = '') {
$sha1 = sha1_file($tmpFilePath);
if ($tofileName == '') $tofileName = splitlast($tmpFilePath, '/')[1];
@@ -537,6 +576,60 @@ class Aliyundrive {
$thumb_url = $res['thumbnail'];
return $thumb_url;
}
public function smallfileupload($path, $tmpfile) {
if (!$_SERVER['admin']) {
$tmp1 = splitlast($tmpfile['name'], '.');
if ($tmp1[0]==''||$tmp1[1]=='') $filename = sha1_file($tmpfile['tmp_name']);
else $filename = sha1_file($tmpfile['tmp_name']) . '.' . $tmp1[1];
} else {
$filename = $tmpfile['name'];
}
//$content = file_get_contents($tmpfile['tmp_name']);
$result = $this->tmpfileCreate($this->list_path($_SERVER['list_path'] . '/' . $path . '/')['file_id'], $tmpfile['tmp_name'], $filename);
//error_log1('1,url:' . $url .' res:' . json_encode($result));
if ($result['stat']==201) {
$res = json_decode($result['body'], true);
$url = $res['part_info_list'][0]['upload_url'];
if (!$url) { // 无url,应该算秒传
//return output('no up url', 0);
$a = 1;
} else {
$file_id = $res['file_id'];
$upload_id = $res['upload_id'];
//$result = curl('PUT', $url, $content, [], 1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$fh_res = fopen($tmpfile['tmp_name'], 'r');
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($tmpfile['tmp_name']));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$tmpres = splitlast(curl_exec($ch), "\r\n\r\n");
$result['body'] = $tmpres[1];
$returnhead = $tmpres[0];
foreach (explode("\r\n", $returnhead) as $head) {
$tmp = explode(': ', $head);
$heads[$tmp[0]] = $tmp[1];
}
$result['returnhead'] = $heads;
$result['stat'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
fclose($fh_res);
curl_close($ch);
//error_log1('2,url:' . $url .' res:' . json_encode($result));
if ($result['stat']==200) { // 块1传好
$result = $this->fileComplete($file_id, $upload_id, [ $result['returnhead']['ETag'] ]);
//error_log1('3, res:' . json_encode($result));
//if ($result['stat']!=200) return output(json_encode($this->files_format(json_decode($result['body'], true))), $result['stat']);
//else return output('success', 0);
}
}
$res = json_decode($result['body'], true);
//if (isset($res['url']))
$res['download_url'] = $_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . $filename);
}
return output(json_encode($this->files_format($res), JSON_UNESCAPED_SLASHES), $result['stat']);
}
public function bigfileupload($path)
{
if (isset($_POST['uploadid'])) {
@@ -544,6 +637,20 @@ class Aliyundrive {
$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 (isset($_POST['CalcProof'])) {
return output(substr(md5($this->access_token), 0, 16), 200);
// Calc proof code
/*if (!function_exists('bcadd')) {
// no php-bcmath
return output(0, 200);
} else {
$r = bchexdec( substr(md5($this->access_token), 0, 16) );
$i = $_POST['filesize'];
//$o = $i ? bcmod($r, $i) : 0;
$o = bcmod($r, $i);
return output($o, 200);
}*/
}
if ($_POST['upbigfilename']=='') return output('error: no file name', 400);
if (!is_numeric($_POST['filesize'])) return output('error: no file size', 400);
if (!isset($_POST['filesha1'])) return output('error: no file sha1', 400);
@@ -573,7 +680,11 @@ class Aliyundrive {
//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']));
//if (!function_exists('bcadd')) {
// $response = $this->fileCreate($parent_file_id, $filename, $_POST['filesha1'], $fileinfo['size'], ceil($fileinfo['size']/$_POST['chunksize']));
//} else {
$response = $this->fileCreate1($parent_file_id, $filename, $_POST['filesha1'], $_POST['proof_code'], $fileinfo['size'], ceil($fileinfo['size']/$_POST['chunksize']));
//}
$res = json_decode($response['body'], true);
if (isset($res['exist'])) {
// 已经有
@@ -631,7 +742,7 @@ class Aliyundrive {
} else {
$str .= '
<script>
var status = "' . $response['status'] . '";
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(min++);
@@ -702,7 +813,7 @@ class Aliyundrive {
</form>
</div>
<script>
var status = "' . $response['status'] . '";
var status = "' . $response['DplStatus'] . '";
function notnull(t)
{
if (t.driveId.value==\'\') {
@@ -768,7 +879,7 @@ class Aliyundrive {
}
return true;
}
var status = "' . $response['status'] . '";
var status = "' . $response['DplStatus'] . '";
</script>
';
return message($html, $title, 201, 1);
@@ -799,7 +910,7 @@ class Aliyundrive {
alert("Do not input ' . $envs . '");
return false;
}
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,})$/;
if (!reg.test(t.disktag_add.value)) {
alert(\'' . getconstStr('TagFormatAlert') . '\');
return false;
+1 -1
View File
@@ -718,7 +718,7 @@ class Googledrive {
alert("Do not input ' . $envs . '");
return false;
}
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,})$/;
if (!reg.test(t.disktag_add.value)) {
alert(\'' . getconstStr('TagFormatAlert') . '\');
return false;
+125 -45
View File
@@ -1,4 +1,7 @@
<?php
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
class Onedrive {
protected $access_token;
@@ -46,9 +49,6 @@ class Onedrive {
{
global $exts;
if (!($files = getcache('path_' . $path, $this->disktag))) {
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
$pos = splitlast($path, '/');
$parentpath = $pos[0];
if ($parentpath=='') $parentpath = '/';
@@ -56,10 +56,28 @@ class Onedrive {
if ($parentfiles = getcache('path_' . $parentpath, $this->disktag)) {
if (isset($parentfiles['children'][$filename][$this->DownurlStrName])) {
if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
//$content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]);
//$parentfiles['children'][$filename]['content'] = $content1;
//savecache('path_' . $parentpath, $parentfiles, $this->disktag);
if ($parentfiles['children'][$filename]['size']<1024*1024) {
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
$content1 = curl('GET', $parentfiles['children'][$filename][$this->DownurlStrName]);
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$txtcode = chkTxtCode($content1['body']);
if ($txtcode!==false) $tmp['body'] = iconv($txtcode, 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']) $content1['body'] = $tmp['body'];
}
$parentfiles['children'][$filename]['content'] = $content1;
savecache('path_' . $parentpath, $parentfiles, $this->disktag);
savecache('path_' . $path, $parentfiles['children'][$filename], $this->disktag);
}
} else {
$parentfiles['children'][$filename]['content']['stat'] = 202;
$parentfiles['children'][$filename]['content']['body'] = 'File too large.';
}
}
}
return $this->files_format($parentfiles['children'][$filename]);
@@ -107,9 +125,10 @@ class Onedrive {
$tmp = null;
$tmp = json_decode(json_encode($content1), true);
if ($tmp['body']===null) {
$tmp['body'] = iconv("GBK", 'UTF-8//TRANSLIT', $content1['body']);
$txtcode = chkTxtCode($content1['body']);
if ($txtcode!==false) $tmp['body'] = iconv($txtcode, 'UTF-8//TRANSLIT', $content1['body']);
$tmp = json_decode(json_encode($tmp), true);
if ($tmp['body']!==null) $content1['body'] = $tmp['body'];
if ($tmp['body']) $content1['body'] = $tmp['body'];
}
$files['content'] = $content1;
savecache('path_' . $path, $files, $this->disktag);
@@ -131,7 +150,7 @@ class Onedrive {
} else {
$files['error']['stat'] = 503;
$files['error']['code'] = 'unknownError';
$files['error']['message'] = 'unknownError';
$files['error']['message'] = 'unknownError ' . $arr['body'] . " ~";
}
//$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
//error_log1(json_encode($files, JSON_PRETTY_PRINT));
@@ -180,6 +199,7 @@ class Onedrive {
return $files;
}
//error_log1(json_encode($tmp));
//echo '<pre>' . json_encode($tmp, JSON_PRETTY_PRINT) . '</pre>';
return $tmp;
}
@@ -350,15 +370,16 @@ class Onedrive {
$filename = spurlencode($file['name']);
$filename = path_format($file['path'] . '/' . $filename);
//echo $filename;
$result = $this->MSAPI('DELETE', $filename);
if ($file['id']) $result = $this->MSAPI('DELETE', "/items/" . $file['id']);
else $result = $this->MSAPI('DELETE', $filename);
if ($result['stat']!=204) $r_body = json_encode($this->files_format(json_decode($result['body'], true)));
return output($r_body, $result['stat']);
//return output($result['body'], $result['stat']);
}
public function Encrypt($folder, $passfilename, $pass) {
$filename = path_format($folder['path'] . '/' . urlencode($passfilename));
$filename = '/items/' . $folder['id'] . ':/' . urlencode($passfilename);
if ($pass==='') {
$result = $this->MSAPI('DELETE', $filename, '');
$result = $this->MSAPI('DELETE', $filename);
} else {
$result = $this->MSAPI('PUT', $filename, $pass);
}
@@ -372,7 +393,8 @@ class Onedrive {
$filename = spurlencode($file['name']);
$filename = path_format($file['path'] . '/' . $filename);
$data = '{"parentReference":{"path": "/drive/root:' . $folder['path'] . '"}}';
$result = $this->MSAPI('PATCH', $filename, $data);
if ($file['id']) $result = $this->MSAPI('PATCH', "/items/" . $file['id'], $data);
else $result = $this->MSAPI('PATCH', $filename, $data);
$path2 = spurlencode($folder['path'], '/');
if ($path2!='/'&&substr($path2, -1)=='/') $path2 = substr($path2, 0, -1);
savecache('path_' . $path2, json_decode('{}', true), $this->disktag, 1);
@@ -391,7 +413,8 @@ class Onedrive {
$newname = '.' . $namearr[1] . ' (' . date("Ymd\THis\Z") . ')';
}
$data = '{ "name": "' . $newname . '" }';
$result = $this->MSAPI('copy', $filename, $data);
if ($file['id']) $result = $this->MSAPI('copy', "/items/" . $file['id'], $data);
else $result = $this->MSAPI('copy', $filename, $data);
/*$num = 0;
while ($result['stat']==409 && json_decode($result['body'], true)['error']['code']=='nameAlreadyExists') {
$num++;
@@ -442,7 +465,7 @@ class Onedrive {
$envs = '';
foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
$url = path_format($_SERVER['PHP_SELF'] . '/');
$url = $_SERVER['PHP_SELF'];
//$this->api_url = splitfirst($_SERVER['api_url'], '/v1.0')[0] . '/v1.0';
if (isset($_GET['Finish'])) {
@@ -474,8 +497,8 @@ class Onedrive {
} else {
return message($arr['stat'] . $arr['body'], 'Get User ID', $arr['stat']);
}*/
if (get_class($this)=='Sharepoint') $tmp['Driver'] = 'Onedrive';
elseif (get_class($this)=='SharepointCN') $tmp['Driver'] = 'OnedriveCN';
if ($tmp['Driver']=='Sharepoint') $tmp['Driver'] = 'Onedrive';
elseif ($tmp['Driver']=='SharepointCN') $tmp['Driver'] = 'OnedriveCN';
$tmp['sharepointSite'] = '';
$tmp['siteid'] = '';
} elseif ($_POST['DriveType']=='Custom') {
@@ -488,14 +511,14 @@ class Onedrive {
//if ($arr['stat']!=200) return message($arr['stat'] . $arr['body'], 'Get Sharepoint Drive ID ' . $_POST['DriveType'], $arr['stat']);
$tmp['siteid'] = $siteid;
$tmp['sharepointSite'] = $_POST['sharepointSite'];
if (get_class($this)=='Onedrive') $tmp['Driver'] = 'Sharepoint';
elseif (get_class($this)=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
if ($tmp['Driver']=='Onedrive') $tmp['Driver'] = 'Sharepoint';
elseif ($tmp['Driver']=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
} else {
// 直接是siteid
$tmp['siteid'] = $_POST['DriveType'];
$tmp['sharepointSite'] = $_POST['sharepointSiteUrl'];
if (get_class($this)=='Onedrive') $tmp['Driver'] = 'Sharepoint';
elseif (get_class($this)=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
if ($tmp['Driver']=='Onedrive') $tmp['Driver'] = 'Sharepoint';
elseif ($tmp['Driver']=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
}
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
@@ -510,17 +533,17 @@ class Onedrive {
var expires = "expires="+expd.toGMTString();
document.cookie=\'disktag=; path=/; \'+expires;
var i = 0;
var status = "' . $response['status'] . '";
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . $url . '";
location.href = "' . $url . '?setup&disktag=' . $_GET['disktag'] . '";
}
}, 1000);
</script>';
return message($html, getconstStr('WaitJumpIndex'), 201, 1);
return message($html, getconstStr('Wait'), 201, 1);
}
}
@@ -550,12 +573,13 @@ class Onedrive {
$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="Onedrive" checked>' . 'Use Onedrive ' . getconstStr(' ') . '</label><br>';
<form name="form1" action="?Finish&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);">
<label><input type="radio" name="DriveType" value="Onedrive">' . 'Use Onedrive ' . getconstStr(' ') . '</label><br>';
if ($sites[0]!='') foreach ($sites as $k => $v) {
$html .= '
<label>
<input type="radio" name="DriveType" value="' . $v['id'] . '" onclick="document.getElementById(\'sharepointSiteUrl\').value=\'' . $v['webUrl'] . '\';">' . 'Use Sharepoint: <br><div style="width:100%;margin:0px 35px">webUrl: ' . $v['webUrl'] . '<br>siteid: ' . $v['id'] . '</div>
<input type="hidden" id="' . $v['id'] . '" name="' . $v['id'] . '" value="' . $v['webUrl'] . '">
</label>';
}
$html .= '
@@ -572,6 +596,26 @@ class Onedrive {
</form>
</div>
<script>
var driver = "' . $_GET['AddDisk'] . '";
if (driver=="Onedrive"||driver=="OnedriveCN") {
document.form1.DriveType[0].checked = true;
} else {
var siteid = "' . getConfig('siteid', $this->disktag) . '";
if (siteid==="") {
document.form1.DriveType[document.form1.DriveType.length-1].checked = true;
} else {
for (i=0; i<document.form1.DriveType.length; i++) {
if (document.form1.DriveType[i].value==siteid) {
document.form1.DriveType[i].checked = true;
document.getElementById(\'sharepointSiteUrl\').value = document.getElementById(siteid).value;
}
}
if (document.getElementById(\'sharepointSiteUrl\').value=="") {
document.form1.DriveType[document.form1.DriveType.length-1].checked = true;
document.getElementById(\'sharepointSite\').value = "' . getConfig('sharepointSite', $this->disktag) . '";
}
}
}
function notnull(t)
{
if (t.DriveType.value==\'\') {
@@ -607,6 +651,7 @@ class Onedrive {
texta[i].style.height = texta[i].scrollHeight + \'px\';
}
</script>';
$tmptoken['Driver'] = $_GET['AddDisk'];
$tmptoken['refresh_token'] = $refresh_token;
$tmptoken['token_expires'] = time()+7*24*60*60;
$response = setConfigResponse( setConfig($tmptoken, $this->disktag) );
@@ -618,13 +663,13 @@ class Onedrive {
savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60);
$html .= '<script>
var i = 0;
var status = "' . $response['status'] . '";
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . $url . '?AddDisk=' . get_class($this) . '&disktag=' . $_GET['disktag'] . '&SelectDrive";
location.href = "' . $url . '?AddDisk=' . $_GET['AddDisk'] . '&disktag=' . $_GET['disktag'] . '&SelectDrive";
}
}, 1000);
</script>';
@@ -636,7 +681,7 @@ class Onedrive {
}
if (isset($_GET['install1'])) {
if (get_class($this)=='Onedrive' || get_class($this)=='OnedriveCN') {
//if (get_class($this)=='Onedrive' || get_class($this)=='OnedriveCN') {
return message('
<a href="" id="a1">' . getconstStr('JumptoOffice') . '</a>
<script>
@@ -647,9 +692,9 @@ class Onedrive {
location.href = url;
</script>
', getconstStr('Wait') . ' 1s', 201);
} else {
return message('Something error, retry after a few seconds.', 'Retry', 201);
}
//} else {
// return message('Something error, retry after a few seconds.', 'Retry', 201);
//}
}
if (isset($_GET['install0'])) {
@@ -676,7 +721,8 @@ class Onedrive {
//$this->disktag = $_POST['disktag_add'];
$tmp['disktag_add'] = $_POST['disktag_add'];
$tmp['diskname'] = $_POST['diskname'];
$tmp['Driver'] = $_POST['Drive_ver'];
//$tmp['Driver'] = $_POST['Drive_ver'];
$tmp['Driver'] = $_GET['AddDisk'];
if ($_POST['Drive_ver']=='Sharelink') {
$tmp['shareurl'] = $_POST['shareurl'];
} else {
@@ -696,10 +742,10 @@ class Onedrive {
} else {
$title = getconstStr('MayinEnv');
$html = getconstStr('Wait');
if ($_POST['Drive_ver']!='Sharelink') $url .= '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_POST['Drive_ver'];
if ($_POST['Drive_ver']!='Sharelink') $url .= '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_GET['AddDisk'];
$html .= '<script>
var i = 0;
var status = "' . $response['status'] . '";
var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
@@ -717,7 +763,7 @@ class Onedrive {
$html = '
<div>
<form id="form1" action="" method="post" onsubmit="return notnull(this);">
<form id="form1" name="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') . ':
@@ -729,7 +775,7 @@ class Onedrive {
<label><input type="checkbox" name="NT_Drive_custom" onclick="document.getElementById(\'NT_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br>
<div id="NT_secret" style="display:none;margin:10px 35px">
<a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br>
return_uri(Reply URL):<br>https://scfonedrive.github.io/<br>
return_uri(Reply URL):<br>' . $this->redirect_uri . '<br>
client_id:<input type="text" name="NT_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br>
client_secret:<input type="text" name="NT_client_secret" style="width:100%"><br>
</div>
@@ -739,7 +785,7 @@ class Onedrive {
<label><input type="checkbox" name="CN_Drive_custom" onclick="document.getElementById(\'CN_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br>
<div id="CN_secret" style="display:none;margin:10px 35px">
<a href="https://portal.azure.cn/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br>
return_uri(Reply URL):<br>https://scfonedrive.github.io/<br>
return_uri(Reply URL):<br>' . $this->redirect_uri . '<br>
client_id:<input type="text" name="CN_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br>
client_secret:<input type="text" name="CN_client_secret" style="width:100%"><br>
</div>
@@ -757,6 +803,21 @@ class Onedrive {
</form>
</div>
<script>
var driver = "' . get_class($this) . '";
if (driver=="Onedrive" || driver=="Sharepoint") {
document.form1.Drive_ver[0].checked = true;
document.getElementById(\'NT_custom\').style.display=\'\';
//document.getElementById(\'CN_custom\').style.display=\'\';
//document.getElementById(\'inputshareurl\').style.display=\'none\';
}
if (driver=="OnedriveCN" || driver=="SharepointCN") {
document.form1.Drive_ver[1].checked = true;
document.getElementById(\'CN_custom\').style.display=\'\';
}
if (driver=="Sharelink") {
document.form1.Drive_ver[2].checked = true;
document.getElementById(\'inputshareurl\').style.display=\'\';
}
function notnull(t)
{
if (t.disktag_add.value==\'\') {
@@ -765,10 +826,10 @@ class Onedrive {
}
envs = [' . $envs . '];
if (envs.indexOf(t.disktag_add.value)>-1) {
alert("Do not input ' . $envs . '");
alert("Do not input \"" + t.disktag_add.value + "\" in ' . getconstStr('DiskTag') . '");
return false;
}
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,})$/;
if (!reg.test(t.disktag_add.value)) {
alert(\'' . getconstStr('TagFormatAlert') . '\');
return false;
@@ -782,25 +843,28 @@ class Onedrive {
alert(\'shareurl\');
return false;
}
driver = \'Sharelink\';
} else {
if ((t.Drive_ver.value==\'Onedrive\') && t.NT_Drive_custom.checked==true) {
if (t.Drive_ver.value==\'Onedrive\') {
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;
}
}
if ((t.Drive_ver.value==\'OnedriveCN\') && t.CN_Drive_custom.checked==true) {
if (driver!="Onedrive" && driver!="Sharepoint") driver = "Onedrive";
}
if (t.Drive_ver.value==\'OnedriveCN\') {
if (t.CN_Drive_custom.checked==true) {
if (t.CN_client_secret.value==\'\'||t.CN_client_id.value==\'\') {
alert(\'client_id & client_secret\');
return false;
}
}
if (driver!="OnedriveCN" && driver!="SharepointCN") driver = "OnedriveCN";
}
document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=" + t.Drive_ver.value;
//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;
}
document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=" + driver;
return true;
}
</script>';
@@ -909,6 +973,20 @@ class Onedrive {
return $thumb_url;
}
public function smallfileupload($path, $tmpfile) {
if (!$_SERVER['admin']) {
$tmp1 = splitlast($tmpfile['name'], '.');
if ($tmp1[0]==''||$tmp1[1]=='') $filename = md5_file($tmpfile['tmp_name']);
else $filename = md5_file($tmpfile['tmp_name']) . '.' . $tmp1[1];
} else {
$filename = $tmpfile['name'];
}
$content = file_get_contents($tmpfile['tmp_name']);
$result = $this->MSAPI('PUT', path_format($_SERVER['list_path'] . '/' . $path . '/' . $filename), $content);
$res = $this->files_format(json_decode($result['body'], true));
if (isset($res['url'])) $res['url'] = $_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . $filename);
return output(json_encode($res, JSON_UNESCAPED_SLASHES), $result['stat']);
}
public function bigfileupload($path)
{
if ($_POST['upbigfilename']=='') return output('error: no file name', 400);
@@ -1007,6 +1085,8 @@ class Onedrive {
} else {
if ($path=='' or $path=='/') {
$url .= $method;
} elseif (substr($path, 0, 6)=="/items") {
$url .= '/' . $method;
} else {
$url .= ':/' . $method;
}
+39 -11
View File
@@ -5,18 +5,19 @@ include 'vendor/autoload.php';
include 'conststr.php';
include 'common.php';
date_default_timezone_set('UTC');
//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';
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
} elseif (isset($_SERVER['FC_FUNC_CODE_PATH'])) {
include 'platform/AliyunFC.php';
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
} elseif (isset($_SERVER['_APP_SHARE_DIR']) && $_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
//if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/HuaweiFG_file.php';
//else include 'platform/HuaweiFG_env.php';
echo 'FG' . PHP_EOL;
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
} elseif (isset($_SERVER['BCE_CFC_RUNTIME_NAME']) && $_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
include 'platform/BaiduCFC.php';
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
include 'platform/Heroku.php';
@@ -30,9 +31,11 @@ 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') {
include 'platform/Vercel.php';
if (getenv('ONEMANAGER_CONFIG_SAVE')=='env') include 'platform/Vercel_env.php';
else include 'platform/Vercel.php';
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
@@ -43,9 +46,11 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
header($headerName . ': ' . $headerVal, true);
}
http_response_code($re['statusCode']);
echo $re['body'];
} else {
include 'platform/Normal.php';
if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} elseif (isset($_SERVER['DOCUMENT_ROOT'])&&substr($_SERVER['DOCUMENT_ROOT'], 0, 13)==='/home/runner/') {
include 'platform/Replit.php';
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
@@ -57,7 +62,27 @@ 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'];
} else {
include 'platform/Normal.php';
if (!function_exists('curl_init')) {
http_response_code(500);
echo '<font color="red">Need curl</font>, please install php-curl.';
exit(1);
}
$path = getpath();
//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'];
}
// Tencent SCF
@@ -66,6 +91,9 @@ function main_handler($event, $context)
$event = json_decode(json_encode($event), true);
$context = json_decode(json_encode($context), true);
printInput($event, $context);
if ( $event['requestContext']['serviceId'] === substr($event['headers']['host'], 0, strlen($event['requestContext']['serviceId'])) ) {
if ($event['path']==='/' . $context['function_name']) return output('add / at last.', 308, ['Location'=>'/'.$event['requestContext']['stage'].'/'.$context['function_name'].'/']);
}
unset($_POST);
unset($_GET);
unset($_COOKIE);
@@ -80,7 +108,7 @@ function main_handler($event, $context)
// Aliyun FC & Huawei FG & Baidu CFC
function handler($event, $context)
{
if (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
if (isset($_SERVER['FC_FUNC_CODE_PATH'])) {
// Aliyun FC
set_error_handler("myErrorHandler");
$tmp = array(
@@ -104,7 +132,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
+8
View File
File diff suppressed because one or more lines are too long
+87 -38
View File
@@ -37,17 +37,23 @@ 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($tmp)-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['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];
@@ -60,8 +66,11 @@ function GetPathSetting($event, $context)
$_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['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'][0];
$_SERVER['FC_FUNC_CODE_PATH'] = getenv('FC_FUNC_CODE_PATH');
$_SERVER['REQUEST_METHOD'] = $event['method'];
return $path;
//return spurlencode($path, '/');
}
function getConfig($str, $disktag = '')
@@ -177,16 +186,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);
@@ -221,10 +230,11 @@ 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 .= '
//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>';
<label>AccessKeySecret:<input name="AccessKeySecret" type="password" placeholder="" size=""></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
@@ -245,7 +255,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;
@@ -411,39 +422,24 @@ function setConfigResponse($response)
return json_decode($response, true);
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['ErrorMessage'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名
/*
@ob_start();
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
$html.='状态:' . $stat . '
结果:
';
$archivefolder = ob_get_clean();
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
$outPath .= $archivefolder;
$html.=htmlspecialchars($archivefolder);
//return $html;
*/
$tmp = scandir($outPath);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
$outPath = findIndexPath($outPath);
// 将目录中文件打包成zip
$zip = new ZipArchive();
@@ -473,7 +469,7 @@ function addFileToZip($zip, $rootpath, $path = '')
}
}
}
@closedir($path);
@closedir($handler);
}
function myErrorHandler($errno, $errstr, $errfile, $errline) {
@@ -501,3 +497,56 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) {
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['AccessKeyID']!=''&&$_POST['AccessKeySecret']!='') {
$tmp['AccessKeyID'] = $_POST['AccessKeyID'];
$tmp['AccessKeySecret'] = $_POST['AccessKeySecret'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $tmp['AccessKeyID'], $tmp['AccessKeySecret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">' . getconstStr('Create') . ' AccessKeyID & AccessKeySecret</a><br>
<label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br>
<label>AccessKeySecret:<input name="AccessKeySecret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.AccessKeyID.value==\'\') {
alert(\'input AccessKeyID\');
return false;
}
if (t.AccessKeySecret.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through FC.', 400);
}
+78 -24
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)
{
@@ -34,8 +36,6 @@ 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['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'];
@@ -50,6 +50,8 @@ function GetPathSetting($event, $context)
$_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['REQUEST_METHOD'] = $event['httpMethod'];
$_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
return $path;
}
@@ -165,16 +167,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);
@@ -208,10 +210,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.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>';
<label>Secret Key:<input name="SecretKey" type="password" placeholder="" size=""></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
@@ -232,7 +235,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;
@@ -375,29 +379,24 @@ function setConfigResponse($response)
return json_decode( $response, true );
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['FunctionBrn'=>$_SERVER['functionBrn'], 'code'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取包中目录名
$tmp = scandir('phar://'.$tarfile);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
// 放入配置文件
//file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
// 获取解压出的目录名
$outPath = findIndexPath($outPath);
// 将目录中文件打包成zip
//$zip=new ZipArchive();
@@ -429,9 +428,64 @@ function addFileToZip($zip, $rootpath, $path = '')
}
}
}
@closedir($path);
@closedir($handler);
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretKey']!='') {
$SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId;
$SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey;
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">' . getconstStr('Create') . ' Access Key & Secret Key</a><br>
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>Secret Key:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input Access Key\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input Secret Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through CFC.', 400);
}
+90 -13
View File
@@ -170,11 +170,8 @@ 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;
}
$HerokuappId = getConfig('HerokuappId');
if ($HerokuappId=='') {
$function_name = getConfig('function_name');
@@ -197,17 +194,27 @@ function install()
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()+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']) {
@@ -218,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 .= '
$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>';
<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 .= '
@@ -247,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;
@@ -313,7 +320,11 @@ function updateHerokuapp($HerokuappId, $apikey, $source)
{
$tmp['source_blob']['url'] = $source;
$data = json_encode($tmp);
return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $HerokuappId . '/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)
@@ -329,10 +340,15 @@ function_name:' . $_SERVER['function_name'] . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
if ($GitSource=='Github') {
//'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
$source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$source = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return ['stat'=>403, 'body'=>json_encode(['id'=>'Error', 'message'=>'Git Source input Error!'])];
return updateHerokuapp(getConfig('HerokuappId'), getConfig('APIKey'), $source);
}
@@ -341,6 +357,67 @@ function setConfigResponse($response)
return json_decode( $response['body'], true );
}
function WaitFunction() {
function WaitFunction($buildId = '') {
// GET /apps/{app_id_or_name}/builds/{build_id}
if ($buildId=='1') return true;
$response = HerokuAPI('GET', 'https://api.heroku.com/apps/' . getConfig('HerokuappId') . '/builds/' . $buildId, '', getConfig('APIKey'));
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['status']=="succeeded") return true;
else return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = setConfigResponse( setHerokuConfig($tmp, getConfig('HerokuappId'), $APIKey) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br>
<label>API Key:<input name="APIKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'input API Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400);
if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400);
return $drive->smallfileupload($path, $_FILES['file1']);
}
+73 -24
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)
@@ -49,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'] = '/';
@@ -56,8 +60,6 @@ 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['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -71,6 +73,8 @@ function GetPathSetting($event, $context)
$_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['REQUEST_METHOD'] = $event['httpMethod'];
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
return $path;
}
@@ -190,18 +194,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['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']) );
@@ -243,13 +238,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>';
@@ -273,7 +269,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;
@@ -433,27 +430,24 @@ function setConfigResponse($response)
return json_decode( $response, true );
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error_code'=>'Error', 'error_msg'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名
$tmp = scandir($outPath);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
$outPath = findIndexPath($outPath);
// 将目录中文件打包成zip
//$zip=new ZipArchive();
@@ -485,9 +479,64 @@ function addFileToZip($zip, $rootpath, $path = '')
}
}
}
@closedir($path);
@closedir($handler);
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through FG.', 400);
}
+82 -48
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)
@@ -49,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'] = '/';
@@ -56,8 +60,6 @@ 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['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -71,16 +73,16 @@ function GetPathSetting($event, $context)
$_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['REQUEST_METHOD'] = $event['httpMethod'];
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
return $path;
}
function getConfig($str, $disktag = '')
{
global $slash;
$projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$projectPath = splitlast(__DIR__, '/')[0];
$configPath = $projectPath . '/.data/config.php';
$s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') {
@@ -105,9 +107,8 @@ function setConfig($arr, $disktag = '')
{
if ($disktag=='') $disktag = $_SERVER['disktag'];
global $slash;
$projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$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);
@@ -204,18 +205,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['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']) );
@@ -257,13 +249,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>';
@@ -287,17 +280,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 .= '
@@ -426,7 +420,6 @@ 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 {
@@ -469,8 +462,8 @@ function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
return $response;
}
$projectPath = splitlast(__DIR__, $slash)[0];
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
$projectPath = splitlast(__DIR__, '/')[0];
$configPath = $projectPath . '/.data/config.php';
$s = file_get_contents($configPath);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') $tmp_env = json_decode($configs, true);
@@ -525,39 +518,24 @@ function setConfigResponse($response)
return json_decode( $response, true );
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error_code'=>'Error', 'error_msg'=>'Git Source input Error!']);
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取解压出的目录名
/*
@ob_start();
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
$html.='状态:' . $stat . '
结果:
';
$archivefolder = ob_get_clean();
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
$outPath .= $archivefolder;
$html.=htmlspecialchars($archivefolder);
//return $html;
*/
$tmp = scandir($outPath);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
$outPath = findIndexPath($outPath);
// 放入配置文件
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
@@ -592,7 +570,7 @@ function addFileToZip($zip, $rootpath, $path = '')
}
}
}
@closedir($path);
@closedir($handler);
}
@@ -602,6 +580,7 @@ function addFileToZip($zip, $rootpath, $path = '')
define("BasicDateFormat", "Ymd\THis\Z");
define("Algorithm", "SDK-HMAC-SHA256");
define("HeaderXDate", "X-Sdk-Date");
@@ -872,3 +851,58 @@ class Signer
function WaitFunction() {
return true;
}
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
<label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through FG.', 400);
}
+27 -19
View File
@@ -5,12 +5,13 @@ 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_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
}
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
$_SERVER['REQUEST_SCHEME'] = 'http';
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
@@ -22,8 +23,6 @@ function getpath()
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path;
//return substr($path, 1);
//return spurlencode($path, '/');
}
function getGET()
@@ -278,8 +277,9 @@ language:<br>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
$title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201);
}
@@ -311,19 +311,23 @@ function setConfigResponse($response)
return json_decode($response, true);
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$slash = '/';
if (strpos(__DIR__, ':')) $slash = '\\';
global $slash;
// __DIR__ is xxx/platform
$projectPath = splitlast(__DIR__, $slash)[0];
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return 0;
$tarfile = $projectPath . $slash .'github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return 0;
file_put_contents($tarfile, $githubfile);
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
$phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
@@ -335,14 +339,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
unlink($tarfile);
$outPath = '';
$tmp = scandir($projectPath);
$name = $auth . '-' . $project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath = $projectPath . $slash . $f;
break;
}
}
$outPath = findIndexPath($projectPath);
//error_log1($outPath);
if ($outPath=='') return 0;
@@ -353,11 +350,12 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
$tmp1['message'] = "Can not move " . $projectPath . $slash . '.data' . $slash . 'config.php' . " to " . $outPath . $slash . '.data' . $slash . 'config.php';
return json_encode($tmp1);
}
return moveFolder($outPath, $projectPath, $slash);
return moveFolder($outPath, $projectPath);
}
function moveFolder($from, $to, $slash)
function moveFolder($from, $to)
{
global $slash;
if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
if (!file_exists($to)) mkdir($to, 0777);
@@ -367,7 +365,7 @@ function moveFolder($from, $to, $slash)
$fromfile = $from . $slash . $filename;
$tofile = $to . $slash . $filename;
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = moveFolder($fromfile, $tofile, $slash);
$response = moveFolder($fromfile, $tofile);
if (api_error(setConfigResponse($response))) return $response;
}else{
//if (file_exists($tofile)) unlink($tofile);
@@ -389,3 +387,13 @@ function moveFolder($from, $to, $slash)
function WaitFunction() {
return true;
}
function changeAuthKey() {
return message("Not need.", 'Change platform Auth token or key', 404);
}
function smallfileupload($drive, $path) {
if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400);
if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400);
return $drive->smallfileupload($path, $_FILES['file1']);
}
+363
View File
@@ -0,0 +1,363 @@
<?php
function getpath()
{
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
}
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = '/';
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path;
}
function getGET()
{
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
$getstrarr = explode("&",$getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function ReplitAPI($op, $key, $value = '') {
//error_log1($op . '_' . $key . '_' . $value);
$apiurl = getenv('REPLIT_DB_URL');
//foreach (explode("\n", curl('GET', $apiurl . '?prefix')['body']) as $a) curl('DELETE', $apiurl . '/' . $a);
if ($op === 'r') {
if (!($config = getcache('REPLIT_CONFIG'))) {
$config = json_decode(curl('GET', $apiurl . '/REPLIT_CONFIG')['body'], true);
savecache('REPLIT_CONFIG', $config);
}
return ['stat'=>200, 'body'=>(is_array($config[$key])?json_encode($config[$key]):$config[$key])];
} elseif ($op === 'w') {
return curl('POST', $apiurl, 'REPLIT_CONFIG=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]);
} elseif ($op === 'd') {
// not use
return curl('DELETE', $apiurl . '/' . $key);
} else {
return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().'];
}
}
function getConfig($str, $disktag = '')
{
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$env = json_decode(ReplitAPI('r', $disktag)['body'], true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']);
else return ReplitAPI('r', $str)['body'];
}
return '';
}
function setConfig($arr, $disktag = '')
{
if (!($envs = getcache('REPLIT_CONFIG'))) {
$envs = json_decode(curl('GET', getenv('REPLIT_DB_URL') . '/REPLIT_CONFIG')['body'], true);
savecache('REPLIT_CONFIG', $envs);
}
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getConfig('disktag'));
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
else $envs[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
else $envs[$disktag][$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$envs[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$envs[$newtag] = $envs[$v];
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$envs[$k] = $v;
}
}
if ($indisk) {
$diskconfig = $envs[$disktag];
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$envs[$disktag] = $diskconfig;
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$envs['disktag'] = implode('|', $tags);
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
unset($envs[$arr['disktag_rename']]);
} else {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
else $envs['disktag'] = '';
}
}
$envs = array_filter($envs, 'array_value_isnot_null');
sortConfig($envs);
$response = ReplitAPI('w', 'REPLIT_CONFIG', json_encode($envs));
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT));
savecache('REPLIT_CONFIG', null, '', 0);
if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "<br>\nError in writting " . $key . "=" . $val];
return $response;
}
function install()
{
global $constStr;
if ($_GET['install2']) {
if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_COOKIE['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$response = setConfigResponse( setConfig($tmp) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 201);
} else {
return output('Jump
<script>
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
}
}
}
if ($_GET['install1']) {
/*if (!ConfigWriteable()) {
$html .= getconstStr('MakesuerWriteable');
$title = 'Error';
return message($html, $title, 201);
}
if (!RewriteEngineOn()) {
$html .= getconstStr('MakesuerRewriteOn');
$title = 'Error';
return message($html, $title, 201);
}*/
$html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);">
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\''.getconstStr('SetAdminPassword').'\');
return false;
}
return true;
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
}
if ($_GET['install0']) {
$html .= '
<form action="?install1" method="post">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
function changelanguage(str)
{
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
location.href = location.href;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
$title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201);
}
function ConfigWriteable()
{
$t = md5( md5(time()).rand(1000,9999) );
$r = setConfig([ 'tmp' => $t ]);
$tmp = getConfig('tmp');
setConfig([ 'tmp' => '' ]);
if ($tmp == $t) return true;
if ($r) return true;
return false;
}
function api_error($response)
{
return !($response['stat']==200||$response['stat']==204||$response['stat']==404);
//return isset($response['message']);
}
function api_error_msg($response)
{
return '<pre>'. json_encode($response, JSON_PRETTY_PRINT).'</pre>' . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function setConfigResponse($response)
{
return $response;
//return json_decode($response, true);
}
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
// __DIR__ is xxx/platform
$projectPath = splitlast(__DIR__, '/')[0];
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return ['stat'=>500, 'body'=>'Git Source input Error!'];
$tarfile = $projectPath . '/github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return ['stat'=>500, 'body'=>'download error from github.'];
file_put_contents($tarfile, $githubfile);
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
$phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
} else {
ob_start();
passthru('tar -xzvf ' . $tarfile, $stat);
ob_get_clean();
}
unlink($tarfile);
$outPath = '';
$outPath = findIndexPath($projectPath);
//error_log1($outPath);
if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.'];
return moveFolder($outPath, $projectPath);
}
function moveFolder($from, $to)
{
if (substr($from, -1)=='/') $from = substr($from, 0, -1);
if (substr($to, -1)=='/') $to = substr($to, 0, -1);
if (!file_exists($to)) mkdir($to, 0777);
$handler=opendir($from);
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..'){
$fromfile = $from . '/' . $filename;
$tofile = $to . '/' . $filename;
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = moveFolder($fromfile, $tofile);
if (api_error(setConfigResponse($response))) return $response;
}else{
if (file_exists($tofile)) unlink($tofile);
$response = rename($fromfile, $tofile);
if (!$response) {
$tmp['code'] = "Move Failed";
$tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
return ['stat'=>500, 'body'=>json_encode($tmp)];
}
if (file_exists($fromfile)) unlink($fromfile);
}
}
}
closedir($handler);
rmdir($from);
return ['stat'=>200, 'body'=>'success.'];
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
return message("Not need.", 'Change platform Auth token or key', 404);
}
function smallfileupload($drive, $path) {
if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400);
if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400);
return $drive->smallfileupload($path, $_FILES['file1']);
}
+379
View File
@@ -0,0 +1,379 @@
<?php
function getpath()
{
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
}
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = '/';
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path;
}
function getGET()
{
if (!$_POST) {
if (!!$HTTP_RAW_POST_DATA) {
$tmpdata = $HTTP_RAW_POST_DATA;
} else {
$tmpdata = file_get_contents('php://input');
}
if (!!$tmpdata) {
$postbody = explode("&", $tmpdata);
foreach ($postbody as $postvalues) {
$pos = strpos($postvalues,"=");
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
}
}
}
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
$p = strpos($_SERVER['REQUEST_URI'],'?');
if ($p>0) {
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
$getstrarr = explode("&",$getstr);
foreach ($getstrarr as $getvalues) {
if ($getvalues != '') {
$pos = strpos($getvalues, "=");
//echo $pos;
if ($pos > 0) {
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
} else {
$getarry[urldecode($getvalues)] = true;
}
}
}
}
if (isset($getarry)) {
return $getarry;
} else {
return [];
}
}
function ReplitAPI($op, $key, $value = '') {
//error_log1($op . '_' . $key . '_' . $value);
$apiurl = getenv('REPLIT_DB_URL');
if ($op === 'r') {
return curl('GET', $apiurl . '/' . $key);
} elseif ($op === 'w') {
return curl('POST', $apiurl, $key . '=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]);
} elseif ($op === 'd') {
return curl('DELETE', $apiurl . '/' . $key);
} else {
return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().'];
}
}
function getConfig($str, $disktag = '')
{
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$env = json_decode(ReplitAPI('r', $disktag)['body'], true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']);
else return ReplitAPI('r', $str)['body'];
}
return '';
}
function setConfig($arr, $disktag = '')
{
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getConfig('disktag'));
if ($disktag!='') $diskconfig = json_decode(ReplitAPI('r', $disktag)['body'], true);
$tmp = [];
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
else $tmp[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
else $diskconfig[$k] = $v;
$indisk = 1;
} elseif ($k=='disktag_add') {
array_push($disktags, $v);
$operatedisk = 1;
} elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]);
$tmp[$v] = '';
$operatedisk = 1;
} elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His");
$tmp[$newtag] = getConfig($v);
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$tmp[$k] = json_encode($v);
}
}
if ($indisk) {
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig);
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$tmp['disktag'] = implode('|', $tags);
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
$tmp[$arr['disktag_rename']] = null;
} else {
$disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = null;
}
}
$response = null;
foreach ($tmp as $key => $val) {
if (!!$val) $response = ReplitAPI('w', $key, $val);
else $response = ReplitAPI('d', $key);
if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "<br>\nError in writting " . $key . "=" . $val];
}
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT));
return $response;
}
function install()
{
global $constStr;
if ($_GET['install2']) {
if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_COOKIE['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$response = setConfigResponse( setConfig($tmp) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 201);
} else {
return output('Jump
<script>
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
</script>
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
}
}
}
if ($_GET['install1']) {
if (!ConfigWriteable()) {
$html .= getconstStr('MakesuerWriteable');
$title = 'Error';
return message($html, $title, 201);
}
/*if (!RewriteEngineOn()) {
$html .= getconstStr('MakesuerRewriteOn');
$title = 'Error';
return message($html, $title, 201);
}*/
$html .= '<button id="checkrewritebtn" onclick="checkrewrite();">'.getconstStr('MakesuerRewriteOn').'</button>
<div id="formdiv" style="display: none">
<form action="?install2" method="post" onsubmit="return notnull(this);">
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'" disabled>
</form>
</div>
<script>
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\''.getconstStr('SetAdminPassword').'\');
return false;
}
return true;
}
function checkrewrite()
{
url=location.protocol + "//" + location.host;
//if (location.port!="") url += ":" + location.port;
url += location.pathname;
if (url.substr(-1)!="/") url += "/";
url += "app.json";
url += "?" + Date.now();
var xhr4 = new XMLHttpRequest();
xhr4.open("GET", url);
xhr4.setRequestHeader("x-requested-with","XMLHttpRequest");
xhr4.send(null);
xhr4.onload = function(e){
console.log(xhr4.responseText+","+xhr4.status);
if (xhr4.status==201) {
document.getElementById("checkrewritebtn").style.display = "none";
document.getElementById("submitbtn").disabled = false;
document.getElementById("formdiv").style.display = "";
} else {
alert("' . getconstStr('MakesuerRewriteOn') . '?\nfalse\n\nUrl: " + url + "\nExpect http code 201, but received " + xhr4.status);
}
}
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
}
if ($_GET['install0']) {
$html .= '
<form action="?install1" method="post">
language:<br>';
foreach ($constStr['languages'] as $key1 => $value1) {
$html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
}
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
function changelanguage(str)
{
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
location.href = location.href;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
$title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201);
}
function ConfigWriteable()
{
$t = md5( md5(time()).rand(1000,9999) );
$r = setConfig([ 'tmp' => $t ]);
$tmp = getConfig('tmp');
setConfig([ 'tmp' => '' ]);
if ($tmp == $t) return true;
if ($r) return true;
return false;
}
function api_error($response)
{
return !($response['stat']==200||$response['stat']==204||$response['stat']==404);
//return isset($response['message']);
}
function api_error_msg($response)
{
return '<pre>'. json_encode($response, JSON_PRETTY_PRINT).'</pre>' . '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
}
function setConfigResponse($response)
{
return $response;
//return json_decode($response, true);
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$slash = '/';
if (strpos(__DIR__, ':')) $slash = '\\';
// __DIR__ is xxx/platform
$projectPath = splitlast(__DIR__, $slash)[0];
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
$tarfile = $projectPath . $slash .'github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return ['stat'=>500, 'body'=>'download error from github.'];
file_put_contents($tarfile, $githubfile);
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
$phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
} else {
ob_start();
passthru('tar -xzvf ' . $tarfile, $stat);
ob_get_clean();
}
unlink($tarfile);
$outPath = '';
$tmp = scandir($projectPath);
$name = $auth . '-' . $project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath = $projectPath . $slash . $f;
break;
}
}
//error_log1($outPath);
if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.'];
return moveFolder($outPath, $projectPath, $slash);
}
function moveFolder($from, $to, $slash)
{
if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
if (!file_exists($to)) mkdir($to, 0777);
$handler=opendir($from);
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..'){
$fromfile = $from . $slash . $filename;
$tofile = $to . $slash . $filename;
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = moveFolder($fromfile, $tofile, $slash);
if (api_error(setConfigResponse($response))) return $response;
}else{
if (file_exists($tofile)) unlink($tofile);
$response = rename($fromfile, $tofile);
if (!$response) {
$tmp['code'] = "Move Failed";
$tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
return ['stat'=>500, 'body'=>json_encode($tmp)];
}
if (file_exists($fromfile)) unlink($fromfile);
}
}
}
closedir($handler);
rmdir($from);
return ['stat'=>200, 'body'=>'success.'];
}
function WaitFunction() {
return true;
}
function changeAuthKey() {
return message("Not need.", 'Change platform Auth token or key', 404);
}
+87 -25
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)
{
@@ -41,8 +44,6 @@ 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['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -56,7 +57,9 @@ function GetPathSetting($event, $context)
//$_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_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
$_SERVER['USER'] = 'qcloud';
return $path;
}
@@ -167,16 +170,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'];
@@ -200,7 +211,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);">
@@ -218,7 +229,7 @@ function install()
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
return message($html, $title, 201, 1);
}
}
if ($_GET['install0']) {
@@ -229,10 +240,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>';
@@ -256,7 +268,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;
@@ -548,29 +561,24 @@ function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKe
return curl('POST', 'https://'.$host, $payload, $headers)['body'];
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['Response'=>['Error'=>['code'=>'Git Source input Error!']]]);
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取包中目录名
$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'));
// 获取解压出的目录名
$outPath = findIndexPath($outPath);
// 将目录中文件打包成zip
//$zip=new ZipArchive();
@@ -602,5 +610,59 @@ function addFileToZip($zip, $rootpath, $path = '')
}
}
}
@closedir($path);
@closedir($handler);
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through SCF.', 400);
}
+88 -29
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)
{
@@ -41,8 +44,6 @@ 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['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -56,7 +57,9 @@ function GetPathSetting($event, $context)
//$_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_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['REQUEST_METHOD'] = $event['httpMethod'];
$_SERVER['USER'] = 'qcloud';
return $path;
}
@@ -179,29 +182,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;
}
$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)) {
@@ -212,7 +217,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);">
@@ -230,7 +235,7 @@ function install()
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
return message($html, $title, 201, 1);
}
}
if ($_GET['install0']) {
@@ -241,10 +246,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>';
@@ -268,7 +274,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;
@@ -589,27 +596,25 @@ function setConfigResponse($response)
return json_decode( $response, true )['Response'];
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$source = '/tmp/code.zip';
$outPath = '/tmp/';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['Response'=>['Error'=>['code'=>'Git Source input Error!']]]);
$tarfile = '/tmp/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
// 获取包中目录名
$tmp = scandir('phar://'.$tarfile);
$name = $auth.'-'.$project;
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
$outPath .= $f;
break;
}
}
// 获取解压出的目录名
$outPath = findIndexPath($outPath);
// 放入配置文件
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
@@ -643,10 +648,64 @@ function addFileToZip($zip, $rootpath, $path = '')
}
}
}
@closedir($path);
@closedir($handler);
}
function WaitFunction() {
if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true;
else return false;
}
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
function smallfileupload($drive, $path) {
return output('Can not upload through SCF.', 400);
}
+189 -138
View File
@@ -67,18 +67,24 @@ function getGET()
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'];
$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];
if (isset($envs[$disktag][$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$disktag][$str]);
else return $envs[$disktag][$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(getenv($str));
else return getenv($str);
if (isset($envs[$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$str]);
else return $envs[$str];
}
}
}
return '';
}
@@ -86,47 +92,45 @@ function getConfig($str, $disktag = '')
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 = [];
$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)) $tmp[$k] = base64y_encode($v);
else $tmp[$k] = $v;
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
else $envs[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
else $diskconfig[$k] = $v;
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 ]);
$tmp[$v] = '';
$envs[$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;
$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 {
$tmp[$k] = json_encode($v);
$envs[$k] = $v;
}
}
if ($indisk) {
$diskconfig = $envs[$disktag];
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig);
$envs[$disktag] = $diskconfig;
}
if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
@@ -135,23 +139,22 @@ function setConfig($arr, $disktag = '')
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;
$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!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = null;
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
else $envs['disktag'] = '';
}
}
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'));
$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()
@@ -184,16 +187,24 @@ function install()
$title = 'Error';
return message($html, $title, 400);
} else {
/*$html = '<script>
var status = "' . $response['status'] . '";
$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);*/
$data["dplId"] = $response['status'];
return output(json_encode($data), 201);
return message($html, $title, 201, 1);
}
}
}
@@ -205,10 +216,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 .= '<br>
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value="' . getConfig('APIKey') . '"></label><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 .= '
@@ -241,52 +251,7 @@ language:<br>';
alert(\'input Token\');
return false;
}
t.style.display = "none";
errordiv.innerHTML = "' . getconstStr('Wait') . '";
var xhr = new XMLHttpRequest();
xhr.open("POST", t.action);
xhr.onload = function(e) {
if (xhr.status==201) {
var res = JSON.parse(xhr.responseText);
getStatus(res.dplId, t.APIKey.value);
} else {
t.style.display = "";
errordiv.innerHTML = xhr.status + "<br>" + xhr.responseText;
}
}
xhr.send("admin=" + t.admin.value + "&APIKey=" + t.APIKey.value);
var x = "";
var min = 0;
function getStatus(id, VercelToken) {
x += ".";
min++;
var xhr = new XMLHttpRequest();
var url = "https://api.vercel.com/v11/now/deployments/" + id;
xhr.open("GET", url);
xhr.setRequestHeader("Authorization", "Bearer " + VercelToken);
xhr.onload = function(e) {
if (xhr.status==200) {
var deployStat = JSON.parse(xhr.responseText).readyState;
if (deployStat=="READY") {
x = "";
min = 0;
errordiv.innerHTML = "Deploy done.";
location.href = "/";
} else {
errordiv.innerHTML = deployStat + ", " + min + ".<br>' . getconstStr('Wait') . ' " + x;
if (deployStat!=="ERROR") setTimeout(function() { getStatus(id, VercelToken) }, 1000);
}
} else {
t.style.display = "";
console.log(xhr.status);
console.log(xhr.responseText);
}
}
xhr.send(null);
}
return false;
return true;
}
</script>';
$title = getconstStr('SelectLanguage');
@@ -303,39 +268,47 @@ language:<br>';
return message($html, $title, 201);
}
// POST /v8/projects/:id/env
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)
{
$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"];
}
$response = null;
foreach ($envs as $key => $value) {
$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>" . json_encode($response, JSON_PRETTY_PRINT) . "<br>";
if ($response['stat']!=200) return $response['body'];
}
return VercelUpdate($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 = "")
{
$url = "https://api.vercel.com/v12/now/deployments";
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";
@@ -343,7 +316,7 @@ function VercelUpdate($appId, $token, $sourcePath = "")
$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";
$data["functions"]["api/index.php"]["runtime"] = "vercel-php@0.5.1";
if ($sourcePath=="") $sourcePath = splitlast(splitlast(__DIR__, "/")[0], "/")[0];
//echo $sourcePath . "<br>";
getEachFiles($file, $sourcePath);
@@ -351,11 +324,29 @@ function VercelUpdate($appId, $token, $sourcePath = "")
//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['status'] = $result['id'];
$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);
@@ -397,42 +388,51 @@ function setConfigResponse($response)
return json_decode($response, true);
}
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$tmppath = '/tmp';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error'=>['code'=>'Git Source input Error!']]);
$tarfile = $tmppath . '/github.tar.gz';
$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);//路径 要解压的文件 是否覆盖
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $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 = findIndexPath($tmppath);
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
$name = $project . 'CODE';
mkdir($tmppath . "/" . $name, 0777, 1);
rename($outPath, $tmppath . "/" . $name . '/api');
$outPath = $tmppath . "/" . $name;
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) {
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/now/deployments/" . $deployid;
$url = "https://api.vercel.com/v13/deployments/" . $deployid;
$response = curl("GET", $url, "", $header);
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
@@ -444,3 +444,54 @@ function WaitFunction($deployid) {
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);
}
function smallfileupload($drive, $path) {
if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400);
if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400);
return $drive->smallfileupload($path, $_FILES['file1']);
}
+473
View File
@@ -0,0 +1,473 @@
<?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($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
{
$tmppath = '/tmp';
if ($GitSource=='Github') {
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
} elseif ($GitSource=='HITGitlab') {
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
} else return json_encode(['error'=>['code'=>'Git Source input Error!']]);
$tarfile = $tmppath . '/github.tar.gz';
file_put_contents($tarfile, file_get_contents($url));
$phar = new PharData($tarfile);
$html = $phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
unlink($tarfile);
// 获取解压出的目录名
$outPath = findIndexPath($tmppath);
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
$name = $project . 'CODE';
mkdir($tmppath . "/" . $name, 0777, 1);
rename($outPath, $tmppath . "/" . $name . '/api');
$outPath = $tmppath . "/" . $name;
//echo $outPath . "<br>";
//error_log1($outPath);
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
}
function WaitFunction($deployid) {
if ($buildId=='1') {
$tmp['stat'] = 400;
$tmp['body'] = 'id must provided.';
return $tmp;
}
$header["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/deployments/" . $deployid;
$response = curl("GET", $url, "", $header);
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['readyState']=="READY") return true;
if ($result['readyState']=="ERROR") return $response;
return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = json_decode(setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'Input Token\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+193 -101
View File
@@ -1,137 +1,229 @@
# NOTICE: the release is used as archive.
# 注意:release只是用来存档的。
[中文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~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
> Fork this project, create a heroku app, then turn to Deploy tab, deploy via connect to 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.
---
# Deploy to Vercel
Official: https://vercel.com/
Demo: null
Notice:
> 1, you must wait 30-50s to make sure deploy READY after change config;
> 2, the max size of environment is 4k, so you can add 3 onedrive or less;
> 3, Vercel limit 100 deploy every day.
How to Install: https://scfonedrive.github.io/Vercel/Deploy.html .
### Official
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### Notice
> 1. you must wait 30-50s to make sure deploy READY after change config;
>
> 2. Vercel limit 100 deploy every day.
### How to Install
> https://scfonedrive.github.io/Vercel/Deploy.html .
---
# Deploy to Replit
### Official
https://repl.it/
https://replit.com/
### Demo
https://onemanager.qkqpttgf.repl.co/
### Notice
> `Import from Github` useing the `.replit` file in code files will cause an empty web page, may someone help me?
### How to Install
> 1. Click the "+" or "Create Repl", find template "PHP Web Server" (via input "php"), input a name for your project in "Title" or left it default, Click the "+ Create Repl".
> 2. After done, input `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` to Console or Shell on the right, press "Enter" to run it.
> 3. Click the green button "Run", it will show the web page on the right, you can open it in a new tab or window.
---
# 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) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
>
> Star this project, then Fork, create an app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork.
---
# Deploy to Glitch
### 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 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
(重点:勾选集成响应)
https://console.huaweicloud.com/functiongraph/
添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。
### DEMO
null
# Deploy to Huawei cloud Function Graph (FG 华为云函数工作流)
Official: https://console.huaweicloud.com/functiongraph/
DEMO: 无
注意:FG中,环境变量整体大小为2KB,所以最多添加2个盘(一个onedrive一个aliyundrive)。
### How to Install
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,然后不用点下一步了,点立即完成,然后去发布生效
see CN readme.
----
# Deploy to Aliyun Function Compute (FC 阿里云函数计算)
Official: https://fc.console.aliyun.com/
DEMO: 无
# Deploy to Aliyun Function Compute (FC)
How to Install:
1,新建函数 -- HTTP函数
2,运行环境选择php7.2
3,触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
4,上传代码
5,触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
6,访问你的域名,开始安装
### Official:
https://fc.console.aliyun.com/
# Deploy to Baidu Cloud Function Compute (CFC 百度云函数计算)
Official: https://console.bce.baidu.com/cfc/#/cfc/functions
DEMO: 无
自定义域名需要另外使用API网关,并备案。
### DEMO
How to Install:
1,在函数列表,点创建函数
2,创建方式改为空白函数,点下一步
3,输入名称,选择运行时为PHP7.2,点下一步
4,触发器:下拉选择HTTP触发器,URL路径填 /{filepath+} ,HTTP方法全选,身份验证:不验证,点提交
5,进入代码编辑页,编辑类型改上传函数ZIP包,选择文件(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。),开始上传
6,点击右边触发器,复制并访问提供的url,开始安装
null
### How to Install
see CN readme.
---
# Deploy to Baidu Cloud Function Compute (CFC)
### Official
https://console.bce.baidu.com/cfc/#/cfc/functions
### DEMO
null
### How to Install
see CN readme.
---
# Deploy to Virtual Private Server (VPS) or php host
### DEMO
null
### How to Install
# Deploy to Virtual Private Server (VPS 或空间)
DEMO: 无
How to Install:
1. Start web service on your server (httpd or other), make sure you can visit it.
启动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 .data/config.php can be read&write (666 is suggested).
使web身份可读写代码中的.data/config.php文件,推荐chmod 666 .data/config.php。
5. View the website in chrome or other.
在浏览器中访问。
----
# Features
# Features 特性
When downloading files, the program produce a direct url, visitor download files from MS OFFICE via the direct url, the server expend a few bandwidth in produce.
下载时,由程序解析出直链,浏览器直接从微软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.
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
# Functional files 功能性文件
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). 放在第一个盘的显示目录(不一定是onedrive根目录)。
put it in the showing home folder of FIRST disk (maybe not root of onedrive).
### index.html
show content of index.html as html. 将index.html以静态网页显示出来。
### head.md readme.md
it will showed at top or bottom as markdown. 以MD语法显示在顶部或底部。
### head.omf foot.omf
it will showed at top or bottom as html (javascript works!). 以html显示在顶部或底部(可以跑js)。
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
paypal.me/qkqpttgf
https://paypal.me/qkqpttgf
-----
# Chat
QQ Group: 212088653 (请看完上面的中英双语再加群,谢谢!)
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
### Telegram Group
https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
+271
View File
@@ -0,0 +1,271 @@
[Readme EN](readme.md)
# 注意:
请关掉浏览器的翻译。
Releases只是当存档在用的,并不是最新代码。
请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。
---
# 部署到 Vercel
### 官网
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### 注意
> 1. 每次更改配置后都要等 30-50s 来确保部署成功;
>
> 2. Vercel 每天限制 100 次部署。
### 安装(英文)
https://scfonedrive.github.io/Vercel/Deploy.html
---
# 部署到 Replit
### 官网
https://repl.it/
https://replit.com/
### Demo
https://onemanager.qkqpttgf.repl.co/
### 注意
> 直接`Import from Github`通过`.replit`文件指定php时,网页会空白,有人帮忙解决吗?
### 安装
> 1. 点右上的 "+" 或左上的 "+ Create Repl"template中输入php,点选"PHP Web Server",在"Title"里输入你想要的名称或者让它默认, 点下面的"+ Create Repl"。
> 2. 结束后,在右边的Console或Shell里输入 `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` 敲回车运行。
> 3. 点上方的绿色 "Run" 按钮,右边会显示一个网页,你要在新窗口打开它来安装,不然不能登录。
---
# 部署到 Heroku
### 官网
https://heroku.com
### Demo
https://herooneindex.herokuapp.com/
### 安装
> 给这个项目点star,然后fork,在Heroku创建一个app,然后点进Deploy页,在"Deployment method"处点"Connect GitHub",选择你的fork。
---
# 部署到 Glitch
### 官网
https://glitch.com/
### Demo
https://onemanager.glitch.me/
### 安装
点 [New Project] -> 点 [Import form Github] -> 粘贴 "https://github.com/qkqpttgf/OneManager-php" ,结束后,左上角点 [Show] -> [In a New Window]。
---
# 部署到腾讯无服务器云函数 Serverless Cloud Function (SCF)
### 官网
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
+8 -3
View File
@@ -305,7 +305,7 @@
<div>
<div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&nbsp;<!--constStr@Download--></a>
</div>
</div>
<div>
@@ -386,7 +386,7 @@
<div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center>
<form action="<!--IsPreview?-->admin" method="post">
<form action="<!--IsPreview?-->login=admin" method="post">
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input type="submit" value="<!--constStr@Login-->">
</form>
@@ -396,6 +396,7 @@
<!--LoginEnd-->
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script>
<!--AdminStart-->
window.onload = function ()
{
// 获取所有radios元素
@@ -448,6 +449,7 @@
radios[i].setAttribute("currStatus", false);
}
}
<!--AdminEnd-->
function changelanguage(str)
{
if (str=='Language') str = '';
@@ -479,7 +481,10 @@
<!--IsFileStart-->
var $url = document.getElementById('url');
if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px';
}
<!--IsvideoFileStart-->
+191 -62
View File
@@ -42,7 +42,7 @@
.more-disk a:hover, .more-disk a[now]{ background-color: rgba(85,85,85,0.7); color: white; }
.list-table{width:100%;padding:0 20px 20px 20px;border-spacing:0}
.list-table tr{height:40px}
.list-table tr[data-to]:hover{background:rgba(85,85,85,0.7);color:white;}
.list-table tr[data-to]:hover{background:rgba(85,85,85,0.7) !important;color:white;}
.list-table tr[data-to]:hover a{color:white}
.list-table tr:first-child{background:rgba(245,245,245,0)}
.list-table td,.list-table th{padding:0 10px;text-align:left}
@@ -94,12 +94,12 @@
</ul></li>
<!--AdminEnd-->
&nbsp;
<select class="changelanguage" name="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
<!--<select class="changelanguage" name="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
<option value="">Language</option>
<!--SelectLanguageStart-->
<option value="<!--SelectLanguageKey-->" <!--SelectLanguageSelected-->><!--SelectLanguageValue--></option>
<!--SelectLanguageEnd-->
</select>
</select>-->
</div>
<!--NeedUpdateStart-->
<div style='position:absolute;'><font color='red'><!--constStr@NeedUpdate--></font></div>
@@ -202,6 +202,7 @@
<div id="txt">
<!--AdminStart-->
<form id="txt-form" action="" method="POST">
<input name="_admin" type="hidden" value="">
<a onclick="document.getElementById('txt-a').readOnly='';document.getElementById('txt-save').style.display='';document.getElementById('txt-editbutton').style.display='none';document.getElementById('txt-cancelbutton').style.display='';" id="txt-editbutton"><ion-icon name="create"></ion-icon><!--constStr@ClicktoEdit--></a>
<a onclick="document.getElementById('txt-a').readOnly='readonly';document.getElementById('txt-save').style.display='none';document.getElementById('txt-editbutton').style.display='';document.getElementById('txt-cancelbutton').style.display='none';" id="txt-cancelbutton" style="display:none"><ion-icon name="close"></ion-icon><!--constStr@CancelEdit--></a>&nbsp;&nbsp;&nbsp;
<a id="txt-save" style="display:none"><ion-icon name="save"></ion-icon><!--constStr@Save--></a>
@@ -209,6 +210,12 @@
<textarea id="txt-a" name="editfile" readonly style="width: 100%; margin-top: 2px;" <!--AdminStart-->onchange="document.getElementById('txt-save').onclick=function(){document.getElementById('txt-form').submit();}"<!--AdminEnd--> ><!--TxtContent--></textarea>
<!--AdminStart-->
</form>
<script>
var inputAdminStorage = document.getElementsByName("_admin");
for (i=0;i<inputAdminStorage.length;i++) {
inputAdminStorage[i].value = localStorage.getItem("admin");
}
</script>
<!--AdminEnd-->
</div>
<!--IstxtFileEnd-->
@@ -222,7 +229,7 @@
<table class="list-table" id="list-table">
<tr id="tr0">
<th class="file">
<a onclick="sortby('a');"><!--constStr@File--></a>
<a id="file_a0" fileid="<!--FolderId-->" onclick="sortby('a');"><!--constStr@File--></a>
<!--ShowThumbnailsStart-->
&nbsp;&nbsp;&nbsp;
<label><input type="checkbox" id="originalpic"><!--constStr@OriginalPic--></label>
@@ -464,7 +471,7 @@
<div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center>
<form action="<!--IsPreview?-->admin" method="post" onsubmit="return sha1loginpass(this);">
<form action="<!--IsPreview?-->login=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-->">
@@ -476,12 +483,13 @@
<div style="color: rgba(247,247,249,0);"><!--FootStr--></div>
</body>
<!--MdRequireStart--><link rel="stylesheet" href="https://unpkg.com/github-markdown-css@3.0.1/github-markdown.css">
<script type="text/javascript" src="https://unpkg.com/marked@0.6.2/lib/marked.js"></script><!--MdRequireEnd-->
<!--ListStart-->
<!--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-->
<!--AliyundriveUploadJsStart--><script src="https://unpkg.com/bignumber.js@9.0.2/bignumber.js"></script>
<script src="https://www.unpkg.com/js-sha1@0.6.0/src/sha1.js"></script><!--AliyundriveUploadJsEnd-->
<!--IsFileStart--><!--IspdfFileStart--><script src="https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--ListEnd-->
<script type="text/javascript">
function changelanguage(str)
@@ -512,17 +520,60 @@
f.password1.value = sha1(timestamp + "" + f.password1.value);
return true;
} catch {
alert("sha1.js not loaded.");
//alert("sha1.js not loaded.");
if (confirm("sha1.js not loaded.\n\nLoad from program?")) loadjs("?jsFile=sha1.min.js");
return false;
}
}
function loadjs(url) {
var xhr = new XMLHttpRequest;
xhr.open("GET", url);
xhr.onload = function(e) {
if (xhr.status==200) {
var script = document.createElement("script");
script.type = "text/javascript";
script.text = xhr.responseText;
document.body.appendChild(script);
} else {
console.log(xhr.response);
}
}
xhr.send(null);
}
<!--LoginEnd-->
<!--WriteTimezoneStart-->
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
if (timezone!=<!--timezone-->) {
//alert('Your timezone is '+timezone+', reload local timezone.');
location.href=location.href;
}
<!--WriteTimezoneEnd-->
<!--HeadmdStart-->
var $head = document.getElementById('head');
if ($head) {
//document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div'));
$head.innerHTML = marked(document.getElementById('head-md').innerText);
}
<!--HeadmdEnd-->
<!--ReadmemdStart-->
var $readme = document.getElementById('readme');
if ($readme) {
$readme.innerHTML = marked(document.getElementById('readme-md').innerText);
}
<!--ReadmemdEnd-->
<!--ListStart-->
<!--IsFileStart-->
var $url = document.getElementById('url');
if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px';
}
<!--IsofficeFileStart-->
@@ -601,29 +652,68 @@
});
}
}
addVideos(['<!--FileEncodeUrl-->']);
addVideos(["<!--FileEncodeUrl-->"]);
<!--IsvideoFileEnd-->
<!--IspdfFileStart-->
pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
//cdn.bootcss.com/pdf.js/2.4.456/pdf.worker.min.js
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.worker.min.js';
var loadingTask = pdfjsLib.getDocument({
url: '<!--FileDownUrl-->',
cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/",
url: "<!--FileDownUrl-->",
cMapUrl: "https://unpkg.com/pdfjs-dist@2.4.456/cmaps/",
cMapPacked: true,
disableStream: true,
disableAutoFetch: true,
rangeChunkSize: 65535
});
/*loadingTask.onProgress = (e) => {
//console.log(e);
var p = document.getElementById('p');
if (p==null) {
p = document.createElement('div');
p.id = 'p';
p.setAttribute('onclick', "this.style.display = 'none';");
p.style = 'left: 10px; top: 30%; position: fixed;';
document.body.appendChild(p);
}
p.innerHTML = 'Loaded: ' + ((e.loaded/e.total)*100).toFixed(2) + '%<br>(' + size_format(e.loaded) + ' / ' + size_format(e.total) + ')';
p.style.display = '';
if (e.loaded==e.total) p.style.display = 'none';
}*/
loadingTask.promise.then(function(pdf) {
var pagenum = pdf.numPages;
var pdfContainer = document.getElementById('pdf-d');
pdfContainer.innerHTML = '';
for (var i=1;i<=pagenum;i++) {
var pagepos = 1;
var pdfnextpagebutton = document.createElement('button');
pdfnextpagebutton.id = 'pdfnextpagebutton';
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
pdfnextpagebutton.setAttribute('onclick', "this.style.display = 'none';");
pdfnextpagebutton.style.display = 'none';
pdfContainer.appendChild(pdfnextpagebutton);
var pdfWaitNextPage = setInterval(function(){
//console.log(document.documentElement.scrollTop + ", " + document.body.scrollHeight);
if (pdfnextpagebutton.style.display=='none') {
for (var i=pagepos;i<=(pagepos+4<pagenum?pagepos+4:pagenum);i++) {
var canvasNew = document.createElement('canvas');
canvasNew.id = 'pdf-c'+i;
pdfContainer.appendChild(canvasNew);
renderpage(pdf,i);
}
pagepos = i;
if (pagepos<pagenum) {
console.log("next page: " + pagepos + " / " + pagenum);
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
pdfnextpagebutton.style.display ='';
pdfContainer.appendChild(pdfnextpagebutton);
} else {
console.log("end of pdf");
clearInterval(pdfWaitNextPage);
}
}
}, 1000);
});
function renderpage(pdf,i)
{
function renderpage(pdf,i) {
pdf.getPage(i).then(function(page) {
var scale = 1.5;
var viewport = page.getViewport({ scale: scale, });
@@ -638,22 +728,27 @@
page.render(renderContext);
});
}
function size_format(num) {
if (num>1024) {
num=num/1024;
} else {
return num.toFixed(2) + ' B';
}
if (num>1024) {
num=num/1024;
} else {
return num.toFixed(2) + ' KB';
}
if (num>1024) {
num=num/1024;
} else {
return num.toFixed(2) + ' MB';
}
return num.toFixed(2) + ' GB';
}
<!--IspdfFileEnd-->
<!--IsFileEnd-->
<!--IsFolderStart-->
<!--HeadmdStart-->
var $head = document.getElementById('head');
if ($head) {
//document.getElementById('head-div').parentNode.insertBefore(document.getElementById('head-div'),document.getElementById('list-div'));
$head.innerHTML = marked(document.getElementById('head-md').innerText);
}
<!--HeadmdEnd-->
<!--ReadmemdStart-->
var $readme = document.getElementById('readme');
if ($readme) {
$readme.innerHTML = marked(document.getElementById('readme-md').innerText);
}
<!--ReadmemdEnd-->
<!--ShowThumbnailsStart-->
function showthumbnails(obj) {
images = [<!--ImgExts-->];
@@ -775,6 +870,7 @@
}
function size_reformat(str) {
if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
if (str.substr(-2)=='TB') num=str.substr(0,str.length-3)*1024*1024*1024*1024;
if (str.substr(-2)=='GB') num=str.substr(0,str.length-3)*1024*1024*1024;
if (str.substr(-2)=='MB') num=str.substr(0,str.length-3)*1024*1024;
if (str.substr(-2)=='KB') num=str.substr(0,str.length-3)*1024;
@@ -783,18 +879,6 @@
}
<!--IsNotHiddenEnd-->
<!--IsFolderEnd-->
<!--WriteTimezoneStart-->
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
if (timezone!=<!--timezone-->) {
alert('Your timezone is '+timezone+', reload local timezone.');
location.href=location.href;
}
<!--WriteTimezoneEnd-->
function CopyAllDownloadUrl(str) {
var tmptextarea=document.createElement('textarea');
document.body.appendChild(tmptextarea);
@@ -988,7 +1072,7 @@
delete uploading[upbigfilename];
}
}
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5);
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5 + '&_admin=' + localStorage.getItem("admin"));
<!--GuestStart-->
}
}
@@ -1046,7 +1130,9 @@
let tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
lastCurrentSpeed = tmpspeed;
let remaintime = (totalsize-asize-e.loaded)/tmpspeed;
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
let percent = ((asize+e.loaded)*100/totalsize).toFixed(2);
label.parentNode.style.background = "linear-gradient(to right, rgba(0,0,0,25%) " + percent + "%, rgba(0,0,0,0%) 0%)";
label.innerHTML = StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + percent + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
}
}
var C_starttime = new Date();
@@ -1075,7 +1161,7 @@
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';
label.parentNode.style.background = 'rgba(0,80,0,25%)';
// uploadbuttonshow();
<!--AdminStart-->
@@ -1132,7 +1218,39 @@
}// else console.log(Object.keys(uploading).length);
} else clearInterval(uploadList);
}, 1000);
//getuplink(i);
function CalcProof(file) {
return new Promise(function(resolve, reject){
var xhr = new XMLHttpRequest();
xhr.open("POST", '?action=upbigfile');
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
xhr.setRequestHeader('x-requested-with', 'XMLHttpRequest');
xhr.onload = function(e){
var html;
if (xhr.status==200) {
//console.log(xhr.responseText);
var r = new BigNumber("0x".concat(xhr.responseText));
var i = new BigNumber(file.size);
var o = i ? r.mod(i) : 0;
var reader1 = new FileReader();
var start = o.toNumber();
var end = start + 8;
//if (file.size<end) end = file.size;
console.log(start + " ~ " + end);
//reader1.readAsBinaryString(file.slice(start,end));
reader1.readAsDataURL(file.slice(start,end));
reader1.onload = function(e) {
var proof = this.result;
proof = proof.substr(proof.indexOf('base64,')+7);
resolve(proof);
}
} else {
//console.log(xhr.status+'calc proof code\n'+xhr.responseText);
reject(xhr.status+"\ncalc proof code\n"+xhr.responseText);
}
}
xhr.send('CalcProof=1');
});
}
function getuplink(i, r=0) {
var file=files[i];
var td1;
@@ -1160,6 +1278,7 @@
uploadbuttonshow();
return;
}*/
var upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
uploading[upbigfilename] = [i];
var spark = sha1.create();
@@ -1171,7 +1290,14 @@
var blob = file.slice(start,end);
reader.readAsArrayBuffer(blob);
}
var proof_code = '';
CalcProof(file).then(a => {
proof_code = a;
console.log('proof: ' + proof_code);
readblob(asize);
}, e => {
td2.innerHTML = e;
});
reader.onload = function(e){
td2.innerHTML='<!--constStr@Calculate--> SHA1: '+(asize*100/file.size).toFixed(2)+'%';
@@ -1239,7 +1365,7 @@
getuplink(i);
}*/
}
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&filesha1=' + filesha1 + '&chunksize=' + chunksize);
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&proof_code=' + proof_code + '&filesha1=' + filesha1 + '&chunksize=' + chunksize + '&_admin=' + localStorage.getItem("admin"));
}
}
}
@@ -1318,14 +1444,14 @@
}
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr;
label.style.color='green';
label.parentNode.style.background = 'rgba(0,80,0,25%)';
} 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']));
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']) + '&_admin=' + localStorage.getItem("admin"));
} else {
var binary = this.result;
var xhr = new XMLHttpRequest();
@@ -1338,7 +1464,9 @@
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));
let percent = ((asize+e.loaded)*100/totalsize).toFixed(2);
label.parentNode.style.background = "linear-gradient(to right, rgba(0,0,0,25%) " + percent + "%, rgba(0,0,0,0%) 0%)";
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + percent + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
}
}
var C_starttime = new Date();
@@ -1389,14 +1517,14 @@
}
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="<!--base_disk_path--><!--Path-->'+filename+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="<!--base_disk_path--><!--Path-->'+filename+'" id="upfile_a1_'+tdnum+'"></a><!--constStr@UploadComplete--><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');" id="upfile_cpbt_'+tdnum+'" <!--AdminStart--> style="display:none"<!--AdminEnd--> ><!--constStr@CopyUrl--></button></div>';
label.innerHTML=StartStr+MiddleStr;
label.style.color='green';
label.parentNode.style.background = 'rgba(0,80,0,25%)';
} 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']));
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']) + '&_admin=' + localStorage.getItem("admin"));
// uploadbuttonshow();
} else {
readblob(asize);
@@ -1439,7 +1567,7 @@
var expd = new Date();
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie = "admin=; path=/; "+expires;
document.cookie = "admin=; path=<!--base_path-->; "+expires;
location.href = location.href;
}
/*for some mobile browser*/
@@ -1467,17 +1595,18 @@
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';
var str;
if (num=='') {
var str='';
var fileid='';
str = '';
num = 0;
} else {
var str=decodeURIComponent(document.getElementById('file_a'+num).href);
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;
}
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;
@@ -1533,7 +1662,7 @@
document.getElementById(str+'_div').style.display='none';
document.getElementById('mask').style.display='none';
}
xhr.send(serializeForm(str+'_form'));
xhr.send(serializeForm(str+'_form') + '&_admin=' + localStorage.getItem("admin"));
return false;
}
function addelement(html) {
@@ -1634,7 +1763,7 @@
document.getElementById('password1').focus();
<!--EncryptedEnd-->
</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-->
<script src="https://www.unpkg.com/ionicons@6.0.1/dist/ionicons.js"></script>
<!--LoginStart--><script src="https://www.unpkg.com/js-sha1@0.6.0/src/sha1.js"></script><!--LoginEnd-->
<!--customScript-->
</html>
+52 -6
View File
@@ -49,14 +49,29 @@
.more-disk a{flex-grow: 1;text-align: center;font-size: 15px;padding:14px 20px;transition-duration: 0.4s;background-color: #f4f5f8; color: #353535;display: inline-block;}
.more-disk a:hover, .more-disk a[now]{ background-color: rgb(79 116 220); color: white; }
.list-table{width:100%;padding:0 20px 20px 20px;border-spacing:0}
.list-table tr{height:33px}
.list-table tr{height:2rem; line-height: 1.5rem;}
.list-table tr[data-to]:hover{background: rgb(79 116 220);color:white;}
.list-table tr[data-to]:hover a{color:white}
.list-table tr:first-child{background:rgba(245,245,245,0)}
.list-table tr[data-to]:hover .operate ul li a{color:black}
.list-table tr ion-icon {vertical-align: middle; height: 2rem;}
.list-table td,.list-table th{padding:0 10px;text-align:left}
.list-table td.file a {vertical-align: middle;}
.list-table .size,.list-table .updated_at{text-align:right}
.updated_at{width:25%}
.size{width:15%}
.list-table tbody.grid-view {display: flex;flex-wrap: wrap;position: relative;width: 100%;grid-template: repeat(auto-fill, 100px) / repeat(auto-fill, minmax(100px, 50%));grid-auto-rows: 100px;}
.list-table tbody.grid-view td, .list-table tbody.grid-view th {padding:0;}
.list-table tbody.grid-view img {height: 150px;width: 100%;object-fit: cover;position:relative;}
.list-table tbody.grid-view #tr0{width: 100%;height: 33px;background-color: unset !important;}
.list-table tbody.grid-view tr {width: unset;height: 150px;background-color: #efefef;margin: 2px;position: relative;flex-grow: 1;min-width: 100px;}
.list-table tbody.grid-view td.file {display: block;width: 100%;height: 100%;}
.list-table tbody.grid-view td.file a {width: 100%;height: 100%;display: inline-block;position:relative}
.list-table tbody.grid-view td.file a > span {position: absolute;left: 3px;}
.list-table tbody.grid-view td.file .download {display: none;}
.list-table tbody.grid-view td.file ion-icon{position: absolute;top: calc(50% - 25px);left: calc(50% - 25px);width: 50px;height: 50px;color: #0002}
.list-table tbody.grid-view td.updated_at {position: absolute;bottom: 0px;height: 1.5em;overflow-y: hidden;width: 100%;background-image: linear-gradient(#ffffff00, #0000008f);color: #fffc;z-index: 3;}
.list-table tbody.grid-view td.size {display: none;}
.mask{position:absolute;left:0px;top:0px;width:100%;background-color:#000;filter:alpha(opacity=50);opacity:0.5;z-index:2;}
<!--AdminStart-->
#top-op {position: absolute;color: white;font-size: 12px;}
@@ -66,7 +81,6 @@
body .active ul{position:absolute;display:inline-table;} /*for some mobile browser */
.operate ul li{padding:7px;list-style:none;display:block;}
.operate ul li:hover {background-color: #f4f5f8;}
.list-table tr[data-to]:hover .operate ul li a{color:black}
#tr0{height: 40px;}
<!--AdminEnd-->
.operatediv{position:absolute;border-radius: 8px;background-color:#ffffff;z-index:2;box-shadow: 5px 5px 10px 0 #00000033;padding: 15px 4px;}
@@ -483,7 +497,7 @@
<div>
<a onclick="operatediv_close('login')" class="operatediv_close">×</a>
<center>
<form action="<!--IsPreview?-->admin" method="post" onsubmit="return sha1loginpass(this);">
<form action="<!--IsPreview?-->login=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-->">
@@ -544,7 +558,9 @@
<!--IsFileStart-->
var $url = document.getElementById('url');
if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px';
}
<!--IsofficeFileStart-->
@@ -677,9 +693,39 @@
}
<!--ReadmemdEnd-->
<!--ShowThumbnailsStart-->
var isGrid = false;
var isthumbLoaded = false;
function showthumbnails(obj) {
images = [<!--ImgExts-->];
var files=document.getElementsByName('filelist');
if (document.getElementById('originalpic').checked==true){
if(isGrid){
var list_body = document.getElementById('list-table').firstElementChild
list_body.classList.remove('grid-view')
isGrid = false
}
}else {
if(!isGrid){
// turn to grid view
var list_body = document.getElementById('list-table').firstElementChild
list_body.classList.add('grid-view')
isGrid = true
if (isthumbLoaded) {
return
}else {
isthumbLoaded = true
}
} else {
var list_body = document.getElementById('list-table').firstElementChild
list_body.classList.remove('grid-view')
isGrid = false
return
}
}
for ($i=0;$i<files.length;$i++) {
str=files[$i].innerText;
if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
@@ -698,7 +744,7 @@
}
}
}
obj.disabled='disabled';
// obj.disabled='disabled';
}
function get_thumbnails_url(url, name, filea) {
var xhr = new XMLHttpRequest();
@@ -706,7 +752,7 @@
xhr.send('');
xhr.onload = function(e){
if (xhr.status==200) {
if (xhr.responseText!='') filea.innerHTML='<img src="'+xhr.responseText+'" alt="'+name+'">';
if (xhr.responseText!='') filea.innerHTML= '<span>' + filea.innerHTML + '</span>' + '<img src="'+xhr.responseText+'" alt="'+name+'">';
} else console.log(xhr.status+'\n'+xhr.responseText);
}
}
+6 -3
View File
@@ -89,7 +89,7 @@
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="?admin" method="post">
<form action="?login=admin" method="post">
<div class="modal-body">
<input class="form-control" id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
</div>
@@ -222,7 +222,7 @@
<div style="margin: 12px 4px 4px; text-align: center">
<div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&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-->
@@ -717,7 +717,10 @@ return false;
<!--IsFileStart-->
var $url = document.getElementById('url');
if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px';
}
<!--IsofficeFileStart-->
+5 -2
View File
@@ -421,7 +421,7 @@
<div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center>
<form action="<!--IsPreview?-->admin" method="post" onsubmit="return sha1loginpass(this);">
<form action="<!--IsPreview?-->login=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-->">
@@ -479,7 +479,10 @@
<!--IsFileStart-->
var $url = document.getElementById('url');
if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px';
}
<!--IsofficeFileStart-->
+6 -3
View File
@@ -179,7 +179,7 @@
<div style="margin: 12px 4px 4px; text-align: center">
<div style="margin: 24px">
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon>&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-->
@@ -457,7 +457,7 @@
<div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
<center>
<form action="<!--IsPreview?-->admin" method="post">
<form action="<!--IsPreview?-->login=admin" method="post">
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
<input type="submit" value="<!--constStr@Login-->">
</form>
@@ -509,7 +509,10 @@
<!--IsFileStart-->
var $url = document.getElementById('url');
if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px';
}
<!--IsofficeFileStart-->
+6 -10
View File
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
<link rel="preconnect" href="https://fastly.jsdelivr.net" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<meta charset="utf-8" />
@@ -16,7 +16,7 @@
/>
<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" />
<link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/css/app.css"><meta name="theme-color" content="#fff" />
<!--BackgroundStart-->
<style>
body {
@@ -98,13 +98,9 @@
<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 class="mdui-list-item mdui-ripple" href="?login=admin" >
<a class="mdui-list-item-icon mdui-icon material-icons">account_circle</a>
<a class="mdui-list-item-content" href="?login=admin">登录</a>
</li>
<!--LoginEnd-->
<!--AdminStart-->
@@ -515,5 +511,5 @@
{ "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@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>
<script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@1b381f3c.a4f2dc4618121eac37e2.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@28a13772.98a11cc0c1cf2495c3d8.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@34e3d95a.2f8dbf552095a86a7f1b.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@798ab416.9ed46bb752b71a3c13a4.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@9c50beac.30955a99f08c9574cd14.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/app@f0256996.956ea71aa357ba3fdc28.js"></script><script src="https://fastly.jsdelivr.net/gh/186526/renexmoe-cdn@v1.3/js/webpack-runtime.93708ab3e9cb84dcc01a.js"></script>
</html>
+8 -11
View File
@@ -187,10 +187,10 @@
</path></svg></div>
<div style="padding:1px" id="top-div">
<!--LoginStart-->
<a class="login" href="?admin"><ion-icon name="ban-outline"></ion-icon></a><!--onclick="login();"-->
<a class="login" href="?login=admin"><ion-icon name="add-circle-outline"></ion-icon></a><!--onclick="login();"-->
<!--LoginEnd-->
<!--AdminStart-->
<li class="operate" id="opflow"><ion-icon name="ban-outline"></ion-icon><ul>
<li class="operate" id="opflow"><ion-icon name="add-circle-outline"></ion-icon><ul>
<!--IsFolderStart-->
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle-outline"></ion-icon><!--constStr@Create--></a></li>
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed-outline"></ion-icon><!--constStr@Encrypt--></a></li>
@@ -300,7 +300,9 @@
var prePath = strFullPath.substring(0, pos);
var width = window.innerWidth;
// var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
document.getElementById("url").value= prePath + "<!--FileEncodeUrl-->";
let url = location.href;
url = url.substr(0, url.length-8);
document.getElementById("url").value= url;
// document.getElementById("url").value= prePath + postPath + "<!--FileEncodeUrl-->";
if(width < 495) {
if(document.getElementById("office-a")) {
@@ -583,7 +585,7 @@
<div style="margin:50px">
<a onclick="operatediv_close('login')" class="operatediv_close">×</a>
<center>
<form action="<!--IsPreview?-->admin" method="post" onsubmit="return sha1loginpass(this);">
<form action="<!--IsPreview?-->login=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-->">
@@ -603,7 +605,7 @@
<!--MdRequireStart--><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/marked@2.0.0/lib/marked.min.js"></script><!--MdRequireEnd-->
<!--GuestUploadStart--><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/spark-md5@3.0.1/spark-md5.min.js"></script><!--GuestUploadEnd-->
<!--AliyundriveUploadJsStart--><script src="https://cdn.jsdelivr.net/npm/sha1@1.1.1/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
<!--AliyundriveUploadJsStart--><script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
<!--IsFileStart--><!--IspdfFileStart--><script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.8.335/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--ListEnd-->
<script type="text/javascript">
@@ -642,11 +644,6 @@
<!--LoginEnd-->
<!--ListStart-->
<!--IsFileStart-->
var $url = document.getElementById('url').value;
if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
$url.style.height = $url.scrollHeight + 'px';
}
<!--IsofficeFileStart-->
var $officearea=document.getElementById('office-a');
if ($officearea) {
@@ -1807,6 +1804,6 @@ function size_format(num) {
document.getElementById('password1').focus();
<!--EncryptedEnd-->
</script>
<!--LoginStart--><script src="https://cdn.jsdelivr.net/npm/sha1@1.1.1/sha1.min.js"></script><!--LoginEnd-->
<!--LoginStart--><script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script><!--LoginEnd-->
<!--customScript-->
</html>
+31 -1
View File
@@ -1,7 +1,37 @@
20220127-1234.43
<font color="red">change login page, default not '?admin' but '?login=admin' now! and if set adminloginpage, it will be '?login=[value]'.</font> rm JumpFirstDisk, 403 in operating root, change sorting disk, remake disktags tab, add global md config. Allow Preview when enable downloadencrypt. some change in adding Onedrive disk. show upload progress in table background. fix some bugs.
<font color="red">更改登录地址,默认不再是'?admin'而是'?login=admin',如果设置了adminloginpage,那登录地址会是'?login=值'。</font>移除 JumpFirstDisk,在root操作时返回403,更改盘排序,重做盘符排列,添加全局md配置。在开启downloadencrypt后可以网页预览了。添加onedrive盘时稍做修改。上传时以背景做进度条。修复其它bug。
20211220-1100.42
Add new platform Replit. Add a git source for update. sha1.js use jsdelivr cdn. fix some bugs.
新增Replit平台。新增国内git源,以后国内可以选择从HIT源更新。sha1.js换成jsdelivr CDN。修复bug。
20211201-1602.41
add a latent function, you can edit platform token(or API key) via '?setup=auth' when the token invalid, not need edit it in Environment(or Config Var) manually, (even in Vercel, config saved in file, and can't modiy it manually).
新增隐藏功能,在平台操作代码的token或API key失效时,可以在 '?setup=auth' 修改它,不用去环境变量修改了(特别地,Vercel保存在代码中时都改不到)。
20211129
check if there is another deployment building when start deploy.
Vercel部署时检测是否有另一个部署。
20211104
check if exist php-curl or not in php host and VPS.
在VPS中检测是否有php-curl。
20211021
specialchars, fix: list folder, encrypt folder, preview files, rename, show in title, error on back link after login at specialchars folder, etc.
针对特殊字符,解决目录的列表,目录的加密,文件的预览,目录与文件重命名,在网页标题的显示,在特殊字符处登录后跳转出错等问题。
20211006
oprate files by fileID, write a localStorage when login to anti CSRF.
管理时对文件id操作,管理登录时写入一个localStorage预防CSRF。
20210908
add fileConduitSize&fileConduitCacheTime, little files can stream from program, better to show html/js as local file.
增加fileConduitSizefileConduitCacheTime,小文件可以从服务器中转,以对html/js本地化更好的支持。
20210903
add a latent function, you can run some command by '?setup=cmd', be care, please dont try "top", and set times by "ping -c 4".
新增隐藏功能,你可以通过'?setup=cmd'来跑一些命令,注意不要试图跑top,另外ping请-c设置次数。
20210820-1810.40
because Vercel must redeploy after change Environment Variables, and it must <4k, so decide that, save config in code file. <font color=red>in Vercel, after update, please install again. if you want continue use Environment, please add a ( name: "ONEMANAGER_CONFIG_SAVE", value: "env" ) in Environment Variables in Project Settings before update.</font>
因为Vercel修改环境变量也必须重新部署才生效,而且环境变量只能小于4k,所以决定将配置保存在代码文件中。<font color=red>升级更新后,用Vercel的请重新安装。如果还想继续使用环境变量,请在更新前,在Project Settings的Environment Variables中,新增一个( name: "ONEMANAGER_CONFIG_SAVE", value: "env" )的环境变量。</font>
20210817-2030.39
fix bugs in Vercel. add wait function in operating. change update method in SCF. add payme in readme.
修复一些Vercel上的bug。在操作完后添加等待功能,确认平台已经准备好。SCF的更新方式改变。在readme中添加讨饭链接。
20210804-1535.38
try fix "&"/"&amp;" in filename. try show an img too height. change upload chunk size when upload speed>10M/s. fix forceHttps when custom domain in Glitch. fix ionicons svg lost.try use file id when rename. background (or other) based on width/height not only width. fix some bugs. Pre-Add platform Vercel, just wait bugs fixed.
尝试修复文件名含 "&"/"&amp;"。尝试在一屏内显示过长的图片。上传时分割的块大小随着上传速度改变。修复Glitch中使用自定义域名时forceHttps问题。修复ionicons图标失踪。尝试在重命名时使用file id来操作。背景(或其它)基于长宽来看是竖屏还是横屏,不再只看宽度。修复其它bug。预加入Vercel平台,等修复bugs。