mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-05-10 07:26:28 +02:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86adfd018a | ||
|
|
3b93ee1203 | ||
|
|
a5145accd6 | ||
|
|
30427a9704 | ||
|
|
4145e282f9 | ||
|
|
53ec0e12df | ||
|
|
b8addd6d27 | ||
|
|
0d1d7d3c67 | ||
|
|
8bdf58651c | ||
|
|
350a0bd306 | ||
|
|
ab074da839 |
@@ -362,6 +362,11 @@ class Domain extends BaseController
|
||||
$row['LineName'] = isset($recordLine[$row['Line']]) ? $recordLine[$row['Line']]['name'] : $row['Line'];
|
||||
}
|
||||
|
||||
$dnstype = Db::name('account')->where('id', $drow['aid'])->value('type');
|
||||
if($dnstype == 'baidu'){
|
||||
return json($domainRecords['list']);
|
||||
}
|
||||
|
||||
return json(['total'=>$domainRecords['total'], 'rows'=>$domainRecords['list']]);
|
||||
}
|
||||
|
||||
@@ -402,6 +407,7 @@ class Domain extends BaseController
|
||||
$value = input('post.value', null, 'trim');
|
||||
$line = input('post.line', null, 'trim');
|
||||
$ttl = input('post.ttl/d', 600);
|
||||
$weight = input('post.weight/d', 0);
|
||||
$mx = input('post.mx/d', 1);
|
||||
$remark = input('post.remark', null, 'trim');
|
||||
|
||||
@@ -410,7 +416,7 @@ class Domain extends BaseController
|
||||
}
|
||||
|
||||
$dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']);
|
||||
$recordid = $dns->addDomainRecord($name, $type, $value, $line, $ttl, $mx, $remark);
|
||||
$recordid = $dns->addDomainRecord($name, $type, $value, $line, $ttl, $mx, $weight, $remark);
|
||||
if($recordid){
|
||||
$this->add_log($drow['name'], '添加解析', $type.'记录 '.$name.' '.$value.' (线路:'.$line.' TTL:'.$ttl.')');
|
||||
return json(['code'=>0, 'msg'=>'添加解析记录成功!']);
|
||||
@@ -433,6 +439,7 @@ class Domain extends BaseController
|
||||
$value = input('post.value', null, 'trim');
|
||||
$line = input('post.line', null, 'trim');
|
||||
$ttl = input('post.ttl/d', 600);
|
||||
$weight = input('post.weight/d', 0);
|
||||
$mx = input('post.mx/d', 1);
|
||||
$remark = input('post.remark', null, 'trim');
|
||||
|
||||
@@ -441,7 +448,7 @@ class Domain extends BaseController
|
||||
}
|
||||
|
||||
$dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']);
|
||||
$recordid = $dns->updateDomainRecord($recordid, $name, $type, $value, $line, $ttl, $mx, $remark);
|
||||
$recordid = $dns->updateDomainRecord($recordid, $name, $type, $value, $line, $ttl, $mx, $weight, $remark);
|
||||
if($recordid){
|
||||
$this->add_log($drow['name'], '修改解析', $type.'记录 '.$name.' '.$value.' (线路:'.$line.' TTL:'.$ttl.')');
|
||||
return json(['code'=>0, 'msg'=>'修改解析记录成功!']);
|
||||
@@ -603,7 +610,7 @@ class Domain extends BaseController
|
||||
|
||||
$success = 0; $fail = 0;
|
||||
foreach($recordinfo as $record){
|
||||
$recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $type, $value, $record['line'], $record['ttl'], $record['mx'], $record['remark']);
|
||||
$recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $type, $value, $record['line'], $record['ttl'], $record['mx'], $record['weight'], $record['remark']);
|
||||
if($recordid){
|
||||
$this->add_log($drow['name'], '修改解析', $type.'记录 '.$record['name'].' '.$value.' (线路:'.$record['line'].' TTL:'.$record['ttl'].')');
|
||||
$success++;
|
||||
@@ -624,7 +631,7 @@ class Domain extends BaseController
|
||||
|
||||
$success = 0; $fail = 0;
|
||||
foreach($recordinfo as $record){
|
||||
$recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $record['type'], $record['value'], $line, $record['ttl'], $record['mx'], $record['remark']);
|
||||
$recordid = $dns->updateDomainRecord($record['recordid'], $record['name'], $record['type'], $record['value'], $line, $record['ttl'], $record['mx'], $record['weight'], $record['remark']);
|
||||
if($recordid){
|
||||
$this->add_log($drow['name'], '修改解析', $record['type'].'记录 '.$record['name'].' '.$record['value'].' (线路:'.$line.' TTL:'.$record['ttl'].')');
|
||||
$success++;
|
||||
|
||||
@@ -16,6 +16,7 @@ class DnsHelper
|
||||
'status' => true, //是否支持启用暂停
|
||||
'redirect' => true, //是否支持域名转发
|
||||
'log' => true, //是否支持查看日志
|
||||
'weight' => false, //是否支持权重
|
||||
],
|
||||
'dnspod' => [
|
||||
'name' => '腾讯云',
|
||||
@@ -27,6 +28,7 @@ class DnsHelper
|
||||
'status' => true,
|
||||
'redirect' => true,
|
||||
'log' => true,
|
||||
'weight' => true,
|
||||
],
|
||||
'huawei' => [
|
||||
'name' => '华为云',
|
||||
@@ -38,6 +40,19 @@ class DnsHelper
|
||||
'status' => true,
|
||||
'redirect' => false,
|
||||
'log' => false,
|
||||
'weight' => true,
|
||||
],
|
||||
'baidu' => [
|
||||
'name' => '百度云',
|
||||
'config' => [
|
||||
'ak' => 'AccessKey',
|
||||
'sk' => 'SecretKey'
|
||||
],
|
||||
'remark' => 2,
|
||||
'status' => false,
|
||||
'redirect' => false,
|
||||
'log' => false,
|
||||
'weight' => false,
|
||||
],
|
||||
'west' => [
|
||||
'name' => '西部数码',
|
||||
@@ -49,6 +64,19 @@ class DnsHelper
|
||||
'status' => true,
|
||||
'redirect' => false,
|
||||
'log' => false,
|
||||
'weight' => false,
|
||||
],
|
||||
'huoshan' => [
|
||||
'name' => '火山引擎',
|
||||
'config' => [
|
||||
'ak' => 'AccessKeyId',
|
||||
'sk' => 'SecretAccessKey'
|
||||
],
|
||||
'remark' => 2,
|
||||
'status' => true,
|
||||
'redirect' => false,
|
||||
'log' => false,
|
||||
'weight' => true,
|
||||
],
|
||||
'dnsla' => [
|
||||
'name' => 'DNSLA',
|
||||
@@ -60,6 +88,7 @@ class DnsHelper
|
||||
'status' => true,
|
||||
'redirect' => true,
|
||||
'log' => false,
|
||||
'weight' => true,
|
||||
],
|
||||
'cloudflare' => [
|
||||
'name' => 'Cloudflare',
|
||||
@@ -71,6 +100,7 @@ class DnsHelper
|
||||
'status' => false,
|
||||
'redirect' => false,
|
||||
'log' => false,
|
||||
'weight' => false,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ interface DnsInterface
|
||||
|
||||
function getDomainRecordInfo($RecordId);
|
||||
|
||||
function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Remark = null);
|
||||
function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Weight = null, $Remark = null);
|
||||
|
||||
function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Remark = null);
|
||||
function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Weight = null, $Remark = null);
|
||||
|
||||
function updateDomainRecordRemark($RecordId, $Remark);
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ class OptimizeService
|
||||
'huawei' => ['DEF'=>'default_view', 'CT'=>'Dianxin', 'CU'=>'Liantong', 'CM'=>'Yidong', 'AB'=>'Abroad'],
|
||||
'west' => ['DEF'=>'', 'CT'=>'LTEL', 'CU'=>'LCNC', 'CM'=>'LMOB', 'AB'=>'LFOR'],
|
||||
'dnsla' => ['DEF'=>'', 'CT'=>'84613316902921216', 'CU'=>'84613316923892736', 'CM'=>'84613316953252864', 'AB'=>''],
|
||||
'huoshan' => ['DEF'=>'default', 'CT'=>'telecom', 'CU'=>'unicom', 'CM'=>'mobile', 'AB'=>'oversea'],
|
||||
'baidu' => ['DEF'=>'default', 'CT'=>'ct', 'CU'=>'cnc', 'CM'=>'cmnet', 'AB'=>''],
|
||||
];
|
||||
|
||||
private $ip_address = [];
|
||||
@@ -21,10 +23,12 @@ class OptimizeService
|
||||
private $del_num = 0;
|
||||
|
||||
public static function get_license($api, $key){
|
||||
if($api == 1){
|
||||
if($api == 2){
|
||||
throw new Exception('当前接口暂不支持');
|
||||
}elseif($api == 1){
|
||||
$url = 'https://api.hostmonit.com/get_license?license='.$key;
|
||||
}else{
|
||||
$url = 'https://monitor.gacjie.cn/api/client/get_account_integral?license='.$key;
|
||||
$url = 'https://www.wetest.vip/api/cf2dns/get_license?license='.$key;
|
||||
}
|
||||
$response = get_curl($url);
|
||||
$arr = json_decode($response, true);
|
||||
@@ -39,18 +43,24 @@ class OptimizeService
|
||||
|
||||
public function get_ip_address($cdn_type = 1, $ip_type = 'v4'){
|
||||
$api = config_get('optimize_ip_api', 0);
|
||||
if($api == 1){
|
||||
if($api == 2){
|
||||
$url = 'https://api.345673.xyz/get_data';
|
||||
}elseif($api == 1){
|
||||
$url = 'https://api.hostmonit.com/get_optimization_ip';
|
||||
}else{
|
||||
$url = 'https://monitor.gacjie.cn/api/client/get_ip_address';
|
||||
$url = 'https://www.wetest.vip/api/cf2dns/';
|
||||
if($cdn_type == 1){
|
||||
$url .= 'get_cloudflare_ip';
|
||||
}elseif($cdn_type == 2){
|
||||
$url .= 'get_cloudfront_ip';
|
||||
}elseif($cdn_type == 3){
|
||||
$url .= 'get_gcore_ip';
|
||||
}
|
||||
}
|
||||
$params = [
|
||||
'key' => config_get('optimize_ip_key', 'o1zrmHAF'),
|
||||
'type' => $ip_type,
|
||||
];
|
||||
if($api == 0){
|
||||
$params['cdn_server'] = $cdn_type;
|
||||
}
|
||||
$response = get_curl($url, json_encode($params), 0, 0, 0, 0, 0, ['Content-Type: application/json; charset=UTF-8']);
|
||||
$arr = json_decode($response, true);
|
||||
if(isset($arr['code']) && $arr['code'] == 200){
|
||||
|
||||
@@ -135,10 +135,10 @@ class aliyun implements DnsInterface {
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Remark = null){
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Weight = null, $Remark = null){
|
||||
$param = ['Action' => 'AddDomainRecord', 'DomainName' => $this->domain, 'RR' => $Name, 'Type' => $Type, 'Value' => $Value, 'Line' => $this->convertLineCode($Line), 'TTL' => intval($TTL)];
|
||||
if($MX){
|
||||
$params['Priority'] = intval($MX);
|
||||
$param['Priority'] = intval($MX);
|
||||
}
|
||||
$data = $this->request($param, true);
|
||||
if($data){
|
||||
@@ -148,10 +148,10 @@ class aliyun implements DnsInterface {
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Remark = null){
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = null, $Weight = null, $Remark = null){
|
||||
$param = ['Action' => 'UpdateDomainRecord', 'RecordId' => $RecordId, 'RR' => $Name, 'Type' => $Type, 'Value' => $Value, 'Line' => $this->convertLineCode($Line), 'TTL' => intval($TTL)];
|
||||
if($MX){
|
||||
$params['Priority'] = intval($MX);
|
||||
$param['Priority'] = intval($MX);
|
||||
}
|
||||
return $this->request($param);
|
||||
}
|
||||
|
||||
@@ -49,10 +49,9 @@ class baidu implements DnsInterface {
|
||||
|
||||
//获取解析记录列表
|
||||
public function getDomainRecords($PageNumber=1, $PageSize=20, $KeyWord = null, $SubDomain = null, $Value = null, $Type = null, $Line = null, $Status = null){
|
||||
$marker = cookie('baidu_record_marker');
|
||||
$query = ['rr' => $KeyWord];
|
||||
if(!isNullOrEmpty(($SubDomain))){
|
||||
$param['rr'] = $SubDomain;
|
||||
if(!isNullOrEmpty($SubDomain)){
|
||||
$query['rr'] = $SubDomain;
|
||||
}
|
||||
$data = $this->send_reuqest('GET', '/v1/dns/zone/'.$this->domain.'/record', $query);
|
||||
if($data){
|
||||
@@ -86,38 +85,40 @@ class baidu implements DnsInterface {
|
||||
|
||||
//获取解析记录详细信息
|
||||
public function getDomainRecordInfo($RecordId){
|
||||
$data = $this->send_reuqest('GET', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId);
|
||||
if($data){
|
||||
$query = ['id' => $RecordId];
|
||||
$data = $this->send_reuqest('GET', '/v1/dns/zone/'.$this->domain.'/record', $query);
|
||||
if($data && !empty($data['records'])){
|
||||
$data = $data['records'][0];
|
||||
return [
|
||||
'RecordId' => $data['id'],
|
||||
'Domain' => rtrim($data['zone_name'], '.'),
|
||||
'Name' => str_replace('.'.$data['zone_name'], '', $data['name']),
|
||||
'Type' => $data['type'],
|
||||
'Value' => $data['records'],
|
||||
'Value' => $data['value'],
|
||||
'Line' => $data['line'],
|
||||
'TTL' => $data['ttl'],
|
||||
'MX' => $data['weight'],
|
||||
'Status' => $data['status'] == 'ACTIVE' ? '1' : '0',
|
||||
'Weight' => $data['weight'],
|
||||
'MX' => $data['priority'],
|
||||
'Status' => $data['status'] == 'running' ? '1' : '0',
|
||||
'Weight' => null,
|
||||
'Remark' => $data['description'],
|
||||
'UpdateTime' => $data['updated_at'],
|
||||
'UpdateTime' => null,
|
||||
];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$params = ['rr' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if($Type == 'MX')$param['priority'] = intval($MX);
|
||||
if($Type == 'MX')$params['priority'] = intval($MX);
|
||||
$query = ['clientToken' => getSid()];
|
||||
return $this->send_reuqest('POST', '/v1/dns/zone/'.$this->domain.'/record', $query, $params);
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$params = ['rr' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if($Type == 'MX')$param['priority'] = intval($MX);
|
||||
if($Type == 'MX')$params['priority'] = intval($MX);
|
||||
$query = ['clientToken' => getSid()];
|
||||
return $this->send_reuqest('PUT', '/v1/dns/zone/'.$this->domain.'/record/'.$RecordId, $query, $params);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class cloudflare implements DnsInterface {
|
||||
'Line' => $row['proxied'] ? '1' : '0',
|
||||
'TTL' => $row['ttl'],
|
||||
'MX' => isset($row['priority']) ? $row['priority'] : null,
|
||||
'Status' => $row['locked'] ? '0' : '1',
|
||||
'Status' => '1',
|
||||
'Weight' => null,
|
||||
'Remark' => $row['comment'],
|
||||
'UpdateTime' => $row['modified_on'],
|
||||
@@ -102,7 +102,7 @@ class cloudflare implements DnsInterface {
|
||||
'Line' => $data['result']['proxied'] ? '1' : '0',
|
||||
'TTL' => $data['result']['ttl'],
|
||||
'MX' => isset($data['result']['priority']) ? $data['result']['priority'] : null,
|
||||
'Status' => $data['result']['locked'] ? '0' : '1',
|
||||
'Status' => '1',
|
||||
'Weight' => null,
|
||||
'Remark' => $data['result']['comment'],
|
||||
'UpdateTime' => $data['result']['modified_on'],
|
||||
@@ -112,17 +112,25 @@ class cloudflare implements DnsInterface {
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $Weight = null, $MX = 1, $Remark = null){
|
||||
$param = ['name' => $Name, 'type' => $this->convertType($Type), 'content' => $Value, 'proxied' => $Line=='1', 'ttl' => intval($TTL), 'comment' => $Remark];
|
||||
if($Type == 'MX')$param['priority'] = intval($MX);
|
||||
if($Type == 'CAA' || $Type == 'SRV'){
|
||||
unset($param['content']);
|
||||
$param['data'] = $this->convertValue($Value, $Type);
|
||||
}
|
||||
$data = $this->send_reuqest('POST', '/zones/'.$this->domainid.'/dns_records', $param);
|
||||
return is_array($data) ? $data['result']['id'] : false;
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $Weight = null, $MX = 1, $Remark = null){
|
||||
$param = ['name' => $Name, 'type' => $this->convertType($Type), 'content' => $Value, 'proxied' => $Line=='1', 'ttl' => intval($TTL), 'comment' => $Remark];
|
||||
if($Type == 'MX')$param['priority'] = intval($MX);
|
||||
if($Type == 'CAA' || $Type == 'SRV'){
|
||||
unset($param['content']);
|
||||
$param['data'] = $this->convertValue($Value, $Type);
|
||||
}
|
||||
$data = $this->send_reuqest('PATCH', '/zones/'.$this->domainid.'/dns_records/'.$RecordId, $param);
|
||||
return is_array($data);
|
||||
}
|
||||
@@ -175,6 +183,34 @@ class cloudflare implements DnsInterface {
|
||||
return $type;
|
||||
}
|
||||
|
||||
private function convertValue($value, $type){
|
||||
if($type == 'SRV'){
|
||||
$arr = explode(' ', $value);
|
||||
if(count($arr) > 3){
|
||||
$data = [
|
||||
'priority' => intval($arr[0]),
|
||||
'weight' => intval($arr[1]),
|
||||
'port' => intval($arr[2]),
|
||||
'target' => $arr[3],
|
||||
];
|
||||
}else{
|
||||
$data = [
|
||||
'weight' => intval($arr[0]),
|
||||
'port' => intval($arr[1]),
|
||||
'target' => $arr[2],
|
||||
];
|
||||
}
|
||||
}elseif($type == 'CAA'){
|
||||
$arr = explode(' ', $value);
|
||||
$data = [
|
||||
'flags' => intval($arr[0]),
|
||||
'tag' => $arr[1],
|
||||
'value' => trim($arr[2], '"'),
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function send_reuqest($method, $path, $params = null){
|
||||
$url = $this->baseUrl . $path;
|
||||
|
||||
|
||||
@@ -102,21 +102,23 @@ class dnsla implements DnsInterface {
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$param = ['domainId' => $this->domainid, 'type' => $this->convertType($Type), 'host' => $Name, 'data' => $Value, 'ttl' => intval($TTL), 'lineId' => $Line];
|
||||
if($Type == 'MX')$param['preference'] = intval($MX);
|
||||
if($Type == 'REDIRECT_URL'){$param['type'] = 256;$param['dominant'] = true;}
|
||||
elseif($Type == 'FORWARD_URL'){$param['type'] = 256;$param['dominant'] = false;}
|
||||
if($Weight > 0) $param['weight'] = $Weight;
|
||||
$data = $this->execute('POST', '/api/record', $param);
|
||||
return is_array($data) ? $data['id'] : false;
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$param = ['id' => $RecordId, 'type' => $this->convertType($Type), 'host' => $Name, 'data' => $Value, 'ttl' => intval($TTL), 'lineId' => $Line];
|
||||
if($Type == 'MX')$param['preference'] = intval($MX);
|
||||
if($Type == 'REDIRECT_URL'){$param['type'] = 256;$param['dominant'] = true;}
|
||||
elseif($Type == 'FORWARD_URL'){$param['type'] = 256;$param['dominant'] = false;}
|
||||
if($Weight > 0) $param['weight'] = $Weight;
|
||||
$data = $this->execute('PUT', '/api/record', $param);
|
||||
return $data!==false;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class dnspod implements DnsInterface {
|
||||
];
|
||||
}
|
||||
return ['total' => $data['RecordCountInfo']['TotalCount'], 'list' => $list];
|
||||
}elseif($this->error == '记录列表为空。'){
|
||||
}elseif($this->error == '记录列表为空。' || $this->error == 'No records on the list.'){
|
||||
return ['total' => 0, 'list' => []];
|
||||
}
|
||||
return false;
|
||||
@@ -128,18 +128,18 @@ class dnspod implements DnsInterface {
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$action = 'CreateRecord';
|
||||
$param = ['Domain' => $this->domain, 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL)];
|
||||
$param = ['Domain' => $this->domain, 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL), 'Weight' => $Weight];
|
||||
if($Type == 'MX')$param['MX'] = intval($MX);
|
||||
$data = $this->send_reuqest($action, $param);
|
||||
return is_array($data) ? $data['RecordId'] : false;
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$action = 'ModifyRecord';
|
||||
$param = ['Domain' => $this->domain, 'RecordId' => intval($RecordId), 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL)];
|
||||
$param = ['Domain' => $this->domain, 'RecordId' => intval($RecordId), 'SubDomain' => $Name, 'RecordType' => $this->convertType($Type), 'Value' => $Value, 'RecordLine'=>$Line, 'RecordLineId' => $this->convertLineCode($Line), 'TTL' => intval($TTL), 'Weight' => $Weight];
|
||||
if($Type == 'MX')$param['MX'] = intval($MX);
|
||||
$data = $this->send_reuqest($action, $param);
|
||||
return is_array($data);
|
||||
@@ -210,7 +210,8 @@ class dnspod implements DnsInterface {
|
||||
|
||||
private function processLineList(&$list, $line_list, $parent){
|
||||
foreach($line_list as $row){
|
||||
if(!isNullOrEmpty($row['LineId']) && $row['Useful'] && !isset($list[$row['LineId']])){
|
||||
if(isNullOrEmpty($row['LineId'])) $row['LineId'] = 'N.'.$row['LineName'];
|
||||
if($row['Useful'] && !isset($list[$row['LineId']])){
|
||||
$list[$row['LineId']] = ['name'=>$row['LineName'], 'parent'=>$parent];
|
||||
if($row['SubGroup']){
|
||||
$this->processLineList($list, $row['SubGroup'], $row['LineId']);
|
||||
@@ -269,8 +270,8 @@ class dnspod implements DnsInterface {
|
||||
foreach($data['LineGroupList'] as $row){
|
||||
$line_list[] = ['Name' => $row['Name'], 'LineId' => $row['LineId']];
|
||||
}
|
||||
return $line_list;
|
||||
}
|
||||
return $line_list;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ class huawei implements DnsInterface {
|
||||
$list = [];
|
||||
foreach($data['recordsets'] as $row){
|
||||
if($row['name'] == $row['zone_name']) $row['name'] = '@';
|
||||
if($row['type'] == 'MX') list($row['mx'], $row['records']) = explode(' ', $row['records'][0]);
|
||||
$list[] = [
|
||||
'RecordId' => $row['id'],
|
||||
'Domain' => rtrim($row['zone_name'], '.'),
|
||||
@@ -74,7 +75,7 @@ class huawei implements DnsInterface {
|
||||
'Value' => $row['records'],
|
||||
'Line' => $row['line'],
|
||||
'TTL' => $row['ttl'],
|
||||
'MX' => $row['weight'],
|
||||
'MX' => isset($row['mx']) ? $row['mx'] : null,
|
||||
'Status' => $row['status'] == 'ACTIVE' ? '1' : '0',
|
||||
'Weight' => $row['weight'],
|
||||
'Remark' => $row['description'],
|
||||
@@ -96,6 +97,7 @@ class huawei implements DnsInterface {
|
||||
$data = $this->send_reuqest('GET', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId);
|
||||
if($data){
|
||||
if($data['name'] == $data['zone_name']) $data['name'] = '@';
|
||||
if($data['type'] == 'MX') list($data['mx'], $data['records']) = explode(' ', $data['records'][0]);
|
||||
return [
|
||||
'RecordId' => $data['id'],
|
||||
'Domain' => rtrim($data['zone_name'], '.'),
|
||||
@@ -104,7 +106,7 @@ class huawei implements DnsInterface {
|
||||
'Value' => $data['records'],
|
||||
'Line' => $data['line'],
|
||||
'TTL' => $data['ttl'],
|
||||
'MX' => $data['weight'],
|
||||
'MX' => isset($data['mx']) ? $data['mx'] : null,
|
||||
'Status' => $data['status'] == 'ACTIVE' ? '1' : '0',
|
||||
'Weight' => $data['weight'],
|
||||
'Remark' => $data['description'],
|
||||
@@ -115,21 +117,25 @@ class huawei implements DnsInterface {
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$Name = $this->getHost($Name);
|
||||
if($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"'.$Value.'"';
|
||||
$records = explode(',', $Value);
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if($Type == 'MX')$param['weight'] = intval($MX);
|
||||
if($Type == 'MX') $params['records'][0] = intval($MX) . ' ' . $Value;
|
||||
if($Weight > 0) $params['weight'] = intval($Weight);
|
||||
$data = $this->send_reuqest('POST', '/v2.1/zones/'.$this->domainid.'/recordsets', null, $params);
|
||||
return is_array($data) ? $data['id'] : false;
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$Name = $this->getHost($Name);
|
||||
if($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"'.$Value.'"';
|
||||
$records = explode(',', $Value);
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if($Type == 'MX')$param['weight'] = intval($MX);
|
||||
if($Type == 'MX') $params['records'][0] = intval($MX) . ' ' . $Value;
|
||||
if($Weight > 0) $params['weight'] = intval($Weight);
|
||||
$data = $this->send_reuqest('PUT', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId, null, $params);
|
||||
return is_array($data);
|
||||
}
|
||||
|
||||
387
app/lib/dns/huoshan.php
Normal file
387
app/lib/dns/huoshan.php
Normal file
@@ -0,0 +1,387 @@
|
||||
<?php
|
||||
namespace app\lib\dns;
|
||||
|
||||
use app\lib\DnsInterface;
|
||||
|
||||
class huoshan implements DnsInterface {
|
||||
private $AccessKeyId;
|
||||
private $SecretAccessKey;
|
||||
private $endpoint = "open.volcengineapi.com";
|
||||
private $service = "DNS";
|
||||
private $version = "2018-08-01";
|
||||
private $region = "cn-north-1";
|
||||
private $error;
|
||||
private $domain;
|
||||
private $domainid;
|
||||
private $domainInfo;
|
||||
|
||||
private static $trade_code_list = [
|
||||
'free_inner' => ['level' => 1, 'name' => '免费版', 'ttl' => 600],
|
||||
'professional_inner' => ['level' => 2, 'name' => '专业版', 'ttl' => 300],
|
||||
'enterprise_inner' => ['level' => 3, 'name' => '企业版', 'ttl' => 60],
|
||||
'ultimate_inner' => ['level' => 4, 'name' => '旗舰版', 'ttl' => 1],
|
||||
'ultimate_exclusive_inner' => ['level' => 5, 'name' => '尊享版', 'ttl' => 1],
|
||||
];
|
||||
|
||||
function __construct($config){
|
||||
$this->AccessKeyId = $config['ak'];
|
||||
$this->SecretAccessKey = $config['sk'];
|
||||
$this->domain = $config['domain'];
|
||||
$this->domainid = $config['domainid'];
|
||||
}
|
||||
|
||||
public function getError(){
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function check(){
|
||||
if($this->getDomainList() != false){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取域名列表
|
||||
public function getDomainList($KeyWord=null, $PageNumber=1, $PageSize=20){
|
||||
$query = ['PageNumber' => $PageNumber, 'PageSize' => $PageSize, 'Key' => $KeyWord];
|
||||
$data = $this->send_reuqest('GET', 'ListZones', $query);
|
||||
if($data){
|
||||
$list = [];
|
||||
if(!empty($data['Zones'])){
|
||||
foreach($data['Zones'] as $row){
|
||||
$list[] = [
|
||||
'DomainId' => $row['ZID'],
|
||||
'Domain' => $row['ZoneName'],
|
||||
'RecordCount' => $row['RecordCount'],
|
||||
];
|
||||
}
|
||||
}
|
||||
return ['total' => $data['Total'], 'list' => $list];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取解析记录列表
|
||||
public function getDomainRecords($PageNumber=1, $PageSize=20, $KeyWord = null, $SubDomain = null, $Value = null, $Type = null, $Line = null, $Status = null){
|
||||
$query = ['ZID' => intval($this->domainid), 'PageNumber' => $PageNumber, 'PageSize' => $PageSize, 'SearchOrder' => 'desc'];
|
||||
if(!empty($SubDomain) || !empty($Type) || !empty($Line) || !empty($Value)){
|
||||
$query += ['Host' => $SubDomain, 'Value' => $Value, 'Type' => $Type, 'Line' => $Line];
|
||||
}elseif(!empty($KeyWord)){
|
||||
$query += ['Host' => $KeyWord];
|
||||
}
|
||||
$data = $this->send_reuqest('GET', 'ListRecords', $query);
|
||||
if($data){
|
||||
$list = [];
|
||||
foreach($data['Records'] as $row){
|
||||
if($row['Type'] == 'MX') list($row['MX'], $row['Value']) = explode(' ', $row['Value']);
|
||||
$list[] = [
|
||||
'RecordId' => $row['RecordID'],
|
||||
'Domain' => $this->domain,
|
||||
'Name' => $row['Host'],
|
||||
'Type' => $row['Type'],
|
||||
'Value' => $row['Value'],
|
||||
'Line' => $row['Line'],
|
||||
'TTL' => $row['TTL'],
|
||||
'MX' => isset($row['MX']) ? $row['MX'] : null,
|
||||
'Status' => $row['Enable'] ? '1' : '0',
|
||||
'Weight' => $row['Weight'],
|
||||
'Remark' => $row['Remark'],
|
||||
'UpdateTime' => $row['UpdatedAt'],
|
||||
];
|
||||
}
|
||||
return ['total' => $data['TotalCount'], 'list' => $list];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取子域名解析记录列表
|
||||
public function getSubDomainRecords($SubDomain, $PageNumber=1, $PageSize=20, $Type = null, $Line = null){
|
||||
return $this->getDomainRecords($PageNumber, $PageSize, null, $SubDomain, null, $Type, $Line);
|
||||
}
|
||||
|
||||
//获取解析记录详细信息
|
||||
public function getDomainRecordInfo($RecordId){
|
||||
$data = $this->send_reuqest('GET', 'QueryRecord', ['RecordID' => $RecordId]);
|
||||
if($data){
|
||||
if($data['name'] == $data['zone_name']) $data['name'] = '@';
|
||||
if($data['Type'] == 'MX') list($data['MX'], $data['Value']) = explode(' ', $data['Value']);
|
||||
return [
|
||||
'RecordId' => $data['RecordID'],
|
||||
'Domain' => $this->domain,
|
||||
'Name' => $data['Host'],
|
||||
'Type' => $data['Type'],
|
||||
'Value' => $data['Value'],
|
||||
'Line' => $data['Line'],
|
||||
'TTL' => $data['TTL'],
|
||||
'MX' => isset($data['MX']) ? $data['MX'] : null,
|
||||
'Status' => $data['Enable'] ? '1' : '0',
|
||||
'Weight' => $data['Weight'],
|
||||
'Remark' => $data['Remark'],
|
||||
'UpdateTime' => $data['UpdatedAt'],
|
||||
];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$params = ['ZID' => intval($this->domainid), 'Host' => $Name, 'Type' => $this->convertType($Type), 'Value' => $Value, 'Line'=>$Line, 'TTL' => intval($TTL), 'Remark' => $Remark];
|
||||
if($Type == 'MX') $params['Value'] = intval($MX) . ' ' . $Value;
|
||||
if($Weight > 0) $params['Weight'] = $Weight;
|
||||
$data = $this->send_reuqest('POST', 'CreateRecord', $params);
|
||||
return is_array($data) ? $data['RecordID'] : false;
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$params = ['RecordID' => $RecordId, 'Host' => $Name, 'Type' => $this->convertType($Type), 'Value' => $Value, 'Line'=>$Line, 'TTL' => intval($TTL), 'Remark' => $Remark];
|
||||
if($Type == 'MX') $params['Value'] = intval($MX) . ' ' . $Value;
|
||||
if($Weight > 0) $params['Weight'] = $Weight;
|
||||
$data = $this->send_reuqest('POST', 'UpdateRecord', $params);
|
||||
return is_array($data);
|
||||
}
|
||||
|
||||
//修改解析记录备注
|
||||
public function updateDomainRecordRemark($RecordId, $Remark){
|
||||
return false;
|
||||
}
|
||||
|
||||
//删除解析记录
|
||||
public function deleteDomainRecord($RecordId){
|
||||
$data = $this->send_reuqest('POST', 'DeleteRecord', ['RecordID' => $RecordId]);
|
||||
return $data;
|
||||
}
|
||||
|
||||
//设置解析记录状态
|
||||
public function setDomainRecordStatus($RecordId, $Status){
|
||||
$params = ['RecordID' => $RecordId, 'Enable' => $Status == '1'];
|
||||
$data = $this->send_reuqest('POST', 'UpdateRecordStatus', $params);
|
||||
return is_array($data);
|
||||
}
|
||||
|
||||
//获取解析记录操作日志
|
||||
public function getDomainRecordLog($PageNumber = 1, $PageSize = 20, $KeyWord = null, $StartDate = null, $endDate = null){
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取解析线路列表
|
||||
public function getRecordLine(){
|
||||
$domainInfo = $this->getDomainInfo();
|
||||
if(!$domainInfo) return false;
|
||||
$level = $this->getTradeInfo($domainInfo['TradeCode'])['level'];
|
||||
$data = $this->send_reuqest('GET', 'ListLines', []);
|
||||
if($data){
|
||||
$list = [];
|
||||
$list['default'] = ['name' => '默认', 'parent' => null];
|
||||
foreach($data['Lines'] as $row){
|
||||
if($row['Value'] == 'default') continue;
|
||||
if($row['Level'] > $level) continue;
|
||||
$list[$row['Value']] = ['name' => $row['Name'], 'parent' => isset($row['FatherValue']) ? $row['FatherValue'] : null];
|
||||
}
|
||||
|
||||
$data = $this->send_reuqest('GET', 'ListCustomLines', []);
|
||||
if($data && $data['TotalCount'] > 0){
|
||||
$list['N.customer_lines'] = ['name' => '自定义线路', 'parent' => null];
|
||||
foreach($data['CustomerLines'] as $row){
|
||||
$list[$row['Line']] = ['name' => $row['NameCN'], 'parent' => 'N.customer_lines'];
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取域名概览信息
|
||||
public function getDomainInfo(){
|
||||
if(!empty($this->domainInfo)) return $this->domainInfo;
|
||||
$query = ['ZID' => intval($this->domainid)];
|
||||
$data = $this->send_reuqest('GET', 'QueryZone', $query);
|
||||
if($data){
|
||||
$this->domainInfo = $data;
|
||||
return $data;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取域名最低TTL
|
||||
public function getMinTTL(){
|
||||
$domainInfo = $this->getDomainInfo();
|
||||
if($domainInfo){
|
||||
$ttl = $this->getTradeInfo($domainInfo['TradeCode'])['ttl'];
|
||||
return $ttl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function convertType($type){
|
||||
return $type;
|
||||
}
|
||||
|
||||
private function getTradeInfo($trade_code){
|
||||
if(array_key_exists($trade_code, self::$trade_code_list)){
|
||||
$trade_code = $trade_code;
|
||||
}else{
|
||||
$trade_code = 'free_inner';
|
||||
}
|
||||
return self::$trade_code_list[$trade_code];
|
||||
}
|
||||
|
||||
private function send_reuqest($method, $action, $params = []){
|
||||
if(!empty($params)){
|
||||
$params = array_filter($params, function($a){ return $a!==null;});
|
||||
}
|
||||
|
||||
$query = [
|
||||
'Action' => $action,
|
||||
'Version' => $this->version,
|
||||
];
|
||||
|
||||
$body = '';
|
||||
if($method == 'GET'){
|
||||
$query = array_merge($query, $params);
|
||||
}else{
|
||||
$body = !empty($params) ? json_encode($params) : '';
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$headers = [
|
||||
'Host' => $this->endpoint,
|
||||
'X-Date' => gmdate("Ymd\THis\Z", $time),
|
||||
//'X-Content-Sha256' => hash("sha256", $body),
|
||||
];
|
||||
if($body){
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
$path = '/';
|
||||
|
||||
$authorization = $this->generateSign($method, $path, $query, $headers, $body, $time);
|
||||
$headers['Authorization'] = $authorization;
|
||||
|
||||
$url = 'https://'.$this->endpoint.$path.'?'.http_build_query($query);
|
||||
$header = [];
|
||||
foreach($headers as $key => $value){
|
||||
$header[] = $key.': '.$value;
|
||||
}
|
||||
return $this->curl($method, $url, $body, $header);
|
||||
}
|
||||
|
||||
private function generateSign($method, $path, $query, $headers, $body, $time){
|
||||
$algorithm = "HMAC-SHA256";
|
||||
|
||||
// step 1: build canonical request string
|
||||
$httpRequestMethod = $method;
|
||||
$canonicalUri = $path;
|
||||
if(substr($canonicalUri, -1) != "/") $canonicalUri .= "/";
|
||||
$canonicalQueryString = $this->getCanonicalQueryString($query);
|
||||
[$canonicalHeaders, $signedHeaders] = $this->getCanonicalHeaders($headers);
|
||||
$hashedRequestPayload = hash("sha256", $body);
|
||||
$canonicalRequest = $httpRequestMethod."\n"
|
||||
.$canonicalUri."\n"
|
||||
.$canonicalQueryString."\n"
|
||||
.$canonicalHeaders."\n"
|
||||
.$signedHeaders."\n"
|
||||
.$hashedRequestPayload;
|
||||
|
||||
// step 2: build string to sign
|
||||
$date = gmdate("Ymd\THis\Z", $time);
|
||||
$shortDate = substr($date, 0, 8);
|
||||
$credentialScope = $shortDate . '/' .$this->region . '/' . $this->service . '/request';
|
||||
$hashedCanonicalRequest = hash("sha256", $canonicalRequest);
|
||||
$stringToSign = $algorithm."\n"
|
||||
.$date."\n"
|
||||
.$credentialScope."\n"
|
||||
.$hashedCanonicalRequest;
|
||||
|
||||
// step 3: sign string
|
||||
$kDate = hash_hmac("sha256", $shortDate, $this->SecretAccessKey, true);
|
||||
$kRegion = hash_hmac("sha256", $this->region, $kDate, true);
|
||||
$kService = hash_hmac("sha256", $this->service, $kRegion, true);
|
||||
$kSigning = hash_hmac("sha256", "request", $kService, true);
|
||||
$signature = hash_hmac("sha256", $stringToSign, $kSigning);
|
||||
|
||||
// step 4: build authorization
|
||||
$credential = $this->AccessKeyId . '/' . $shortDate . '/' . $this->region . '/' . $this->service . '/request';
|
||||
$authorization = $algorithm . ' Credential=' . $credential . ", SignedHeaders=" . $signedHeaders . ", Signature=" . $signature;
|
||||
|
||||
return $authorization;
|
||||
}
|
||||
|
||||
private function escape($str)
|
||||
{
|
||||
$search = ['+', '*', '%7E'];
|
||||
$replace = ['%20', '%2A', '~'];
|
||||
return str_replace($search, $replace, urlencode($str));
|
||||
}
|
||||
|
||||
private function getCanonicalQueryString($parameters)
|
||||
{
|
||||
if(empty($parameters)) return '';
|
||||
ksort($parameters);
|
||||
$canonicalQueryString = '';
|
||||
foreach ($parameters as $key => $value) {
|
||||
$canonicalQueryString .= '&' . $this->escape($key). '=' . $this->escape($value);
|
||||
}
|
||||
return substr($canonicalQueryString, 1);
|
||||
}
|
||||
|
||||
private function getCanonicalHeaders($oldheaders){
|
||||
$headers = array();
|
||||
foreach ($oldheaders as $key => $value) {
|
||||
$headers[strtolower($key)] = trim($value);
|
||||
}
|
||||
ksort($headers);
|
||||
|
||||
$canonicalHeaders = '';
|
||||
$signedHeaders = '';
|
||||
foreach ($headers as $key => $value) {
|
||||
$canonicalHeaders .= $key . ':' . $value . "\n";
|
||||
$signedHeaders .= $key . ';';
|
||||
}
|
||||
$signedHeaders = substr($signedHeaders, 0, -1);
|
||||
return [$canonicalHeaders, $signedHeaders];
|
||||
}
|
||||
|
||||
private function curl($method, $url, $body, $header){
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
||||
if(!empty($body)){
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
||||
}
|
||||
$response = curl_exec($ch);
|
||||
$errno = curl_errno($ch);
|
||||
if ($errno) {
|
||||
$this->setError('Curl error: ' . curl_error($ch));
|
||||
}
|
||||
curl_close($ch);
|
||||
if ($errno) return false;
|
||||
|
||||
$arr=json_decode($response,true);
|
||||
if($arr){
|
||||
if(isset($arr['ResponseMetadata']['Error']['MessageCN'])){
|
||||
$this->setError($arr['ResponseMetadata']['Error']['MessageCN']);
|
||||
return false;
|
||||
}elseif(isset($arr['ResponseMetadata']['Error']['Message'])){
|
||||
$this->setError($arr['ResponseMetadata']['Error']['Message']);
|
||||
return false;
|
||||
}elseif(isset($arr['Result'])){
|
||||
return $arr['Result'];
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
$this->setError('返回数据解析失败');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function setError($message){
|
||||
$this->error = $message;
|
||||
//file_put_contents('logs.txt',date('H:i:s').' '.$message."\r\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
@@ -91,14 +91,14 @@ class west implements DnsInterface {
|
||||
}
|
||||
|
||||
//添加解析记录
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$param = ['act' => 'adddnsrecord', 'domain' => $this->domain, 'host' => $Name, 'type' => $this->convertType($Type), 'value' => $Value, 'level' => $MX, 'ttl' => intval($TTL), 'line' => $Line];
|
||||
$data = $this->execute('/domain/', $param);
|
||||
return is_array($data) ? $data['id'] : false;
|
||||
}
|
||||
|
||||
//修改解析记录
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){
|
||||
public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Weight = null, $Remark = null){
|
||||
$param = ['act' => 'moddnsrecord', 'domain' => $this->domain, 'id' => $RecordId, 'type' => $this->convertType($Type), 'value' => $Value, 'level' => $MX, 'ttl' => intval($TTL), 'line' => $Line];
|
||||
$data = $this->execute('/domain/', $param);
|
||||
return is_array($data);
|
||||
|
||||
@@ -198,7 +198,7 @@ function save(){
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
$("#modal-store").modal('hide');
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
@@ -220,7 +220,7 @@ function delItem(id) {
|
||||
layer.close(ii);
|
||||
if(data.code == 0){
|
||||
layer.closeAll();
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2});
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ function saveAdd(){
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
$("#modal-store").modal('hide');
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
@@ -289,7 +289,7 @@ function saveEdit(){
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
$("#modal-store2").modal('hide');
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
@@ -311,7 +311,7 @@ function delItem(id) {
|
||||
layer.close(ii);
|
||||
if(data.code == 0){
|
||||
layer.closeAll();
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2});
|
||||
}
|
||||
|
||||
@@ -63,6 +63,12 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:360px;
|
||||
<input type="text" class="form-control" name="ttl" value="600" placeholder="指解析结果在DNS服务器中的缓存时间" required min="{$minTTL}">
|
||||
</div>
|
||||
</div>
|
||||
{if $dnsconfig.weight}<div class="form-group" style="display:none" id="weight">
|
||||
<label class="col-sm-3 control-label no-padding-right">权重</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" name="weight" value="" placeholder="留空则不使用权重">
|
||||
</div>
|
||||
</div>{/if}
|
||||
{if $dnsconfig.remark == 2}<div class="form-group">
|
||||
<label class="col-sm-3 control-label no-padding-right">备注</label>
|
||||
<div class="col-sm-9">
|
||||
@@ -225,11 +231,13 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:360px;
|
||||
<script src="{$cdnpublic}bootstrap-table/1.21.4/bootstrap-table.min.js"></script>
|
||||
<script src="{$cdnpublic}bootstrap-table/1.21.4/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
|
||||
<script src="/static/js/bootstrapValidator.min.js"></script>
|
||||
<script src="/static/js/custom.js?v=1002"></script>
|
||||
<script src="/static/js/custom.js?v=1003"></script>
|
||||
<script>
|
||||
var recordLine = {$recordLine|json_encode|raw};
|
||||
var dnsconfig = {$dnsconfig|json_encode|raw};
|
||||
var defaultLine = recordLine[0].id;
|
||||
var sidePagination = dnsconfig.type == 'baidu' ? 'client' : 'server';
|
||||
var showWeight = dnsconfig.weight;
|
||||
$(document).ready(function(){
|
||||
updateToolbar();
|
||||
let defaultPageSize = getCookie('record_pagesize') ? getCookie('record_pagesize') : 15;
|
||||
@@ -242,7 +250,7 @@ $(document).ready(function(){
|
||||
pageSize: pageSize,
|
||||
classes: 'table table-striped table-hover table-bordered',
|
||||
uniqueId: 'RecordId',
|
||||
sidePagination: "{if $dnsconfig.type=='baidu'}client{else}server{/if}",
|
||||
sidePagination: sidePagination,
|
||||
columns: [
|
||||
{
|
||||
field: '',
|
||||
@@ -282,6 +290,11 @@ $(document).ready(function(){
|
||||
field: 'TTL',
|
||||
title: 'TTL'
|
||||
},
|
||||
{
|
||||
field: 'Weight',
|
||||
visible: showWeight,
|
||||
title: '权重'
|
||||
},
|
||||
{
|
||||
field: 'Remark',
|
||||
visible: dnsconfig.remark > 0,
|
||||
@@ -332,13 +345,23 @@ $(document).ready(function(){
|
||||
},
|
||||
});
|
||||
|
||||
$("select[name=type]").change(function(){
|
||||
var typeChange = function(){
|
||||
if($(this).val() == 'MX'){
|
||||
$("#mx_type").show();
|
||||
}else{
|
||||
$("#mx_type").hide();
|
||||
}
|
||||
});
|
||||
if(showWeight){
|
||||
if($(this).val() == 'A' || $(this).val() == 'CNAME' || $(this).val() == 'AAAA'){
|
||||
$("#weight").show();
|
||||
}else{
|
||||
$("#weight").hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$("#form-store select[name=type]").change(typeChange);
|
||||
$("#form-store2 select[name=type]").change(typeChange);
|
||||
|
||||
$("#form-store").bootstrapValidator();
|
||||
$("#form-store2").bootstrapValidator();
|
||||
@@ -372,7 +395,7 @@ function changeLine(obj, elem){
|
||||
if($(obj).find("option:selected").text() == '子集线路(非必填)') return;
|
||||
var tempLine = recordLine.filter((x) => x.parent == line)
|
||||
if(tempLine.length > 0){
|
||||
var option = '<option value="'+line+'">子集线路(非必填)</option>';
|
||||
var option = line.substr(0,2) == 'N.' ? '' : '<option value="'+line+'">子集线路(非必填)</option>';
|
||||
$.each(tempLine, function(index, item){
|
||||
option += '<option value="'+item.id+'">'+item.name+'</option>';
|
||||
})
|
||||
@@ -386,10 +409,11 @@ function addframe(){
|
||||
$("#form-store input[name=recordid]").val('');
|
||||
$("#form-store input[name=name]").val('');
|
||||
$("#form-store select[name=type]").val('A');
|
||||
$("select[name=type]").change();
|
||||
$("#form-store select[name=type]").change();
|
||||
initLine();
|
||||
$("#form-store input[name=value]").val('');
|
||||
$("#form-store input[name=ttl]").val('600');
|
||||
$("#form-store input[name=weight]").val('');
|
||||
$("#form-store input[name=remark]").val('');
|
||||
$("#form-store").data("bootstrapValidator").resetForm();
|
||||
}
|
||||
@@ -401,7 +425,7 @@ function editframe(recordid){
|
||||
$("#form-store input[name=recordid]").val(recordid);
|
||||
$("#form-store input[name=name]").val(row.Name);
|
||||
$("#form-store select[name=type]").val(row.Type);
|
||||
$("select[name=type]").change();
|
||||
$("#form-store select[name=type]").change();
|
||||
initLine();
|
||||
if($('#form-store select[name=line] option[value="'+row.Line+'"]').length > 0){
|
||||
$("#form-store select[name=line]").val(row.Line);
|
||||
@@ -412,6 +436,7 @@ function editframe(recordid){
|
||||
$("#form-store input[name=value]").val(row.Value);
|
||||
$("#form-store input[name=mx]").val(row.MX);
|
||||
$("#form-store input[name=ttl]").val(row.TTL);
|
||||
$("#form-store input[name=weight]").val(row.Weight);
|
||||
$("#form-store input[name=remark]").val(row.Remark);
|
||||
$("#form-store").data("bootstrapValidator").resetForm();
|
||||
}
|
||||
@@ -436,7 +461,7 @@ function save(){
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
$("#modal-store").modal('hide');
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
@@ -456,7 +481,7 @@ function setStatus(recordid, status){
|
||||
if(data.code == 0){
|
||||
layer.closeAll();
|
||||
layer.msg(status=='1'?'开启成功':'暂停成功', {icon: 1, time:500});
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2});
|
||||
}
|
||||
@@ -478,7 +503,7 @@ function delItem(recordid) {
|
||||
if(data.code == 0){
|
||||
layer.closeAll();
|
||||
layer.msg('删除成功', {icon: 1, time:800});
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2});
|
||||
}
|
||||
@@ -510,7 +535,7 @@ function setRemark(recordid) {
|
||||
if(data.code == 0){
|
||||
layer.closeAll();
|
||||
layer.msg('保存成功', {icon: 1, time:800});
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.alert(data.msg, {icon:2});
|
||||
}
|
||||
@@ -532,14 +557,14 @@ function operation(action){
|
||||
if(action == 'edit'){
|
||||
var records = [];
|
||||
$.each(rows, function(index, item){
|
||||
records.push({recordid:item.RecordId, name:item.Name, line:item.Line, mx:item.MX, ttl:item.TTL, remark:item.Remark});
|
||||
records.push({recordid:item.RecordId, name:item.Name, line:item.Line, mx:item.MX, ttl:item.TTL, weight:item.Weight, remark:item.Remark});
|
||||
})
|
||||
batch_edit(records)
|
||||
return;
|
||||
}else if(action == 'editline'){
|
||||
var records = [];
|
||||
$.each(rows, function(index, item){
|
||||
records.push({recordid:item.RecordId, name:item.Name, type:item.Type, value:item.Value, mx:item.MX, ttl:item.TTL, remark:item.Remark});
|
||||
records.push({recordid:item.RecordId, name:item.Name, type:item.Type, value:item.Value, mx:item.MX, ttl:item.TTL, weight:item.Weight, remark:item.Remark});
|
||||
})
|
||||
batch_edit_line(records)
|
||||
return;
|
||||
@@ -570,7 +595,7 @@ function operation(action){
|
||||
if(data.code == 0){
|
||||
layer.closeAll();
|
||||
layer.alert(data.msg, {icon: 1});
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2});
|
||||
}
|
||||
@@ -588,7 +613,7 @@ function batch_edit(records){
|
||||
$("#form-store2 input[name=recordid]").val(row.RecordId);
|
||||
$("#form-store2 input[name=name]").val(row.Name);
|
||||
$("#form-store2 select[name=type]").val(row.Type);
|
||||
$("select[name=type]").change();
|
||||
$("#form-store2 select[name=type]").change();
|
||||
$("#form-store2 input[name=value]").val(row.Value);
|
||||
$("#form-store2").data("bootstrapValidator").resetForm();
|
||||
}
|
||||
@@ -612,7 +637,7 @@ function batch_save(){
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
$("#modal-store2").modal('hide');
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
@@ -642,7 +667,7 @@ function batch_save_line(){
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
$("#modal-store3").modal('hide');
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
@@ -673,7 +698,7 @@ function batch_edit_remark(recordids) {
|
||||
closeBtn: false
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
},
|
||||
error:function(data){
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="panel panel-warning">
|
||||
<div class="panel-heading"><h3 class="panel-title">使用说明</h3></div>
|
||||
<div class="panel-body">
|
||||
<p><li>数据接口:<a href="https://monitor.gacjie.cn/" target="_blank" rel="noreferrer">GacJieMonitor</a> 数据接口支持CloudFlare、CloudFront、Gcore;<a href="https://hostmonit.com/" target="_blank" rel="noreferrer">HostMonit</a> 只支持CloudFlare。</li></p>
|
||||
<p><li>数据接口:<a href="https://www.wetest.vip/" target="_blank" rel="noreferrer">wetest.vip</a> 数据接口支持CloudFlare、CloudFront、Gcore;<a href="https://stock.hostmonit.com/" target="_blank" rel="noreferrer">HostMonit</a> 只支持CloudFlare。</li></p>
|
||||
<p><li>接口密钥:默认o1zrmHAF为免费KEY可永久免费使用。</li></p>
|
||||
<p><li>计划任务:将以下命令添加到计划任务,周期设置为15分钟以上</li></p>
|
||||
<p><code>cd {:app()->getRootPath()} && php think opiptask</code></p>
|
||||
@@ -27,7 +27,7 @@
|
||||
<form onsubmit="return saveSetting(this)" method="post" class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">数据接口</label>
|
||||
<div class="col-sm-9"><select class="form-control" name="optimize_ip_api" default="{:config_get('optimize_ip_api')}"><option value="0">GacJieMonitor</option><option value="1">HostMonit</option></select></div>
|
||||
<div class="col-sm-9"><select class="form-control" name="optimize_ip_api" default="{:config_get('optimize_ip_api')}"><option value="0">wetest.vip</option><option value="1">HostMonit</option></select></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">接口密钥</label>
|
||||
|
||||
@@ -253,7 +253,7 @@ function save(){
|
||||
}, function(){
|
||||
layer.closeAll();
|
||||
$("#modal-store").modal('hide');
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
});
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2})
|
||||
@@ -271,7 +271,7 @@ function setStatus(id,status) {
|
||||
success : function(data) {
|
||||
layer.close(ii);
|
||||
if(data.code == 0){
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.msg(data.msg, {icon:2, time:1500});
|
||||
}
|
||||
@@ -292,7 +292,7 @@ function delItem(id) {
|
||||
layer.close(ii);
|
||||
if(data.code == 0){
|
||||
layer.closeAll();
|
||||
searchSubmit();
|
||||
searchRefresh();
|
||||
}else{
|
||||
layer.alert(data.msg, {icon: 2});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ return [
|
||||
'show_error_msg' => true,
|
||||
'exception_tmpl' => \think\facade\App::getAppPath() . 'view/exception.tpl',
|
||||
|
||||
'version' => '1011',
|
||||
'version' => '1017',
|
||||
|
||||
'dbversion' => '1011'
|
||||
];
|
||||
|
||||
BIN
public/static/images/huoshan.ico
Normal file
BIN
public/static/images/huoshan.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
@@ -14,8 +14,16 @@ if (parameter_str !== undefined) {
|
||||
window.$_GET = [];
|
||||
}
|
||||
|
||||
function searchRefresh(){
|
||||
$('#listTable').bootstrapTable('refresh');
|
||||
return false;
|
||||
}
|
||||
function searchSubmit(){
|
||||
$('#listTable').bootstrapTable('selectPage', 1);
|
||||
if(typeof sidePagination != 'undefined' && sidePagination == 'client'){
|
||||
$('#listTable').bootstrapTable('refresh');
|
||||
}else{
|
||||
$('#listTable').bootstrapTable('selectPage', 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function searchClear(){
|
||||
@@ -25,7 +33,11 @@ function searchClear(){
|
||||
$('#searchToolbar').find('select[name]').each(function() {
|
||||
$(this).find('option:first').prop("selected", 'selected');
|
||||
});
|
||||
$('#listTable').bootstrapTable('selectPage', 1);
|
||||
if(typeof sidePagination != 'undefined' && sidePagination == 'client'){
|
||||
$('#listTable').bootstrapTable('refresh');
|
||||
}else{
|
||||
$('#listTable').bootstrapTable('selectPage', 1);
|
||||
}
|
||||
}
|
||||
function updateToolbar(){
|
||||
$('#searchToolbar').find(':input[name]').each(function() {
|
||||
|
||||
Reference in New Issue
Block a user