1 | <?php |
||||
2 | |||||
3 | namespace Puerari\Cwp; |
||||
4 | |||||
5 | /** |
||||
6 | * @trait Account |
||||
7 | * @package Puerari\Cwp |
||||
8 | * @author Leandro Puerari <[email protected]> |
||||
9 | */ |
||||
10 | trait Account |
||||
11 | { |
||||
12 | /** |
||||
13 | * @param string $domain : main domain associated with the account |
||||
14 | * @param string $user : username to create |
||||
15 | * @param string $pass : Password for the account |
||||
16 | * @param string $email : Email Address of the account owner |
||||
17 | * @param string $server_ips : Ip server |
||||
18 | * @param string $package : Create account with package |
||||
19 | * @param int $inode : Limit inodes, 0 for unlimited |
||||
20 | * @param int $limit_nproc : Limit number of processes for account, don’t use 0 as it will not allow any processes |
||||
21 | * @param int $limit_nofile : Limit number of open files for account |
||||
22 | * @param bool $autossl : Autossl (false = Not / true = Yes) |
||||
23 | * @param bool $encodepass : (true/false if the option is true, you must send the password base64 encoded) |
||||
24 | * @param $reseller : (1 = To resell, Account Reseller for a Reseller's Package, Empty for Standard Package) |
||||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||||
25 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
26 | * status -> OK |
||||
27 | * status -> Error, msj -> Account already exists. |
||||
28 | */ |
||||
29 | public function createAccount(string $domain, string $user, string $pass, string $email, string $server_ips, |
||||
30 | string $package = 'default', int $inode = 0, int $limit_nproc = 40, int $limit_nofile = 150, |
||||
31 | bool $autossl = false, bool $encodepass = false, $reseller = null) |
||||
32 | { |
||||
33 | $autossl = intval($autossl); |
||||
34 | $this->data = compact('domain', 'user', 'pass', 'email', 'package', 'inode', |
||||
0 ignored issues
–
show
|
|||||
35 | 'limit_nproc', 'limit_nofile', 'server_ips', 'autossl', 'encodepass', 'reseller'); |
||||
36 | $this->data['debug'] = $this->debug; |
||||
37 | $this->data['action'] = 'add'; |
||||
38 | $this->cwpuri = 'account'; |
||||
0 ignored issues
–
show
|
|||||
39 | return $this->execCurl(); |
||||
0 ignored issues
–
show
It seems like
execCurl() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
40 | } |
||||
41 | |||||
42 | /** |
||||
43 | * @param string $user : Account username |
||||
44 | * @param string $email : Email Address of the account owner |
||||
45 | * @param string $server_ips : Ip to edit |
||||
46 | * @param string $package : Package name or ID with @ front Ex: @12 |
||||
47 | * @param string $backup : on/off |
||||
48 | * @param int $inode : number of Inodes |
||||
49 | * @param int $processes : number of processes |
||||
50 | * @param int $openfiles : number of open files |
||||
51 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
52 | * status -> OK |
||||
53 | * status -> Error, msj -> must indicate a user |
||||
54 | * status -> Error, msj -> User does not exist |
||||
55 | * status -> Error, msj -> You must indicate an email |
||||
56 | * status -> Error, msj -> There is no package with this name |
||||
57 | * status -> Error, msj-> There was an error updating |
||||
58 | * status -> Error, msj -> User is root |
||||
59 | */ |
||||
60 | public function updateAccount(string $user, string $email, string $server_ips, string $package = 'default', |
||||
61 | string $backup = 'on', int $inode = 0, int $processes = 40, int $openfiles = 150) |
||||
62 | { |
||||
63 | $this->data = compact('user', 'email', 'server_ips', 'package', 'backup', 'inode', 'processes', 'openfiles'); |
||||
0 ignored issues
–
show
|
|||||
64 | $this->data['debug'] = $this->debug; |
||||
65 | $this->data['action'] = 'udp'; |
||||
66 | $this->cwpuri = 'account'; |
||||
0 ignored issues
–
show
|
|||||
67 | return $this->execCurl(); |
||||
68 | } |
||||
69 | |||||
70 | /** |
||||
71 | * @param string $user : Account username |
||||
72 | * @param string $email : Email Address of the account owner |
||||
73 | * @param bool $all : (false or entry / true) Delete all Accounts associated with a reseller (true by default) |
||||
74 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
75 | * status -> OK |
||||
76 | * status -> Error, msj -> account does not exist |
||||
77 | */ |
||||
78 | public function deleteAccount(string $user, string $email, bool $all = true) |
||||
79 | { |
||||
80 | $all = intval($all); |
||||
81 | $this->data = compact('user', 'email', 'all'); |
||||
0 ignored issues
–
show
|
|||||
82 | $this->data['debug'] = $this->debug; |
||||
83 | $this->data['action'] = 'del'; |
||||
84 | $this->cwpuri = 'account'; |
||||
0 ignored issues
–
show
|
|||||
85 | return $this->execCurl(); |
||||
86 | } |
||||
87 | |||||
88 | /** |
||||
89 | * @param $reseller : defaults to null - (1 = To resell, Account Reseller for a Reseller's Package, Empty for Standard Package) |
||||
0 ignored issues
–
show
|
|||||
90 | * @param string $op : defaults to null - count (if this option is present, only the number of accounts for the server will be shown) |
||||
91 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
92 | * status -> OK, msj -> array accounts |
||||
93 | * status -> OK, msj -> no records exist |
||||
94 | */ |
||||
95 | public function listAccounts($reseller = null, $op = null) |
||||
96 | { |
||||
97 | $this->data = compact('reseller', 'op'); |
||||
0 ignored issues
–
show
|
|||||
98 | $this->data['debug'] = $this->debug; |
||||
99 | $this->data['action'] = 'list'; |
||||
100 | $this->cwpuri = 'account'; |
||||
0 ignored issues
–
show
|
|||||
101 | return $this->execCurl(); |
||||
102 | } |
||||
103 | |||||
104 | /** |
||||
105 | * @param string $user : Account username |
||||
106 | * @param bool $all : (false or entry / true) Suspend all Accounts associated with a reseller (true by default) |
||||
107 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
108 | * status -> OK |
||||
109 | * status -> Error, msj -> account does not exist |
||||
110 | */ |
||||
111 | public function suspendAccount(string $user, bool $all = true) |
||||
112 | { |
||||
113 | $all = intval($all); |
||||
114 | $this->data = compact('user', 'all'); |
||||
0 ignored issues
–
show
|
|||||
115 | $this->data['debug'] = $this->debug; |
||||
116 | $this->data['action'] = 'susp'; |
||||
117 | $this->cwpuri = 'account'; |
||||
0 ignored issues
–
show
|
|||||
118 | return $this->execCurl(); |
||||
119 | } |
||||
120 | |||||
121 | /** |
||||
122 | * @param string $user : Account username |
||||
123 | * @param bool $all : (false or entry / true) Suspend all Accounts associated with a reseller (true by default) |
||||
124 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
125 | * status -> OK |
||||
126 | * status -> Error, msj -> account does not exist |
||||
127 | */ |
||||
128 | public function unsuspendAccount(string $user, bool $all = true) |
||||
129 | { |
||||
130 | $all = intval($all); |
||||
131 | $this->data = compact('user', 'all'); |
||||
0 ignored issues
–
show
|
|||||
132 | $this->data['debug'] = $this->debug; |
||||
133 | $this->data['action'] = 'unsp'; |
||||
134 | $this->cwpuri = 'account'; |
||||
0 ignored issues
–
show
|
|||||
135 | return $this->execCurl(); |
||||
136 | } |
||||
137 | |||||
138 | /** |
||||
139 | * @param string $user : Account username |
||||
140 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
141 | * status -> OK, Array(domain, subdomains, database, user database) |
||||
142 | * status -> Error, msj -> account does not exist |
||||
143 | */ |
||||
144 | public function listAccountDetails(string $user) |
||||
145 | { |
||||
146 | $this->data = compact('user'); |
||||
0 ignored issues
–
show
|
|||||
147 | $this->data['debug'] = $this->debug; |
||||
148 | $this->data['action'] = 'list'; |
||||
149 | $this->cwpuri = 'accountdetail'; |
||||
0 ignored issues
–
show
|
|||||
150 | return $this->execCurl(); |
||||
151 | } |
||||
152 | |||||
153 | /** |
||||
154 | * @param string $user : Account username |
||||
155 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
156 | * status -> OK, msj -> array Sniffers (Email, Ftp, Domains, Subdomains, Mysql, User Mysql) |
||||
157 | * status -> Error, msj -> account does not exist |
||||
158 | */ |
||||
159 | public function listAccountQuota(string $user) |
||||
160 | { |
||||
161 | $this->data = compact('user'); |
||||
0 ignored issues
–
show
|
|||||
162 | $this->data['debug'] = $this->debug; |
||||
163 | $this->data['action'] = 'list'; |
||||
164 | $this->cwpuri = 'accountquota'; |
||||
0 ignored issues
–
show
|
|||||
165 | return $this->execCurl(); |
||||
166 | } |
||||
167 | |||||
168 | /** |
||||
169 | * @param string $user : Account username |
||||
170 | * @param string $package : Package name or ID with @ front Ex: @12 |
||||
171 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
172 | * status -> OK |
||||
173 | * status -> Error, msj=> The package does not exist |
||||
174 | */ |
||||
175 | public function updateAccountPackage(string $user, string $package) |
||||
176 | { |
||||
177 | $this->data = compact('user', 'pass', 'server_ips', 'package', 'backup', 'inode', 'processes', 'openfiles'); |
||||
0 ignored issues
–
show
|
|||||
178 | $this->data['debug'] = $this->debug; |
||||
179 | $this->data['action'] = 'udp'; |
||||
180 | $this->cwpuri = 'changepack'; |
||||
0 ignored issues
–
show
|
|||||
181 | return $this->execCurl(); |
||||
182 | } |
||||
183 | |||||
184 | /** |
||||
185 | * @param string $user : Account username (If not specified, a list of accounts will be displayed) |
||||
186 | * @param int $timer : Expiration time of the session, expressed in Minute, example 2 |
||||
187 | * @param string $module : Indicate the name of the module to be redirected |
||||
188 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
189 | * status -> OK |
||||
190 | */ |
||||
191 | public function listAccountAutoLogin(string $user, int $timer, string $module) |
||||
192 | { |
||||
193 | $this->data = compact('user', 'timer', 'module'); |
||||
0 ignored issues
–
show
|
|||||
194 | $this->data['debug'] = $this->debug; |
||||
195 | $this->data['action'] = 'list'; |
||||
196 | $this->cwpuri = 'user_session'; |
||||
0 ignored issues
–
show
|
|||||
197 | return $this->execCurl(); |
||||
198 | } |
||||
199 | |||||
200 | /** |
||||
201 | * @param string $user : Account username to change password |
||||
202 | * @param string $pass : New password (Must be greater than 8 characters) |
||||
203 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
204 | * status -> OK |
||||
205 | * status -> Error, msj=> The package does not exist |
||||
206 | */ |
||||
207 | public function updateAccountPassword(string $user, string $pass) |
||||
208 | { |
||||
209 | $this->data = compact('user', 'pass'); |
||||
0 ignored issues
–
show
|
|||||
210 | $this->data['action'] = 'udp'; |
||||
211 | $this->cwpuri = 'changepass'; |
||||
0 ignored issues
–
show
|
|||||
212 | return $this->execCurl(); |
||||
213 | } |
||||
214 | |||||
215 | /** |
||||
216 | * @param string $user : Account username |
||||
217 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
218 | * status -> OK |
||||
219 | * status -> Error -> user does not exist |
||||
220 | */ |
||||
221 | public function listAccountMetadata(string $user) |
||||
222 | { |
||||
223 | $this->data = compact('user'); |
||||
0 ignored issues
–
show
|
|||||
224 | $this->data['action'] = 'list'; |
||||
225 | $this->cwpuri = 'account_metadata'; |
||||
0 ignored issues
–
show
|
|||||
226 | return $this->execCurl(); |
||||
227 | } |
||||
228 | |||||
229 | /** |
||||
230 | * @param string $user : Account username |
||||
231 | * @return string|bool: false on failure, result on success (JSON / XML) |
||||
232 | * status -> OK, mysql->0/10, email->1/10, domain->3/10, ftp->1/5 |
||||
233 | * status -> Error, msj -> User does not exist |
||||
234 | */ |
||||
235 | public function listAccountQuotasLimits(string $user) |
||||
236 | { |
||||
237 | $this->data = compact('user'); |
||||
0 ignored issues
–
show
|
|||||
238 | $this->data['debug'] = $this->debug; |
||||
239 | $this->data['action'] = 'list'; |
||||
240 | $this->cwpuri = 'quotalimit'; |
||||
0 ignored issues
–
show
|
|||||
241 | return $this->execCurl(); |
||||
242 | } |
||||
243 | } |
||||
244 |