commit | author | age
|
18341e
|
1 |
<?php |
T |
2 |
/* |
69944a
|
3 |
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh |
18341e
|
4 |
All rights reserved. |
T |
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
|
|
31 |
/****************************************** |
|
32 |
* Begin Form configuration |
|
33 |
******************************************/ |
|
34 |
|
|
35 |
$tform_def_file = "form/web_domain.tform.php"; |
|
36 |
|
|
37 |
/****************************************** |
|
38 |
* End Form configuration |
|
39 |
******************************************/ |
|
40 |
|
|
41 |
require_once('../../lib/config.inc.php'); |
|
42 |
require_once('../../lib/app.inc.php'); |
|
43 |
|
910093
|
44 |
//* Check permissions for module |
T |
45 |
$app->auth->check_module_permissions('sites'); |
18341e
|
46 |
|
T |
47 |
// Loading classes |
|
48 |
$app->uses('tpl,tform,tform_actions'); |
|
49 |
$app->load('tform_actions'); |
|
50 |
|
|
51 |
class page_action extends tform_actions { |
|
52 |
|
4fae7e
|
53 |
function onShowNew() { |
T |
54 |
global $app, $conf; |
|
55 |
|
|
56 |
// we will check only users, not admins |
|
57 |
if($_SESSION["s"]["user"]["typ"] == 'user') { |
8c4aa3
|
58 |
if(!$app->tform->checkClientLimit('limit_web_domain',"type = 'vhost'")) { |
T |
59 |
$app->error($app->tform->wordbook["limit_web_domain_txt"]); |
|
60 |
} |
|
61 |
if(!$app->tform->checkResellerLimit('limit_web_domain',"type = 'vhost'")) { |
|
62 |
$app->error('Reseller: '.$app->tform->wordbook["limit_web_domain_txt"]); |
4fae7e
|
63 |
} |
T |
64 |
} |
|
65 |
|
|
66 |
parent::onShowNew(); |
|
67 |
} |
|
68 |
|
18341e
|
69 |
function onShowEnd() { |
T |
70 |
global $app, $conf; |
|
71 |
|
51d0a2
|
72 |
//* Client: If the logged in user is not admin and has no sub clients (no rseller) |
b5a23a
|
73 |
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
18341e
|
74 |
|
T |
75 |
// Get the limits of the client |
|
76 |
$client_group_id = $_SESSION["s"]["user"]["default_group"]; |
b5a23a
|
77 |
$client = $app->db->queryOneRecord("SELECT limit_web_domain, default_webserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
18341e
|
78 |
|
T |
79 |
// Set the webserver to the default server of the client |
|
80 |
$tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = $client[default_webserver]"); |
|
81 |
$app->tpl->setVar("server_id","<option value='$client[default_webserver]'>$tmp[server_name]</option>"); |
|
82 |
unset($tmp); |
|
83 |
|
|
84 |
// Fill the IP select field with the IP addresses that are allowed for this client |
51d0a2
|
85 |
// $ip_select = "<option value='*'>*</option>"; |
T |
86 |
// $app->tpl->setVar("ip_address",$ip_select); |
|
87 |
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']; |
|
88 |
$ips = $app->db->queryAllRecords($sql); |
b5a23a
|
89 |
$ip_select = "<option value='*'>*</option>"; |
51d0a2
|
90 |
//$ip_select = ""; |
T |
91 |
if(is_array($ips)) { |
|
92 |
foreach( $ips as $ip) { |
|
93 |
$selected = ($ip["ip_address"] == $this->dataRecord["ip_address"])?'SELECTED':''; |
|
94 |
$ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n"; |
|
95 |
} |
|
96 |
} |
b5a23a
|
97 |
$app->tpl->setVar("ip_address",$ip_select); |
51d0a2
|
98 |
unset($tmp); |
T |
99 |
unset($ips); |
327124
|
100 |
|
51d0a2
|
101 |
//* Reseller: If the logged in user is not admin and has sub clients (is a rseller) |
b5a23a
|
102 |
} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
T |
103 |
|
|
104 |
// Get the limits of the client |
|
105 |
$client_group_id = $_SESSION["s"]["user"]["default_group"]; |
8c4aa3
|
106 |
$client = $app->db->queryOneRecord("SELECT client.client_id, limit_web_domain, default_webserver, client.contact_name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
b5a23a
|
107 |
|
T |
108 |
// Set the webserver to the default server of the client |
|
109 |
$tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = $client[default_webserver]"); |
|
110 |
$app->tpl->setVar("server_id","<option value='$client[default_webserver]'>$tmp[server_name]</option>"); |
|
111 |
unset($tmp); |
|
112 |
|
|
113 |
// Fill the client select field |
e56b39
|
114 |
$sql = "SELECT groupid, name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']; |
b5a23a
|
115 |
$clients = $app->db->queryAllRecords($sql); |
8c4aa3
|
116 |
$client_select = '<option value="'.$client['client_id'].'">'.$client['contact_name'].'</option>'; |
b5a23a
|
117 |
if(is_array($clients)) { |
T |
118 |
foreach( $clients as $client) { |
|
119 |
$selected = @($client["groupid"] == $this->dataRecord["sys_groupid"])?'SELECTED':''; |
|
120 |
$client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n"; |
|
121 |
} |
|
122 |
} |
|
123 |
$app->tpl->setVar("client_group_id",$client_select); |
|
124 |
|
|
125 |
// Fill the IP select field with the IP addresses that are allowed for this client |
51d0a2
|
126 |
//$ip_select = "<option value='*'>*</option>"; |
T |
127 |
//$app->tpl->setVar("ip_address",$ip_select); |
|
128 |
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']; |
|
129 |
$ips = $app->db->queryAllRecords($sql); |
b5a23a
|
130 |
$ip_select = "<option value='*'>*</option>"; |
51d0a2
|
131 |
//$ip_select = ""; |
T |
132 |
if(is_array($ips)) { |
|
133 |
foreach( $ips as $ip) { |
|
134 |
$selected = ($ip["ip_address"] == $this->dataRecord["ip_address"])?'SELECTED':''; |
|
135 |
$ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n"; |
|
136 |
} |
|
137 |
} |
b5a23a
|
138 |
$app->tpl->setVar("ip_address",$ip_select); |
51d0a2
|
139 |
unset($tmp); |
T |
140 |
unset($ips); |
327124
|
141 |
|
51d0a2
|
142 |
//* Admin: If the logged in user is admin |
18341e
|
143 |
} else { |
T |
144 |
|
|
145 |
// The user is admin, so we fill in all IP addresses of the server |
|
146 |
if($this->id > 0) { |
327124
|
147 |
$server_id = @$this->dataRecord["server_id"]; |
18341e
|
148 |
} else { |
T |
149 |
// Get the first server ID |
|
150 |
$tmp = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = 1 ORDER BY server_name LIMIT 0,1"); |
|
151 |
$server_id = $tmp['server_id']; |
|
152 |
} |
|
153 |
|
|
154 |
$sql = "SELECT ip_address FROM server_ip WHERE server_id = $server_id"; |
|
155 |
$ips = $app->db->queryAllRecords($sql); |
|
156 |
$ip_select = "<option value='*'>*</option>"; |
|
157 |
//$ip_select = ""; |
|
158 |
if(is_array($ips)) { |
|
159 |
foreach( $ips as $ip) { |
|
160 |
$selected = ($ip["ip_address"] == $this->dataRecord["ip_address"])?'SELECTED':''; |
|
161 |
$ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n"; |
|
162 |
} |
|
163 |
} |
|
164 |
$app->tpl->setVar("ip_address",$ip_select); |
|
165 |
unset($tmp); |
|
166 |
unset($ips); |
|
167 |
|
|
168 |
// Fill the client select field |
|
169 |
$sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0"; |
|
170 |
$clients = $app->db->queryAllRecords($sql); |
|
171 |
$client_select = "<option value='0'></option>"; |
|
172 |
if(is_array($clients)) { |
|
173 |
foreach( $clients as $client) { |
df52d4
|
174 |
$selected = @($client["groupid"] == $this->dataRecord["sys_groupid"])?'SELECTED':''; |
18341e
|
175 |
$client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n"; |
T |
176 |
} |
|
177 |
} |
|
178 |
$app->tpl->setVar("client_group_id",$client_select); |
|
179 |
|
|
180 |
} |
|
181 |
|
b94726
|
182 |
if($this->id > 0) { |
T |
183 |
//* we are editing a existing record |
6a8d0d
|
184 |
$app->tpl->setVar("edit_disabled", 1); |
T |
185 |
$app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]); |
b94726
|
186 |
} else { |
6a8d0d
|
187 |
$app->tpl->setVar("edit_disabled", 0); |
b94726
|
188 |
} |
T |
189 |
|
18341e
|
190 |
parent::onShowEnd(); |
T |
191 |
} |
|
192 |
|
|
193 |
function onSubmit() { |
|
194 |
global $app, $conf; |
|
195 |
|
|
196 |
// Set a few fixed values |
|
197 |
$this->dataRecord["parent_domain_id"] = 0; |
|
198 |
$this->dataRecord["type"] = 'vhost'; |
|
199 |
$this->dataRecord["vhost_type"] = 'name'; |
|
200 |
|
|
201 |
if($_SESSION["s"]["user"]["typ"] != 'admin') { |
|
202 |
// Get the limits of the client |
|
203 |
$client_group_id = $_SESSION["s"]["user"]["default_group"]; |
8c4aa3
|
204 |
$client = $app->db->queryOneRecord("SELECT limit_web_domain, default_webserver, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
18341e
|
205 |
|
T |
206 |
// When the record is updated |
|
207 |
if($this->id > 0) { |
|
208 |
// restore the server ID if the user is not admin and record is edited |
|
209 |
$tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".intval($this->id)); |
|
210 |
$this->dataRecord["server_id"] = $tmp["server_id"]; |
|
211 |
unset($tmp); |
|
212 |
// When the record is inserted |
|
213 |
} else { |
|
214 |
// set the server ID to the default mailserver of the client |
|
215 |
$this->dataRecord["server_id"] = $client["default_webserver"]; |
|
216 |
|
4fae7e
|
217 |
|
T |
218 |
// Check if the user may add another web_domain |
|
219 |
if($client["limit_web_domain"] >= 0) { |
|
220 |
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'vhost'"); |
|
221 |
if($tmp["number"] >= $client["limit_web_domain"]) { |
|
222 |
$app->error($app->tform->wordbook["limit_web_domain_txt"]); |
18341e
|
223 |
} |
T |
224 |
} |
4fae7e
|
225 |
|
18341e
|
226 |
} |
T |
227 |
|
b5a23a
|
228 |
// Clients may not set the client_group_id, so we unset them if user is not a admin and the client is not a reseller |
T |
229 |
if(!$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]); |
18341e
|
230 |
} |
T |
231 |
|
|
232 |
|
|
233 |
parent::onSubmit(); |
|
234 |
} |
|
235 |
|
|
236 |
function onAfterInsert() { |
|
237 |
global $app, $conf; |
|
238 |
|
|
239 |
// make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it |
|
240 |
// also make sure that the user can not delete domain created by a admin |
|
241 |
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { |
|
242 |
$client_group_id = intval($this->dataRecord["client_group_id"]); |
|
243 |
$app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id); |
b5a23a
|
244 |
} |
T |
245 |
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { |
|
246 |
$client_group_id = intval($this->dataRecord["client_group_id"]); |
|
247 |
$app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id); |
18341e
|
248 |
} |
T |
249 |
|
|
250 |
// Get configuration for the web system |
|
251 |
$app->uses("getconf"); |
e2d6ed
|
252 |
$web_rec = $app->tform->getDataRecord($this->id); |
T |
253 |
$web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web'); |
18341e
|
254 |
$document_root = str_replace("[website_id]",$this->id,$web_config["website_path"]); |
T |
255 |
|
|
256 |
// get the ID of the client |
542146
|
257 |
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
18341e
|
258 |
$client_group_id = $_SESSION["s"]["user"]["default_group"]; |
22b413
|
259 |
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id"); |
18341e
|
260 |
$client_id = intval($client["client_id"]); |
T |
261 |
} else { |
15d78a
|
262 |
//$client_id = intval($this->dataRecord["client_group_id"]); |
e535ba
|
263 |
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($this->dataRecord["client_group_id"])); |
18341e
|
264 |
$client_id = intval($client["client_id"]); |
T |
265 |
} |
|
266 |
|
|
267 |
// Set the values for document_root, system_user and system_group |
|
268 |
$system_user = 'web'.$this->id; |
|
269 |
$system_group = 'client'.$client_id; |
|
270 |
$document_root = str_replace("[client_id]",$client_id,$document_root); |
|
271 |
|
|
272 |
$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group', document_root = '$document_root' WHERE domain_id = ".$this->id; |
|
273 |
$app->db->query($sql); |
|
274 |
} |
|
275 |
|
327124
|
276 |
function onBeforeUpdate () { |
T |
277 |
global $app, $conf; |
67fbfc
|
278 |
|
V |
279 |
//* Check if the server has been changed |
|
280 |
// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway |
|
281 |
if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
ee3584
|
282 |
if (isset($this->dataRecord["server_id"])){ |
V |
283 |
$rec = $app->db->queryOneRecord("SELECT server_id from web_domain WHERE domain_id = ".$this->id); |
|
284 |
if($rec['server_id'] != $this->dataRecord["server_id"]) { |
|
285 |
//* Add a error message and switch back to old server |
|
286 |
$app->tform->errorMessage .= $app->lng('The Server can not be changed.'); |
|
287 |
$this->dataRecord["server_id"] = $rec['server_id']; |
|
288 |
} |
|
289 |
unset($rec); |
67fbfc
|
290 |
} |
8c4aa3
|
291 |
//* If the user is neither admin nor reseller |
T |
292 |
} else { |
|
293 |
//* We do not allow users to change a domain which has been created by the admin |
|
294 |
$rec = $app->db->queryOneRecord("SELECT domain from web_domain WHERE domain_id = ".$this->id); |
|
295 |
if(isset($this->dataRecord["domain"]) && $rec['domain'] != $this->dataRecord["domain"] && $app->tform->checkPerm($this->id,'u')) { |
|
296 |
//* Add a error message and switch back to old server |
|
297 |
$app->tform->errorMessage .= $app->lng('The Domain can not be changed. Please ask your Administrator if you want to change the domain name.'); |
|
298 |
$this->dataRecord["domain"] = $rec['domain']; |
|
299 |
} |
|
300 |
unset($rec); |
67fbfc
|
301 |
} |
327124
|
302 |
|
T |
303 |
//* Check that all fields for the SSL cert creation are filled |
|
304 |
if(isset($this->dataRecord['ssl_action']) && $this->dataRecord['ssl_action'] == 'create') { |
|
305 |
if($this->dataRecord['ssl_state'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_state_empty').'<br />'; |
|
306 |
if($this->dataRecord['ssl_locality'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_locality_empty').'<br />'; |
|
307 |
if($this->dataRecord['ssl_organisation'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_organisation_empty').'<br />'; |
|
308 |
if($this->dataRecord['ssl_organisation_unit'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_organisation_unit_empty').'<br />'; |
|
309 |
if($this->dataRecord['ssl_country'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_country_empty').'<br />'; |
|
310 |
} |
|
311 |
|
|
312 |
} |
|
313 |
|
18341e
|
314 |
function onAfterUpdate() { |
T |
315 |
global $app, $conf; |
|
316 |
|
67fbfc
|
317 |
// make sure that the record belongs to the clinet group and not the admin group when a admin inserts it |
18341e
|
318 |
// also make sure that the user can not delete domain created by a admin |
T |
319 |
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { |
|
320 |
$client_group_id = intval($this->dataRecord["client_group_id"]); |
|
321 |
$app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id); |
|
322 |
} |
b5a23a
|
323 |
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { |
T |
324 |
$client_group_id = intval($this->dataRecord["client_group_id"]); |
|
325 |
$app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id); |
|
326 |
} |
18341e
|
327 |
|
T |
328 |
// Get configuration for the web system |
|
329 |
$app->uses("getconf"); |
e2d6ed
|
330 |
$web_rec = $app->tform->getDataRecord($this->id); |
T |
331 |
$web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web'); |
18341e
|
332 |
$document_root = str_replace("[website_id]",$this->id,$web_config["website_path"]); |
T |
333 |
|
|
334 |
// get the ID of the client |
b5a23a
|
335 |
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
18341e
|
336 |
$client_group_id = $_SESSION["s"]["user"]["default_group"]; |
22b413
|
337 |
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id"); |
18341e
|
338 |
$client_id = intval($client["client_id"]); |
T |
339 |
} else { |
15d78a
|
340 |
//$client_id = intval(@$web_rec["client_group_id"]); |
b35cfd
|
341 |
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval(@$this->dataRecord["client_group_id"])); |
18341e
|
342 |
$client_id = intval($client["client_id"]); |
T |
343 |
} |
|
344 |
|
542146
|
345 |
if(($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) && isset($this->dataRecord["client_group_id"]) && $this->dataRecord["client_group_id"] != $this->oldDataRecord["client_group_id"]) { |
d053cb
|
346 |
// Set the values for document_root, system_user and system_group |
T |
347 |
$system_user = 'web'.$this->id; |
|
348 |
$system_group = 'client'.$client_id; |
8c4aa3
|
349 |
$document_root = str_replace("[client_id]",$client_id,$document_root); |
18341e
|
350 |
|
8c4aa3
|
351 |
$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group', document_root = '$document_root' WHERE domain_id = ".$this->id; |
T |
352 |
//$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group' WHERE domain_id = ".$this->id; |
d053cb
|
353 |
$app->db->query($sql); |
T |
354 |
} |
18341e
|
355 |
|
69944a
|
356 |
//* If the domain name has been changed, we will have to change all subdomains |
T |
357 |
if($this->dataRecord["domain"] != '' && $this->oldDataRecord["domain"] != '' && $this->dataRecord["domain"] != $this->oldDataRecord["domain"]) { |
|
358 |
$records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE type = 'subdomain' AND domain LIKE '%.".$app->db->quote($this->oldDataRecord["domain"])."'"); |
|
359 |
foreach($records as $rec) { |
|
360 |
$subdomain = $app->db->quote(str_replace($this->oldDataRecord["domain"],$this->dataRecord["domain"],$rec['domain'])); |
|
361 |
$app->db->datalogUpdate('web_domain', "domain = '".$subdomain."'", 'domain_id', $rec['domain_id']); |
|
362 |
} |
|
363 |
unset($records); |
|
364 |
unset($rec); |
|
365 |
unset($subdomain); |
|
366 |
} |
|
367 |
|
18341e
|
368 |
} |
T |
369 |
|
18dc99
|
370 |
function onAfterDelete() { |
T |
371 |
global $app, $conf; |
|
372 |
|
|
373 |
// Delete the sub and alias domains |
|
374 |
$child_domains = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$this->id); |
|
375 |
foreach($child_domains as $d) { |
|
376 |
// Saving record to datalog when db_history enabled |
|
377 |
if($app->tform->formDef["db_history"] == 'yes') { |
|
378 |
$app->tform->datalogSave('DELETE',$d["domain_id"],$d,array()); |
|
379 |
} |
|
380 |
|
|
381 |
$app->db->query("DELETE FROM web_domain WHERE domain_id = ".$d["domain_id"]." LIMIT 0,1"); |
|
382 |
} |
|
383 |
unset($child_domains); |
|
384 |
unset($d); |
|
385 |
|
|
386 |
} |
|
387 |
|
18341e
|
388 |
} |
T |
389 |
|
|
390 |
$page = new page_action; |
|
391 |
$page->onLoad(); |
|
392 |
|
|
393 |
?> |