Skip to content

Commit 48b9c11

Browse files
author
Till Brehm
committed
Merge branch '4048-client-protection' into 'stable-3.1'
Add ui setting for client protection mode Closes #4048 See merge request ispconfig/ispconfig3!1088
2 parents 7aaaaa1 + 9097813 commit 48b9c11

32 files changed

+80
-20
lines changed

install/tpl/system.ini.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ backups_include_into_web_quota=n
3636
reseller_can_use_options=n
3737
web_php_options=no,fast-cgi,mod,php-fpm
3838
show_aps_menu=n
39+
client_protection=y
3940

4041

4142
[tools]

interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,20 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
4646
$vhostdomain_type = 'domain';
4747
if($page_form->dataRecord['type'] == 'vhostalias') $vhostdomain_type = 'aliasdomain';
4848
elseif($page_form->dataRecord['type'] == 'vhostsubdomain') $vhostdomain_type = 'subdomain';
49-
50-
// make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it
51-
// also make sure that the user can not delete domain created by a admin
49+
50+
// make sure that the record belongs to the client group and not the admin group when a admin inserts it
51+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
5252
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) {
5353
$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
54-
$app->db->query("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $page_form->id);
54+
$app->uses('getconf');
55+
$global_config = $app->getconf->get_global_config('sites');
56+
if($global_config['client_protection'] == 'y') {
57+
$app->db->query("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $this->id);
58+
} else {
59+
$sysuser = $app->db->queryOneRecord('SELECT userid FROM sys_user WHERE default_group = ?',$client_group_id);
60+
$sysuser_id = (is_array($sysuser) && isset($sysuser['userid']) && $sysuser['userid'] > 0)?$sysuser['userid']:1;
61+
$app->db->query("UPDATE web_domain SET sys_userid = ?, sys_groupid = ?, sys_perm_group = 'riud' WHERE domain_id = ?", $sysuser_id, $client_group_id, $this->id);
62+
}
5563
}
5664
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) {
5765
$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
@@ -62,7 +70,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
6270
$web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web');
6371
if(isset($app->tform) && is_object($app->tform)) $web_rec = $app->tform->getDataRecord($page_form->id);
6472
else $web_rec = $app->remoting_lib->getDataRecord($page_form->id);
65-
73+
6674
if($vhostdomain_type == 'domain') {
6775
$document_root = str_replace("[website_id]", $page_form->id, $web_config["website_path"]);
6876
$document_root = str_replace("[website_idhash_1]", $this->id_hash($page_form->id, 1), $document_root);
@@ -97,7 +105,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
97105
$document_root = str_replace("[client_idhash_2]", $this->id_hash($client_id, 2), $document_root);
98106
$document_root = str_replace("[client_idhash_3]", $this->id_hash($client_id, 3), $document_root);
99107
$document_root = str_replace("[client_idhash_4]", $this->id_hash($client_id, 4), $document_root);
100-
108+
101109
if($event_name == 'sites:web_vhost_domain:on_after_update') {
102110
if(($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) && isset($page_form->dataRecord["client_group_id"]) && $page_form->dataRecord["client_group_id"] != $page_form->oldDataRecord["sys_groupid"]) {
103111

@@ -280,7 +288,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
280288
$php_open_basedir = str_replace("[website_path]", $document_root, $web_config["php_open_basedir"]);
281289
$php_open_basedir = str_replace("[website_domain]", $app->functions->idn_encode($page_form->dataRecord['domain']), $php_open_basedir);
282290
$htaccess_allow_override = $web_config["htaccess_allow_override"];
283-
291+
284292
$sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ?";
285293
$app->db->query($sql, $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $page_form->id);
286294
}

interface/web/admin/form/system_config.tform.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@
148148
'width' => '30',
149149
'maxlength' => '255'
150150
),
151+
'client_protection' => array (
152+
'datatype' => 'VARCHAR',
153+
'formtype' => 'CHECKBOX',
154+
'default' => 'y',
155+
'value' => array(0 => 'n', 1 => 'y')
156+
),
151157
'vhost_subdomains' => array (
152158
'datatype' => 'VARCHAR',
153159
'formtype' => 'CHECKBOX',
@@ -795,4 +801,3 @@
795801
)
796802
)
797803
);
798-

interface/web/admin/lib/lang/ar_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ $wb['active_txt'] = 'Aktive';
9595
$wb['btn_save_txt'] = 'Save';
9696
$wb['btn_cancel_txt'] = 'Cancel';
9797
$wb['web_php_options_txt'] = 'PHP Handler (Apache only)';
98+
$wb['client_protection_txt'] = 'Client protection';
9899
?>

interface/web/admin/lib/lang/bg_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ $wb['active_txt'] = 'Aktive';
9595
$wb['btn_save_txt'] = 'Save';
9696
$wb['btn_cancel_txt'] = 'Cancel';
9797
$wb['web_php_options_txt'] = 'PHP Handler (Apache only)';
98+
$wb['client_protection_txt'] = 'Client protection';
9899
?>

interface/web/admin/lib/lang/br_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,5 @@ $wb['active_txt'] = 'Ativo';
9494
$wb['btn_save_txt'] = 'Salvar';
9595
$wb['btn_cancel_txt'] = 'Cancelar';
9696
$wb['web_php_options_txt'] = 'Manipulador do php (Somente apache)';
97+
$wb['client_protection_txt'] = 'Client protection';
9798
?>

interface/web/admin/lib/lang/ca_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ $wb['active_txt'] = 'Aktive';
9595
$wb['btn_save_txt'] = 'Save';
9696
$wb['btn_cancel_txt'] = 'Cancel';
9797
$wb['web_php_options_txt'] = 'PHP Handler (Apache only)';
98+
$wb['client_protection_txt'] = 'Client protection';
9899
?>

interface/web/admin/lib/lang/cz_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ $wb['active_txt'] = 'Aktivní';
9595
$wb['btn_save_txt'] = 'Uložit';
9696
$wb['btn_cancel_txt'] = 'Zrušit';
9797
$wb['web_php_options_txt'] = 'PHP Handler (Apache only)';
98+
$wb['client_protection_txt'] = 'Client protection';
9899
?>

interface/web/admin/lib/lang/de_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@ $wb['active_txt'] = 'Aktiv';
9999
$wb['btn_save_txt'] = 'Speichern';
100100
$wb['btn_cancel_txt'] = 'Abbrechen';
101101
$wb['web_php_options_txt'] = 'PHP Handler (Nur Apache)';
102+
$wb['client_protection_txt'] = 'Client protection';
102103
?>

interface/web/admin/lib/lang/dk_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ $wb['active_txt'] = 'Aktive';
9595
$wb['btn_save_txt'] = 'Save';
9696
$wb['btn_cancel_txt'] = 'Cancel';
9797
$wb['web_php_options_txt'] = 'PHP Handler (Apache only)';
98+
$wb['client_protection_txt'] = 'Client protection';
9899
?>

0 commit comments

Comments
 (0)