|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DevOpsSantana\AAPanel; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class AAPanelSite |
|
7
|
|
|
* @package DevOpsSantana\AAPanel |
|
8
|
|
|
* @author Rogério Santana <https://github.com/devopssantana> |
|
9
|
|
|
* @since : 2022 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
class AAPanelSite extends AAPanelConnect |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class Construct |
|
17
|
|
|
*/ |
|
18
|
|
|
public function __construct() |
|
19
|
|
|
{ |
|
20
|
|
|
parent::__construct(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @description List Site |
|
25
|
|
|
* @param int $type |
|
26
|
|
|
* @param int $limit |
|
27
|
|
|
* @param string $orderBy |
|
28
|
|
|
* |
|
29
|
|
|
*/ |
|
30
|
|
|
public function List(int $type = -1, int $limit = 100, string $orderBy = 'id') |
|
31
|
|
|
{ |
|
32
|
|
|
$url = $this->serverUrl . '/data?action=getData&table=sites'; |
|
33
|
|
|
|
|
34
|
|
|
$this->data['type'] = $type; |
|
35
|
|
|
$this->data['limit'] = $limit; |
|
36
|
|
|
$this->data['order'] = $orderBy; |
|
37
|
|
|
|
|
38
|
|
|
return (parent::Execute($url, $this->data)); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @description Site Stop |
|
43
|
|
|
* @param $id |
|
44
|
|
|
* @param $domain |
|
45
|
|
|
* @return mixed |
|
46
|
|
|
*/ |
|
47
|
|
|
public function Stop($id, $domain): mixed |
|
48
|
|
|
{ |
|
49
|
|
|
$url = $this->serverUrl . '/site?action=SiteStop'; |
|
50
|
|
|
|
|
51
|
|
|
$this->data['id'] = $id; |
|
52
|
|
|
$this->data['name'] = $domain; |
|
53
|
|
|
return (parent::Execute($url, $this->data)); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @description Site Start |
|
58
|
|
|
* @param $id |
|
59
|
|
|
* @param $domain |
|
60
|
|
|
* @return mixed |
|
61
|
|
|
*/ |
|
62
|
|
|
public function Start($id, $domain): mixed |
|
63
|
|
|
{ |
|
64
|
|
|
$url = $this->serverUrl . '/site?action=SiteStart'; |
|
65
|
|
|
|
|
66
|
|
|
$this->data['id'] = $id; |
|
67
|
|
|
$this->data['name'] = $domain; |
|
68
|
|
|
return (parent::Execute($url, $this->data)); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @description Site Size |
|
73
|
|
|
* @param string $path |
|
74
|
|
|
* @return mixed |
|
75
|
|
|
*/ |
|
76
|
|
|
public function Size(string $domain, string $path = '/www/wwwroot/'): mixed |
|
77
|
|
|
{ |
|
78
|
|
|
$url = $this->serverUrl . '/files?action=GetDirSize'; |
|
79
|
|
|
|
|
80
|
|
|
$this->data['path'] = $path . $domain; |
|
81
|
|
|
return (parent::Execute($url, $this->data)); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @description Create Account Server |
|
86
|
|
|
* @param string $domain -- Domain Account Create |
|
87
|
|
|
* @param $typeId -- Account Category |
|
|
|
|
|
|
88
|
|
|
* @param string $type -- Language Type |
|
89
|
|
|
* @param int $version -- Language Version |
|
90
|
|
|
* @param int $port -- Port |
|
91
|
|
|
* @param $description -- Account Description |
|
92
|
|
|
* @param bool $ftp -- Create FTP Account |
|
93
|
|
|
* @param bool $sql -- Create SQL Account |
|
94
|
|
|
* @param bool $ssl -- Enable Certificate SSL |
|
95
|
|
|
* @param bool $https -- Force Https use |
|
96
|
|
|
* @param array $domainList -- Domain Add |
|
97
|
|
|
* @param $path -- Dir Path |
|
98
|
|
|
* @return bool|string |
|
99
|
|
|
*/ |
|
100
|
|
|
public function Create( |
|
101
|
|
|
string $domain, |
|
102
|
|
|
int $typeId, |
|
103
|
|
|
bool $ftp = false, |
|
104
|
|
|
$sql, |
|
105
|
|
|
bool $ssl = true, |
|
106
|
|
|
bool $https = true, |
|
107
|
|
|
array $domainList = [], |
|
108
|
|
|
string $path = null, |
|
109
|
|
|
string $type = 'PHP', |
|
110
|
|
|
int $version = 81, |
|
111
|
|
|
int $port = 80, |
|
112
|
|
|
string $description = null, |
|
113
|
|
|
string $sqlDataUser = null, |
|
114
|
|
|
string $sqlDataPassword = null, |
|
115
|
|
|
string $ftpUsername = null, |
|
116
|
|
|
string $ftpPassword = null, |
|
117
|
|
|
) { |
|
118
|
|
|
$url = $this->serverUrl . '/site?action=AddSite'; |
|
119
|
|
|
$path = !empty($path) ? $path : $domain; |
|
120
|
|
|
|
|
121
|
|
|
$this->data['webname'] = json_encode(array("domain" => $domain, "domainlist" => $domainList, "count" => 0)); |
|
122
|
|
|
$this->data['path'] = '/www/wwwroot/' . $path; |
|
123
|
|
|
$this->data['type_id'] = $typeId; |
|
124
|
|
|
$this->data['type'] = $type; |
|
125
|
|
|
$this->data['version'] = $version; |
|
126
|
|
|
$this->data['port'] = $port; |
|
127
|
|
|
$this->data['ps'] = $description; |
|
128
|
|
|
$this->data['ftp'] = $ftp; |
|
129
|
|
|
$this->data['sql'] = $sql === false ? false : (string) $sql; |
|
130
|
|
|
$this->data['codeing'] = 'utf8'; |
|
131
|
|
|
$this->data['set_ssl'] = $ssl; |
|
132
|
|
|
$this->data['force_ssl'] = $https; |
|
133
|
|
|
|
|
134
|
|
|
|
|
135
|
|
|
if ($this->data['ftp'] === true && (new AAPanelFTP())->Verify($ftpUsername, $ftpPassword) === false) |
|
|
|
|
|
|
136
|
|
|
{ |
|
137
|
|
|
echo json_encode(array()); |
|
138
|
|
|
return; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
$this->data['ftp_username'] = $ftpUsername; |
|
142
|
|
|
$this->data['ftp_password'] = $ftpPassword; |
|
143
|
|
|
|
|
144
|
|
|
|
|
145
|
|
|
if ($this->data['sql'] !== false && (new AAPanelDatabase())->Verify($sqlDataUser, $sqlDataPassword) === false) |
|
|
|
|
|
|
146
|
|
|
{ |
|
147
|
|
|
echo json_encode(array()); |
|
148
|
|
|
return; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
$this->data['datauser'] = $sqlDataUser; |
|
152
|
|
|
$this->data['datapassword'] = $sqlDataPassword; |
|
153
|
|
|
|
|
154
|
|
|
return (parent::Execute($url, $this->data)); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @description Delete Site |
|
159
|
|
|
* @param $id |
|
160
|
|
|
* @param $domain |
|
161
|
|
|
* @param bool $ftp |
|
162
|
|
|
* @param bool $this->database |
|
163
|
|
|
* @param bool $path |
|
164
|
|
|
* @return mixed |
|
165
|
|
|
*/ |
|
166
|
|
|
public function Delete($id, $domain, bool $ftp = true, bool $database = true, bool $path = true): mixed |
|
167
|
|
|
{ |
|
168
|
|
|
$url = $this->serverUrl . '/site?action=DeleteSite'; |
|
169
|
|
|
|
|
170
|
|
|
$this->data['id'] = $id; |
|
171
|
|
|
$this->data['webname'] = $domain; |
|
172
|
|
|
$this->data['ftp'] = $ftp; |
|
173
|
|
|
$this->data['database'] = $database; |
|
174
|
|
|
$this->data['path'] = $path; |
|
175
|
|
|
return (parent::Execute($url, $this->data)); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @description Update Site Note |
|
180
|
|
|
* @param int $id |
|
181
|
|
|
* @param string $description |
|
182
|
|
|
* @return mixed |
|
183
|
|
|
*/ |
|
184
|
|
|
public function Note(int $id, string $description): mixed |
|
185
|
|
|
{ |
|
186
|
|
|
$url = $this->serverUrl . '/data?action=setPs&table=sites'; |
|
187
|
|
|
|
|
188
|
|
|
$this->data['id'] = $id; |
|
189
|
|
|
$this->data['ps'] = $description; |
|
190
|
|
|
return (parent::Execute($url, $this->data)); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @description Turn On/Off Base directory limit [Anti-XSS attack (Base directory limit)(open_basedir)] |
|
195
|
|
|
* @param int $id |
|
196
|
|
|
* @param string $domain |
|
197
|
|
|
* @return mixed |
|
198
|
|
|
*/ |
|
199
|
|
|
public function BaseDir(int $id, string $domain): mixed |
|
200
|
|
|
{ |
|
201
|
|
|
$url = $this->serverUrl . '/site?action=SetDirUserINI'; |
|
202
|
|
|
|
|
203
|
|
|
$this->data['id'] = $id; |
|
204
|
|
|
$this->data['path'] = '/www/wwwroot/' . $domain; |
|
205
|
|
|
return (parent::Execute($url, $this->data)); |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* @description Set File Default |
|
210
|
|
|
* @param int $id |
|
211
|
|
|
* @return mixed |
|
212
|
|
|
*/ |
|
213
|
|
|
public function SetIndex(int $id): mixed |
|
214
|
|
|
{ |
|
215
|
|
|
$url = $this->serverUrl . '/site?action=SetIndex'; |
|
216
|
|
|
|
|
217
|
|
|
$this->data['id'] = $id; |
|
218
|
|
|
$this->data['Index'] = 'index.php'; |
|
219
|
|
|
return (parent::Execute($url, $this->data)); |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* @description Get File Default |
|
224
|
|
|
* @param int $id |
|
225
|
|
|
* @return mixed |
|
226
|
|
|
*/ |
|
227
|
|
|
public function GetIndex(int $id): mixed |
|
228
|
|
|
{ |
|
229
|
|
|
$url = $this->serverUrl . '/site?action=GetIndex'; |
|
230
|
|
|
|
|
231
|
|
|
$this->data['id'] = $id; |
|
232
|
|
|
return (parent::Execute($url, $this->data)); |
|
233
|
|
|
} |
|
234
|
|
|
} |
|
235
|
|
|
|