add setup=auth

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

View File

@ -1,4 +1,7 @@
<?php <?php
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0110.html
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0111.html
global $contextUserData; global $contextUserData;
function printInput($event, $context) function printInput($event, $context)
@ -190,18 +193,9 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = getConfig('HW_urn'); $tmp['HW_urn'] = $_POST['HW_urn'];
if ($tmp['HW_urn']=='') { $tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_urn'] = $_POST['HW_urn']; $tmp['HW_secret'] = $_POST['HW_secret'];
}
$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']; $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response']; //$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']) ); $response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
@ -243,13 +237,14 @@ 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('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= ' //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
在函数代码操作页上方找到URN鼠标放上去后显示URN复制填入<br> 在函数代码操作页上方找到URN鼠标放上去后显示URN复制填入<br>
<label>URN:<input name="HW_urn" type="text" placeholder="" size=""></label><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>,新增访问密钥, <a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息填入<br> 在下载的credentials.csv文件中找到对应信息填入<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><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 .= ' $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'==$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>'; <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 +268,8 @@ language:<br>';
} }
function notnull(t) 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==\'\') { if (t.HW_urn.value==\'\') {
alert(\'input URN\'); alert(\'input URN\');
return false; return false;
@ -491,3 +487,54 @@ function addFileToZip($zip, $rootpath, $path = '')
function WaitFunction() { function WaitFunction() {
return true; 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);
}