Commit 92eeb89a authored by Till Brehm's avatar Till Brehm
Browse files

Fixes #5635 Reseller limits are not correctly enforced when using templates

parent a430c403
......@@ -44,3 +44,7 @@ ALTER TABLE `web_domain` DROP COLUMN `enable_spdy`;
-- was missing in incremental, inserted for fixing older installations
ALTER TABLE `web_domain` ADD `folder_directive_snippets` TEXT NULL AFTER `https_port`;
-- Fix issue #5635
ALTER TABLE `client_template` CHANGE `ssh_chroot` `ssh_chroot` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
ALTER TABLE `client_template` CHANGE `web_php_options` `web_php_options` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
......@@ -330,7 +330,7 @@ CREATE TABLE `client_template` (
`limit_web_ip` text,
`limit_web_domain` int(11) NOT NULL default '-1',
`limit_web_quota` int(11) NOT NULL default '-1',
`web_php_options` varchar(255) NOT NULL DEFAULT 'no',
`web_php_options` varchar(255) NOT NULL DEFAULT '',
`limit_cgi` enum('n','y') NOT NULL DEFAULT 'n',
`limit_ssi` enum('n','y') NOT NULL DEFAULT 'n',
`limit_perl` enum('n','y') NOT NULL DEFAULT 'n',
......@@ -345,7 +345,7 @@ CREATE TABLE `client_template` (
`limit_web_aliasdomain` int(11) NOT NULL default '-1',
`limit_ftp_user` int(11) NOT NULL default '-1',
`limit_shell_user` int(11) NOT NULL default '0',
`ssh_chroot` varchar(255) NOT NULL DEFAULT 'no',
`ssh_chroot` varchar(255) NOT NULL DEFAULT '',
`limit_webdav_user` int(11) NOT NULL default '0',
`limit_backup` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'y',
`limit_directive_snippets` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n',
......
......@@ -336,11 +336,11 @@ class tform_base {
}
//* If the parameter 'valuelimit' is set
function applyValueLimit($limit, $values, $current_value = '') {
function applyValueLimit($formtype, $limit, $values, $current_value = '') {
global $app;
// we mas have multiple limits, therefore we explode by ; first
// we may have multiple limits, therefore we explode by ; first
// Example: "system:sites:web_php_options;client:web_php_options"
$limits = explode(';',$limit);
......@@ -399,18 +399,31 @@ class tform_base {
$tmp_key = $limit_parts[2];
$allowed = $allowed = explode(',',$tmp_conf[$tmp_key]);
}
if($formtype == 'CHECKBOX') {
if(strstr($limit,'force_')) {
// Force the checkbox field to be ticked and enabled
if($allowed[0] == $values[1]) {
$values = 'on';
}
} else {
// Force the checkbox field to be unchecked and disabled
if($allowed[0] == $values[0]) {
$values = 'off';
}
}
} else {
// add the current value to the allowed array
$allowed[] = $current_value;
// add the current value to the allowed array
$allowed[] = $current_value;
// remove all values that are not allowed
$values_new = array();
foreach($values as $key => $val) {
if(in_array($key, $allowed)) $values_new[$key] = $val;
// remove all values that are not allowed
$values_new = array();
foreach($values as $key => $val) {
if(in_array($key, $allowed)) $values_new[$key] = $val;
}
$values = $values_new;
}
$values = $values_new;
}
return $values;
......@@ -479,7 +492,7 @@ class tform_base {
// If a limitation for the values is set
if(isset($field['valuelimit']) && is_array($field["value"])) {
$field["value"] = $this->applyValueLimit($field['valuelimit'], $field["value"], $val);
$field["value"] = $this->applyValueLimit($field['formtype'], $field['valuelimit'], $field["value"], $val);
}
switch ($field['formtype']) {
......@@ -521,8 +534,14 @@ class tform_base {
break;
case 'CHECKBOX':
$checked = ($val == $field['value'][1])?' CHECKED':'';
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" $checked />\r\n";
if($field["value"] == 'off') {
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" disabled=\"disabled\" />\r\n";
} elseif ($field["value"] == 'on') {
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" disabled=\"disabled\" CHECKED />\r\n";
} else {
$checked = ($val == $field['value'][1])?' CHECKED':'';
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" $checked />\r\n";
}
break;
case 'CHECKBOXARRAY':
......@@ -614,7 +633,7 @@ class tform_base {
// If a limitation for the values is set
if(isset($field['valuelimit']) && is_array($field["value"])) {
$field["value"] = $this->applyValueLimit($field['valuelimit'], $field["value"], $field['default']);
$field["value"] = $this->applyValueLimit($field['formtype'], $field['valuelimit'], $field["value"], $field['default']);
}
switch ($field['formtype']) {
......@@ -651,9 +670,15 @@ class tform_base {
break;
case 'CHECKBOX':
// $checked = (empty($field["default"]))?'':' CHECKED';
$checked = ($field["default"] == $field['value'][1])?' CHECKED':'';
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" $checked />\r\n";
if($field["value"] == 'off') {
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" disabled=\"disabled\" />\r\n";
} elseif ($field["value"] == 'on') {
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" disabled=\"disabled\" CHECKED />\r\n";
} else {
// $checked = (empty($field["default"]))?'':' CHECKED';
$checked = ($field["default"] == $field['value'][1])?' CHECKED':'';
$new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" $checked />\r\n";
}
break;
case 'CHECKBOXARRAY':
......
......@@ -985,42 +985,49 @@ $form["tabs"]['limits'] = array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_muc',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_anon' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_anon',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_vjud' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_vjud',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_proxy' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_proxy',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_status' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_status',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_pastebin' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_pastebin',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_httparchive' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_httparchive',
'value' => array(0 => 'n', 1 => 'y')
),
'default_webserver' => array (
......@@ -1087,67 +1094,77 @@ $form["tabs"]['limits'] = array (
),
'default' => '',
'separator' => ',',
'valuelimit' => 'system:sites:web_php_options',
'valuelimit' => 'system:sites:web_php_options;client:web_php_options',
'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM', 'hhvm' => 'HHVM')
),
'limit_cgi' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_cgi',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ssi' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ssi',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_perl' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_perl',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ruby' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ruby',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_python' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_python',
'value' => array(0 => 'n', 1 => 'y')
),
'force_suexec' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'valuelimit' => 'client:force_suexec',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_hterror' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_hterror',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_wildcard' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_wildcard',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ssl' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ssl',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ssl_letsencrypt' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ssl_letsencrypt',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_web_aliasdomain' => array (
......@@ -1235,12 +1252,14 @@ $form["tabs"]['limits'] = array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'valuelimit' => 'client:limit_backup',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_directive_snippets' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_directive_snippets',
'value' => array(0 => 'n', 1 => 'y')
),
'default_dnsserver' => array (
......
......@@ -401,42 +401,49 @@ $form["tabs"]['limits'] = array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_muc',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_anon' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_anon',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_vjud' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_vjud',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_proxy' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_proxy',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_status' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_status',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_pastebin' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_pastebin',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_xmpp_httparchive' => array(
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_xmpp_httparchive',
'value' => array(0 => 'n', 1 => 'y')
),/*
'default_webserver' => array (
......@@ -495,67 +502,77 @@ $form["tabs"]['limits'] = array (
'formtype' => 'CHECKBOXARRAY',
'default' => '',
'separator' => ',',
'valuelimit' => 'system:sites:web_php_options',
'valuelimit' => 'system:sites:web_php_options;client:web_php_options',
'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM', 'hhvm' => 'HHVM')
),
'limit_cgi' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_cgi',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ssi' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ssi',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_perl' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_perl',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ruby' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ruby',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_python' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_python',
'value' => array(0 => 'n', 1 => 'y')
),
'force_suexec' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'valuelimit' => 'client:force_suexec',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_hterror' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_hterror',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_wildcard' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_wildcard',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ssl' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ssl',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_ssl_letsencrypt' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_ssl_letsencrypt',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_web_aliasdomain' => array (
......@@ -646,12 +663,14 @@ $form["tabs"]['limits'] = array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'valuelimit' => 'client:limit_backup',
'value' => array(0 => 'n', 1 => 'y')
),
'limit_directive_snippets' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'valuelimit' => 'client:limit_directive_snippets',
'value' => array(0 => 'n', 1 => 'y')
),/*
'default_dnsserver' => array (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment