Skip to content

Commit 4733cfe

Browse files
author
Marius Burkard
committed
- fixed IDN handling in vhost domain plugin, fixes #4685, #4738
1 parent 7829deb commit 4733cfe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,17 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
197197
}
198198

199199
//* If the domain name has been changed, we will have to change all subdomains + APS instances
200-
if(!empty($page_form->dataRecord["domain"]) && !empty($page_form->oldDataRecord["domain"]) && $page_form->dataRecord["domain"] != $page_form->oldDataRecord["domain"]) {
200+
if(!empty($page_form->dataRecord["domain"]) && !empty($page_form->oldDataRecord["domain"]) && $app->functions->idn_encode($page_form->dataRecord["domain"]) != $page_form->oldDataRecord["domain"]) {
201201
//* Change SSL Domain
202202
$tmp=$app->db->queryOneRecord("SELECT ssl_domain FROM web_domain WHERE domain_id = ?", $page_form->id);
203203
if($tmp['ssl_domain'] != '') {
204-
$plain=str_replace($page_form->oldDataRecord["domain"], $page_form->dataRecord["domain"], $tmp);
204+
$plain=str_replace($page_form->oldDataRecord["domain"], $app->functions->idn_encode($page_form->dataRecord["domain"]), $tmp);
205205
$app->db->query("UPDATE web_domain SET ssl_domain = ? WHERE domain_id = ?", $plain, $page_form->id);
206206
}
207207

208208
$records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE (type = 'subdomain' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND domain LIKE ?", "%." . $page_form->oldDataRecord["domain"]);
209209
foreach($records as $rec) {
210-
$subdomain = str_replace($page_form->oldDataRecord["domain"], $page_form->dataRecord["domain"], $rec['domain']);
210+
$subdomain = str_replace($page_form->oldDataRecord["domain"], $app->functions->idn_encode($page_form->dataRecord["domain"]), $rec['domain']);
211211
$app->db->datalogUpdate('web_domain', array("domain" => $subdomain), 'domain_id', $rec['domain_id']);
212212
}
213213
unset($records);
@@ -218,7 +218,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
218218
$records = $app->db->queryAllRecords("SELECT id, instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = ?", $page_form->oldDataRecord["domain"]);
219219
if(is_array($records) && !empty($records)){
220220
foreach($records as $rec){
221-
$app->db->datalogUpdate('aps_instances_settings', array("value" => $page_form->dataRecord["domain"]), 'id', $rec['id']);
221+
$app->db->datalogUpdate('aps_instances_settings', array("value" => $app->functions->idn_encode($page_form->dataRecord["domain"])), 'id', $rec['id']);
222222
}
223223
}
224224
unset($records);
@@ -233,7 +233,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
233233

234234
//* Set php_open_basedir if empty or domain or client has been changed
235235
if(empty($web_rec['php_open_basedir']) ||
236-
(!empty($page_form->dataRecord["domain"]) && !empty($page_form->oldDataRecord["domain"]) && $page_form->dataRecord["domain"] != $page_form->oldDataRecord["domain"])) {
236+
(!empty($page_form->dataRecord["domain"]) && !empty($page_form->oldDataRecord["domain"]) && $app->functions->idn_encode($page_form->dataRecord["domain"]) != $page_form->oldDataRecord["domain"])) {
237237
$php_open_basedir = $web_rec['php_open_basedir'];
238238
$php_open_basedir = str_replace($page_form->oldDataRecord['domain'], $web_rec['domain'], $php_open_basedir);
239239
$sql = "UPDATE web_domain SET php_open_basedir = ? WHERE domain_id = ?";
@@ -274,7 +274,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
274274
}
275275
} else {
276276
$php_open_basedir = str_replace("[website_path]", $document_root, $web_config["php_open_basedir"]);
277-
$php_open_basedir = str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir);
277+
$php_open_basedir = str_replace("[website_domain]", $app->functions->idn_encode($page_form->dataRecord['domain']), $php_open_basedir);
278278
$htaccess_allow_override = $web_config["htaccess_allow_override"];
279279

280280
$sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ?";
@@ -289,9 +289,9 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
289289
$system_group = $parent_domain['system_group'];
290290
$document_root = $parent_domain['document_root'];
291291
$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$page_form->dataRecord['web_folder'], $web_config["php_open_basedir"]);
292-
$php_open_basedir = str_replace("[website_domain]/web", $page_form->dataRecord['domain'].'/'.$page_form->dataRecord['web_folder'], $php_open_basedir);
292+
$php_open_basedir = str_replace("[website_domain]/web", $app->functions->idn_encode($page_form->dataRecord['domain']).'/'.$page_form->dataRecord['web_folder'], $php_open_basedir);
293293
$php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir);
294-
$php_open_basedir = str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir);
294+
$php_open_basedir = str_replace("[website_domain]", $app->functions->idn_encode($page_form->dataRecord['domain']), $php_open_basedir);
295295
$htaccess_allow_override = $parent_domain['allow_override'];
296296
$sql = "UPDATE web_domain SET sys_groupid = ?,system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ?";
297297
$app->db->query($sql, $parent_domain['sys_groupid'], $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $page_form->id);

0 commit comments

Comments
 (0)