add setup=auth

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

View File

@ -1,4 +1,6 @@
<?php <?php
// https://cloud.baidu.com/doc/CFC/s/jjwvz45ex
// https://cloud.baidu.com/doc/CFC/s/2jwvz44ns
function printInput($event, $context) function printInput($event, $context)
{ {
@ -164,16 +166,16 @@ function install()
} }
if ($_GET['install1']) { if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$SecretId = getConfig('SecretId'); //$SecretId = getConfig('SecretId');
if ($SecretId=='') { //if ($SecretId=='') {
$SecretId = $_POST['SecretId']; $SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId; $tmp['SecretId'] = $SecretId;
} //}
$SecretKey = getConfig('SecretKey'); //$SecretKey = getConfig('SecretKey');
if ($SecretKey=='') { //if ($SecretKey=='') {
$SecretKey = $_POST['SecretKey']; $SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey; $tmp['SecretKey'] = $SecretKey;
} //}
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey)); $response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
@ -207,12 +209,13 @@ 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('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
<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>';
$html .= ' $html .= '
<input type="submit" value="'.getconstStr('Submit').'"> <a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">' . getconstStr('Create') . ' Access Key & Secret Key</a><br>
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>Secret Key:<input name="SecretKey" type="password" placeholder="" size=""></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form> </form>
<script> <script>
var nowtime= new Date(); var nowtime= new Date();
@ -231,7 +234,8 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
if (t.SecretId.value==\'\') { if (t.SecretId.value==\'\') {
alert(\'input Access Key\'); alert(\'input Access Key\');
return false; return false;
@ -434,3 +438,54 @@ function addFileToZip($zip, $rootpath, $path = '')
function WaitFunction() { function WaitFunction() {
return true; 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);
}