Skip to content

Commit e23c47d

Browse files
author
Till Brehm
committed
FS#3635 - Adding Shell Users with remote API is broken in 3.0.5.4p3
FS#3632 - Adding websites with remote API is broken in 3.0.5.4p3 release. Missed to commit one file for: FS#3634 - Add option to disable statistics for a website
1 parent b54d416 commit e23c47d

File tree

8 files changed

+73
-33
lines changed

8 files changed

+73
-33
lines changed

interface/lib/classes/validate_ftpuser.inc.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ class validate_ftpuser {
3636
function ftp_dir($field_name, $field_value, $validator) {
3737
global $app;
3838

39-
if($app->tform->primary_id == 0) {
39+
$primary_id = (isset($app->tform->primary_id) && $app->tform->primary_id > 0)?$app->tform->primary_id:$app->remoting_lib->primary_id;
40+
$primary_id = $app->functions->intval($primary_id);
41+
42+
if($primary_id == 0 && !isset($app->remoting_lib->dataRecord['parent_domain_id'])) {
4043
$errmsg = $validator['errmsg'];
4144
if(isset($app->tform->wordbook[$errmsg])) {
4245
return $app->tform->wordbook[$errmsg]."<br>\r\n";
@@ -45,18 +48,25 @@ function ftp_dir($field_name, $field_value, $validator) {
4548
}
4649
}
4750

48-
49-
$ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = '".$app->db->quote($app->tform->primary_id)."'");
50-
if(!is_array($ftp_data) || $ftp_data["parent_domain_id"] < 1) {
51-
$errmsg = $validator['errmsg'];
52-
if(isset($app->tform->wordbook[$errmsg])) {
53-
return $app->tform->wordbook[$errmsg]."<br>\r\n";
51+
if($primary_id > 0) {
52+
//* get parent_domain_id from website
53+
$ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = '".$app->db->quote($primary_id)."'");
54+
if(!is_array($ftp_data) || $ftp_data["parent_domain_id"] < 1) {
55+
$errmsg = $validator['errmsg'];
56+
if(isset($app->tform->wordbook[$errmsg])) {
57+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
58+
} else {
59+
return $errmsg."<br>\r\n";
60+
}
5461
} else {
55-
return $errmsg."<br>\r\n";
62+
$parent_domain_id = $ftp_data["parent_domain_id"];
5663
}
64+
} else {
65+
//* get parent_domain_id from dataRecord when we have a insert operation trough remote API
66+
$parent_domain_id = $app->functions->intval($app->remoting_lib->dataRecord['parent_domain_id']);
5767
}
5868

59-
$domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($ftp_data["parent_domain_id"])."'");
69+
$domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($parent_domain_id)."'");
6070
if(!is_array($domain_data) || $domain_data["domain_id"] < 1) {
6171
$errmsg = $validator['errmsg'];
6272
if(isset($app->tform->wordbook[$errmsg])) {

interface/lib/classes/validate_systemuser.inc.php

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,32 @@
2929
*/
3030

3131
class validate_systemuser {
32+
33+
function get_error($errmsg) {
34+
global $app;
35+
36+
if(isset($app->tform->wordbook[$errmsg])) {
37+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
38+
} else {
39+
return $errmsg."<br>\r\n";
40+
}
41+
}
3242

3343
/*
3444
Validator function to check if a given user is ok.
3545
*/
3646
function check_sysuser($field_name, $field_value, $validator) {
3747
global $app;
3848

49+
//* Skip Test if we have the placeholder input of the remote APi for the web_domain system_user field here.
50+
if($field_name == 'system_user' && $field_value == '-') return '';
51+
52+
//* Check the input
3953
$errmsg = $validator['errmsg'];
4054
$check_names = (isset($validator['check_names']) && $validator['check_names'] == true)?true:false;
4155

4256
if($app->functions->is_allowed_user(trim(strtolower($field_value)),$check_names) == false) {
43-
return $app->tform->wordbook[$errmsg]."<br>\r\n";
57+
return $this->get_error($errmsg);
4458
}
4559
}
4660

@@ -50,11 +64,14 @@ function check_sysuser($field_name, $field_value, $validator) {
5064
function check_sysgroup($field_name, $field_value, $validator) {
5165
global $app;
5266

67+
//* Skip Test if we have the placeholder input of the remote APi for the web_domain system_group field here.
68+
if($field_name == 'system_group' && $field_value == '-') return '';
69+
5370
$errmsg = $validator['errmsg'];
5471
$check_names = (isset($validator['check_names']) && $validator['check_names'] == true)?true:false;
5572

5673
if($app->functions->is_allowed_group(trim(strtolower($field_value)),$check_names) == false) {
57-
return $app->tform->wordbook[$errmsg]."<br>\r\n";
74+
return $this->get_error($errmsg);
5875
}
5976
}
6077

@@ -63,8 +80,11 @@ function check_sysgroup($field_name, $field_value, $validator) {
6380
*/
6481
function shelluser_dir($field_name, $field_value, $validator) {
6582
global $app;
66-
67-
if($app->tform->primary_id == 0) {
83+
84+
$primary_id = (isset($app->tform->primary_id) && $app->tform->primary_id > 0)?$app->tform->primary_id:$app->remoting_lib->primary_id;
85+
$primary_id = $app->functions->intval($primary_id);
86+
87+
if($primary_id == 0 && !isset($app->remoting_lib->dataRecord['parent_domain_id'])) {
6888
$errmsg = $validator['errmsg'];
6989
if(isset($app->tform->wordbook[$errmsg])) {
7090
return $app->tform->wordbook[$errmsg]."<br>\r\n";
@@ -73,18 +93,25 @@ function shelluser_dir($field_name, $field_value, $validator) {
7393
}
7494
}
7595

76-
77-
$shell_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM shell_user WHERE shell_user_id = '".$app->db->quote($app->tform->primary_id)."'");
78-
if(!is_array($shell_data) || $shell_data["parent_domain_id"] < 1) {
79-
$errmsg = $validator['errmsg'];
80-
if(isset($app->tform->wordbook[$errmsg])) {
81-
return $app->tform->wordbook[$errmsg]."<br>\r\n";
96+
if($primary_id > 0) {
97+
//* get parent_domain_id from website
98+
$shell_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM shell_user WHERE shell_user_id = '".$app->db->quote($primary_id)."'");
99+
if(!is_array($shell_data) || $shell_data["parent_domain_id"] < 1) {
100+
$errmsg = $validator['errmsg'];
101+
if(isset($app->tform->wordbook[$errmsg])) {
102+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
103+
} else {
104+
return $errmsg."<br>\r\n";
105+
}
82106
} else {
83-
return $errmsg."<br>\r\n";
107+
$parent_domain_id = $shell_data["parent_domain_id"];
84108
}
109+
} else {
110+
//* get parent_domain_id from dataRecord when we have a insert operation trough remote API
111+
$parent_domain_id = $app->functions->intval($app->remoting_lib->dataRecord['parent_domain_id']);
85112
}
86113

87-
$domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($shell_data["parent_domain_id"])."'");
114+
$domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($parent_domain_id)."'");
88115
if(!is_array($domain_data) || $domain_data["domain_id"] < 1) {
89116
$errmsg = $validator['errmsg'];
90117
if(isset($app->tform->wordbook[$errmsg])) {
@@ -116,5 +143,4 @@ function shelluser_dir($field_name, $field_value, $validator) {
116143
}
117144
}
118145

119-
120146
}

interface/web/sites/form/ftp_user.tform.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@
205205
1 => array ( 'type' => 'REGEX',
206206
'regex' => '/^\/[a-zA-Z0-9\ \.\-\_\/]{10,128}$/',
207207
'errmsg'=> 'directory_error_regex'),
208+
2 => array ( 'type' => 'CUSTOM',
209+
'class' => 'validate_ftpuser',
210+
'function' => 'ftp_dir',
211+
'errmsg' => 'directory_error_notinweb'),
208212
),
209213
'default' => '',
210214
'value' => '',

interface/web/sites/form/web_vhost_subdomain.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@
486486
'datatype' => 'VARCHAR',
487487
'formtype' => 'SELECT',
488488
'default' => 'webalizer',
489-
'value' => array('webalizer' => 'Webalizer', 'awstats' => 'AWStats')
489+
'value' => array('webalizer' => 'Webalizer', 'awstats' => 'AWStats', '' => 'None')
490490
),
491491
//#################################
492492
// ENDE Datatable fields

remoting_client/examples/sites_ftp_user_add.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
$params = array(
2121
'server_id' => 1,
2222
'parent_domain_id' => 1,
23-
'username' => 'threep',
24-
'password' => 'wood',
23+
'username' => 'tom',
24+
'password' => 'secret',
2525
'quota_size' => 10000,
2626
'active' => 'y',
2727
'uid' => '5000',
2828
'gid' => '5000',
29-
'dir' => 'maybe',
29+
'dir' => '/var/www/clients/client0/web1',
3030
'quota_files' => -1,
3131
'ul_ratio' => -1,
3232
'dl_ratio' => -1,

remoting_client/examples/sites_ftp_user_update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616

1717
//* Parameters
18-
$client_id = 1;
18+
$client_id = 0;
1919
$ftp_user_id = 1;
2020

2121

remoting_client/examples/sites_shell_user_add.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
$params = array(
2121
'server_id' => 1,
2222
'parent_domain_id' => 1,
23-
'username' => 'threep2',
24-
'password' => 'wood',
23+
'username' => 'tom',
24+
'password' => 'test',
2525
'quota_size' => 10000,
2626
'active' => 'y',
27-
'puser' => 'null',
28-
'pgroup' => 'null',
27+
'puser' => 'web1',
28+
'pgroup' => 'client0',
2929
'shell' => '/bin/bash',
30-
'dir' => 'maybe',
30+
'dir' => '/var/www/clients/client0/web1',
3131
'chroot' => ''
3232
);
3333

remoting_client/examples/sites_shell_user_update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616

1717
//* Parameters
18-
$client_id = 3;
18+
$client_id = 0;
1919
$shell_user_id = 1;
2020

2121

0 commit comments

Comments
 (0)