1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Hosting Plugin for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
6
|
|
|
* @package hipanel-module-hosting |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\models; |
12
|
|
|
|
13
|
|
|
use Yii; |
14
|
|
|
|
15
|
|
|
class Vhost extends \hipanel\base\Model |
16
|
|
|
{ |
17
|
|
|
use \hipanel\base\ModelTrait; |
18
|
|
|
|
19
|
|
|
public $backend; |
20
|
|
|
|
21
|
|
|
public function init() |
22
|
|
|
{ |
23
|
|
|
$this->on(self::EVENT_AFTER_FIND, function ($event) { |
|
|
|
|
24
|
|
|
$this->setAttributes([ |
25
|
|
|
'backend_ip' => $this->getAttribute('backend')['ip'], |
26
|
|
|
'proxy_enabled' => $this->getIsProxied(), |
27
|
|
|
]); |
28
|
|
|
}); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function rules() |
32
|
|
|
{ |
33
|
|
|
return [ |
34
|
|
|
[ |
35
|
|
|
[ |
36
|
|
|
'domain', |
37
|
|
|
'ip', |
38
|
|
|
'port', |
39
|
|
|
'path', |
40
|
|
|
'client', |
41
|
|
|
'device', |
42
|
|
|
'account', |
43
|
|
|
'service', |
44
|
|
|
'server', |
45
|
|
|
'soft', |
46
|
|
|
'type', |
47
|
|
|
'state', |
48
|
|
|
'state_label', |
49
|
|
|
'backuping_type', |
50
|
|
|
'backuping_type_label', |
51
|
|
|
'cgibin_postfix', |
52
|
|
|
'domain_prefix', |
53
|
|
|
'docroot_postfix', |
54
|
|
|
'apache_conf', |
55
|
|
|
'nginx_conf', |
56
|
|
|
'docroot', |
57
|
|
|
'cgibin', |
58
|
|
|
'fullpath', |
59
|
|
|
'proxy_enabled', |
60
|
|
|
], |
61
|
|
|
'safe', |
62
|
|
|
], |
63
|
|
|
[ |
64
|
|
|
[ |
65
|
|
|
'id', |
66
|
|
|
'ip_id', |
67
|
|
|
'frontend_id', |
68
|
|
|
'client_id', |
69
|
|
|
'device_id', |
70
|
|
|
'server_id', |
71
|
|
|
'account_id', |
72
|
|
|
'soft_id', |
73
|
|
|
'service_id', |
74
|
|
|
], |
75
|
|
|
'integer', |
76
|
|
|
], |
77
|
|
|
[ |
78
|
|
|
[ |
79
|
|
|
'enable_ssi', |
80
|
|
|
'enable_suexec', |
81
|
|
|
'enable_accesslog', |
82
|
|
|
'enable_errorslog', |
83
|
|
|
'enable_scripts', |
84
|
|
|
'dns_on', |
85
|
|
|
], |
86
|
|
|
'boolean', |
87
|
|
|
], |
88
|
|
|
[ |
89
|
|
|
['id'], |
90
|
|
|
'required', |
91
|
|
|
'on' => ['advanced-config', 'manage-proxy'], |
92
|
|
|
], |
93
|
|
|
[['ip', 'backend_ip'], 'ip'], |
94
|
|
|
[['ip'], 'required', 'on' => ['manage-proxy']], |
95
|
|
|
]; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* {@inheritdoc} |
100
|
|
|
*/ |
101
|
|
|
public function attributeLabels() |
102
|
|
|
{ |
103
|
|
|
return $this->mergeAttributeLabels([ |
104
|
|
|
'domain_prefix' => Yii::t('hipanel:hosting', 'Domain directory prefix'), |
105
|
|
|
'docroot_postfix' => Yii::t('hipanel:hosting', 'DocumentRoot directory postfix'), |
106
|
|
|
'cgibin' => Yii::t('hipanel:hosting', 'CGI-BIN directory postfix'), |
107
|
|
|
'nginx_conf' => Yii::t('hipanel:hosting', 'Additional NGINX config'), |
108
|
|
|
'apache_conf' => Yii::t('hipanel:hosting', 'Additional Apache config'), |
109
|
|
|
'enable_accesslog' => Yii::t('hipanel:hosting', 'Enable access log'), |
110
|
|
|
'enable_errorslog' => Yii::t('hipanel:hosting', 'Enable error log'), |
111
|
|
|
'enable_suexec' => Yii::t('hipanel:hosting', 'Enable suexec'), |
112
|
|
|
'enable_scripts' => Yii::t('hipanel:hosting', 'Allow scripts execution'), |
113
|
|
|
'enable_ssi' => Yii::t('hipanel:hosting', 'Enable SSI'), |
114
|
|
|
'proxy_enabled' => Yii::t('hipanel:hosting', 'Proxy enabled'), |
115
|
|
|
'path' => Yii::t('hipanel:hosting', 'Path'), |
116
|
|
|
]); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getIsProxied() |
120
|
|
|
{ |
121
|
|
|
return isset($this->getAttribute('backend')['id']); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function getBackend_ip() |
125
|
|
|
{ |
126
|
|
|
return $this->getAttribute('backend')['ip']; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function scenarioActions() |
130
|
|
|
{ |
131
|
|
|
return [ |
132
|
|
|
'advanced-config' => 'set-advanced-config', |
133
|
|
|
]; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.