mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-02-21 07:17:22 +08:00
修复API接口操作记录报错
This commit is contained in:
parent
684a4e59ce
commit
d368a0190a
@ -536,7 +536,6 @@ class Domain extends BaseController
|
||||
$remark = input('post.remark', null, 'trim');
|
||||
|
||||
$recordinfo = input('post.recordinfo', null, 'trim');
|
||||
$recordinfo = json_decode($recordinfo, true);
|
||||
|
||||
if (empty($recordid) || empty($name) || empty($type) || empty($value)) {
|
||||
return json(['code' => -1, 'msg' => '参数不能为空']);
|
||||
@ -546,6 +545,7 @@ class Domain extends BaseController
|
||||
$recordid = $dns->updateDomainRecord($recordid, $name, $type, $value, $line, $ttl, $mx, $weight, $remark);
|
||||
if ($recordid) {
|
||||
if ($recordinfo) {
|
||||
$recordinfo = json_decode($recordinfo, true);
|
||||
if (is_array($recordinfo['Value'])) $recordinfo['Value'] = implode(',', $recordinfo['Value']);
|
||||
if ($recordinfo['Name'] != $name || $recordinfo['Type'] != $type || $recordinfo['Value'] != $value) {
|
||||
$this->add_log($drow['name'], '修改解析', $recordinfo['Name'].' ['.$recordinfo['Type'].'] '.$recordinfo['Value'].' → '.$name.' ['.$type.'] '.$value.' (线路:'.$line.' TTL:'.$ttl.')');
|
||||
@ -572,7 +572,6 @@ class Domain extends BaseController
|
||||
|
||||
$recordid = input('post.recordid', null, 'trim');
|
||||
$recordinfo = input('post.recordinfo', null, 'trim');
|
||||
$recordinfo = json_decode($recordinfo, true);
|
||||
|
||||
if (empty($recordid)) {
|
||||
return json(['code' => -1, 'msg' => '参数不能为空']);
|
||||
@ -581,6 +580,7 @@ class Domain extends BaseController
|
||||
$dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']);
|
||||
if ($dns->deleteDomainRecord($recordid)) {
|
||||
if ($recordinfo) {
|
||||
$recordinfo = json_decode($recordinfo, true);
|
||||
if (is_array($recordinfo['Value'])) $recordinfo['Value'] = implode(',', $recordinfo['Value']);
|
||||
$this->add_log($drow['name'], '删除解析', $recordinfo['Name'].' ['.$recordinfo['Type'].'] '.$recordinfo['Value'].' (线路:'.$recordinfo['Line'].' TTL:'.$recordinfo['TTL'].')');
|
||||
} else {
|
||||
@ -604,7 +604,6 @@ class Domain extends BaseController
|
||||
$recordid = input('post.recordid', null, 'trim');
|
||||
$status = input('post.status', null, 'trim');
|
||||
$recordinfo = input('post.recordinfo', null, 'trim');
|
||||
$recordinfo = json_decode($recordinfo, true);
|
||||
|
||||
if (empty($recordid)) {
|
||||
return json(['code' => -1, 'msg' => '参数不能为空']);
|
||||
@ -614,6 +613,7 @@ class Domain extends BaseController
|
||||
if ($dns->setDomainRecordStatus($recordid, $status)) {
|
||||
$action = $status == '1' ? '启用解析' : '暂停解析';
|
||||
if ($recordinfo) {
|
||||
$recordinfo = json_decode($recordinfo, true);
|
||||
if (is_array($recordinfo['Value'])) $recordinfo['Value'] = implode(',', $recordinfo['Value']);
|
||||
$this->add_log($drow['name'], $action, $recordinfo['Name'].' ['.$recordinfo['Type'].'] '.$recordinfo['Value'].' (线路:'.$recordinfo['Line'].' TTL:'.$recordinfo['TTL'].')');
|
||||
} else {
|
||||
|
||||
@ -168,10 +168,10 @@ class aliyun implements DeployInterface
|
||||
$sitename = $config['esa_sitename'];
|
||||
if (empty($sitename)) throw new Exception('ESA站点名称不能为空');
|
||||
|
||||
if ($config['region'] == 'cn-hangzhou') {
|
||||
$endpoint = 'esa.cn-hangzhou.aliyuncs.com';
|
||||
} else {
|
||||
if ($config['region'] == 'ap-southeast-1') {
|
||||
$endpoint = 'esa.ap-southeast-1.aliyuncs.com';
|
||||
} else {
|
||||
$endpoint = 'esa.cn-hangzhou.aliyuncs.com';
|
||||
}
|
||||
|
||||
$client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2024-09-10');
|
||||
|
||||
@ -127,7 +127,14 @@ class CheckUtils
|
||||
}
|
||||
$timeout = 1;
|
||||
exec('ping -c 1 -w '.$timeout.' '.$target, $output, $return_var);
|
||||
$usetime = !empty($output[1]) ? round(getSubstr($output[1], 'time=', ' ms')) : 0;
|
||||
if (!empty($output[1])) {
|
||||
if (strpos($output[1], '毫秒') !== false) {
|
||||
$usetime = getSubstr($output[1], '时间=', ' 毫秒');
|
||||
} else {
|
||||
$usetime = getSubstr($output[1], 'time=', ' ms');
|
||||
}
|
||||
}
|
||||
$usetime = !empty($usetime) ? round(trim($usetime)) : 0;
|
||||
$errmsg = null;
|
||||
if ($return_var !== 0) {
|
||||
$usetime = $usetime == 0 ? $timeout * 1000 : $usetime;
|
||||
|
||||
@ -7,21 +7,21 @@
|
||||
<div class="panel-heading"><h3 class="panel-title">修改密码</h3></div>
|
||||
<div class="panel-body">
|
||||
<form onsubmit="return saveAccount(this)" method="post" class="form" role="form">
|
||||
<div class="form-group">
|
||||
<label>旧密码:</label>
|
||||
<input type="password" name="oldpwd" value="" class="form-control" placeholder="请输入当前的密码" required/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>旧密码:</label>
|
||||
<input type="password" name="oldpwd" value="" class="form-control" placeholder="请输入当前的密码" required/>
|
||||
</div>
|
||||
<label>新密码:</label>
|
||||
<input type="password" name="newpwd" value="" class="form-control" placeholder="" required/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>新密码:</label>
|
||||
<input type="password" name="newpwd" value="" class="form-control" placeholder="" required/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>重输密码:</label>
|
||||
<input type="password" name="newpwd2" value="" class="form-control" placeholder="" required/>
|
||||
</div>
|
||||
<div class="form-group text-center">
|
||||
<input type="submit" name="submit" value="确定" class="btn btn-success btn-block"/>
|
||||
</div>
|
||||
<label>重输密码:</label>
|
||||
<input type="password" name="newpwd2" value="" class="form-control" placeholder="" required/>
|
||||
</div>
|
||||
<div class="form-group text-center">
|
||||
<input type="submit" name="submit" value="确定" class="btn btn-success btn-block"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -29,18 +29,18 @@
|
||||
<div class="panel-heading"><h3 class="panel-title">TOTP二次验证</h3></div>
|
||||
<div class="panel-body">
|
||||
<form onsubmit="return saveAccount(this)" method="post" class="form" role="form">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
{if $user.totp_open == 1}
|
||||
<input type="text" name="totp_status" value="已开启" style="color:green" class="form-control" readonly/>
|
||||
<div class="input-group-btn"><button type="button" class="btn btn-info" onclick="open_totp()">重置</button></div>
|
||||
<div class="input-group-btn"><button type="button" class="btn btn-danger" onclick="close_totp()">关闭</button></div>
|
||||
{else}
|
||||
<input type="text" name="totp_status" value="未开启" style="color:blue" class="form-control" readonly/>
|
||||
<div class="input-group-btn"><button type="button" class="btn btn-info" onclick="open_totp()">开启</button></div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
{if $user.totp_open == 1}
|
||||
<input type="text" name="totp_status" value="已开启" style="color:green" class="form-control" readonly/>
|
||||
<div class="input-group-btn"><button type="button" class="btn btn-info" onclick="open_totp()">重置</button></div>
|
||||
<div class="input-group-btn"><button type="button" class="btn btn-danger" onclick="close_totp()">关闭</button></div>
|
||||
{else}
|
||||
<input type="text" name="totp_status" value="未开启" style="color:blue" class="form-control" readonly/>
|
||||
<div class="input-group-btn"><button type="button" class="btn btn-info" onclick="open_totp()">开启</button></div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
@ -49,26 +49,26 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal" id="modal-totp" data-backdrop="static" data-keyboard="false" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title">TOTP绑定</h4>
|
||||
</div>
|
||||
<div class="modal-body text-center">
|
||||
<p>使用支持TOTP的认证软件扫描以下二维码</p>
|
||||
<div class="qr-image mt-4" id="qrcode"></div>
|
||||
<p><a href="javascript:;" data-clipboard-text="" id="copy-btn">复制密钥</a></p>
|
||||
<form id="form-totp" style="text-align: left;" onsubmit="return bind_totp()">
|
||||
<div class="form-group mt-4">
|
||||
<div class="input-group"><input type="number" class="form-control input-lg" name="code" id="code" value="" placeholder="填写动态口令" autocomplete="off" required><div class="input-group-btn"><input type="submit" name="submit" value="完成绑定" class="btn btn-success btn-lg btn-block"/></div></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title">TOTP绑定</h4>
|
||||
</div>
|
||||
<div class="modal-body text-center">
|
||||
<p>使用支持TOTP的认证软件扫描以下二维码</p>
|
||||
<div class="qr-image mt-4" id="qrcode"></div>
|
||||
<p><a href="javascript:;" data-clipboard-text="" id="copy-btn">复制密钥</a></p>
|
||||
<form id="form-totp" style="text-align: left;" onsubmit="return bind_totp()">
|
||||
<div class="form-group mt-4">
|
||||
<div class="input-group"><input type="number" class="form-control input-lg" name="code" id="code" value="" placeholder="填写动态口令" autocomplete="off" required><div class="input-group-btn"><input type="submit" name="submit" value="完成绑定" class="btn btn-success btn-lg btn-block"/></div></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
@ -78,110 +78,110 @@
|
||||
<script>
|
||||
var commonData = {secret:null,qrcode:null};
|
||||
function saveAccount(obj){
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : '/setpwd',
|
||||
data : $(obj).serialize(),
|
||||
dataType : 'json',
|
||||
success : function(data) {
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : '/setpwd',
|
||||
data : $(obj).serialize(),
|
||||
dataType : 'json',
|
||||
success : function(data) {
|
||||
layer.close(ii);
|
||||
if(data.code == 0){
|
||||
layer.alert('密码修改成功!请重新登录。', {
|
||||
icon: 1,
|
||||
closeBtn: false
|
||||
}, function(){
|
||||
window.location.reload()
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
}
|
||||
},
|
||||
error:function(data){
|
||||
layer.close(ii);
|
||||
if(data.code == 0){
|
||||
layer.alert('密码修改成功!请重新登录。', {
|
||||
icon: 1,
|
||||
closeBtn: false
|
||||
}, function(){
|
||||
window.location.reload()
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
}
|
||||
},
|
||||
error:function(data){
|
||||
layer.close(ii);
|
||||
layer.msg('服务器错误');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
layer.msg('服务器错误');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function open_totp(){
|
||||
if(!commonData.qrcode || !commonData.secret){
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.post('/totp/generate', {}, function(res){
|
||||
layer.close(ii);
|
||||
if(res.code == 0){
|
||||
commonData.secret = res.data.secret;
|
||||
commonData.qrcode = res.data.qrcode;
|
||||
$('#qrcode').qrcode({
|
||||
text: commonData.qrcode,
|
||||
width: 150,
|
||||
height: 150,
|
||||
foreground: "#000000",
|
||||
background: "#ffffff",
|
||||
typeNumber: -1
|
||||
});
|
||||
$("#copy-btn").attr('data-clipboard-text', commonData.secret);
|
||||
$('#modal-totp').modal('show');
|
||||
$("#code").focus();
|
||||
}else{
|
||||
layer.alert(res.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$('#modal-totp').modal('show');
|
||||
$("#code").focus();
|
||||
}
|
||||
if(!commonData.qrcode || !commonData.secret){
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.post('/totp/generate', {}, function(res){
|
||||
layer.close(ii);
|
||||
if(res.code == 0){
|
||||
commonData.secret = res.data.secret;
|
||||
commonData.qrcode = res.data.qrcode;
|
||||
$('#qrcode').qrcode({
|
||||
text: commonData.qrcode,
|
||||
width: 150,
|
||||
height: 150,
|
||||
foreground: "#000000",
|
||||
background: "#ffffff",
|
||||
typeNumber: -1
|
||||
});
|
||||
$("#copy-btn").attr('data-clipboard-text', commonData.secret);
|
||||
$('#modal-totp').modal('show');
|
||||
$("#code").focus();
|
||||
}else{
|
||||
layer.alert(res.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$('#modal-totp').modal('show');
|
||||
$("#code").focus();
|
||||
}
|
||||
}
|
||||
function bind_totp(){
|
||||
var code = $("#code").val();
|
||||
if(code.length != 6){
|
||||
layer.msg('动态口令格式错误', {icon: 2});
|
||||
return false;
|
||||
}
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.post('/totp/bind', {secret:commonData.secret, code:code}, function(res){
|
||||
layer.close(ii);
|
||||
if(res.code == 0){
|
||||
layer.alert('TOTP绑定成功', {icon: 1}, function(){
|
||||
window.location.reload();
|
||||
});
|
||||
}else{
|
||||
layer.alert(res.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
var code = $("#code").val();
|
||||
if(code.length != 6){
|
||||
layer.msg('动态口令格式错误', {icon: 2});
|
||||
return false;
|
||||
}
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.post('/totp/bind', {secret:commonData.secret, code:code}, function(res){
|
||||
layer.close(ii);
|
||||
if(res.code == 0){
|
||||
layer.alert('TOTP绑定成功', {icon: 1}, function(){
|
||||
window.location.reload();
|
||||
});
|
||||
}else{
|
||||
layer.alert(res.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function close_totp(){
|
||||
layer.confirm('确定要关闭TOTP二次验证吗?', {
|
||||
btn: ['确定','取消']
|
||||
}, function(){
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.post('/totp/close', {}, function(res){
|
||||
layer.close(ii);
|
||||
if(res.code == 0){
|
||||
layer.alert('TOTP已关闭', {icon: 1}, function(){
|
||||
window.location.reload();
|
||||
});
|
||||
}else{
|
||||
layer.alert(res.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
});
|
||||
layer.confirm('确定要关闭TOTP二次验证吗?', {
|
||||
btn: ['确定','取消']
|
||||
}, function(){
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.post('/totp/close', {}, function(res){
|
||||
layer.close(ii);
|
||||
if(res.code == 0){
|
||||
layer.alert('TOTP已关闭', {icon: 1}, function(){
|
||||
window.location.reload();
|
||||
});
|
||||
}else{
|
||||
layer.alert(res.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
$(document).ready(function(){
|
||||
var clipboard = new Clipboard('#copy-btn');
|
||||
clipboard.on('success', function (e) {
|
||||
layer.msg('复制成功!', {icon: 1, time: 600});
|
||||
});
|
||||
clipboard.on('error', function (e) {
|
||||
layer.msg('复制失败', {icon: 2});
|
||||
});
|
||||
$("#code").keyup(function(){
|
||||
var code = $(this).val();
|
||||
if(code.length == 6){
|
||||
$("#form-totp").submit();
|
||||
}
|
||||
});
|
||||
var clipboard = new Clipboard('#copy-btn');
|
||||
clipboard.on('success', function (e) {
|
||||
layer.msg('复制成功!', {icon: 1, time: 600});
|
||||
});
|
||||
clipboard.on('error', function (e) {
|
||||
layer.msg('复制失败', {icon: 2});
|
||||
});
|
||||
$("#code").keyup(function(){
|
||||
var code = $(this).val();
|
||||
if(code.length == 6){
|
||||
$("#form-totp").submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
2
composer.lock
generated
2
composer.lock
generated
@ -1878,5 +1878,5 @@
|
||||
"ext-ssh2": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user