fix error in wait function

pull/427/head
root 2021-08-26 10:09:57 +00:00
parent b6860e373a
commit bdfee2c81b
6 changed files with 30 additions and 20 deletions

View File

@ -837,7 +837,7 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
x += "."; x += ".";
min++; min++;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var url = "?WaitFunction" + (status!=""?"=" + status:""); var url = "?WaitFunction=" + (status!=""?status:"1");
xhr.open("GET", url); xhr.open("GET", url);
//xhr.setRequestHeader("Authorization", "Bearer "); //xhr.setRequestHeader("Authorization", "Bearer ");
xhr.onload = function(e) { xhr.onload = function(e) {
@ -862,7 +862,6 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
xhr.send(null); xhr.send(null);
} }
getStatus(); getStatus();
//setTimeout(function() { getStatus() }, 3000);
</script>'; </script>';
} else { } else {
$html .= ' $html .= '
@ -1167,7 +1166,7 @@ function EnvOpt($needUpdate = 0)
return message($html, $title, 400); return message($html, $title, 400);
} else { } else {
//WaitSCFStat(); //WaitSCFStat();
$html .= getconstStr('UpdateSuccess') . '<br><a href="">' . getconstStr('Back') . '</a><script>var status = "' . $response['status'] . '";</script>'; $html .= getconstStr('UpdateSuccess') . '<br><a href="">' . getconstStr('Back') . '</a><script>var status = "' . $response['DplStatus'] . '";</script>';
$title = getconstStr('Setup'); $title = getconstStr('Setup');
return message($html, $title, 202, 1); return message($html, $title, 202, 1);
} }
@ -1217,7 +1216,7 @@ function EnvOpt($needUpdate = 0)
$html .= getconstStr('Success') . '!<br> $html .= getconstStr('Success') . '!<br>
<a href="">' . getconstStr('Back') . '</a> <a href="">' . getconstStr('Back') . '</a>
<script> <script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
</script>'; </script>';
$title = getconstStr('Setup'); $title = getconstStr('Setup');
return message($html, $title, 200, 1); return message($html, $title, 200, 1);
@ -1293,7 +1292,7 @@ function EnvOpt($needUpdate = 0)
if (api_error($response)) { if (api_error($response)) {
return message(api_error_msg($response) . "<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403); return message(api_error_msg($response) . "<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403);
} else { } else {
return message("Success<a href=\"\">" . getconstStr('Back') . "</a><script>var status = \"" . $response['status'] . "\";</script>", "Success", 200, 1); return message("Success<a href=\"\">" . getconstStr('Back') . "</a><script>var status = \"" . $response['DplStatus'] . "\";</script>", "Success", 200, 1);
} }
} else { } else {
return message("Old pass error<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403); return message("Old pass error<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403);

View File

@ -631,7 +631,7 @@ class Aliyundrive {
} else { } else {
$str .= ' $str .= '
<script> <script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(min++); console.log(min++);
@ -702,7 +702,7 @@ class Aliyundrive {
</form> </form>
</div> </div>
<script> <script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
function notnull(t) function notnull(t)
{ {
if (t.driveId.value==\'\') { if (t.driveId.value==\'\') {
@ -768,7 +768,7 @@ class Aliyundrive {
} }
return true; return true;
} }
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
</script> </script>
'; ';
return message($html, $title, 201, 1); return message($html, $title, 201, 1);

View File

@ -510,7 +510,7 @@ class Onedrive {
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'disktag=; path=/; \'+expires; document.cookie=\'disktag=; path=/; \'+expires;
var i = 0; var i = 0;
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(i++); console.log(i++);
@ -618,7 +618,7 @@ class Onedrive {
savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60); savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60);
$html .= '<script> $html .= '<script>
var i = 0; var i = 0;
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(i++); console.log(i++);
@ -699,7 +699,7 @@ class Onedrive {
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=' . $_POST['Drive_ver'];
$html .= '<script> $html .= '<script>
var i = 0; var i = 0;
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(i++); console.log(i++);

View File

@ -315,7 +315,7 @@ function updateHerokuapp($HerokuappId, $apikey, $source)
$data = json_encode($tmp); $data = json_encode($tmp);
$response = 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 = json_decode( $response['body'], true );
$result['status'] = $result['id']; $result['DplStatus'] = $result['id'];
$response['body'] = json_encode($result); $response['body'] = json_encode($result);
return $response; return $response;
} }
@ -345,8 +345,9 @@ function setConfigResponse($response)
return json_decode( $response['body'], true ); return json_decode( $response['body'], true );
} }
function WaitFunction($buildId) { function WaitFunction($buildId = '') {
// GET /apps/{app_id_or_name}/builds/{build_id} // 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')); $response = HerokuAPI('GET', 'https://api.heroku.com/apps/' . getConfig('HerokuappId') . '/builds/' . $buildId, '', getConfig('APIKey'));
if ($response['stat']==200) { if ($response['stat']==200) {
$result = json_decode($response['body'], true); $result = json_decode($response['body'], true);

View File

@ -187,14 +187,14 @@ function install()
return message($html, $title, 400); return message($html, $title, 400);
} else { } else {
/*$html = '<script> /*$html = '<script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1000); expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script>'; </script>';
return message($html, $title, 201, 1);*/ return message($html, $title, 201, 1);*/
$data["dplId"] = $response['status']; $data["dplId"] = $response['DplStatus'];
return output(json_encode($data), 201); return output(json_encode($data), 201);
} }
} }
@ -362,7 +362,7 @@ function VercelUpdate($appId, $token, $sourcePath = "")
$response = curl("POST", $url, json_encode($data), $header); $response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>"; //echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true); $result = json_decode($response["body"], true);
$result['status'] = $result['id']; $result['DplStatus'] = $result['id'];
return json_encode($result); return json_encode($result);
} }
@ -444,7 +444,12 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath); 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["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json"; $header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/now/deployments/" . $deployid; $url = "https://api.vercel.com/v11/now/deployments/" . $deployid;

View File

@ -185,14 +185,14 @@ function install()
return message($html, $title, 400); return message($html, $title, 400);
} else { } else {
/*$html = '<script> /*$html = '<script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1000); expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script>'; </script>';
return message($html, $title, 201, 1);*/ return message($html, $title, 201, 1);*/
$data["dplId"] = $response['status']; $data["dplId"] = $response['DplStatus'];
return output(json_encode($data), 201); return output(json_encode($data), 201);
} }
} }
@ -353,7 +353,7 @@ function VercelUpdate($appId, $token, $sourcePath = "")
$response = curl("POST", $url, json_encode($data), $header); $response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>"; //echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true); $result = json_decode($response["body"], true);
$result['status'] = $result['id']; $result['DplStatus'] = $result['id'];
return json_encode($result); return json_encode($result);
} }
@ -431,6 +431,11 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
} }
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["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json"; $header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/now/deployments/" . $deployid; $url = "https://api.vercel.com/v11/now/deployments/" . $deployid;