Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwsswl
OneManager-php
提交
f2ee21b6
O
OneManager-php
项目概览
lwsswl
/
OneManager-php
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneManager-php
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f2ee21b6
编写于
8月 17, 2021
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add WaitFunction in operate
上级
729e1e11
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
340 addition
and
138 deletion
+340
-138
common.php
common.php
+74
-14
conststr.php
conststr.php
+5
-5
disk/Aliyundrive.php
disk/Aliyundrive.php
+26
-13
disk/Onedrive.php
disk/Onedrive.php
+44
-11
platform/AliyunFC.php
platform/AliyunFC.php
+4
-0
platform/BaiduCFC.php
platform/BaiduCFC.php
+4
-0
platform/Heroku.php
platform/Heroku.php
+5
-0
platform/HuaweiFG_env.php
platform/HuaweiFG_env.php
+4
-0
platform/HuaweiFG_file.php
platform/HuaweiFG_file.php
+4
-0
platform/Normal.php
platform/Normal.php
+5
-1
platform/TencentSCF_env.php
platform/TencentSCF_env.php
+8
-0
platform/TencentSCF_file.php
platform/TencentSCF_file.php
+5
-0
platform/Vercel.php
platform/Vercel.php
+152
-94
未找到文件。
common.php
浏览文件 @
f2ee21b6
...
...
@@ -198,6 +198,13 @@ function main($path)
$url
=
path_format
(
$_SERVER
[
'PHP_SELF'
]
.
'/'
);
return
output
(
'<script>alert(\''
.
getconstStr
(
'SetSecretsFirst'
)
.
'\');</script>'
,
302
,
[
'Location'
=>
$url
]);
}
if
(
isset
(
$_GET
[
'WaitFunction'
]))
{
$response
=
WaitFunction
(
$_GET
[
'WaitFunction'
]);
//var_dump($response);
if
(
$response
===
true
)
return
output
(
"ok"
,
200
);
elseif
(
$response
===
false
)
return
output
(
""
,
206
);
else
return
$response
;
}
$_SERVER
[
'sitename'
]
=
getConfig
(
'sitename'
);
if
(
empty
(
$_SERVER
[
'sitename'
]))
$_SERVER
[
'sitename'
]
=
getconstStr
(
'defaultSitename'
);
...
...
@@ -295,6 +302,7 @@ function main($path)
return
$drive
->
bigfileupload
(
$path1
);
}
}
if
(
$_SERVER
[
'admin'
])
{
$tmp
=
adminoperate
(
$path
);
if
(
$tmp
[
'statusCode'
]
>
0
)
{
...
...
@@ -800,9 +808,9 @@ function get_timezone($timezone = '8')
return
$timezones
[
$timezone
];
}
function
message
(
$message
,
$title
=
'Message'
,
$statusCode
=
200
)
function
message
(
$message
,
$title
=
'Message'
,
$statusCode
=
200
,
$wainstat
=
0
)
{
return
output
(
'
$html
=
'
<html lang="'
.
$_SERVER
[
'language'
]
.
'">
<html>
<meta charset=utf-8>
...
...
@@ -810,14 +818,61 @@ function message($message, $title = 'Message', $statusCode = 200)
<body>
<h1>'
.
$title
.
'</h1>
<a href="'
.
$_SERVER
[
'base_path'
]
.
'">'
.
getconstStr
(
'Back'
)
.
getconstStr
(
'Home'
)
.
'</a>
<
p
>
<
div id="dis" style="display: none;"
>
'
.
$message
.
'
</p>
</div>'
;
if
(
$wainstat
)
{
$html
.
=
'
<div id="err"></div>
<script>
var dis = document.getElementById("dis");
var errordiv = document.getElementById("err");
//var deployTime = new Date().getTime();
dis.style.display = "none";
var x = "";
var min = 0;
function getStatus() {
x += ".";
min++;
var xhr = new XMLHttpRequest();
var url = "?WaitFunction" + (status!=""?"=" + status:"");
xhr.open("GET", url);
//xhr.setRequestHeader("Authorization", "Bearer ");
xhr.onload = function(e) {
if (xhr.status==200) {
//var deployStat = JSON.parse(xhr.responseText).readyState;
if (xhr.responseText=="ok") {
errordiv.innerHTML = "";
dis.style.display = "";
} else {
errordiv.innerHTML = "ERROR<br>" + xhr.responseText;
//setTimeout(function() { getStatus() }, 1000);
}
} else if (xhr.status==206) {
errordiv.innerHTML = min + "<br>'
.
getconstStr
(
'Wait'
)
.
'" + x;
setTimeout(function() { getStatus() }, 1000);
} else {
errordiv.innerHTML = "ERROR<br>" + xhr.status + "<br>" + xhr.responseText;
console.log(xhr.status);
console.log(xhr.responseText);
}
}
xhr.send(null);
}
getStatus();
//setTimeout(function() { getStatus() }, 3000);
</script>'
;
}
else
{
$html
.
=
'
<script>document.getElementById("dis").style.display = "";</script>'
;
}
$html
.
=
'
</body>
</html>
'
,
$statusCode
);
'
;
return
output
(
$html
,
$statusCode
);
}
function
needUpdate
()
...
...
@@ -1109,12 +1164,13 @@ function EnvOpt($needUpdate = 0)
if
(
api_error
(
$response
))
{
$html
=
api_error_msg
(
$response
);
$title
=
'Error'
;
return
message
(
$html
,
$title
,
400
);
}
else
{
//WaitSCFStat();
$html
.
=
getconstStr
(
'UpdateSuccess'
)
.
'<br><a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
;
$html
.
=
getconstStr
(
'UpdateSuccess'
)
.
'<br><a href="">'
.
getconstStr
(
'Back'
)
.
'</a>
<script>var status = "'
.
$response
[
'status'
]
.
'";</script>
'
;
$title
=
getconstStr
(
'Setup'
);
return
message
(
$html
,
$title
,
202
,
1
);
}
return
message
(
$html
,
$title
);
}
if
(
isset
(
$_POST
[
'submit1'
]))
{
$_SERVER
[
'disk_oprating'
]
=
''
;
...
...
@@ -1127,11 +1183,11 @@ function EnvOpt($needUpdate = 0)
$f
=
substr
(
$v
,
0
,
1
);
if
(
strlen
(
$v
)
==
1
)
$v
.
=
'_'
;
if
(
isCommonEnv
(
$v
))
{
return
message
(
'Do not input '
.
$envs
.
'<br><a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
,
'Error'
,
201
);
return
message
(
'Do not input '
.
$envs
.
'<br><a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
,
'Error'
,
400
);
}
elseif
(
!
((
'a'
<=
$f
&&
$f
<=
'z'
)
||
(
'A'
<=
$f
&&
$f
<=
'Z'
)))
{
return
message
(
'<a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
,
'Please start with letters'
,
201
);
return
message
(
'<a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
,
'Please start with letters'
,
400
);
}
elseif
(
getConfig
(
$v
))
{
return
message
(
'<a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
,
'Same tag'
,
201
);
return
message
(
'<a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
,
'Same tag'
,
400
);
}
else
{
$tmp
[
$k
]
=
$v
;
}
...
...
@@ -1139,7 +1195,7 @@ function EnvOpt($needUpdate = 0)
if
(
$k
==
'disktag_sort'
)
{
$td
=
implode
(
'|'
,
json_decode
(
$v
));
if
(
strlen
(
$td
)
==
strlen
(
getConfig
(
'disktag'
)))
$tmp
[
'disktag'
]
=
$td
;
else
return
message
(
'Something wrong.'
);
else
return
message
(
'Something wrong.'
,
'ERROR'
,
400
);
}
if
(
$k
==
'disk'
)
$_SERVER
[
'disk_oprating'
]
=
$v
;
}
...
...
@@ -1156,12 +1212,16 @@ function EnvOpt($needUpdate = 0)
if
(
api_error
(
$response
))
{
$html
=
api_error_msg
(
$response
);
$title
=
'Error'
;
return
message
(
$html
,
$title
,
409
);
}
else
{
$html
.
=
getconstStr
(
'Success'
)
.
'!<br>
<a href="">'
.
getconstStr
(
'Back'
)
.
'</a>'
;
<a href="">'
.
getconstStr
(
'Back'
)
.
'</a>
<script>
var status = "'
.
$response
[
'status'
]
.
'";
</script>'
;
$title
=
getconstStr
(
'Setup'
);
return
message
(
$html
,
$title
,
200
,
1
);
}
return
message
(
$html
,
$title
);
}
if
(
isset
(
$_POST
[
'config_b'
]))
{
if
(
!
$_POST
[
'pass'
])
return
output
(
"{\"
Error
\
":
\"
No admin pass
\"
}"
,
403
);
...
...
@@ -1233,7 +1293,7 @@ function EnvOpt($needUpdate = 0)
if
(
api_error
(
$response
))
{
return
message
(
api_error_msg
(
$response
)
.
"<a href=
\"\"
>"
.
getconstStr
(
'Back'
)
.
"</a>"
,
"Error"
,
403
);
}
else
{
return
message
(
"Success<a href=
\"\"
>"
.
getconstStr
(
'Back'
)
.
"</a>
"
,
"Success"
,
200
);
return
message
(
"Success<a href=
\"\"
>"
.
getconstStr
(
'Back'
)
.
"</a>
<script>var status =
\"
"
.
$response
[
'status'
]
.
"
\"
;</script>"
,
"Success"
,
200
,
1
);
}
}
else
{
return
message
(
"Old pass error<a href=
\"\"
>"
.
getconstStr
(
'Back'
)
.
"</a>"
,
"Error"
,
403
);
...
...
conststr.php
浏览文件 @
f2ee21b6
...
...
@@ -1072,11 +1072,11 @@ $constStr = [
'ar-sa'
=>
'أكد بي إتش بي قابل للكتابة'
,
],
'MakesuerRewriteOn'
=>
[
'en-us'
=>
'Plase make sure the RewriteEngine is On
.
'
,
'zh-cn'
=>
'确认重写(伪静态)功能启用
。
'
,
'zh-tw'
=>
'確認重寫(偽靜態)功能啟用
。
'
,
'ja'
=>
'書き換え(擬似静的)機能が有効になっていることを確認します
。
'
,
'ko-kr'
=>
'다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오
.
'
,
'en-us'
=>
'Plase make sure the RewriteEngine is On'
,
'zh-cn'
=>
'确认重写(伪静态)功能启用'
,
'zh-tw'
=>
'確認重寫(偽靜態)功能啟用'
,
'ja'
=>
'書き換え(擬似静的)機能が有効になっていることを確認します'
,
'ko-kr'
=>
'다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오'
,
'fa'
=>
'لطفاً مطمئن شوید که RewriteEngine روشن است.'
,
'ar-sa'
=>
'يؤكد أن الكتابة يمكن أن تكون وظيفة شبه استاتي'
,
],
...
...
disk/Aliyundrive.php
浏览文件 @
f2ee21b6
...
...
@@ -629,8 +629,19 @@ class Aliyundrive {
$title
=
'Error'
;
return
message
(
$html
,
$title
,
201
);
}
else
{
$str
.
=
'<meta http-equiv="refresh" content="5;URL='
.
$url
.
'">'
;
return
message
(
$str
,
getconstStr
(
'WaitJumpIndex'
),
201
);
$str
.
=
'
<script>
var status = "'
.
$response
[
'status'
]
.
'";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(min++);
} else {
clearInterval(uploadList);
location.href = "'
.
$url
.
'";
}
}, 1000);
</script>'
;
return
message
(
$str
,
getconstStr
(
'WaitJumpIndex'
),
201
,
1
);
}
}
if
(
isset
(
$_GET
[
'SelectDrive'
]))
{
...
...
@@ -691,6 +702,7 @@ class Aliyundrive {
</form>
</div>
<script>
var status = "'
.
$response
[
'status'
]
.
'";
function notnull(t)
{
if (t.driveId.value==\'\') {
...
...
@@ -699,9 +711,9 @@ class Aliyundrive {
}
return true;
}
</script>
</script>
'
;
return
message
(
$html
,
$title
,
201
);
return
message
(
$html
,
$title
,
201
,
1
);
}
if
(
isset
(
$_GET
[
'install0'
])
&&
$_POST
[
'disktag_add'
]
!=
''
)
{
$_POST
[
'disktag_add'
]
=
preg_replace
(
'/[^0-9a-zA-Z|_]/i'
,
''
,
$_POST
[
'disktag_add'
]);
...
...
@@ -737,7 +749,7 @@ class Aliyundrive {
if
(
api_error
(
$response
))
{
$html
=
api_error_msg
(
$response
);
$title
=
'Error'
;
return
message
(
$html
,
$title
,
201
);
return
message
(
$html
,
$title
,
400
);
}
else
{
$title
=
'Refresh token'
;
$html
=
'
...
...
@@ -756,9 +768,10 @@ class Aliyundrive {
}
return true;
}
var status = "'
.
$response
[
'status'
]
.
'";
</script>
'
;
return
message
(
$html
,
$title
,
201
);
return
message
(
$html
,
$title
,
201
,
1
);
}
}
...
...
disk/Onedrive.php
浏览文件 @
f2ee21b6
...
...
@@ -504,14 +504,23 @@ class Onedrive {
$title
=
'Error'
;
return
message
(
$html
,
$title
,
201
);
}
else
{
$str
.
=
'<meta http-equiv="refresh" content="5;URL='
.
$url
.
'">
<script>
$html
.
=
'<script>
var expd = new Date();
expd.setTime(expd.getTime()+1);
var expires = "expires="+expd.toGMTString();
document.cookie=\'disktag=; path=/; \'+expires;
var i = 0;
var status = "'
.
$response
[
'status'
]
.
'";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "'
.
$url
.
'";
}
}, 1000);
</script>'
;
return
message
(
$
str
,
getconstStr
(
'WaitJumpIndex'
),
20
1
);
return
message
(
$
html
,
getconstStr
(
'WaitJumpIndex'
),
201
,
1
);
}
}
...
...
@@ -607,9 +616,19 @@ class Onedrive {
return
message
(
$html
,
$title
,
201
);
}
else
{
savecache
(
'access_token'
,
$ret
[
'access_token'
],
$this
->
disktag
,
$ret
[
'expires_in'
]
-
60
);
$str
.
=
'
<meta http-equiv="refresh" content="3;URL='
.
$url
.
'?AddDisk='
.
get_class
(
$this
)
.
'&disktag='
.
$_GET
[
'disktag'
]
.
'&SelectDrive">'
;
return
message
(
$str
,
getconstStr
(
'Wait'
)
.
' 3s'
,
201
);
$html
.
=
'<script>
var i = 0;
var status = "'
.
$response
[
'status'
]
.
'";
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";
}
}, 1000);
</script>'
;
return
message
(
$html
,
getconstStr
(
'Wait'
)
.
' 3s'
,
201
,
1
);
}
}
return
message
(
'<pre>'
.
json_encode
(
json_decode
(
$tmp
[
'body'
]),
JSON_PRETTY_PRINT
)
.
'</pre>'
,
$tmp
[
'stat'
]);
...
...
@@ -639,7 +658,7 @@ class Onedrive {
$f
=
substr
(
$_POST
[
'disktag_add'
],
0
,
1
);
if
(
strlen
(
$_POST
[
'disktag_add'
])
==
1
)
$_POST
[
'disktag_add'
]
.
=
'_'
;
if
(
isCommonEnv
(
$_POST
[
'disktag_add'
]))
{
return
message
(
'Do not input '
.
$envs
.
'<br><button onclick="location.href = location.href;">'
.
getconstStr
(
'Refresh'
)
.
'</button>'
,
'Error'
,
201
);
return
message
(
'Do not input '
.
$envs
.
'<br><button onclick="location.href = location.href;">'
.
getconstStr
(
'Refresh'
)
.
'</button>'
,
'Error'
,
400
);
}
elseif
(
!
((
'a'
<=
$f
&&
$f
<=
'z'
)
||
(
'A'
<=
$f
&&
$f
<=
'Z'
)))
{
return
message
(
'Please start with letters<br><button onclick="location.href = location.href;">'
.
getconstStr
(
'Refresh'
)
.
'</button>
<script>
...
...
@@ -647,7 +666,7 @@ class Onedrive {
expd.setTime(expd.getTime()+1);
var expires = "expires="+expd.toGMTString();
document.cookie=\'disktag=; path=/; \'+expires;
</script>'
,
'Error'
,
201
);
</script>'
,
'Error'
,
400
);
}
$tmp
=
null
;
...
...
@@ -673,12 +692,26 @@ class Onedrive {
if
(
api_error
(
$response
))
{
$html
=
api_error_msg
(
$response
);
$title
=
'Error'
;
return
message
(
$html
,
$title
,
400
);
}
else
{
$title
=
getconstStr
(
'MayinEnv'
);
$html
=
getconstStr
(
'Wait'
)
.
' 3s<meta http-equiv="refresh" content="3;URL='
.
$url
.
'?install1&disktag='
.
$_GET
[
'disktag'
]
.
'&AddDisk='
.
$_POST
[
'Drive_ver'
]
.
'">'
;
if
(
$_POST
[
'Drive_ver'
]
==
'Sharelink'
)
$html
=
getconstStr
(
'Wait'
)
.
' 3s<meta http-equiv="refresh" content="3;URL='
.
$url
.
'">'
;
$html
=
getconstStr
(
'Wait'
);
if
(
$_POST
[
'Drive_ver'
]
!=
'Sharelink'
)
$url
.
=
'?install1&disktag='
.
$_GET
[
'disktag'
]
.
'&AddDisk='
.
$_POST
[
'Drive_ver'
];
$html
.
=
'<script>
var i = 0;
var status = "'
.
$response
[
'status'
]
.
'";
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "'
.
$url
.
'";
}
return
message
(
$html
,
$title
,
201
);
}, 1000);
</script>'
;
return
message
(
$html
,
$title
,
201
,
1
);
}
}
}
...
...
platform/AliyunFC.php
浏览文件 @
f2ee21b6
...
...
@@ -497,3 +497,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) {
}
return
true
;
}
function
WaitFunction
()
{
return
true
;
}
platform/BaiduCFC.php
浏览文件 @
f2ee21b6
...
...
@@ -431,3 +431,7 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@
closedir
(
$path
);
}
function
WaitFunction
()
{
return
true
;
}
platform/Heroku.php
浏览文件 @
f2ee21b6
<?php
// https://devcenter.heroku.com/articles/platform-api-reference#build-create
function
getpath
()
{
...
...
@@ -339,3 +340,7 @@ function setConfigResponse($response)
{
return
json_decode
(
$response
[
'body'
],
true
);
}
function
WaitFunction
()
{
return
true
;
}
platform/HuaweiFG_env.php
浏览文件 @
f2ee21b6
...
...
@@ -487,3 +487,7 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@
closedir
(
$path
);
}
function
WaitFunction
()
{
return
true
;
}
platform/HuaweiFG_file.php
浏览文件 @
f2ee21b6
...
...
@@ -868,3 +868,7 @@ class Signer
return
$curl
;
}
}
function
WaitFunction
()
{
return
true
;
}
platform/Normal.php
浏览文件 @
f2ee21b6
...
...
@@ -246,7 +246,7 @@ function install()
document.getElementById("submitbtn").disabled = false;
document.getElementById("formdiv").style.display = "";
} else {
alert("Url: " + url + "\nExpect http code 201, but received " + xhr4.status);
alert("
'
.
getconstStr
(
'MakesuerRewriteOn'
)
.
'?\nfalse\n\n
Url: " + url + "\nExpect http code 201, but received " + xhr4.status);
}
}
}
...
...
@@ -385,3 +385,7 @@ function moveFolder($from, $to, $slash)
rmdir
(
$from
);
return
json_encode
(
[
'response'
=>
'success'
]
);
}
function
WaitFunction
()
{
return
true
;
}
platform/TencentSCF_env.php
浏览文件 @
f2ee21b6
...
...
@@ -454,6 +454,14 @@ function setConfigResponse($response)
return
json_decode
(
$response
,
true
)[
'Response'
];
}
function
WaitFunction
()
{
//$trynum = 0;
//while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
//'.++$trynum;
if
(
json_decode
(
getfunctioninfo
(
$_SERVER
[
'function_name'
],
$_SERVER
[
'Region'
],
$_SERVER
[
'namespace'
],
getConfig
(
'SecretId'
),
getConfig
(
'SecretKey'
)),
true
)[
'Response'
][
'Status'
]
==
'Active'
)
return
true
;
else
return
false
;
}
function
updateProgram
(
$function_name
,
$Region
,
$Namespace
,
$SecretId
,
$SecretKey
,
$source
)
{
$secretId
=
$SecretId
;
...
...
platform/TencentSCF_file.php
浏览文件 @
f2ee21b6
...
...
@@ -645,3 +645,8 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@
closedir
(
$path
);
}
function
WaitFunction
()
{
if
(
json_decode
(
getfunctioninfo
(
$_SERVER
[
'function_name'
],
$_SERVER
[
'Region'
],
$_SERVER
[
'namespace'
],
getConfig
(
'SecretId'
),
getConfig
(
'SecretKey'
)),
true
)[
'Response'
][
'Status'
]
==
'Active'
)
return
true
;
else
return
false
;
}
platform/Vercel.php
浏览文件 @
f2ee21b6
...
...
@@ -112,7 +112,9 @@ function setConfig($arr, $disktag = '')
$operatedisk
=
1
;
}
elseif
(
$k
==
'disktag_copy'
)
{
$newtag
=
$v
.
'_'
.
date
(
"Ymd_His"
);
$tmp
[
$newtag
]
=
getConfig
(
$v
);
$tagvalue
=
getConfig
(
$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'
)
{
...
...
@@ -134,7 +136,9 @@ function setConfig($arr, $disktag = '')
else
array_push
(
$tags
,
$tag
);
}
$tmp
[
'disktag'
]
=
implode
(
'|'
,
$tags
);
$tmp
[
$arr
[
'disktag_newname'
]]
=
getConfig
(
$arr
[
'disktag_rename'
]);
$tagvalue
=
getConfig
(
$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
);
...
...
@@ -157,15 +161,13 @@ function install()
$tmp
[
'admin'
]
=
$_POST
[
'admin'
];
//$tmp['language'] = $_POST['language'];
$tmp
[
'timezone'
]
=
$_COOKIE
[
'timezone'
];
$APIKey
=
getConfig
(
'APIKey'
);
if
(
$APIKey
==
''
)
{
$APIKey
=
$_POST
[
'APIKey'
];
//if ($APIKey=='') {
// $APIKey = getConfig('APIKey');
//}
$tmp
[
'APIKey'
]
=
$APIKey
;
}
$projectPath
=
splitlast
(
__DIR__
,
"/"
)[
0
];
//$html .= file_get_contents($projectPath . "/.data/config.php") . "<br>";GET /v5/now/deployments /v8/projects/:id/env
$token
=
$tmp
[
'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
);
...
...
@@ -173,33 +175,25 @@ function install()
foreach
(
$aliases
[
"aliases"
]
as
$key
=>
$aliase
)
{
if
(
$host
==
$aliase
[
"alias"
])
$projectId
=
$aliase
[
"projectId"
];
}
//$envs = json_decode(curl("GET", "https://api.vercel.com/v8/projects/" . $projectId . "/env", "", $header)['body'], true);
$tmp
[
'HerokuappId'
]
=
$projectId
;
$response
=
json_decode
(
setVercelConfig
(
$tmp
,
$projectId
,
$APIKey
)[
'body'
],
true
);
$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
{
return
output
(
'<span id="displayBox"></span
>
<script>
/*$html = '<script
>
var status = "' . $response['status'] . '";
var expd = new Date();
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
x = 30;
function countSecond()
{
x--;
document.getElementById("displayBox").innerHTML = x;
if (x>0) setTimeout("countSecond()", 1000);
}
// 执行函数
countSecond();
</script>
<meta http-equiv="refresh" content="30;URL='
.
path_format
(
$_SERVER
[
'base_path'
]
.
'/'
)
.
'">'
,
302
);
</script>';
return message($html, $title, 201, 1);*/
$data
[
"dplId"
]
=
$response
[
'status'
];
return
output
(
json_encode
(
$data
),
201
);
}
return
message
(
$html
,
$title
,
201
);
}
}
if
(
$_GET
[
'install0'
])
{
...
...
@@ -210,14 +204,16 @@ 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
.
=
'
//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="
text" placeholder="" size="
"></label><br>'
;
<label>Token:<input name="APIKey" type="
password" placeholder="" value="'
.
getConfig
(
'APIKey'
)
.
'
"></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;
...
...
@@ -225,6 +221,7 @@ language:<br>';
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();
...
...
@@ -238,14 +235,57 @@ language:<br>';
if (t.admin.value==\'\') {
alert(\'input admin\');
return false;
}'
;
if
(
getConfig
(
'APIKey'
)
==
''
)
$html
.
=
'
}
if (t.APIKey.value==\'\') {
alert(\'input API Key\');
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;
}'
;
$html
.
=
'
return true;
}
</script>'
;
$title
=
getconstStr
(
'SelectLanguage'
);
...
...
@@ -310,7 +350,9 @@ function VercelUpdate($appId, $token, $sourcePath = "")
//echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>";
$response
=
curl
(
"POST"
,
$url
,
json_encode
(
$data
),
$header
);
return
$response
[
"body"
];
$result
=
json_decode
(
$response
[
"body"
],
true
);
$result
[
'status'
]
=
$result
[
'id'
];
return
json_encode
(
$result
);
}
function
getEachFiles
(
&
$file
,
$base
,
$path
=
""
)
...
...
@@ -385,3 +427,19 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
return
VercelUpdate
(
getConfig
(
'HerokuappId'
),
getConfig
(
'APIKey'
),
$outPath
);
}
function
WaitFunction
(
$deployid
)
{
$header
[
"Authorization"
]
=
"Bearer "
.
getConfig
(
'APIKey'
);
$header
[
"Content-Type"
]
=
"application/json"
;
$url
=
"https://api.vercel.com/v11/now/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
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录