DomainInfo.php
4.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
namespace App\Models\Domain;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
/**
* Class DomainInfo
*
* @package App\Models\Aside\DomainLogic
* @Author YiYuan-LIn
* @Date : 2019/5/16
* 域名信息模型
*/
class DomainInfo extends Base
{
const SERVER_IP_301 = '43.135.137.172';
const STATUS_ONE = 1;
const STATUS_ZERO = 0;
public $btAction = [
'create_site' => '/site?action=AddSite',
];
protected $table = 'gl_domain_info';
// 软删除 0:正常 1:删除
/** @var int 软删除 - 正常 */
const DELETED_NORMAL = 0;
/** @var int 软删除 - 删除 */
const DELETED_DELETE = 1;
protected $hidden = [
// 'created_at',
'updated_at'
];
/**
* 字段信息
* @return array
*/
public function FieldsArray()
{
return [
'domain' => '域名',
'belong_to' => '域名归属',
'status' => '域名状态',
'domain_start_time' => '域名开始时间',
'domain_end_time' => '域名结束时间',
'certificate_start_time' => '证书开始时间',
'certificate_end_time' => '证书结束时间',
];
}
/**
* @remark :获取域名信息
* @name :getDomain
* @author :lyh
* @method :post
* @time :2023/9/4 17:05
*/
public function getDomain($domain){
$res_domain = Cache::get('domain_'.$domain);
if(empty($res_domain)){
$info = $this->read(['id'=>$domain]);
if($info === false){
return '';
}
$res_domain = 'https://'.$info['domain'].'/';
Cache::put('domain_'.$domain,$res_domain,24 * 3600);
}
return $res_domain;
}
/**
* @remark :根据项目id获取域名
* @name :getProjectIdDomain
* @author :lyh
* @method :post
* @time :2024/5/29 9:28
*/
public function getProjectIdDomain($project_id){
$info = $this->read(['project_id'=>$project_id],['domain']);
if($info === false){
return '';
}
return 'https://'.$info['domain'].'/';
}
/**
* @remark :301跳转扩展字段
* @name :getExtendConfigAttribute
* @author :lyh
* @method :post
* @time :2023/11/6 15:36
*/
public function getExtendConfigAttribute($value)
{
$value = Arr::s2a($value);
return $value;
}
/**
* @remark :域名列表设置
* @name :getOtherDomainAttribute
* @author :lyh
* @method :post
* @time :2023/11/6 15:39
*/
public function getOtherDomainAttribute($value)
{
$value = Arr::s2a($value);
return $value;
}
/**
* 禁止访问国家
* @param $value
* @return array|mixed
* @author Akun
* @date 2024/07/01 17:05
*/
public function getNotAllowCountryAttribute($value)
{
$value = Arr::s2a($value);
return $value;
}
/**
* 禁止访问ip
* @param $value
* @return array|mixed
* @author Akun
* @date 2024/07/01 17:05
*/
public function getNotAllowIpAttribute($value)
{
$value = Arr::s2a($value);
return $value;
}
/**
* amp301跳转扩展字段
* @param $value
* @return array|mixed
* @author Akun
* @date 2024/12/03 17:26
*/
public function getAmpExtendConfigAttribute($value)
{
$value = Arr::s2a($value);
return $value;
}
public static function getCacheInfoByProjectId($project_id){
$cache_key = 'DOMAIN_INFO_BY_PROJECT_ID_' . $project_id;
$data = Cache::get($cache_key);
if(!$data){
$data = DomainInfo::where('project_id', $project_id)->first();
if($data){
Cache::put($cache_key, $data, 3600);
}
}
return $data;
}
}