commit | author | age
|
c1418f
|
1 |
<?php |
M |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh |
|
5 |
All rights reserved. |
|
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
|
|
30 |
--UPDATED 08.2009-- |
|
31 |
Full SOAP support for ISPConfig 3.1.4 b |
|
32 |
Updated by Arkadiusz Roch & Artur Edelman |
|
33 |
Copyright (c) Tri-Plex technology |
|
34 |
|
|
35 |
--UPDATED 08.2013-- |
|
36 |
Migrated into new remote classes system |
|
37 |
by Marius Cramer <m.cramer@pixcept.de> |
|
38 |
|
|
39 |
*/ |
|
40 |
|
|
41 |
class remoting_sites extends remoting { |
|
42 |
// Website functions --------------------------------------------------------------------------------------- |
b1a6a5
|
43 |
|
c1418f
|
44 |
//* Get cron details |
M |
45 |
public function sites_cron_get($session_id, $cron_id) |
b1a6a5
|
46 |
{ |
c1418f
|
47 |
global $app; |
b1a6a5
|
48 |
|
c1418f
|
49 |
if(!$this->checkPerm($session_id, 'sites_cron_get')) { |
M |
50 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
51 |
return false; |
|
52 |
} |
|
53 |
$app->uses('remoting_lib'); |
|
54 |
$app->remoting_lib->loadFormDef('../sites/form/cron.tform.php'); |
|
55 |
return $app->remoting_lib->getDataRecord($cron_id); |
|
56 |
} |
b1a6a5
|
57 |
|
c1418f
|
58 |
//* Add a cron record |
M |
59 |
public function sites_cron_add($session_id, $client_id, $params) |
b1a6a5
|
60 |
{ |
c1418f
|
61 |
if(!$this->checkPerm($session_id, 'sites_cron_add')) { |
M |
62 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
63 |
return false; |
|
64 |
} |
b1a6a5
|
65 |
return $this->insertQuery('../sites/form/cron.tform.php', $client_id, $params); |
c1418f
|
66 |
} |
b1a6a5
|
67 |
|
c1418f
|
68 |
//* Update cron record |
M |
69 |
public function sites_cron_update($session_id, $client_id, $cron_id, $params) |
b1a6a5
|
70 |
{ |
c1418f
|
71 |
if(!$this->checkPerm($session_id, 'sites_cron_update')) { |
M |
72 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
73 |
return false; |
|
74 |
} |
b1a6a5
|
75 |
$affected_rows = $this->updateQuery('../sites/form/cron.tform.php', $client_id, $cron_id, $params); |
c1418f
|
76 |
return $affected_rows; |
M |
77 |
} |
b1a6a5
|
78 |
|
c1418f
|
79 |
//* Delete cron record |
M |
80 |
public function sites_cron_delete($session_id, $cron_id) |
b1a6a5
|
81 |
{ |
c1418f
|
82 |
if(!$this->checkPerm($session_id, 'sites_cron_delete')) { |
M |
83 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
84 |
return false; |
|
85 |
} |
b1a6a5
|
86 |
$affected_rows = $this->deleteQuery('../sites/form/cron.tform.php', $cron_id); |
c1418f
|
87 |
return $affected_rows; |
M |
88 |
} |
b1a6a5
|
89 |
|
c1418f
|
90 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
91 |
|
c1418f
|
92 |
//* Get record details |
M |
93 |
public function sites_database_get($session_id, $primary_id) |
b1a6a5
|
94 |
{ |
c1418f
|
95 |
global $app; |
b1a6a5
|
96 |
|
c1418f
|
97 |
if(!$this->checkPerm($session_id, 'sites_database_get')) { |
M |
98 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
99 |
return false; |
|
100 |
} |
|
101 |
$app->uses('remoting_lib'); |
|
102 |
$app->remoting_lib->loadFormDef('../sites/form/database.tform.php'); |
|
103 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
104 |
} |
2af58c
|
105 |
|
MC |
106 |
/* TODO: secure queries! */ |
c1418f
|
107 |
//* Add a record |
M |
108 |
public function sites_database_add($session_id, $client_id, $params) |
b1a6a5
|
109 |
{ |
MC |
110 |
global $app; |
|
111 |
|
c1418f
|
112 |
if(!$this->checkPerm($session_id, 'sites_database_add')) { |
M |
113 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
114 |
return false; |
|
115 |
} |
b1a6a5
|
116 |
|
c1418f
|
117 |
//* Check for duplicates |
cc7a82
|
118 |
$tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = ? AND server_id = ?", $params['database_name'], $params["server_id"]); |
c1418f
|
119 |
if($tmp['dbnum'] > 0) { |
M |
120 |
throw new SoapFault('database_name_error_unique', 'There is already a database with that name on the same server.'); |
|
121 |
return false; |
|
122 |
} |
|
123 |
|
b1a6a5
|
124 |
$sql = $this->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params); |
MC |
125 |
if($sql !== false) { |
|
126 |
$app->uses('sites_database_plugin'); |
c1418f
|
127 |
|
b1a6a5
|
128 |
$this->id = 0; |
MC |
129 |
$this->dataRecord = $params; |
|
130 |
|
82b723
|
131 |
$retval = $this->insertQueryExecute($sql, $params); |
76ec4a
|
132 |
$app->sites_database_plugin->processDatabaseInsert($this); |
82b723
|
133 |
|
MC |
134 |
// set correct values for backup_interval and backup_copies |
|
135 |
if(isset($params['backup_interval']) || isset($params['backup_copies'])){ |
|
136 |
$sql_set = array(); |
|
137 |
if(isset($params['backup_interval'])) $sql_set[] = "backup_interval = '".$app->db->quote($params['backup_interval'])."'"; |
|
138 |
if(isset($params['backup_copies'])) $sql_set[] = "backup_copies = ".$app->functions->intval($params['backup_copies']); |
|
139 |
$this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval, $retval, $params); |
|
140 |
} |
|
141 |
|
|
142 |
return $retval; |
b1a6a5
|
143 |
} |
MC |
144 |
|
|
145 |
return false; |
c1418f
|
146 |
} |
b1a6a5
|
147 |
|
c1418f
|
148 |
//* Update a record |
M |
149 |
public function sites_database_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
150 |
{ |
MC |
151 |
global $app; |
|
152 |
|
c1418f
|
153 |
if(!$this->checkPerm($session_id, 'sites_database_update')) { |
M |
154 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
155 |
return false; |
|
156 |
} |
b1a6a5
|
157 |
|
c1418f
|
158 |
$sql = $this->updateQueryPrepare('../sites/form/database.tform.php', $client_id, $primary_id, $params); |
b1a6a5
|
159 |
if($sql !== false) { |
MC |
160 |
$app->uses('sites_database_plugin'); |
|
161 |
|
|
162 |
$this->id = $primary_id; |
|
163 |
$this->dataRecord = $params; |
|
164 |
$app->sites_database_plugin->processDatabaseUpdate($this); |
82b723
|
165 |
$retval = $this->updateQueryExecute($sql, $primary_id, $params); |
MC |
166 |
|
|
167 |
// set correct values for backup_interval and backup_copies |
|
168 |
if(isset($params['backup_interval']) || isset($params['backup_copies'])){ |
|
169 |
$sql_set = array(); |
|
170 |
if(isset($params['backup_interval'])) $sql_set[] = "backup_interval = '".$app->db->quote($params['backup_interval'])."'"; |
|
171 |
if(isset($params['backup_copies'])) $sql_set[] = "backup_copies = ".$app->functions->intval($params['backup_copies']); |
|
172 |
$this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$primary_id, $primary_id, $params); |
|
173 |
} |
|
174 |
|
|
175 |
return $retval; |
b1a6a5
|
176 |
} |
MC |
177 |
|
|
178 |
return false; |
c1418f
|
179 |
} |
b1a6a5
|
180 |
|
c1418f
|
181 |
//* Delete a record |
M |
182 |
public function sites_database_delete($session_id, $primary_id) |
b1a6a5
|
183 |
{ |
MC |
184 |
global $app; |
c1418f
|
185 |
if(!$this->checkPerm($session_id, 'sites_database_delete')) { |
M |
186 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
187 |
return false; |
|
188 |
} |
b1a6a5
|
189 |
|
MC |
190 |
$app->uses('sites_database_plugin'); |
|
191 |
$app->sites_database_plugin->processDatabaseDelete($primary_id); |
|
192 |
|
|
193 |
$affected_rows = $this->deleteQuery('../sites/form/database.tform.php', $primary_id); |
c1418f
|
194 |
return $affected_rows; |
M |
195 |
} |
b1a6a5
|
196 |
|
c1418f
|
197 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
198 |
|
c1418f
|
199 |
//* Get record details |
M |
200 |
public function sites_database_user_get($session_id, $primary_id) |
b1a6a5
|
201 |
{ |
c1418f
|
202 |
global $app; |
b1a6a5
|
203 |
|
c1418f
|
204 |
if(!$this->checkPerm($session_id, 'sites_database_user_get')) { |
M |
205 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
206 |
return false; |
|
207 |
} |
|
208 |
$app->uses('remoting_lib'); |
|
209 |
$app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php'); |
|
210 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
211 |
} |
b1a6a5
|
212 |
|
c1418f
|
213 |
//* Add a record |
M |
214 |
public function sites_database_user_add($session_id, $client_id, $params) |
b1a6a5
|
215 |
{ |
c1418f
|
216 |
if(!$this->checkPerm($session_id, 'sites_database_user_add')) { |
M |
217 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
218 |
return false; |
|
219 |
} |
|
220 |
|
b1a6a5
|
221 |
return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params); |
c1418f
|
222 |
} |
b1a6a5
|
223 |
|
c1418f
|
224 |
//* Update a record |
M |
225 |
public function sites_database_user_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
226 |
{ |
MC |
227 |
global $app; |
|
228 |
|
c1418f
|
229 |
if(!$this->checkPerm($session_id, 'sites_database_user_update')) { |
M |
230 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
231 |
return false; |
|
232 |
} |
|
233 |
$app->uses('remoting_lib'); |
|
234 |
$app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php'); |
b1a6a5
|
235 |
$old_rec = $app->remoting_lib->getDataRecord($primary_id); |
MC |
236 |
|
c1418f
|
237 |
$result = $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params); |
b1a6a5
|
238 |
|
MC |
239 |
$new_rec = $app->remoting_lib->getDataRecord($primary_id); |
|
240 |
|
cc7a82
|
241 |
$records = $app->db->queryAllRecords("SELECT DISTINCT server_id FROM web_database WHERE database_user_id = ? UNION SELECT DISTINCT server_id FROM web_database WHERE database_ro_user_id = ?", $primary_id, $primary_id); |
b1a6a5
|
242 |
foreach($records as $rec) { |
MC |
243 |
$tmp_rec = $new_rec; |
|
244 |
$tmp_rec['server_id'] = $rec['server_id']; |
|
245 |
$app->remoting_lib->datalogSave('UPDATE', $primary_id, $old_rec, $tmp_rec); |
|
246 |
} |
|
247 |
unset($new_rec); |
|
248 |
unset($old_rec); |
|
249 |
unset($records); |
|
250 |
|
|
251 |
return $result; |
|
252 |
} |
|
253 |
|
c1418f
|
254 |
//* Delete a record |
M |
255 |
public function sites_database_user_delete($session_id, $primary_id) |
b1a6a5
|
256 |
{ |
MC |
257 |
global $app; |
|
258 |
|
c1418f
|
259 |
if(!$this->checkPerm($session_id, 'sites_database_user_delete')) { |
M |
260 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
261 |
return false; |
|
262 |
} |
b1a6a5
|
263 |
|
MC |
264 |
$app->db->datalogDelete('web_database_user', 'database_user_id', $primary_id); |
|
265 |
$affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php', $primary_id); |
|
266 |
|
cc7a82
|
267 |
$records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = ?", $primary_id); |
b1a6a5
|
268 |
foreach($records as $rec) { |
3a11d2
|
269 |
$app->db->datalogUpdate('web_database', array('database_user_id' => null), 'database_id', $rec['database_id']); |
b1a6a5
|
270 |
|
MC |
271 |
} |
cc7a82
|
272 |
$records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_ro_user_id = ?", $primary_id); |
b1a6a5
|
273 |
foreach($records as $rec) { |
3a11d2
|
274 |
$app->db->datalogUpdate('web_database', array('database_ro_user_id' => null), 'database_id', $rec['database_id']); |
b1a6a5
|
275 |
} |
MC |
276 |
|
c1418f
|
277 |
return $affected_rows; |
M |
278 |
} |
b1a6a5
|
279 |
|
c1418f
|
280 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
281 |
|
c1418f
|
282 |
//* Get record details |
M |
283 |
public function sites_ftp_user_get($session_id, $primary_id) |
b1a6a5
|
284 |
{ |
c1418f
|
285 |
global $app; |
b1a6a5
|
286 |
|
c1418f
|
287 |
if(!$this->checkPerm($session_id, 'sites_ftp_user_get')) { |
M |
288 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
289 |
return false; |
|
290 |
} |
|
291 |
$app->uses('remoting_lib'); |
|
292 |
$app->remoting_lib->loadFormDef('../sites/form/ftp_user.tform.php'); |
|
293 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
294 |
} |
b1a6a5
|
295 |
|
c1418f
|
296 |
//* Add a record |
M |
297 |
public function sites_ftp_user_add($session_id, $client_id, $params) |
b1a6a5
|
298 |
{ |
c1418f
|
299 |
if(!$this->checkPerm($session_id, 'sites_ftp_user_add')) { |
M |
300 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
301 |
return false; |
|
302 |
} |
b1a6a5
|
303 |
return $this->insertQuery('../sites/form/ftp_user.tform.php', $client_id, $params); |
c1418f
|
304 |
} |
b1a6a5
|
305 |
|
c1418f
|
306 |
//* Update a record |
M |
307 |
public function sites_ftp_user_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
308 |
{ |
c1418f
|
309 |
if(!$this->checkPerm($session_id, 'sites_ftp_user_update')) { |
M |
310 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
311 |
return false; |
|
312 |
} |
b1a6a5
|
313 |
$affected_rows = $this->updateQuery('../sites/form/ftp_user.tform.php', $client_id, $primary_id, $params); |
c1418f
|
314 |
return $affected_rows; |
M |
315 |
} |
b1a6a5
|
316 |
|
c1418f
|
317 |
//* Delete a record |
M |
318 |
public function sites_ftp_user_delete($session_id, $primary_id) |
b1a6a5
|
319 |
{ |
c1418f
|
320 |
if(!$this->checkPerm($session_id, 'sites_ftp_user_delete')) { |
M |
321 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
322 |
return false; |
|
323 |
} |
b1a6a5
|
324 |
$affected_rows = $this->deleteQuery('../sites/form/ftp_user.tform.php', $primary_id); |
c1418f
|
325 |
return $affected_rows; |
M |
326 |
} |
b1a6a5
|
327 |
|
c1418f
|
328 |
//* Get server for an ftp user |
M |
329 |
public function sites_ftp_user_server_get($session_id, $ftp_user) |
b1a6a5
|
330 |
{ |
c1418f
|
331 |
global $app; |
b1a6a5
|
332 |
|
c1418f
|
333 |
if(!$this->checkPerm($session_id, 'sites_ftp_user_server_get')) { |
M |
334 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
335 |
return false; |
|
336 |
} |
b1a6a5
|
337 |
|
cc7a82
|
338 |
$data = $app->db->queryOneRecord("SELECT server_id FROM ftp_user WHERE username = ?", $ftp_user); |
c1418f
|
339 |
//file_put_contents('/tmp/test.txt', serialize($data)); |
b1a6a5
|
340 |
if(!isset($data['server_id'])) return false; |
MC |
341 |
|
|
342 |
$server = $this->server_get($session_id, $data['server_id'], 'server'); |
|
343 |
//file_put_contents('/tmp/test2.txt', serialize($server)); |
|
344 |
|
c1418f
|
345 |
return $server; |
M |
346 |
} |
b1a6a5
|
347 |
|
c1418f
|
348 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
349 |
|
c1418f
|
350 |
//* Get record details |
M |
351 |
public function sites_shell_user_get($session_id, $primary_id) |
b1a6a5
|
352 |
{ |
c1418f
|
353 |
global $app; |
b1a6a5
|
354 |
|
c1418f
|
355 |
if(!$this->checkPerm($session_id, 'sites_shell_user_get')) { |
M |
356 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
357 |
return false; |
|
358 |
} |
|
359 |
$app->uses('remoting_lib'); |
|
360 |
$app->remoting_lib->loadFormDef('../sites/form/shell_user.tform.php'); |
|
361 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
362 |
} |
b1a6a5
|
363 |
|
c1418f
|
364 |
//* Add a record |
M |
365 |
public function sites_shell_user_add($session_id, $client_id, $params) |
b1a6a5
|
366 |
{ |
c1418f
|
367 |
if(!$this->checkPerm($session_id, 'sites_shell_user_add')) { |
M |
368 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
369 |
return false; |
|
370 |
} |
b1a6a5
|
371 |
return $this->insertQuery('../sites/form/shell_user.tform.php', $client_id, $params); |
c1418f
|
372 |
} |
b1a6a5
|
373 |
|
c1418f
|
374 |
//* Update a record |
M |
375 |
public function sites_shell_user_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
376 |
{ |
c1418f
|
377 |
if(!$this->checkPerm($session_id, 'sites_shell_user_update')) { |
M |
378 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
379 |
return false; |
|
380 |
} |
b1a6a5
|
381 |
$affected_rows = $this->updateQuery('../sites/form/shell_user.tform.php', $client_id, $primary_id, $params); |
c1418f
|
382 |
return $affected_rows; |
M |
383 |
} |
b1a6a5
|
384 |
|
c1418f
|
385 |
//* Delete a record |
M |
386 |
public function sites_shell_user_delete($session_id, $primary_id) |
b1a6a5
|
387 |
{ |
c1418f
|
388 |
if(!$this->checkPerm($session_id, 'sites_shell_user_delete')) { |
M |
389 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
390 |
return false; |
|
391 |
} |
b1a6a5
|
392 |
$affected_rows = $this->deleteQuery('../sites/form/shell_user.tform.php', $primary_id); |
c1418f
|
393 |
return $affected_rows; |
M |
394 |
} |
b1a6a5
|
395 |
|
c1418f
|
396 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
397 |
|
c1418f
|
398 |
//* Get record details |
M |
399 |
public function sites_web_domain_get($session_id, $primary_id) |
b1a6a5
|
400 |
{ |
c1418f
|
401 |
global $app; |
b1a6a5
|
402 |
|
c1418f
|
403 |
if(!$this->checkPerm($session_id, 'sites_web_domain_get')) { |
M |
404 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
405 |
return false; |
|
406 |
} |
|
407 |
$app->uses('remoting_lib'); |
af4c7a
|
408 |
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php'); |
c1418f
|
409 |
return $app->remoting_lib->getDataRecord($primary_id); |
M |
410 |
} |
b1a6a5
|
411 |
|
c1418f
|
412 |
//* Add a record |
M |
413 |
public function sites_web_domain_add($session_id, $client_id, $params, $readonly = false) |
|
414 |
{ |
|
415 |
global $app; |
|
416 |
if(!$this->checkPerm($session_id, 'sites_web_domain_add')) { |
|
417 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
418 |
return false; |
|
419 |
} |
b1a6a5
|
420 |
|
c1418f
|
421 |
if(!isset($params['client_group_id']) or (isset($params['client_group_id']) && empty($params['client_group_id']))) { |
cc7a82
|
422 |
$rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client_id); |
c1418f
|
423 |
$params['client_group_id'] = $rec['groupid']; |
M |
424 |
} |
b1a6a5
|
425 |
|
c1418f
|
426 |
//* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin |
M |
427 |
if($params['document_root'] == '') $params['document_root'] = '-'; |
|
428 |
if($params['system_user'] == '') $params['system_user'] = '-'; |
|
429 |
if($params['system_group'] == '') $params['system_group'] = '-'; |
b1a6a5
|
430 |
|
c1418f
|
431 |
//* Set a few defaults for nginx servers |
M |
432 |
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
|
433 |
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
|
434 |
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
|
435 |
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
b1a6a5
|
436 |
|
c10911
|
437 |
$domain_id = $this->insertQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $params, 'sites:web_vhost_domain:on_after_insert'); |
c1418f
|
438 |
if ($readonly === true) |
cc7a82
|
439 |
$app->db->query("UPDATE web_domain SET `sys_userid` = '1' WHERE domain_id = ?", $domain_id); |
b1a6a5
|
440 |
return $domain_id; |
MC |
441 |
} |
|
442 |
|
c1418f
|
443 |
//* Update a record |
M |
444 |
public function sites_web_domain_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
445 |
{ |
c1418f
|
446 |
if(!$this->checkPerm($session_id, 'sites_web_domain_update')) { |
M |
447 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
448 |
return false; |
|
449 |
} |
b1a6a5
|
450 |
|
c1418f
|
451 |
//* Set a few defaults for nginx servers |
M |
452 |
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
|
453 |
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
|
454 |
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
|
455 |
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
b1a6a5
|
456 |
|
af4c7a
|
457 |
$affected_rows = $this->updateQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $primary_id, $params); |
c1418f
|
458 |
return $affected_rows; |
M |
459 |
} |
b1a6a5
|
460 |
|
c1418f
|
461 |
//* Delete a record |
M |
462 |
public function sites_web_domain_delete($session_id, $primary_id) |
b1a6a5
|
463 |
{ |
c1418f
|
464 |
if(!$this->checkPerm($session_id, 'sites_web_domain_delete')) { |
M |
465 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
466 |
return false; |
|
467 |
} |
af4c7a
|
468 |
$affected_rows = $this->deleteQuery('../sites/form/web_vhost_domain.tform.php', $primary_id); |
c1418f
|
469 |
return $affected_rows; |
M |
470 |
} |
b1a6a5
|
471 |
|
c1418f
|
472 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
473 |
|
c1418f
|
474 |
//* Get record details |
511ba5
|
475 |
public function sites_web_vhost_aliasdomain_get($session_id, $primary_id) |
DM |
476 |
{ |
|
477 |
global $app; |
|
478 |
|
29e1b0
|
479 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_get')) { |
511ba5
|
480 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
DM |
481 |
return false; |
|
482 |
} |
|
483 |
$app->uses('remoting_lib'); |
|
484 |
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_aliasdomain.tform.php'); |
|
485 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
486 |
} |
|
487 |
|
|
488 |
//* Add a record |
|
489 |
public function sites_web_vhost_aliasdomain_add($session_id, $client_id, $params) |
|
490 |
{ |
|
491 |
global $app; |
29e1b0
|
492 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_add')) { |
511ba5
|
493 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
DM |
494 |
return false; |
|
495 |
} |
|
496 |
|
|
497 |
//* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin |
|
498 |
if($params['document_root'] == '') $params['document_root'] = '-'; |
|
499 |
if($params['system_user'] == '') $params['system_user'] = '-'; |
|
500 |
if($params['system_group'] == '') $params['system_group'] = '-'; |
|
501 |
|
|
502 |
//* Set a few defaults for nginx servers |
|
503 |
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
|
504 |
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
|
505 |
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
|
506 |
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
|
507 |
|
|
508 |
$domain_id = $this->insertQuery('../sites/form/web_vhost_aliasdomain.tform.php', $client_id, $params, 'sites:web_vhost_aliasdomain:on_after_insert'); |
|
509 |
return $domain_id; |
|
510 |
} |
|
511 |
|
|
512 |
//* Update a record |
|
513 |
public function sites_web_vhost_aliasdomain_update($session_id, $client_id, $primary_id, $params) |
|
514 |
{ |
29e1b0
|
515 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_update')) { |
511ba5
|
516 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
DM |
517 |
return false; |
|
518 |
} |
|
519 |
|
|
520 |
//* Set a few defaults for nginx servers |
|
521 |
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
|
522 |
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
|
523 |
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
|
524 |
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
|
525 |
|
|
526 |
$affected_rows = $this->updateQuery('../sites/form/web_vhost_aliasdomain.tform.php', $client_id, $primary_id, $params, 'sites:web_vhost_aliasdomain:on_after_insert'); |
|
527 |
return $affected_rows; |
|
528 |
} |
|
529 |
|
|
530 |
//* Delete a record |
|
531 |
public function sites_web_vhost_aliasdomain_delete($session_id, $primary_id) |
|
532 |
{ |
29e1b0
|
533 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_delete')) { |
511ba5
|
534 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
DM |
535 |
return false; |
|
536 |
} |
|
537 |
$affected_rows = $this->deleteQuery('../sites/form/web_vhost_aliasdomain.tform.php', $primary_id); |
|
538 |
return $affected_rows; |
|
539 |
} |
|
540 |
|
|
541 |
// ---------------------------------------------------------------------------------------------------------- |
|
542 |
|
|
543 |
//* Get record details |
c1418f
|
544 |
public function sites_web_vhost_subdomain_get($session_id, $primary_id) |
b1a6a5
|
545 |
{ |
c1418f
|
546 |
global $app; |
b1a6a5
|
547 |
|
29e1b0
|
548 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_get')) { |
c1418f
|
549 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
M |
550 |
return false; |
|
551 |
} |
|
552 |
$app->uses('remoting_lib'); |
|
553 |
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_subdomain.tform.php'); |
|
554 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
555 |
} |
b1a6a5
|
556 |
|
c1418f
|
557 |
//* Add a record |
M |
558 |
public function sites_web_vhost_subdomain_add($session_id, $client_id, $params) |
|
559 |
{ |
|
560 |
global $app; |
29e1b0
|
561 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_add')) { |
c1418f
|
562 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
M |
563 |
return false; |
|
564 |
} |
b1a6a5
|
565 |
|
c1418f
|
566 |
//* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin |
M |
567 |
if($params['document_root'] == '') $params['document_root'] = '-'; |
|
568 |
if($params['system_user'] == '') $params['system_user'] = '-'; |
|
569 |
if($params['system_group'] == '') $params['system_group'] = '-'; |
b1a6a5
|
570 |
|
c1418f
|
571 |
//* Set a few defaults for nginx servers |
M |
572 |
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
|
573 |
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
|
574 |
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
|
575 |
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
b1a6a5
|
576 |
|
MC |
577 |
$domain_id = $this->insertQuery('../sites/form/web_vhost_subdomain.tform.php', $client_id, $params, 'sites:web_vhost_subdomain:on_after_insert'); |
|
578 |
return $domain_id; |
|
579 |
} |
|
580 |
|
c1418f
|
581 |
//* Update a record |
M |
582 |
public function sites_web_vhost_subdomain_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
583 |
{ |
29e1b0
|
584 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_update')) { |
c1418f
|
585 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
M |
586 |
return false; |
|
587 |
} |
b1a6a5
|
588 |
|
c1418f
|
589 |
//* Set a few defaults for nginx servers |
M |
590 |
if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; |
|
591 |
if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; |
|
592 |
if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; |
|
593 |
if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; |
b1a6a5
|
594 |
|
MC |
595 |
$affected_rows = $this->updateQuery('../sites/form/web_vhost_subdomain.tform.php', $client_id, $primary_id, $params, 'sites:web_vhost_subdomain:on_after_insert'); |
c1418f
|
596 |
return $affected_rows; |
M |
597 |
} |
b1a6a5
|
598 |
|
c1418f
|
599 |
//* Delete a record |
M |
600 |
public function sites_web_vhost_subdomain_delete($session_id, $primary_id) |
b1a6a5
|
601 |
{ |
29e1b0
|
602 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_delete')) { |
c1418f
|
603 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
M |
604 |
return false; |
|
605 |
} |
b1a6a5
|
606 |
$affected_rows = $this->deleteQuery('../sites/form/web_vhost_subdomain.tform.php', $primary_id); |
c1418f
|
607 |
return $affected_rows; |
M |
608 |
} |
b1a6a5
|
609 |
|
c1418f
|
610 |
// ----------------------------------------------------------------------------------------------- |
b1a6a5
|
611 |
|
c1418f
|
612 |
//* Get record details |
M |
613 |
public function sites_web_aliasdomain_get($session_id, $primary_id) |
b1a6a5
|
614 |
{ |
c1418f
|
615 |
global $app; |
b1a6a5
|
616 |
|
c1418f
|
617 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_get')) { |
M |
618 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
619 |
return false; |
|
620 |
} |
|
621 |
$app->uses('remoting_lib'); |
|
622 |
$app->remoting_lib->loadFormDef('../sites/form/web_aliasdomain.tform.php'); |
|
623 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
624 |
} |
b1a6a5
|
625 |
|
c1418f
|
626 |
//* Add a record |
M |
627 |
public function sites_web_aliasdomain_add($session_id, $client_id, $params) |
b1a6a5
|
628 |
{ |
c1418f
|
629 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_add')) { |
M |
630 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
631 |
return false; |
|
632 |
} |
b1a6a5
|
633 |
return $this->insertQuery('../sites/form/web_aliasdomain.tform.php', $client_id, $params); |
c1418f
|
634 |
} |
b1a6a5
|
635 |
|
c1418f
|
636 |
//* Update a record |
M |
637 |
public function sites_web_aliasdomain_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
638 |
{ |
c1418f
|
639 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_update')) { |
M |
640 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
641 |
return false; |
|
642 |
} |
b1a6a5
|
643 |
$affected_rows = $this->updateQuery('../sites/form/web_aliasdomain.tform.php', $client_id, $primary_id, $params); |
c1418f
|
644 |
return $affected_rows; |
M |
645 |
} |
b1a6a5
|
646 |
|
c1418f
|
647 |
//* Delete a record |
M |
648 |
public function sites_web_aliasdomain_delete($session_id, $primary_id) |
b1a6a5
|
649 |
{ |
c1418f
|
650 |
if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_delete')) { |
M |
651 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
652 |
return false; |
|
653 |
} |
b1a6a5
|
654 |
$affected_rows = $this->deleteQuery('../sites/form/web_aliasdomain.tform.php', $primary_id); |
c1418f
|
655 |
return $affected_rows; |
M |
656 |
} |
b1a6a5
|
657 |
|
c1418f
|
658 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
659 |
|
c1418f
|
660 |
//* Get record details |
M |
661 |
public function sites_web_subdomain_get($session_id, $primary_id) |
b1a6a5
|
662 |
{ |
c1418f
|
663 |
global $app; |
b1a6a5
|
664 |
|
c1418f
|
665 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_get')) { |
M |
666 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
667 |
return false; |
|
668 |
} |
|
669 |
$app->uses('remoting_lib'); |
|
670 |
$app->remoting_lib->loadFormDef('../sites/form/web_subdomain.tform.php'); |
|
671 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
672 |
} |
b1a6a5
|
673 |
|
c1418f
|
674 |
//* Add a record |
M |
675 |
public function sites_web_subdomain_add($session_id, $client_id, $params) |
b1a6a5
|
676 |
{ |
c1418f
|
677 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_add')) { |
M |
678 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
679 |
return false; |
|
680 |
} |
b1a6a5
|
681 |
return $this->insertQuery('../sites/form/web_subdomain.tform.php', $client_id, $params); |
c1418f
|
682 |
} |
b1a6a5
|
683 |
|
c1418f
|
684 |
//* Update a record |
M |
685 |
public function sites_web_subdomain_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
686 |
{ |
c1418f
|
687 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_update')) { |
M |
688 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
689 |
return false; |
|
690 |
} |
b1a6a5
|
691 |
$affected_rows = $this->updateQuery('../sites/form/web_subdomain.tform.php', $client_id, $primary_id, $params); |
c1418f
|
692 |
return $affected_rows; |
M |
693 |
} |
b1a6a5
|
694 |
|
c1418f
|
695 |
//* Delete a record |
M |
696 |
public function sites_web_subdomain_delete($session_id, $primary_id) |
b1a6a5
|
697 |
{ |
c1418f
|
698 |
if(!$this->checkPerm($session_id, 'sites_web_subdomain_delete')) { |
M |
699 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
700 |
return false; |
|
701 |
} |
b1a6a5
|
702 |
$affected_rows = $this->deleteQuery('../sites/form/web_subdomain.tform.php', $primary_id); |
c1418f
|
703 |
return $affected_rows; |
M |
704 |
} |
b1a6a5
|
705 |
|
c1418f
|
706 |
// ---------------------------------------------------------------------------------------------------------- |
b1a6a5
|
707 |
|
c1418f
|
708 |
//* Get record details |
M |
709 |
public function sites_web_folder_get($session_id, $primary_id) |
b1a6a5
|
710 |
{ |
c1418f
|
711 |
global $app; |
b1a6a5
|
712 |
|
c1418f
|
713 |
if(!$this->checkPerm($session_id, 'sites_web_folder_get')) { |
M |
714 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
715 |
return false; |
|
716 |
} |
|
717 |
$app->uses('remoting_lib'); |
|
718 |
$app->remoting_lib->loadFormDef('../sites/form/web_folder.tform.php'); |
|
719 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
720 |
} |
b1a6a5
|
721 |
|
c1418f
|
722 |
//* Add a record |
M |
723 |
public function sites_web_folder_add($session_id, $client_id, $params) |
b1a6a5
|
724 |
{ |
c1418f
|
725 |
if(!$this->checkPerm($session_id, 'sites_web_folder_add')) { |
M |
726 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
727 |
return false; |
|
728 |
} |
b1a6a5
|
729 |
return $this->insertQuery('../sites/form/web_folder.tform.php', $client_id, $params); |
c1418f
|
730 |
} |
b1a6a5
|
731 |
|
c1418f
|
732 |
//* Update a record |
M |
733 |
public function sites_web_folder_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
734 |
{ |
c1418f
|
735 |
if(!$this->checkPerm($session_id, 'sites_web_folder_update')) { |
M |
736 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
737 |
return false; |
|
738 |
} |
b1a6a5
|
739 |
$affected_rows = $this->updateQuery('../sites/form/web_folder.tform.php', $client_id, $primary_id, $params); |
c1418f
|
740 |
return $affected_rows; |
M |
741 |
} |
b1a6a5
|
742 |
|
c1418f
|
743 |
//* Delete a record |
M |
744 |
public function sites_web_folder_delete($session_id, $primary_id) |
b1a6a5
|
745 |
{ |
c1418f
|
746 |
global $app; |
M |
747 |
if(!$this->checkPerm($session_id, 'sites_web_folder_delete')) { |
|
748 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
749 |
return false; |
|
750 |
} |
b1a6a5
|
751 |
|
MC |
752 |
// Delete all users that belong to this folder. - taken from web_folder_delete.php |
cc7a82
|
753 |
$records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = ?", $primary_id); |
c1418f
|
754 |
foreach($records as $rec) { |
b1a6a5
|
755 |
$this->deleteQuery('../sites/form/web_folder_user.tform.php', $rec['web_folder_user_id']); |
c1418f
|
756 |
//$app->db->datalogDelete('web_folder_user','web_folder_user_id',$rec['web_folder_user_id']); |
M |
757 |
} |
|
758 |
unset($records); |
b1a6a5
|
759 |
|
MC |
760 |
$affected_rows = $this->deleteQuery('../sites/form/web_folder.tform.php', $primary_id); |
c1418f
|
761 |
return $affected_rows; |
M |
762 |
} |
b1a6a5
|
763 |
|
c1418f
|
764 |
// ----------------------------------------------------------------------------------------------- |
b1a6a5
|
765 |
|
c1418f
|
766 |
//* Get record details |
M |
767 |
public function sites_web_folder_user_get($session_id, $primary_id) |
b1a6a5
|
768 |
{ |
c1418f
|
769 |
global $app; |
b1a6a5
|
770 |
|
c1418f
|
771 |
if(!$this->checkPerm($session_id, 'sites_web_folder_user_get')) { |
M |
772 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
773 |
return false; |
|
774 |
} |
|
775 |
$app->uses('remoting_lib'); |
|
776 |
$app->remoting_lib->loadFormDef('../sites/form/web_folder_user.tform.php'); |
|
777 |
return $app->remoting_lib->getDataRecord($primary_id); |
|
778 |
} |
b1a6a5
|
779 |
|
c1418f
|
780 |
//* Add a record |
M |
781 |
public function sites_web_folder_user_add($session_id, $client_id, $params) |
b1a6a5
|
782 |
{ |
c1418f
|
783 |
if(!$this->checkPerm($session_id, 'sites_web_folder_user_add')) { |
M |
784 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
785 |
return false; |
|
786 |
} |
b1a6a5
|
787 |
return $this->insertQuery('../sites/form/web_folder_user.tform.php', $client_id, $params); |
c1418f
|
788 |
} |
b1a6a5
|
789 |
|
c1418f
|
790 |
//* Update a record |
M |
791 |
public function sites_web_folder_user_update($session_id, $client_id, $primary_id, $params) |
b1a6a5
|
792 |
{ |
c1418f
|
793 |
if(!$this->checkPerm($session_id, 'sites_web_folder_user_update')) { |
M |
794 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
795 |
return false; |
|
796 |
} |
b1a6a5
|
797 |
$affected_rows = $this->updateQuery('../sites/form/web_folder_user.tform.php', $client_id, $primary_id, $params); |
c1418f
|
798 |
return $affected_rows; |
M |
799 |
} |
b1a6a5
|
800 |
|
c1418f
|
801 |
//* Delete a record |
M |
802 |
public function sites_web_folder_user_delete($session_id, $primary_id) |
b1a6a5
|
803 |
{ |
c1418f
|
804 |
if(!$this->checkPerm($session_id, 'sites_web_folder_user_delete')) { |
M |
805 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
806 |
return false; |
|
807 |
} |
b1a6a5
|
808 |
$affected_rows = $this->deleteQuery('../sites/form/web_folder_user.tform.php', $primary_id); |
c1418f
|
809 |
return $affected_rows; |
M |
810 |
} |
|
811 |
|
|
812 |
/** |
|
813 |
* Gets sites by $sys_userid & $sys_groupid |
b1a6a5
|
814 |
* @param int session id |
MC |
815 |
* @param int user id |
|
816 |
* @param array list of groups |
|
817 |
* @return mixed array with sites by user |
|
818 |
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2010 |
c1418f
|
819 |
*/ |
b1a6a5
|
820 |
|
MC |
821 |
|
c1418f
|
822 |
public function client_get_sites_by_user($session_id, $sys_userid, $sys_groupid) { |
b1a6a5
|
823 |
global $app; |
MC |
824 |
if(!$this->checkPerm($session_id, 'client_get_sites_by_user')) { |
|
825 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
826 |
return false; |
|
827 |
} |
|
828 |
$sys_userid = $app->functions->intval($sys_userid); |
|
829 |
$sys_groupid = explode(',', $sys_groupid); |
|
830 |
$new_group = array(); |
|
831 |
foreach($sys_groupid as $group_id) { |
c1418f
|
832 |
$new_group[] = $app->functions->intval( $group_id); |
b1a6a5
|
833 |
} |
MC |
834 |
$group_list = implode(',', $new_group); |
c1418f
|
835 |
$sql ="SELECT domain, domain_id, document_root, active FROM web_domain WHERE ( (sys_userid = $sys_userid AND sys_perm_user LIKE '%r%') OR (sys_groupid IN ($group_list) AND sys_perm_group LIKE '%r%') OR sys_perm_other LIKE '%r%') AND type = 'vhost'"; |
b1a6a5
|
836 |
$result = $app->db->queryAllRecords($sql); |
MC |
837 |
if(isset($result)) { |
c1418f
|
838 |
return $result; |
b1a6a5
|
839 |
} else { |
c1418f
|
840 |
throw new SoapFault('no_client_found', 'There is no site for this user'); |
M |
841 |
return false; |
b1a6a5
|
842 |
} |
c1418f
|
843 |
} |
M |
844 |
|
b1a6a5
|
845 |
|
MC |
846 |
|
|
847 |
/** |
|
848 |
* Change domains status |
|
849 |
* @param int session id |
|
850 |
* @param int site id |
|
851 |
* @param string active or inactive string |
|
852 |
* @return mixed false if error |
|
853 |
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2010 |
|
854 |
*/ |
|
855 |
public function sites_web_domain_set_status($session_id, $primary_id, $status) { |
|
856 |
global $app; |
|
857 |
if(!$this->checkPerm($session_id, 'sites_web_domain_set_status')) { |
|
858 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
859 |
return false; |
c1418f
|
860 |
} |
b1a6a5
|
861 |
if(in_array($status, array('active', 'inactive'))) { |
MC |
862 |
if ($status == 'active') { |
|
863 |
$status = 'y'; |
|
864 |
} else { |
|
865 |
$status = 'n'; |
|
866 |
} |
af4c7a
|
867 |
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php'); |
def1f7
|
868 |
$params = $app->remoting_lib->getDataRecord($primary_id); |
MC |
869 |
$params['active'] = $status; |
|
870 |
|
af4c7a
|
871 |
$affected_rows = $this->updateQuery('../sites/form/web_vhost_domain.tform.php', 0, $primary_id, $params); |
def1f7
|
872 |
return $affected_rows; |
b1a6a5
|
873 |
} else { |
MC |
874 |
throw new SoapFault('status_undefined', 'The status is not available'); |
|
875 |
return false; |
|
876 |
} |
|
877 |
} |
|
878 |
|
|
879 |
/** |
|
880 |
* Get all databases by user |
|
881 |
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2010 |
|
882 |
*/ |
|
883 |
public function sites_database_get_all_by_user($session_id, $client_id) |
|
884 |
{ |
|
885 |
global $app; |
|
886 |
if(!$this->checkPerm($session_id, 'sites_database_get')) { |
|
887 |
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); |
|
888 |
return false; |
|
889 |
} |
|
890 |
$client_id = $app->functions->intval($client_id); |
cc7a82
|
891 |
$sql = "SELECT d.database_id, d.database_name, d.database_user_id, d.database_ro_user_id, du.database_user, du.database_password FROM web_database d LEFT JOIN web_database_user du ON (du.database_user_id = d.database_user_id) INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = ?"; |
MC |
892 |
$all = $app->db->queryAllRecords($sql, $client_id); |
b1a6a5
|
893 |
return $all; |
c1418f
|
894 |
} |
5f0a37
|
895 |
|
D |
896 |
//** backup functions ----------------------------------------------------------------------------------- |
|
897 |
public function sites_web_domain_backup_list($session_id, $site_id = null) |
|
898 |
{ |
|
899 |
global $app; |
|
900 |
|
|
901 |
if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) { |
|
902 |
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
|
903 |
return false; |
|
904 |
} |
|
905 |
|
cc7a82
|
906 |
$result = $app->db->queryAllRecords("SELECT * FROM web_backup".(($site_id != null)?' WHERE parent_domain_id = ?':''), $site_id); |
5f0a37
|
907 |
return $result; |
D |
908 |
} |
|
909 |
|
|
910 |
//* Backup download and restoration by Abdi Joseph |
|
911 |
public function sites_web_domain_backup($session_id, $primary_id, $action_type) |
|
912 |
{ |
|
913 |
global $app; |
|
914 |
|
|
915 |
if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) { |
|
916 |
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
|
917 |
return false; |
|
918 |
} |
|
919 |
|
|
920 |
//*Set variables |
|
921 |
$backup_record = $app->db->queryOneRecord("SELECT * FROM `web_backup` WHERE `backup_id`= ?", $primary_id); |
|
922 |
$server_id = $backup_record['server_id']; |
|
923 |
|
|
924 |
//*Set default action state |
|
925 |
$action_state = "pending"; |
|
926 |
$tstamp = time(); |
|
927 |
|
|
928 |
//* Basic validation of variables |
|
929 |
if ($server_id <= 0) { |
|
930 |
$this->server->fault('invalid_backup_id', "Invalid or non existant backup_id $primary_id"); |
|
931 |
return false; |
|
932 |
} |
|
933 |
|
634132
|
934 |
if ($action_type != 'backup_download' and $action_type != 'backup_restore' and $action_type != 'backup_delete') { |
5f0a37
|
935 |
$this->server->fault('invalid_action', "Invalid action_type $action_type"); |
D |
936 |
return false; |
|
937 |
} |
|
938 |
|
|
939 |
//* Validate instance |
|
940 |
$instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`= ? and `action_type`= ? and `action_state`= ?", $primary_id, $action_type, 'pending'); |
|
941 |
if ($instance_record['action_id'] >= 1) { |
|
942 |
$this->server->fault('duplicate_action', "There is already a pending $action_type action"); |
|
943 |
return false; |
|
944 |
} |
|
945 |
|
|
946 |
//* Save the record |
|
947 |
if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) { |
|
948 |
return true; |
|
949 |
} else { |
|
950 |
return false; |
|
951 |
} |
|
952 |
} |
|
953 |
|
c7e231
|
954 |
//** quota functions ----------------------------------------------------------------------------------- |
f1c4cd
|
955 |
public function quota_get_by_user($session_id, $client_id) |
c7e231
|
956 |
{ |
DM |
957 |
global $app; |
|
958 |
$app->uses('quota_lib'); |
|
959 |
|
|
960 |
if(!$this->checkPerm($session_id, 'quota_get_by_user')) { |
|
961 |
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
|
962 |
return false; |
|
963 |
} |
|
964 |
|
f1c4cd
|
965 |
return $app->quota_lib->get_quota_data($client_id, false); |
c7e231
|
966 |
} |
DM |
967 |
|
a641dd
|
968 |
public function trafficquota_get_by_user($session_id, $client_id, $lastdays = 0) |
D |
969 |
{ |
|
970 |
global $app; |
|
971 |
$app->uses('quota_lib'); |
|
972 |
|
|
973 |
if(!$this->checkPerm($session_id, 'trafficquota_get_by_user')) { |
|
974 |
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
|
975 |
return false; |
|
976 |
} |
|
977 |
if ($client_id != null) |
|
978 |
$client_id = $app->functions->intval($client_id); |
|
979 |
|
|
980 |
return $app->quota_lib->get_trafficquota_data($client_id, $lastdays); |
|
981 |
} |
|
982 |
|
cfc79e
|
983 |
public function ftptrafficquota_data($session_id, $client_id, $lastdays = 0) |
LC |
984 |
{ |
|
985 |
global $app; |
|
986 |
$app->uses('quota_lib'); |
|
987 |
|
|
988 |
if(!$this->checkPerm($session_id, 'trafficquota_get_by_user')) { |
|
989 |
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
|
990 |
return false; |
|
991 |
} |
|
992 |
if ($client_id != null) |
|
993 |
$client_id = $app->functions->intval($client_id); |
|
994 |
|
|
995 |
return $app->quota_lib->get_ftptrafficquota_data($client_id, $lastdays); |
|
996 |
} |
|
997 |
|
e9a084
|
998 |
public function databasequota_get_by_user($session_id, $client_id) |
D |
999 |
{ |
|
1000 |
global $app; |
|
1001 |
$app->uses('quota_lib'); |
|
1002 |
|
|
1003 |
if(!$this->checkPerm($session_id, 'databasequota_get_by_user')) { |
|
1004 |
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); |
|
1005 |
return false; |
|
1006 |
} |
|
1007 |
|
|
1008 |
return $app->quota_lib->get_databasequota_data($client_id, false); |
|
1009 |
} |
|
1010 |
|
c7e231
|
1011 |
|
c1418f
|
1012 |
} |
M |
1013 |
|
b1a6a5
|
1014 |
?> |