commit | author | age
|
146783
|
1 |
<?php |
MC |
2 |
/* |
|
3 |
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh |
|
4 |
All rights reserved. |
|
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_vhost_subdomain.tform.php"; |
|
36 |
|
|
37 |
/****************************************** |
|
38 |
* End Form configuration |
|
39 |
******************************************/ |
|
40 |
|
7fe908
|
41 |
require_once '../../lib/config.inc.php'; |
MC |
42 |
require_once '../../lib/app.inc.php'; |
146783
|
43 |
|
MC |
44 |
//* Check permissions for module |
|
45 |
$app->auth->check_module_permissions('sites'); |
|
46 |
|
|
47 |
// Loading classes |
|
48 |
$app->uses('tpl,tform,tform_actions,tools_sites'); |
|
49 |
$app->load('tform_actions'); |
|
50 |
|
|
51 |
class page_action extends tform_actions { |
|
52 |
|
|
53 |
//* Returna a "3/2/1" path hash from a numeric id '123' |
7fe908
|
54 |
function id_hash($id, $levels) { |
146783
|
55 |
$hash = "" . $id % 10 ; |
MC |
56 |
$id /= 10 ; |
|
57 |
$levels -- ; |
|
58 |
while ( $levels > 0 ) { |
|
59 |
$hash .= "/" . $id % 10 ; |
|
60 |
$id /= 10 ; |
|
61 |
$levels-- ; |
|
62 |
} |
|
63 |
return $hash; |
|
64 |
} |
7fe908
|
65 |
|
146783
|
66 |
function onShowNew() { |
MC |
67 |
global $app, $conf; |
|
68 |
|
|
69 |
// we will check only users, not admins |
|
70 |
if($_SESSION["s"]["user"]["typ"] == 'user') { |
7fe908
|
71 |
if(!$app->tform->checkClientLimit('limit_web_subdomain', "(type = 'subdomain' OR type = 'vhostsubdomain')")) { |
146783
|
72 |
$app->error($app->tform->wordbook["limit_web_subdomain_txt"]); |
MC |
73 |
} |
7fe908
|
74 |
if(!$app->tform->checkResellerLimit('limit_web_subdomain', "(type = 'subdomain' OR type = 'vhostsubdomain')")) { |
146783
|
75 |
$app->error('Reseller: '.$app->tform->wordbook["limit_web_subdomain_txt"]); |
MC |
76 |
} |
|
77 |
} |
|
78 |
parent::onShowNew(); |
|
79 |
} |
|
80 |
|
|
81 |
function onShowEnd() { |
|
82 |
global $app, $conf; |
7fe908
|
83 |
|
146783
|
84 |
$app->uses('ini_parser,getconf'); |
MC |
85 |
|
7fe908
|
86 |
$read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl'); |
MC |
87 |
|
|
88 |
$parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"])); |
|
89 |
|
146783
|
90 |
//* Client: If the logged in user is not admin and has no sub clients (no reseller) |
MC |
91 |
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
|
92 |
|
|
93 |
// Get the limits of the client |
604c0c
|
94 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
146783
|
95 |
$client = $app->db->queryOneRecord("SELECT client.limit_web_subdomain, client.default_webserver, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
7fe908
|
96 |
|
146783
|
97 |
//* Get global web config |
MC |
98 |
$web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web'); |
|
99 |
|
|
100 |
//PHP Version Selection (FastCGI) |
|
101 |
$server_type = 'apache'; |
|
102 |
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type']; |
|
103 |
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm'; |
|
104 |
if($this->dataRecord['php'] == 'php-fpm'){ |
604c0c
|
105 |
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); |
146783
|
106 |
} |
MC |
107 |
if($this->dataRecord['php'] == 'fast-cgi'){ |
604c0c
|
108 |
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); |
146783
|
109 |
} |
MC |
110 |
$php_select = "<option value=''>Default</option>"; |
|
111 |
if(is_array($php_records) && !empty($php_records)) { |
|
112 |
foreach( $php_records as $php_record) { |
|
113 |
if($this->dataRecord['php'] == 'php-fpm'){ |
|
114 |
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir']; |
|
115 |
} else { |
|
116 |
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; |
|
117 |
} |
|
118 |
$selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; |
|
119 |
$php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n"; |
|
120 |
} |
|
121 |
} |
7fe908
|
122 |
$app->tpl->setVar("fastcgi_php_version", $php_select); |
146783
|
123 |
unset($php_records); |
MC |
124 |
|
7fe908
|
125 |
// add limits to template to be able to hide settings |
MC |
126 |
foreach($read_limits as $limit) $app->tpl->setVar($limit, $client[$limit]); |
|
127 |
|
|
128 |
|
146783
|
129 |
//* Reseller: If the logged in user is not admin and has sub clients (is a reseller) |
MC |
130 |
} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
|
131 |
|
|
132 |
// Get the limits of the client |
604c0c
|
133 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
146783
|
134 |
$client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_subdomain, client.default_webserver, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
7fe908
|
135 |
|
146783
|
136 |
//* Get global web config |
MC |
137 |
$web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web'); |
7fe908
|
138 |
|
146783
|
139 |
//PHP Version Selection (FastCGI) |
MC |
140 |
$server_type = 'apache'; |
|
141 |
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type']; |
|
142 |
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm'; |
|
143 |
if($this->dataRecord['php'] == 'php-fpm'){ |
604c0c
|
144 |
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); |
146783
|
145 |
} |
MC |
146 |
if($this->dataRecord['php'] == 'fast-cgi') { |
604c0c
|
147 |
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); |
146783
|
148 |
} |
MC |
149 |
$php_select = "<option value=''>Default</option>"; |
|
150 |
if(is_array($php_records) && !empty($php_records)) { |
|
151 |
foreach( $php_records as $php_record) { |
|
152 |
if($this->dataRecord['php'] == 'php-fpm'){ |
|
153 |
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir']; |
|
154 |
} else { |
|
155 |
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; |
|
156 |
} |
|
157 |
$selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; |
|
158 |
$php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n"; |
|
159 |
} |
|
160 |
} |
7fe908
|
161 |
$app->tpl->setVar("fastcgi_php_version", $php_select); |
146783
|
162 |
unset($php_records); |
7fe908
|
163 |
|
MC |
164 |
// add limits to template to be able to hide settings |
|
165 |
foreach($read_limits as $limit) $app->tpl->setVar($limit, $client[$limit]); |
|
166 |
|
|
167 |
|
146783
|
168 |
//* Admin: If the logged in user is admin |
MC |
169 |
} else { |
|
170 |
|
|
171 |
//* get global web config |
|
172 |
$web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web'); |
7fe908
|
173 |
|
146783
|
174 |
//PHP Version Selection (FastCGI) |
MC |
175 |
$server_type = 'apache'; |
|
176 |
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type']; |
|
177 |
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm'; |
|
178 |
if($this->dataRecord['php'] == 'php-fpm'){ |
604c0c
|
179 |
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . $app->functions->intval($parent_domain['server_id'])); |
146783
|
180 |
} |
MC |
181 |
if($this->dataRecord['php'] == 'fast-cgi') { |
604c0c
|
182 |
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $app->functions->intval($parent_domain['server_id'])); |
146783
|
183 |
} |
MC |
184 |
$php_select = "<option value=''>Default</option>"; |
|
185 |
if(is_array($php_records) && !empty($php_records)) { |
|
186 |
foreach( $php_records as $php_record) { |
|
187 |
if($this->dataRecord['php'] == 'php-fpm'){ |
|
188 |
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir']; |
|
189 |
} else { |
|
190 |
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; |
|
191 |
} |
|
192 |
$selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; |
|
193 |
$php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n"; |
|
194 |
} |
|
195 |
} |
7fe908
|
196 |
$app->tpl->setVar("fastcgi_php_version", $php_select); |
146783
|
197 |
unset($php_records); |
MC |
198 |
|
7fe908
|
199 |
foreach($read_limits as $limit) $app->tpl->setVar($limit, ($limit == 'force_suexec' ? 'n' : 'y')); |
MC |
200 |
|
146783
|
201 |
// Directive Snippets |
MC |
202 |
$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y'"); |
|
203 |
$php_directive_snippets_txt = ''; |
|
204 |
if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){ |
7fe908
|
205 |
foreach($php_directive_snippets as $php_directive_snippet){ |
1c3655
|
206 |
$php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$php_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($php_directive_snippet['snippet']).'</pre></a> '; |
7fe908
|
207 |
} |
146783
|
208 |
} |
MC |
209 |
if($php_directive_snippets_txt == '') $php_directive_snippets_txt = '------'; |
7fe908
|
210 |
$app->tpl->setVar("php_directive_snippets_txt", $php_directive_snippets_txt); |
MC |
211 |
|
146783
|
212 |
if($server_type == 'apache'){ |
MC |
213 |
$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y'"); |
|
214 |
$apache_directive_snippets_txt = ''; |
|
215 |
if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){ |
7fe908
|
216 |
foreach($apache_directive_snippets as $apache_directive_snippet){ |
1c3655
|
217 |
$apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$apache_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($apache_directive_snippet['snippet']).'</pre></a> '; |
7fe908
|
218 |
} |
146783
|
219 |
} |
MC |
220 |
if($apache_directive_snippets_txt == '') $apache_directive_snippets_txt = '------'; |
7fe908
|
221 |
$app->tpl->setVar("apache_directive_snippets_txt", $apache_directive_snippets_txt); |
146783
|
222 |
} |
7fe908
|
223 |
|
146783
|
224 |
if($server_type == 'nginx'){ |
MC |
225 |
$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y'"); |
|
226 |
$nginx_directive_snippets_txt = ''; |
|
227 |
if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){ |
7fe908
|
228 |
foreach($nginx_directive_snippets as $nginx_directive_snippet){ |
1c3655
|
229 |
$nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$nginx_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($nginx_directive_snippet['snippet']).'</pre></a> '; |
7fe908
|
230 |
} |
146783
|
231 |
} |
MC |
232 |
if($nginx_directive_snippets_txt == '') $nginx_directive_snippets_txt = '------'; |
7fe908
|
233 |
$app->tpl->setVar("nginx_directive_snippets_txt", $nginx_directive_snippets_txt); |
146783
|
234 |
} |
7fe908
|
235 |
|
146783
|
236 |
$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'"); |
MC |
237 |
$proxy_directive_snippets_txt = ''; |
|
238 |
if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){ |
7fe908
|
239 |
foreach($proxy_directive_snippets as $proxy_directive_snippet){ |
1c3655
|
240 |
$proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$proxy_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($proxy_directive_snippet['snippet']).'</pre></a> '; |
7fe908
|
241 |
} |
146783
|
242 |
} |
MC |
243 |
if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------'; |
7fe908
|
244 |
$app->tpl->setVar("proxy_directive_snippets_txt", $proxy_directive_snippets_txt); |
146783
|
245 |
} |
MC |
246 |
|
|
247 |
$ssl_domain_select = ''; |
|
248 |
$tmp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ".$this->id); |
1c3655
|
249 |
$ssl_domains = array($tmp["domain"], 'www.'.$tmp["domain"], '*.'.$tmp["domain"]); |
146783
|
250 |
if(is_array($ssl_domains)) { |
MC |
251 |
foreach( $ssl_domains as $ssl_domain) { |
|
252 |
$selected = ($ssl_domain == $this->dataRecord['ssl_domain'])?'SELECTED':''; |
|
253 |
$ssl_domain_select .= "<option value='$ssl_domain' $selected>$ssl_domain</option>\r\n"; |
|
254 |
} |
|
255 |
} |
1c3655
|
256 |
$app->tpl->setVar("ssl_domain", $ssl_domain_select); |
MC |
257 |
unset($ssl_domain_select); |
|
258 |
unset($ssl_domains); |
|
259 |
unset($ssl_domain); |
7fe908
|
260 |
|
MC |
261 |
if($this->id > 0) { |
|
262 |
$app->tpl->setVar('fixed_folder', 'y'); |
|
263 |
$app->tpl->setVar('server_id_value', $parent_domain['server_id']); |
|
264 |
} else { |
|
265 |
$app->tpl->setVar('fixed_folder', 'n'); |
|
266 |
$app->tpl->setVar('server_id_value', $parent_domain['server_id']); |
|
267 |
} |
146783
|
268 |
|
MC |
269 |
$tmp_txt = ($this->dataRecord['traffic_quota_lock'] == 'y')?'<b>('.$app->tform->lng('traffic_quota_exceeded_txt').')</b>':''; |
|
270 |
$app->tpl->setVar("traffic_quota_exceeded_txt", $tmp_txt); |
|
271 |
|
|
272 |
|
|
273 |
$app->uses('ini_parser,getconf'); |
|
274 |
$settings = $app->getconf->get_global_config('domains'); |
|
275 |
if ($settings['use_domain_module'] == 'y') { |
|
276 |
/* |
|
277 |
* The domain-module is in use. |
|
278 |
*/ |
7fe908
|
279 |
$domains = $app->tools_sites->getDomainModuleDomains(); |
146783
|
280 |
$domain_select = ''; |
7fe908
|
281 |
$selected_domain = ''; |
146783
|
282 |
if(is_array($domains) && sizeof($domains) > 0) { |
MC |
283 |
/* We have domains in the list, so create the drop-down-list */ |
|
284 |
foreach( $domains as $domain) { |
|
285 |
$domain_select .= "<option value=" . $domain['domain_id'] ; |
|
286 |
if ('.' . $domain['domain'] == substr($this->dataRecord["domain"], -strlen($domain['domain']) - 1)) { |
|
287 |
$domain_select .= " selected"; |
7fe908
|
288 |
$selected_domain = $domain['domain']; |
146783
|
289 |
} |
MC |
290 |
$domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . "</option>\r\n"; |
|
291 |
} |
|
292 |
} |
|
293 |
else { |
|
294 |
/* |
|
295 |
* We have no domains in the domain-list. This means, we can not add ANY new domain. |
|
296 |
* To avoid, that the variable "domain_option" is empty and so the user can |
|
297 |
* free enter a domain, we have to create a empty option! |
|
298 |
*/ |
|
299 |
$domain_select .= "<option value=''></option>\r\n"; |
|
300 |
} |
7fe908
|
301 |
$app->tpl->setVar("domain_option", $domain_select); |
MC |
302 |
$this->dataRecord['domain'] = substr($this->dataRecord["domain"], 0, strlen($this->dataRecord['domain']) - strlen($selected_domain) - 1); |
146783
|
303 |
} else { |
7fe908
|
304 |
|
MC |
305 |
// remove the parent domain part of the domain name before we show it in the text field. |
|
306 |
$this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"], '', $this->dataRecord["domain"]); |
|
307 |
} |
|
308 |
$app->tpl->setVar("domain", $this->dataRecord["domain"]); |
1c3655
|
309 |
|
MC |
310 |
// check for configuration errors in sys_datalog |
|
311 |
if($this->id > 0) { |
|
312 |
$datalog = $app->db->queryOneRecord("SELECT sys_datalog.error, sys_log.tstamp FROM sys_datalog, sys_log WHERE sys_datalog.dbtable = 'web_domain' AND sys_datalog.dbidx = 'domain_id:".$app->functions->intval($this->id)."' AND sys_datalog.datalog_id = sys_log.datalog_id AND sys_log.message = CONCAT('Processed datalog_id ',sys_log.datalog_id) ORDER BY sys_datalog.tstamp DESC"); |
|
313 |
if(is_array($datalog) && !empty($datalog)){ |
|
314 |
if(trim($datalog['error']) != ''){ |
|
315 |
$app->tpl->setVar("config_error_msg", nl2br(htmlentities($datalog['error']))); |
|
316 |
$app->tpl->setVar("config_error_tstamp", date($app->lng('conf_format_datetime'), $datalog['tstamp'])); |
|
317 |
} |
|
318 |
} |
|
319 |
} |
146783
|
320 |
|
MC |
321 |
parent::onShowEnd(); |
|
322 |
} |
7fe908
|
323 |
|
146783
|
324 |
function onSubmit() { |
MC |
325 |
global $app, $conf; |
|
326 |
|
|
327 |
// Get the record of the parent domain |
7fe908
|
328 |
if(!@$this->dataRecord["parent_domain_id"] && $this->id) { |
MC |
329 |
$tmp = $app->db->queryOneRecord("SELECT parent_domain_id FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id)); |
|
330 |
if($tmp) $this->dataRecord["parent_domain_id"] = $tmp['parent_domain_id']; |
|
331 |
unset($tmp); |
|
332 |
} |
|
333 |
|
146783
|
334 |
$parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]) . " AND ".$app->tform->getAuthSQL('r')); |
7fe908
|
335 |
if(!$parent_domain || $parent_domain['domain_id'] != @$this->dataRecord['parent_domain_id']) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm"); |
146783
|
336 |
|
MC |
337 |
// Set a few fixed values |
|
338 |
$this->dataRecord["type"] = 'vhostsubdomain'; |
|
339 |
$this->dataRecord["server_id"] = $parent_domain["server_id"]; |
|
340 |
$this->dataRecord["ip_address"] = $parent_domain["ip_address"]; |
|
341 |
$this->dataRecord["ipv6_address"] = $parent_domain["ipv6_address"]; |
|
342 |
$this->dataRecord["client_group_id"] = $parent_domain["client_group_id"]; |
|
343 |
$this->dataRecord["vhost_type"] = 'name'; |
e98a15
|
344 |
$this->dataRecord["system_user"] = $parent_domain["system_user"]; |
TB |
345 |
$this->dataRecord["system_group"] = $parent_domain["system_group"]; |
146783
|
346 |
|
MC |
347 |
$this->parent_domain_record = $parent_domain; |
7fe908
|
348 |
|
MC |
349 |
$read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl'); |
|
350 |
|
|
351 |
if($app->tform->getCurrentTab() == 'domain') { |
|
352 |
|
15b96b
|
353 |
// Check that domain (the subdomain part) is not empty |
baa7f2
|
354 |
if(!preg_match('/^[a-zA-Z0-9].*/',$this->dataRecord['domain'])) { |
15b96b
|
355 |
$app->tform->errorMessage .= $app->tform->lng("subdomain_error_empty")."<br />"; |
TB |
356 |
} |
|
357 |
|
7fe908
|
358 |
/* check if the domain module is used - and check if the selected domain can be used! */ |
MC |
359 |
$app->uses('ini_parser,getconf'); |
|
360 |
$settings = $app->getconf->get_global_config('domains'); |
|
361 |
if ($settings['use_domain_module'] == 'y') { |
|
362 |
$domain_check = $app->tools_sites->checkDomainModuleDomain($this->dataRecord['sel_domain']); |
|
363 |
if(!$domain_check) { |
|
364 |
// invalid domain selected |
|
365 |
$app->tform->errorMessage .= $app->tform->lng("domain_error_empty")."<br />"; |
|
366 |
} else { |
|
367 |
$this->dataRecord['domain'] = $this->dataRecord['domain'] . '.' . $domain_check; |
|
368 |
} |
|
369 |
} else { |
|
370 |
$this->dataRecord["domain"] = $this->dataRecord["domain"].'.'.$parent_domain["domain"]; |
|
371 |
} |
|
372 |
|
|
373 |
|
|
374 |
$this->dataRecord['web_folder'] = strtolower($this->dataRecord['web_folder']); |
146783
|
375 |
if(substr($this->dataRecord['web_folder'], 0, 1) === '/') $this->dataRecord['web_folder'] = substr($this->dataRecord['web_folder'], 1); |
MC |
376 |
if(substr($this->dataRecord['web_folder'], -1) === '/') $this->dataRecord['web_folder'] = substr($this->dataRecord['web_folder'], 0, -1); |
7fe908
|
377 |
$forbidden_folders = array('', 'cgi-bin', 'log', 'private', 'ssl', 'tmp', 'webdav'); |
MC |
378 |
$check_folder = strtolower($this->dataRecord['web_folder']); |
|
379 |
if(substr($check_folder, 0, 1) === '/') $check_folder = substr($check_folder, 1); // strip / at beginning to check against forbidden entries |
|
380 |
if(strpos($check_folder, '/') !== false) $check_folder = substr($check_folder, 0, strpos($check_folder, '/')); // get the first part of the path to check it |
|
381 |
if(in_array($check_folder, $forbidden_folders)) { |
|
382 |
$app->tform->errorMessage .= $app->tform->lng("web_folder_invalid_txt")."<br>"; |
|
383 |
} |
|
384 |
|
146783
|
385 |
// vhostsubdomains do not have a quota of their own |
MC |
386 |
$this->dataRecord["hd_quota"] = 0; |
7fe908
|
387 |
|
MC |
388 |
// check for duplicate folder usage |
146783
|
389 |
/* |
MC |
390 |
$check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain' AND `parent_domain_id` = '" . $app->functions->intval($this->dataRecord['parent_domain_id']) . "' AND `web_folder` = '" . $app->db->quote($this->dataRecord['web_folder']) . "' AND `domain_id` != '" . $app->functions->intval($this->id) . "'"); |
|
391 |
if($check && $check['cnt'] > 0) { |
|
392 |
$app->tform->errorMessage .= $app->tform->lng("web_folder_unique_txt")."<br>"; |
|
393 |
} |
|
394 |
*/ |
7fe908
|
395 |
} else { |
MC |
396 |
$this->dataRecord["domain"] = $this->dataRecord["domain"].'.'.$parent_domain["domain"]; |
|
397 |
} |
|
398 |
|
146783
|
399 |
if($_SESSION["s"]["user"]["typ"] != 'admin') { |
MC |
400 |
// Get the limits of the client |
604c0c
|
401 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
146783
|
402 |
$client = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_subdomain, default_webserver, parent_client_id, limit_web_quota, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
7fe908
|
403 |
|
31143b
|
404 |
if($client['limit_cgi'] != 'y') $this->dataRecord['cgi'] = 'n'; |
TB |
405 |
if($client['limit_ssi'] != 'y') $this->dataRecord['ssi'] = 'n'; |
|
406 |
if($client['limit_perl'] != 'y') $this->dataRecord['perl'] = 'n'; |
|
407 |
if($client['limit_ruby'] != 'y') $this->dataRecord['ruby'] = 'n'; |
|
408 |
if($client['limit_python'] != 'y') $this->dataRecord['python'] = 'n'; |
1c3655
|
409 |
if($client['force_suexec'] == 'y') $this->dataRecord['suexec'] = 'y'; |
31143b
|
410 |
if($client['limit_hterror'] != 'y') $this->dataRecord['errordocs'] = 'n'; |
TB |
411 |
if($client['limit_wildcard'] != 'y' && $this->dataRecord['subdomain'] == '*') $this->dataRecord['subdomain'] = 'n'; |
|
412 |
if($client['limit_ssl'] != 'y') $this->dataRecord['ssl'] = 'n'; |
7fe908
|
413 |
|
146783
|
414 |
// only generate quota and traffic warnings if value has changed |
MC |
415 |
if($this->id > 0) { |
|
416 |
$old_web_values = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id)); |
|
417 |
} else { |
1c3655
|
418 |
$old_web_values = array(); |
146783
|
419 |
} |
MC |
420 |
|
|
421 |
//* Check the traffic quota of the client |
|
422 |
if(isset($_POST["traffic_quota"]) && $client["limit_traffic_quota"] > 0 && $_POST["traffic_quota"] != $old_web_values["traffic_quota"]) { |
|
423 |
$tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u')); |
|
424 |
$trafficquota = $tmp["trafficquota"]; |
|
425 |
$new_traffic_quota = $app->functions->intval($this->dataRecord["traffic_quota"]); |
|
426 |
if(($trafficquota + $new_traffic_quota > $client["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $client["limit_traffic_quota"] >= 0)) { |
|
427 |
$max_free_quota = floor($client["limit_traffic_quota"] - $trafficquota); |
|
428 |
if($max_free_quota < 0) $max_free_quota = 0; |
|
429 |
$app->tform->errorMessage .= $app->tform->lng("limit_traffic_quota_free_txt").": ".$max_free_quota." MB<br>"; |
|
430 |
// Set the quota field to the max free space |
|
431 |
$this->dataRecord["traffic_quota"] = $max_free_quota; |
|
432 |
} |
|
433 |
unset($tmp); |
|
434 |
unset($tmp_quota); |
|
435 |
} |
7fe908
|
436 |
|
146783
|
437 |
if($client['parent_client_id'] > 0) { |
MC |
438 |
// Get the limits of the reseller |
604c0c
|
439 |
$reseller = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_subdomain, default_webserver, limit_web_quota FROM client WHERE client_id = ".$app->functions->intval($client['parent_client_id'])); |
146783
|
440 |
|
MC |
441 |
//* Check the traffic quota of the client |
|
442 |
if(isset($_POST["traffic_quota"]) && $reseller["limit_traffic_quota"] > 0 && $_POST["traffic_quota"] != $old_web_values["traffic_quota"]) { |
|
443 |
$tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u')); |
|
444 |
$trafficquota = $tmp["trafficquota"]; |
|
445 |
$new_traffic_quota = $app->functions->intval($this->dataRecord["traffic_quota"]); |
|
446 |
if(($trafficquota + $new_traffic_quota > $reseller["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $reseller["limit_traffic_quota"] >= 0)) { |
|
447 |
$max_free_quota = floor($reseller["limit_traffic_quota"] - $trafficquota); |
|
448 |
if($max_free_quota < 0) $max_free_quota = 0; |
|
449 |
$app->tform->errorMessage .= $app->tform->lng("limit_traffic_quota_free_txt").": ".$max_free_quota." MB<br>"; |
|
450 |
// Set the quota field to the max free space |
|
451 |
$this->dataRecord["traffic_quota"] = $max_free_quota; |
|
452 |
} |
|
453 |
unset($tmp); |
|
454 |
unset($tmp_quota); |
|
455 |
} |
|
456 |
} |
|
457 |
|
|
458 |
// When the record is updated |
|
459 |
if($this->id > 0) { |
7fe908
|
460 |
// restore the server ID if the user is not admin and record is edited |
146783
|
461 |
$tmp = $app->db->queryOneRecord("SELECT server_id, `web_folder`, `cgi`, `ssi`, `perl`, `ruby`, `python`, `suexec`, `errordocs`, `subdomain`, `ssl` FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id)); |
7fe908
|
462 |
$this->dataRecord['web_folder'] = $tmp['web_folder']; // cannot be changed! |
MC |
463 |
|
|
464 |
// set the settings to current if not provided (or cleared due to limits) |
31143b
|
465 |
if($this->dataRecord['cgi'] == 'n') $this->dataRecord['cgi'] = $tmp['cgi']; |
TB |
466 |
if($this->dataRecord['ssi'] == 'n') $this->dataRecord['ssi'] = $tmp['ssi']; |
|
467 |
if($this->dataRecord['perl'] == 'n') $this->dataRecord['perl'] = $tmp['perl']; |
|
468 |
if($this->dataRecord['ruby'] == 'n') $this->dataRecord['ruby'] = $tmp['ruby']; |
|
469 |
if($this->dataRecord['python'] == 'n') $this->dataRecord['python'] = $tmp['python']; |
|
470 |
if($this->dataRecord['suexec'] == 'n') $this->dataRecord['suexec'] = $tmp['suexec']; |
|
471 |
if($this->dataRecord['errordocs'] == 'n') $this->dataRecord['errordocs'] = $tmp['errordocs']; |
|
472 |
if($this->dataRecord['subdomain'] == 'n') $this->dataRecord['subdomain'] = $tmp['subdomain']; |
|
473 |
if($this->dataRecord['ssl'] == 'n') $this->dataRecord['ssl'] = $tmp['ssl']; |
7fe908
|
474 |
|
146783
|
475 |
unset($tmp); |
MC |
476 |
// When the record is inserted |
|
477 |
} else { |
|
478 |
// Check if the user may add another web_domain |
|
479 |
if($client["limit_web_subdomain"] >= 0) { |
|
480 |
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and (type = 'subdomain' OR type = 'vhostsubdomain')"); |
|
481 |
if($tmp["number"] >= $client["limit_web_subdomain"]) { |
|
482 |
$app->error($app->tform->wordbook["limit_web_subdomain_txt"]); |
|
483 |
} |
|
484 |
} |
|
485 |
} |
|
486 |
} |
7fe908
|
487 |
|
146783
|
488 |
//* make sure that the domain is lowercase |
MC |
489 |
if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]); |
7fe908
|
490 |
|
146783
|
491 |
//* get the server config for this server |
MC |
492 |
$app->uses("getconf"); |
7fe908
|
493 |
$web_config = $app->getconf->get_server_config($app->functions->intval(isset($this->dataRecord["server_id"]) ? $this->dataRecord["server_id"] : 0), 'web'); |
146783
|
494 |
//* Check for duplicate ssl certs per IP if SNI is disabled |
MC |
495 |
if(isset($this->dataRecord['ssl']) && $this->dataRecord['ssl'] == 'y' && $web_config['enable_sni'] != 'y') { |
|
496 |
$sql = "SELECT count(domain_id) as number FROM web_domain WHERE `ssl` = 'y' AND ip_address = '".$app->db->quote($this->dataRecord['ip_address'])."' and domain_id != ".$this->id; |
|
497 |
$tmp = $app->db->queryOneRecord($sql); |
|
498 |
if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("error_no_sni_txt"); |
|
499 |
} |
7fe908
|
500 |
|
146783
|
501 |
// Check if pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0 |
MC |
502 |
if(isset($this->dataRecord['pm_max_children']) && $this->dataRecord['pm'] == 'dynamic') { |
|
503 |
if($app->functions->intval($this->dataRecord['pm_max_children'], true) >= $app->functions->intval($this->dataRecord['pm_max_spare_servers'], true) && $app->functions->intval($this->dataRecord['pm_max_spare_servers'], true) >= $app->functions->intval($this->dataRecord['pm_start_servers'], true) && $app->functions->intval($this->dataRecord['pm_start_servers'], true) >= $app->functions->intval($this->dataRecord['pm_min_spare_servers'], true) && $app->functions->intval($this->dataRecord['pm_min_spare_servers'], true) > 0){ |
7fe908
|
504 |
|
146783
|
505 |
} else { |
MC |
506 |
$app->tform->errorMessage .= $app->tform->lng("error_php_fpm_pm_settings_txt").'<br>'; |
|
507 |
} |
|
508 |
} |
7fe908
|
509 |
|
146783
|
510 |
// Check rewrite rules |
MC |
511 |
$server_type = $web_config['server_type']; |
7fe908
|
512 |
|
146783
|
513 |
if($server_type == 'nginx' && isset($this->dataRecord['rewrite_rules']) && trim($this->dataRecord['rewrite_rules']) != '') { |
MC |
514 |
$rewrite_rules = trim($this->dataRecord['rewrite_rules']); |
|
515 |
$rewrites_are_valid = true; |
|
516 |
// use this counter to make sure all curly brackets are properly closed |
|
517 |
$if_level = 0; |
|
518 |
// Make sure we only have Unix linebreaks |
|
519 |
$rewrite_rules = str_replace("\r\n", "\n", $rewrite_rules); |
|
520 |
$rewrite_rules = str_replace("\r", "\n", $rewrite_rules); |
|
521 |
$rewrite_rule_lines = explode("\n", $rewrite_rules); |
|
522 |
if(is_array($rewrite_rule_lines) && !empty($rewrite_rule_lines)){ |
|
523 |
foreach($rewrite_rule_lines as $rewrite_rule_line){ |
|
524 |
// ignore comments |
7fe908
|
525 |
if(substr(ltrim($rewrite_rule_line), 0, 1) == '#') continue; |
146783
|
526 |
// empty lines |
MC |
527 |
if(trim($rewrite_rule_line) == '') continue; |
|
528 |
// rewrite |
|
529 |
if(preg_match('@^\s*rewrite\s+(^/)?\S+(\$)?\s+\S+(\s+(last|break|redirect|permanent|))?\s*;\s*$@', $rewrite_rule_line)) continue; |
|
530 |
// if |
|
531 |
if(preg_match('@^\s*if\s+\(\s*\$\S+(\s+(\!?(=|~|~\*))\s+(\S+|\".+\"))?\s*\)\s*\{\s*$@', $rewrite_rule_line)){ |
|
532 |
$if_level += 1; |
|
533 |
continue; |
|
534 |
} |
|
535 |
// if - check for files, directories, etc. |
|
536 |
if(preg_match('@^\s*if\s+\(\s*\!?-(f|d|e|x)\s+\S+\s*\)\s*\{\s*$@', $rewrite_rule_line)){ |
|
537 |
$if_level += 1; |
|
538 |
continue; |
|
539 |
} |
|
540 |
// break |
|
541 |
if(preg_match('@^\s*break\s*;\s*$@', $rewrite_rule_line)){ |
|
542 |
continue; |
|
543 |
} |
|
544 |
// return code [ text ] |
|
545 |
if(preg_match('@^\s*return\s+\d\d\d.*;\s*$@', $rewrite_rule_line)) continue; |
|
546 |
// return code URL |
|
547 |
// return URL |
|
548 |
if(preg_match('@^\s*return(\s+\d\d\d)?\s+(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*\@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*\s*;\s*$@', $rewrite_rule_line)) continue; |
|
549 |
// set |
|
550 |
if(preg_match('@^\s*set\s+\$\S+\s+\S+\s*;\s*$@', $rewrite_rule_line)) continue; |
|
551 |
// closing curly bracket |
|
552 |
if(trim($rewrite_rule_line) == '}'){ |
|
553 |
$if_level -= 1; |
|
554 |
continue; |
|
555 |
} |
|
556 |
$rewrites_are_valid = false; |
|
557 |
break; |
|
558 |
} |
|
559 |
} |
7fe908
|
560 |
|
146783
|
561 |
if(!$rewrites_are_valid || $if_level != 0){ |
MC |
562 |
$app->tform->errorMessage .= $app->tform->lng("invalid_rewrite_rules_txt").'<br>'; |
|
563 |
} |
|
564 |
} |
e1b4ca
|
565 |
|
TB |
566 |
// Check custom PHP version |
|
567 |
if(isset($this->dataRecord['fastcgi_php_version']) && $this->dataRecord['fastcgi_php_version'] != '') { |
|
568 |
// Check php-fpm mode |
|
569 |
if($this->dataRecord['php'] == 'php-fpm'){ |
|
570 |
$tmp = $app->db->queryOneRecord("SELECT * FROM server_php WHERE CONCAT(name,':',php_fpm_init_script,':',php_fpm_ini_dir,':',php_fpm_pool_dir) = '".$app->db->quote($this->dataRecord['fastcgi_php_version'])."'"); |
|
571 |
if(is_array($tmp)) { |
|
572 |
$this->dataRecord['fastcgi_php_version'] = $tmp['name'].':'.$tmp['php_fpm_init_script'].':'.$tmp['php_fpm_ini_dir'].':'.$tmp['php_fpm_pool_dir']; |
|
573 |
} else { |
|
574 |
$this->dataRecord['fastcgi_php_version'] = ''; |
|
575 |
} |
|
576 |
unset($tmp); |
|
577 |
// Check fast-cgi mode |
|
578 |
} elseif($this->dataRecord['php'] == 'fast-cgi') { |
|
579 |
$tmp = $app->db->queryOneRecord("SELECT * FROM server_php WHERE CONCAT(name,':',php_fastcgi_binary,':',php_fastcgi_ini_dir) = '".$app->db->quote($this->dataRecord['fastcgi_php_version'])."'"); |
|
580 |
if(is_array($tmp)) { |
|
581 |
$this->dataRecord['fastcgi_php_version'] = $tmp['name'].':'.$tmp['php_fastcgi_binary'].':'.$tmp['php_fastcgi_ini_dir']; |
|
582 |
} else { |
|
583 |
$this->dataRecord['fastcgi_php_version'] = ''; |
|
584 |
} |
|
585 |
unset($tmp); |
|
586 |
} else { |
|
587 |
// Other PHP modes do not have custom versions, so we force the value to be empty |
|
588 |
$this->dataRecord['fastcgi_php_version'] = ''; |
|
589 |
} |
|
590 |
} |
146783
|
591 |
|
MC |
592 |
parent::onSubmit(); |
|
593 |
} |
|
594 |
|
|
595 |
function onAfterInsert() { |
|
596 |
global $app, $conf; |
|
597 |
|
|
598 |
// Get configuration for the web system |
|
599 |
$app->uses("getconf"); |
|
600 |
$web_rec = $app->tform->getDataRecord($this->id); |
7fe908
|
601 |
$web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]), 'web'); |
MC |
602 |
//var_dump($this->parent_domain_record, $web_rec); |
146783
|
603 |
// Set the values for document_root, system_user and system_group |
MC |
604 |
$system_user = $app->db->quote($this->parent_domain_record['system_user']); |
|
605 |
$system_group = $app->db->quote($this->parent_domain_record['system_group']); |
|
606 |
$document_root = $app->db->quote($this->parent_domain_record['document_root']); |
7fe908
|
607 |
$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$web_rec['web_folder'], $web_config["php_open_basedir"]); |
MC |
608 |
$php_open_basedir = str_replace("[website_domain]/web", $web_rec['domain'].'/'.$web_rec['web_folder'], $php_open_basedir); |
|
609 |
$php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir); |
|
610 |
$php_open_basedir = $app->db->quote(str_replace("[website_domain]", $web_rec['domain'], $php_open_basedir)); |
146783
|
611 |
$htaccess_allow_override = $app->db->quote($this->parent_domain_record['allow_override']); |
MC |
612 |
|
|
613 |
$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir' WHERE domain_id = ".$this->id; |
|
614 |
$app->db->query($sql); |
|
615 |
} |
|
616 |
|
|
617 |
function onBeforeUpdate () { |
|
618 |
global $app, $conf; |
|
619 |
|
|
620 |
//* Check that all fields for the SSL cert creation are filled |
|
621 |
if(isset($this->dataRecord['ssl_action']) && $this->dataRecord['ssl_action'] == 'create') { |
|
622 |
if($this->dataRecord['ssl_state'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_state_empty').'<br />'; |
|
623 |
if($this->dataRecord['ssl_locality'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_locality_empty').'<br />'; |
|
624 |
if($this->dataRecord['ssl_organisation'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_organisation_empty').'<br />'; |
|
625 |
if($this->dataRecord['ssl_organisation_unit'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_organisation_unit_empty').'<br />'; |
|
626 |
if($this->dataRecord['ssl_country'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_country_empty').'<br />'; |
|
627 |
} |
7fe908
|
628 |
|
146783
|
629 |
if(isset($this->dataRecord['ssl_action']) && $this->dataRecord['ssl_action'] == 'save') { |
MC |
630 |
if(trim($this->dataRecord['ssl_cert']) == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_cert_empty').'<br />'; |
|
631 |
} |
|
632 |
|
|
633 |
} |
|
634 |
|
|
635 |
function onAfterUpdate() { |
|
636 |
global $app, $conf; |
eccd04
|
637 |
|
TB |
638 |
//* Update settings when parent domain gets changed |
|
639 |
if(isset($this->dataRecord["parent_domain_id"]) && $this->dataRecord["parent_domain_id"] != $this->oldDataRecord["parent_domain_id"]) { |
|
640 |
// Get configuration for the web system |
|
641 |
$app->uses("getconf"); |
|
642 |
$web_rec = $app->tform->getDataRecord($this->id); |
|
643 |
$web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]), 'web'); |
146783
|
644 |
|
eccd04
|
645 |
// Set the values for document_root, system_user and system_group |
TB |
646 |
$system_user = $app->db->quote($this->parent_domain_record['system_user']); |
|
647 |
$system_group = $app->db->quote($this->parent_domain_record['system_group']); |
|
648 |
$document_root = $app->db->quote($this->parent_domain_record['document_root']); |
|
649 |
$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$web_rec['web_folder'], $web_config["php_open_basedir"]); |
|
650 |
$php_open_basedir = str_replace("[website_domain]/web", $web_rec['domain'].'/'.$web_rec['web_folder'], $php_open_basedir); |
|
651 |
$php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir); |
|
652 |
$php_open_basedir = $app->db->quote(str_replace("[website_domain]", $web_rec['domain'], $php_open_basedir)); |
|
653 |
$htaccess_allow_override = $app->db->quote($this->parent_domain_record['allow_override']); |
146783
|
654 |
|
eccd04
|
655 |
$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir' WHERE domain_id = ".$this->id; |
TB |
656 |
$app->db->query($sql); |
|
657 |
} |
146783
|
658 |
} |
MC |
659 |
|
|
660 |
} |
|
661 |
|
|
662 |
$page = new page_action; |
|
663 |
$page->onLoad(); |
|
664 |
|
7fe908
|
665 |
?> |