add setup=auth

pull/493/head
qkqpttgf 2021-12-01 14:30:36 +08:00 committed by GitHub
parent 7d56bde181
commit 92d4401070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 65 additions and 13 deletions

View File

@ -170,11 +170,8 @@ function install()
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language']; //$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = getConfig('APIKey'); $APIKey = $_POST['APIKey'];
if ($APIKey=='') { $tmp['APIKey'] = $APIKey;
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
}
$HerokuappId = getConfig('HerokuappId'); $HerokuappId = getConfig('HerokuappId');
if ($HerokuappId=='') { if ($HerokuappId=='') {
$function_name = getConfig('function_name'); $function_name = getConfig('function_name');
@ -197,17 +194,27 @@ function install()
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
$title = 'Error'; $title = 'Error';
return message($html, $title, 400);
} else { } else {
return output('Jump $html = getconstStr('Success') . '
<script> <script>
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> var status = "' . $response['DplStatus'] . '";
<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>';
return message($html, $title, 201, 1);
} }
return message($html, $title, 201);
} }
} }
if ($_GET['install0']) { if ($_GET['install0']) {
@ -218,9 +225,9 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <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> <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 .= ' $html .= '
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>'; <label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= ' $html .= '
@ -247,7 +254,7 @@ language:<br>';
alert(\'input admin\'); alert(\'input admin\');
return false; return false;
}'; }';
if (getConfig('APIKey')=='') $html .= ' $html .= '
if (t.APIKey.value==\'\') { if (t.APIKey.value==\'\') {
alert(\'input API Key\'); alert(\'input API Key\');
return false; return false;
@ -358,3 +365,48 @@ function WaitFunction($buildId = '') {
return $response; 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);
}