mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-07-09 09:17:26 +08:00
阿里云腾讯云DNS支持解析记录分组
This commit is contained in:
@@ -771,6 +771,18 @@ class Domain extends BaseController
|
||||
}
|
||||
}
|
||||
$msg = '批量修改备注,成功' . $success . '条,失败' . $fail . '条';
|
||||
} else if ($action == 'group') {
|
||||
$dnstype = Db::name('account')->where('id', $drow['aid'])->value('type');
|
||||
if (!in_array($dnstype, ['aliyun', 'dnspod'])) {
|
||||
return json(['code' => -1, 'msg' => '该DNS类型不支持分组']);
|
||||
}
|
||||
$groupid = input('post.groupid', '', 'trim');
|
||||
$recordIdList = array_column($recordinfo, 'RecordId');
|
||||
if ($dns->changeRecordGroup($recordIdList, $groupid)) {
|
||||
$msg = '成功修改' . count($recordIdList) . '条记录的分组';
|
||||
} else {
|
||||
return json(['code' => -1, 'msg' => '修改分组失败,' . $dns->getError()]);
|
||||
}
|
||||
}
|
||||
return json(['code' => 0, 'msg' => $msg]);
|
||||
}
|
||||
@@ -1078,6 +1090,38 @@ class Domain extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function record_groups()
|
||||
{
|
||||
$id = input('param.id/d');
|
||||
$drow = Db::name('domain')->where('id', $id)->find();
|
||||
if (!$drow) {
|
||||
return json(['code' => -1, 'msg' => '域名不存在']);
|
||||
}
|
||||
if (!checkPermission(0, $drow['name'])) return json(['code' => -1, 'msg' => '无权限']);
|
||||
|
||||
$dnstype = Db::name('account')->where('id', $drow['aid'])->value('type');
|
||||
if (!in_array($dnstype, ['aliyun', 'dnspod'])) {
|
||||
return json(['code' => -1, 'msg' => '该DNS类型不支持分组']);
|
||||
}
|
||||
|
||||
$dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']);
|
||||
$groups = $dns->getRecordGroups();
|
||||
if ($groups === false) {
|
||||
return json(['code' => -1, 'msg' => '获取分组列表失败,' . $dns->getError()]);
|
||||
}
|
||||
$groupList = [];
|
||||
if ($dnstype == 'dnspod') {
|
||||
$groupList[] = ['id' => '', 'name' => '全部记录'];
|
||||
}
|
||||
foreach ($groups as $group) {
|
||||
$groupList[] = [
|
||||
'id' => $group['GroupId'],
|
||||
'name' => $group['GroupName'] . (isset($group['RecordCount']) ? '(' . $group['RecordCount'] . ')' : ''),
|
||||
];
|
||||
}
|
||||
return json(['code' => 0, 'data' => $groupList]);
|
||||
}
|
||||
|
||||
private function add_log($domain, $action, $data)
|
||||
{
|
||||
if (strlen($data) > 500) $data = substr($data, 0, 500);
|
||||
|
||||
+23
-1
@@ -72,6 +72,10 @@ class aliyun implements DnsInterface
|
||||
$Status = $Status == '1' ? 'Enable' : 'Disable';
|
||||
$param += ['Status' => $Status];
|
||||
}
|
||||
$groupid = request()->post('groupid');
|
||||
if (!empty($groupid)) {
|
||||
$param += ['GroupId' => $groupid];
|
||||
}
|
||||
$data = $this->request($param, true);
|
||||
if ($data) {
|
||||
$list = [];
|
||||
@@ -234,7 +238,7 @@ class aliyun implements DnsInterface
|
||||
public function getDomainInfo()
|
||||
{
|
||||
if (!empty($this->domainInfo)) return $this->domainInfo;
|
||||
$param = ['Action' => 'DescribeDomainInfo', 'DomainName' => $this->domain, 'NeedDetailAttributes' => 'true'];
|
||||
$param = ['Action' => 'DescribeDomainInfo', 'DomainName' => $this->domain, 'NeedDetailAttributes' => 'true', 'Lang' => 'zh'];
|
||||
$data = $this->request($param, true);
|
||||
if ($data) {
|
||||
$this->domainInfo = $data;
|
||||
@@ -253,6 +257,24 @@ class aliyun implements DnsInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取解析记录分组列表
|
||||
public function getRecordGroups()
|
||||
{
|
||||
$param = ['Action' => 'DescribeRecordGroups', 'DomainName' => $this->domain, 'PageSize' => 100, 'Lang' => 'zh'];
|
||||
$data = $this->request($param, true);
|
||||
if ($data) {
|
||||
return $data['RecordGroups']['RecordGroup'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//修改解析记录分组
|
||||
public function changeRecordGroup($RecordIdList, $GroupId)
|
||||
{
|
||||
$param = ['Action' => 'ChangeRecordGroup', 'DomainName' => $this->domain, 'RecordIdList' => json_encode($RecordIdList), 'GroupId' => $GroupId];
|
||||
return $this->request($param);
|
||||
}
|
||||
|
||||
//获取权重配置子域名列表
|
||||
public function getWeightSubDomains($PageNumber = 1, $PageSize = 20, $SubDomain = null)
|
||||
{
|
||||
|
||||
+25
-1
@@ -66,7 +66,8 @@ class dnspod implements DnsInterface
|
||||
public function getDomainRecords($PageNumber = 1, $PageSize = 20, $KeyWord = null, $SubDomain = null, $Value = null, $Type = null, $Line = null, $Status = null)
|
||||
{
|
||||
$offset = ($PageNumber - 1) * $PageSize;
|
||||
if (!isNullOrEmpty($Status) || !isNullOrEmpty($Value)) {
|
||||
$groupid = request()->post('groupid');
|
||||
if (!isNullOrEmpty($Status) || !isNullOrEmpty($Value) || !empty($groupid)) {
|
||||
$action = 'DescribeRecordFilterList';
|
||||
$param = ['Domain' => $this->domain, 'Offset' => $offset, 'Limit' => $PageSize, 'RecordValue' => $Value];
|
||||
if (!isNullOrEmpty($SubDomain)) $param['SubDomain'] = $SubDomain;
|
||||
@@ -78,6 +79,7 @@ class dnspod implements DnsInterface
|
||||
}
|
||||
if (!isNullOrEmpty($Type)) $param['RecordType'] = [$this->convertType($Type)];
|
||||
if (!isNullOrEmpty($Line)) $param['RecordLine'] = [$Line];
|
||||
if (!empty($groupid)) $param['GroupId'] = [intval($groupid)];
|
||||
} else {
|
||||
$action = 'DescribeRecordList';
|
||||
$param = ['Domain' => $this->domain, 'Subdomain' => $SubDomain, 'RecordType' => $this->convertType($Type), 'RecordLineId' => $Line, 'Keyword' => $KeyWord, 'Offset' => $offset, 'Limit' => $PageSize];
|
||||
@@ -365,6 +367,28 @@ class dnspod implements DnsInterface
|
||||
return is_array($data);
|
||||
}
|
||||
|
||||
//获取解析记录分组列表
|
||||
public function getRecordGroups()
|
||||
{
|
||||
$action = 'DescribeRecordGroupList';
|
||||
$param = ['Domain' => $this->domain];
|
||||
$data = $this->send_request($action, $param);
|
||||
if ($data) {
|
||||
return $data['GroupList'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//将记录移动到分组
|
||||
public function changeRecordGroup($RecordIdList, $GroupId)
|
||||
{
|
||||
$action = 'ModifyRecordToGroup';
|
||||
$RecordIdList = implode('|', $RecordIdList);
|
||||
$param = ['Domain' => $this->domain, 'GroupId' => intval($GroupId), 'RecordId' => strval($RecordIdList)];
|
||||
$data = $this->send_request($action, $param);
|
||||
return is_array($data);
|
||||
}
|
||||
|
||||
private function convertLineCode($line)
|
||||
{
|
||||
$convert_dict = ['default' => '0', 'unicom' => '10=1', 'telecom' => '10=0', 'mobile' => '10=3', 'edu' => '10=2', 'oversea' => '3=0', 'btvn' => '10=22', 'search' => '80=0', 'internal' => '7=0'];
|
||||
|
||||
@@ -188,7 +188,7 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:360px;
|
||||
{if $dnsconfig.type=='dnspod'}<a href="/record/alias/{$domainId}" class="btn btn-default">域名别名</a>{/if}
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">批量操作 <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu"><li><a href="/record/batchadd/{$domainId}">添加</a></li><li><a href="javascript:operation('open')">启用</a></li><li><a href="javascript:operation('pause')">暂停</a></li><li><a href="javascript:operation('edit')">修改记录</a></li><li><a href="javascript:operation('editline')">修改线路</a></li>{if $dnsconfig.remark == 1}<li><a href="javascript:operation('editremark')">修改备注</a></li>{/if}<li><a href="javascript:operation('delete')">删除</a></li></ul>
|
||||
<ul class="dropdown-menu"><li><a href="/record/batchadd/{$domainId}">添加</a></li><li><a href="javascript:operation('open')">启用</a></li><li><a href="javascript:operation('pause')">暂停</a></li><li><a href="javascript:operation('edit')">修改记录</a></li><li><a href="javascript:operation('editline')">修改线路</a></li>{if $dnsconfig.remark == 1}<li><a href="javascript:operation('editremark')">修改备注</a></li>{/if}{if $dnsconfig.type=='aliyun' || $dnsconfig.type=='dnspod'}<li><a href="javascript:operation('editgroup')">修改分组</a></li>{/if}<li><a href="javascript:operation('delete')">删除</a></li></ul>
|
||||
</div>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">日志 <span class="caret"></span></button>
|
||||
@@ -223,6 +223,11 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:360px;
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="value" placeholder="输入记录值">
|
||||
</div>
|
||||
{if $dnsconfig.type=='aliyun' || $dnsconfig.type=='dnspod'}
|
||||
<div class="form-group">
|
||||
<select name="groupid" id="groupid" class="form-control"></select>
|
||||
</div>
|
||||
{/if}
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
|
||||
<a href="javascript:searchClear()" class="btn btn-default" title="刷新解析记录列表"><i class="fa fa-refresh"></i> 刷新</a>
|
||||
<a href="javascript:advanceSearch()" class="btn"><i class="fa fa-angle-up"></i> 收起</a>
|
||||
@@ -241,7 +246,7 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:360px;
|
||||
<script src="/static/js/bootstrap-table-1.21.4.min.js"></script>
|
||||
<script src="/static/js/bootstrap-table-page-jump-to-1.21.4.min.js"></script>
|
||||
<script src="/static/js/bootstrapValidator.min.js"></script>
|
||||
<script src="/static/js/custom.js?v=1003"></script>
|
||||
<script src="/static/js/custom.js?v=1004"></script>
|
||||
<script>
|
||||
var recordLine = {$recordLine|json_encode|raw};
|
||||
var dnsconfig = {$dnsconfig|json_encode|raw};
|
||||
@@ -397,6 +402,7 @@ $(document).ready(function(){
|
||||
$("#searchToolbar select[name='line']").append('<option value="'+item.id+'">'+item.name+'</option>');
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
function initLine(option, elem){
|
||||
option = option || '';
|
||||
@@ -588,6 +594,9 @@ function operation(action){
|
||||
}else if(action == 'editremark'){
|
||||
batch_edit_remark(rows)
|
||||
return;
|
||||
}else if(action == 'editgroup'){
|
||||
batch_edit_group(rows)
|
||||
return;
|
||||
}
|
||||
|
||||
layer.confirm('确定要'+(action=='open'?'启用':(action=='pause'?'暂停':'删除'))+'所选记录吗?', {title: '提示', icon: 0}, function(){
|
||||
@@ -714,6 +723,74 @@ function batch_edit_remark(rows) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function batch_edit_group(rows) {
|
||||
var showDialog = function(options){
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['350px'],
|
||||
closeBtn: 2,
|
||||
title: '批量修改分组',
|
||||
content: '<div style="padding:15px"><div class="form-group"><select class="form-control" id="batch_groupid">'+options+'</select></div></div>',
|
||||
btn: ['确认', '取消'],
|
||||
yes: function(){
|
||||
var groupid = $('#batch_groupid').val();
|
||||
var recordIds = rows.map(function(r){ return r.RecordId; });
|
||||
var ii = layer.load(2, {shade:[0.1,'#fff']});
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/record/batch/{$domainId}',
|
||||
data: {action:'group', recordinfo: JSON.stringify(rows), groupid: groupid},
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
layer.close(ii);
|
||||
layer.alert(data.msg, {icon: data.code==0?1:2, closeBtn: false}, function(){
|
||||
layer.closeAll();
|
||||
if(data.code == 0) searchRefresh();
|
||||
groupLoaded = false;
|
||||
});
|
||||
},
|
||||
error: function(){
|
||||
layer.close(ii);
|
||||
layer.msg('服务器错误');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
if(groupLoaded && $('#groupid').length > 0){
|
||||
var options = '';
|
||||
$('#groupid option').each(function(){ options += '<option value="'+$(this).val()+'">'+$(this).text()+'</option>'; });
|
||||
showDialog(options);
|
||||
}else{
|
||||
var ii = layer.load(2);
|
||||
$.post('/record/groups/{$domainId}', function(res){
|
||||
layer.close(ii);
|
||||
if(res.code == 0){
|
||||
var options = '';
|
||||
$.each(res.data, function(i, item){
|
||||
options += '<option value="'+item.id+'">'+item.name+'</option>';
|
||||
});
|
||||
showDialog(options);
|
||||
}else{
|
||||
layer.alert(res.msg, {icon: 2});
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
}
|
||||
var groupLoaded = false;
|
||||
function loadRecordGroups(){
|
||||
if(groupLoaded || (dnsconfig.type != 'aliyun' && dnsconfig.type != 'dnspod')) return;
|
||||
groupLoaded = true;
|
||||
$.post('/record/groups/{$domainId}', function(res){
|
||||
if(res.code == 0){
|
||||
$('#groupid').empty();
|
||||
$.each(res.data, function(i, item){
|
||||
$('#groupid').append('<option value="'+item.id+'">'+item.name+'</option>');
|
||||
});
|
||||
updateToolbar();
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
function advanceSearch(){
|
||||
$('#searchToolbar').find('input[name]').each(function() {
|
||||
$(this).val('');
|
||||
@@ -724,6 +801,7 @@ function advanceSearch(){
|
||||
if($("#searchbox1").is(":visible")){
|
||||
$("#searchbox1").slideUp();
|
||||
$("#searchbox2").slideDown();
|
||||
loadRecordGroups();
|
||||
}else{
|
||||
$("#searchbox2").slideUp();
|
||||
$("#searchbox1").slideDown();
|
||||
|
||||
+2
-1
@@ -4,5 +4,6 @@
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:/$1]
|
||||
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
|
||||
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||
</IfModule>
|
||||
|
||||
@@ -49,7 +49,7 @@ function updateToolbar(){
|
||||
function updateQueryStr(obj){
|
||||
var arr = [];
|
||||
for (var p in obj){
|
||||
if (obj.hasOwnProperty(p) && typeof obj[p] != 'undefined' && obj[p] != '') {
|
||||
if (obj.hasOwnProperty(p) && typeof obj[p] != 'undefined' && obj[p] != null && obj[p] != '') {
|
||||
arr.push(p + "=" + encodeURIComponent(obj[p]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ Route::group(function () {
|
||||
Route::get('/record/batchadd', 'domain/record_batch_add2');
|
||||
Route::any('/record/batchedit', 'domain/record_batch_edit2');
|
||||
Route::any('/record/log/:id', 'domain/record_log');
|
||||
Route::post('/record/groups/:id', 'domain/record_groups');
|
||||
Route::post('/record/list', 'domain/record_list');
|
||||
Route::post('/record/weight/data/:id', 'domain/weight_data');
|
||||
Route::any('/record/weight/:id', 'domain/weight');
|
||||
|
||||
Reference in New Issue
Block a user