Skip to content

Commit 6f11f6d

Browse files
author
thom
committed
Make client protection configurable (#4048)
1 parent e7db797 commit 6f11f6d

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ 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+
$app->db->query("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'riud' WHERE domain_id = ?", $client_group_id, $this->id);
60+
}
5561
}
5662
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) {
5763
$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
@@ -62,7 +68,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
6268
$web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web');
6369
if(isset($app->tform) && is_object($app->tform)) $web_rec = $app->tform->getDataRecord($page_form->id);
6470
else $web_rec = $app->remoting_lib->getDataRecord($page_form->id);
65-
71+
6672
if($vhostdomain_type == 'domain') {
6773
$document_root = str_replace("[website_id]", $page_form->id, $web_config["website_path"]);
6874
$document_root = str_replace("[website_idhash_1]", $this->id_hash($page_form->id, 1), $document_root);
@@ -97,7 +103,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
97103
$document_root = str_replace("[client_idhash_2]", $this->id_hash($client_id, 2), $document_root);
98104
$document_root = str_replace("[client_idhash_3]", $this->id_hash($client_id, 3), $document_root);
99105
$document_root = str_replace("[client_idhash_4]", $this->id_hash($client_id, 4), $document_root);
100-
106+
101107
if($event_name == 'sites:web_vhost_domain:on_after_update') {
102108
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"]) {
103109

@@ -280,7 +286,7 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
280286
$php_open_basedir = str_replace("[website_path]", $document_root, $web_config["php_open_basedir"]);
281287
$php_open_basedir = str_replace("[website_domain]", $app->functions->idn_encode($page_form->dataRecord['domain']), $php_open_basedir);
282288
$htaccess_allow_override = $web_config["htaccess_allow_override"];
283-
289+
284290
$sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ?";
285291
$app->db->query($sql, $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $page_form->id);
286292
}

interface/lib/plugins/vm_openvz_plugin.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function openvz_vm_insert($event_name, $page_form) {
3838
$this->oldDataRecord = $page_form->oldDataRecord;
3939

4040
// make sure that the record belongs to the clinet group and not the admin group when admin inserts it
41-
// also make sure that the user can not delete domain created by a admin
41+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
4242
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
4343
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
4444
$app->db->query("UPDATE openvz_vm SET sys_groupid = ? WHERE vm_id = ?", $client_group_id, $this->id);
@@ -87,7 +87,7 @@ function openvz_vm_update($event_name, $page_form) {
8787
$this->oldDataRecord = $page_form->oldDataRecord;
8888

8989
// make sure that the record belongs to the clinet group and not the admin group when a admin inserts it
90-
// also make sure that the user can not delete domain created by a admin
90+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
9191
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
9292
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
9393
$app->db->query("UPDATE openvz_vm SET sys_groupid = ? WHERE vm_id = ?", $client_group_id, $this->id);

interface/web/client/domain_edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function onAfterInsert() {
197197
global $app, $conf;
198198

199199
// make sure that the record belongs to the client group and not the admin group when admin inserts it
200-
// also make sure that the user can not delete domain created by a admin
200+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
201201
if(($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) || ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid']))) {
202202
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
203203
$app->db->query("UPDATE domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $this->id);
@@ -215,7 +215,7 @@ function onAfterUpdate() {
215215
}
216216

217217
// make sure that the record belongs to the client group and not the admin group when admin inserts it
218-
// also make sure that the user can not delete domain created by a admin
218+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
219219
if(isset($this->dataRecord["client_group_id"])) {
220220
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
221221
$app->db->query("UPDATE domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $this->id);

interface/web/mail/mail_mailinglist_edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function onAfterInsert() {
198198
global $app, $conf;
199199

200200
// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
201-
// also make sure that the user can not delete domain created by a admin
201+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
202202
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
203203
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
204204
$app->db->query("UPDATE mail_mailinglist SET sys_groupid = ?, sys_perm_group = 'ru' WHERE mailinglist_id = ?", $client_group_id, $this->id);
@@ -235,7 +235,7 @@ function onAfterUpdate() {
235235
global $app, $conf;
236236

237237
// make sure that the record belongs to the clinet group and not the admin group when admin inserts it
238-
// also make sure that the user can not delete domain created by a admin
238+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
239239
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
240240
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
241241
$app->db->query("UPDATE mail_mailinglist SET sys_groupid = ?, sys_perm_group = 'ru' WHERE mailinglist_id = ?", $client_group_id, $this->id);

interface/web/mail/xmpp_domain_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function onAfterInsert() {
318318
global $app, $conf;
319319

320320
// make sure that the record belongs to the client group and not the admin group when admin inserts it
321-
// also make sure that the user can not delete domain created by a admin
321+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
322322
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
323323
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
324324
$app->db->query("UPDATE xmpp_domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $this->id);

interface/web/sites/web_vhost_domain_edit.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,14 +1377,14 @@ function onAfterInsert() {
13771377
global $app, $conf;
13781378

13791379
// make sure that the record belongs to the client group and not the admin group when admin inserts it
1380-
// also make sure that the user can not delete domain created by a admin
1380+
// also make sure that the user can not delete domain created by a admin if client protection is enabled
13811381
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
13821382
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
13831383
$app->uses('getconf');
1384-
$global_config = $app->getconf->get_global_config('global');
1384+
$global_config = $app->getconf->get_global_config('sites');
13851385
if($global_config['client_protection'] == 'y') {
13861386
$app->db->query("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $this->id);
1387-
else
1387+
} else {
13881388
$app->db->query("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'riud' WHERE domain_id = ?", $client_group_id, $this->id);
13891389
}
13901390
}

0 commit comments

Comments
 (0)