mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-05-12 16:26:26 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06b43fa33f | ||
|
|
fa9235562a | ||
|
|
92ba34833b | ||
|
|
83c1afc186 |
@@ -38,7 +38,7 @@ class Auth extends BaseController
|
||||
$user = Db::name('user')->where('username', $username)->find();
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
if ($user['status'] == 0) return json(['code' => -1, 'msg' => '此用户已被封禁', 'vcode' => 1]);
|
||||
if ($user['totp_open'] == 1 && !empty($user['totp_secret'])) {
|
||||
if (isset($user['totp_open']) && $user['totp_open'] == 1 && !empty($user['totp_secret'])) {
|
||||
session('pre_login_user', $user['id']);
|
||||
if (file_exists($login_limit_file)) {
|
||||
unlink($login_limit_file);
|
||||
@@ -53,7 +53,7 @@ class Auth extends BaseController
|
||||
} else {
|
||||
if ($user) {
|
||||
Db::name('log')->insert(['uid' => $user['id'], 'action' => '登录失败', 'data' => 'IP:' . $this->clientip, 'addtime' => date("Y-m-d H:i:s")]);
|
||||
if ($user['totp_open'] == 1 && !empty($user['totp_secret'])) $login_limit_count = 10;
|
||||
if (isset($user['totp_open']) && $user['totp_open'] == 1 && !empty($user['totp_secret'])) $login_limit_count = 10;
|
||||
}
|
||||
if (!file_exists($login_limit_file)) {
|
||||
$login_limit = ['count' => 0, 'time' => 0];
|
||||
|
||||
@@ -600,6 +600,7 @@ class DeployHelper
|
||||
'type' => 'input',
|
||||
'placeholder' => '',
|
||||
'show' => 'product!=\'clb\'&&product!=\'tke\'',
|
||||
'note' => 'CDN、EO、WAF多个域名可用,隔开,其他只能填写1个域名',
|
||||
'required' => true,
|
||||
],
|
||||
],
|
||||
@@ -813,7 +814,7 @@ class DeployHelper
|
||||
'domain' => [
|
||||
'name' => '绑定的域名',
|
||||
'type' => 'input',
|
||||
'placeholder' => '多个域名可使用英文逗号分隔',
|
||||
'placeholder' => '多个域名可使用,分隔',
|
||||
'required' => true,
|
||||
],
|
||||
],
|
||||
@@ -1266,7 +1267,7 @@ class DeployHelper
|
||||
];
|
||||
|
||||
public static $class_config = [
|
||||
1 => '自建面板',
|
||||
1 => '自建系统',
|
||||
2 => '云服务商',
|
||||
3 => '服务器',
|
||||
];
|
||||
|
||||
@@ -150,6 +150,7 @@ class HuaweiCloud
|
||||
curl_close($ch);
|
||||
throw new Exception('Curl error: ' . curl_error($ch));
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$arr = json_decode($response, true);
|
||||
@@ -164,7 +165,6 @@ class HuaweiCloud
|
||||
return $arr;
|
||||
}
|
||||
} else {
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode >= 200 && $httpCode < 300) {
|
||||
return null;
|
||||
} else {
|
||||
|
||||
@@ -42,6 +42,7 @@ class opanel implements DeployInterface
|
||||
$errmsg = null;
|
||||
foreach ($data['items'] as $row) {
|
||||
if (empty($row['primaryDomain'])) continue;
|
||||
$cert_domains = [];
|
||||
$cert_domains[] = $row['primaryDomain'];
|
||||
if(!empty($row['domains'])) $cert_domains += explode(',', $row['domains']);
|
||||
$flag = false;
|
||||
@@ -96,7 +97,7 @@ class opanel implements DeployInterface
|
||||
'1Panel-Token: '.$token,
|
||||
'1Panel-Timestamp: '.$timestamp
|
||||
];
|
||||
$body = $params ? json_encode($params) : null;
|
||||
$body = $params ? json_encode($params) : '{}';
|
||||
if($body) $headers[] = 'Content-Type: application/json';
|
||||
$response = curl_client($url, $body, null, null, $headers, $this->proxy);
|
||||
$result = json_decode($response['body'], true);
|
||||
|
||||
@@ -104,9 +104,14 @@ class tencent implements DeployInterface
|
||||
|
||||
private function deploy_common($product, $cert_id, $instance_id)
|
||||
{
|
||||
if (in_array($product, ['cdn', 'waf', 'teo', 'ddos', 'live', 'vod']) && strpos($instance_id, ',') !== false) {
|
||||
$instance_ids = explode(',', $instance_id);
|
||||
} else {
|
||||
$instance_ids = [$instance_id];
|
||||
}
|
||||
$param = [
|
||||
'CertificateId' => $cert_id,
|
||||
'InstanceIdList' => [$instance_id],
|
||||
'InstanceIdList' => $instance_ids,
|
||||
'ResourceType' => $product,
|
||||
];
|
||||
$data = $this->client->request('DeployCertificateInstance', $param);
|
||||
|
||||
@@ -134,7 +134,7 @@ class huawei implements DnsInterface
|
||||
{
|
||||
$Name = $this->getHost($Name);
|
||||
if ($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"' . $Value . '"';
|
||||
$records = explode(',', $Value);
|
||||
$records = array_reverse(explode(',', $Value));
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line' => $Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if ($Type == 'MX') $params['records'][0] = intval($MX) . ' ' . $Value;
|
||||
if ($Weight > 0) $params['weight'] = intval($Weight);
|
||||
@@ -147,7 +147,7 @@ class huawei implements DnsInterface
|
||||
{
|
||||
$Name = $this->getHost($Name);
|
||||
if ($Type == 'TXT' && substr($Value, 0, 1) != '"') $Value = '"' . $Value . '"';
|
||||
$records = explode(',', $Value);
|
||||
$records = array_reverse(explode(',', $Value));
|
||||
$params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => $records, 'line' => $Line, 'ttl' => intval($TTL), 'description' => $Remark];
|
||||
if ($Type == 'MX') $params['records'][0] = intval($MX) . ' ' . $Value;
|
||||
if ($Weight > 0) $params['weight'] = intval($Weight);
|
||||
|
||||
@@ -131,6 +131,7 @@ class CertDeployService
|
||||
private function saveLog($txt)
|
||||
{
|
||||
if (empty($this->task['processid'])) return;
|
||||
if (!is_dir(app()->getRuntimePath() . 'log')) mkdir(app()->getRuntimePath() . 'log');
|
||||
$file_name = app()->getRuntimePath().'log/'.$this->task['processid'].'.log';
|
||||
file_put_contents($file_name, $txt . PHP_EOL, FILE_APPEND);
|
||||
if(php_sapi_name() == 'cli'){
|
||||
|
||||
@@ -417,6 +417,7 @@ class CertOrderService
|
||||
private function saveLog($txt)
|
||||
{
|
||||
if (empty($this->order['processid'])) return;
|
||||
if (!is_dir(app()->getRuntimePath() . 'log')) mkdir(app()->getRuntimePath() . 'log');
|
||||
$file_name = app()->getRuntimePath().'log/'.$this->order['processid'].'.log';
|
||||
file_put_contents($file_name, $txt . PHP_EOL, FILE_APPEND);
|
||||
if(php_sapi_name() == 'cli'){
|
||||
|
||||
@@ -39,6 +39,9 @@ class CertDnsUtils
|
||||
usort($list, function ($a, $b) {
|
||||
return strcmp($a['name'], $b['name']);
|
||||
});
|
||||
if ($drow['type'] == 'huawei') {
|
||||
$list = self::getHuaweiDnsRecords($list);
|
||||
}
|
||||
$records = [];
|
||||
foreach ($list as $row) {
|
||||
$domain = $row['name'] . '.' . $mainDomain;
|
||||
@@ -46,7 +49,8 @@ class CertDnsUtils
|
||||
if (!$records[$row['name']]) throw new Exception('获取'.$domain.'记录列表失败,'.$dns->getError());
|
||||
|
||||
$filter_records = array_filter($records[$row['name']]['list'], function ($v) use ($row) {
|
||||
return $v['Type'] == $row['type'] && $v['Value'] == $row['value'];
|
||||
if (is_array($v['Value'])) $v['Value'] = implode(',', $v['Value']);
|
||||
return $v['Type'] == $row['type'] && ($v['Value'] == $row['value'] || rtrim($v['Value'], '.') == $row['value']);
|
||||
});
|
||||
if (!empty($filter_records)) {
|
||||
foreach ($filter_records as $recordid => $record) {
|
||||
@@ -76,6 +80,22 @@ class CertDnsUtils
|
||||
}
|
||||
}
|
||||
|
||||
private static function getHuaweiDnsRecords($list)
|
||||
{
|
||||
//将name相同的TXT记录合并
|
||||
$txt_records = [];
|
||||
foreach ($list as $key => $row) {
|
||||
if ($row['type'] == 'TXT') {
|
||||
$txt_records[$row['name']][] = $row['value'];
|
||||
unset($list[$key]);
|
||||
}
|
||||
}
|
||||
foreach ($txt_records as $name => $rows) {
|
||||
$list[] = ['name' => $name, 'type' => 'TXT', 'value' => '"' . implode('","', $rows) . '"'];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function delDns($dnsList, callable $log, $cname = false)
|
||||
{
|
||||
$cnameDomainList = [];
|
||||
@@ -107,6 +127,9 @@ class CertDnsUtils
|
||||
usort($list, function ($a, $b) {
|
||||
return strcmp($a['name'], $b['name']);
|
||||
});
|
||||
if ($drow['type'] == 'huawei') {
|
||||
$list = self::getHuaweiDnsRecords($list);
|
||||
}
|
||||
$records = [];
|
||||
foreach ($list as $row) {
|
||||
//if ($row['type'] == 'CAA') continue;
|
||||
@@ -115,6 +138,7 @@ class CertDnsUtils
|
||||
if (!$records[$row['name']]) throw new Exception('获取'.$domain.'记录列表失败,'.$dns->getError());
|
||||
|
||||
$filter_records = array_filter($records[$row['name']]['list'], function ($v) use ($row) {
|
||||
if (is_array($v['Value'])) $v['Value'] = implode(',', $v['Value']);
|
||||
return $v['Type'] == $row['type'] && ($v['Value'] == $row['value'] || rtrim($v['Value'], '.') == $row['value']);
|
||||
});
|
||||
if (empty($filter_records)) continue;
|
||||
|
||||
@@ -31,7 +31,7 @@ return [
|
||||
'show_error_msg' => true,
|
||||
'exception_tmpl' => \think\facade\App::getAppPath() . 'view/exception.tpl',
|
||||
|
||||
'version' => '1021',
|
||||
'version' => '1022',
|
||||
|
||||
'dbversion' => '1021'
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user