diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 2d2920ecd14b5ef421a01dce4280a14480b23182..6aba152b8835e8613ad7079c260e391e6498754e 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -459,6 +459,73 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'default_webserver' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'value' => '' + ), + 'limit_web_domain' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_web_domain_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_web_aliasdomain' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_web_aliasdomain_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_web_subdomain' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_web_subdomain_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_ftp_user' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_ftp_user_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), ################################## # END Datatable fields ################################## diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng index 39cd44b543fd1dc9e47844c3a48a62d46a5af9f9..90472f60c65faa77511124e7c3c63951fd1adff4 100644 --- a/interface/web/client/lib/lang/en_client.lng +++ b/interface/web/client/lib/lang/en_client.lng @@ -45,4 +45,10 @@ $wb["ip_address_txt"] = 'ip_address'; $wb["limit_client_error_notint"] = 'Client Limit is not a number.'; $wb["firstname_error_empty"] = 'Firstname is empty.'; $wb["contact_error_empty"] = 'Contact name is empty.'; +$wb["default_webserver_txt"] = 'Default Webserver'; +$wb["limit_web_domain_txt"] = 'Max. number of web domains'; +$wb["limit_web_aliasdomain_txt"] = 'Max. number of web aliasdomains'; +$wb["limit_web_subdomain_txt"] = 'Max. number of web subdomains'; +$wb["limit_ftp_user_txt"] = 'Max. number of FTP users'; + ?> \ No newline at end of file diff --git a/interface/web/client/templates/client_edit_limits.htm b/interface/web/client/templates/client_edit_limits.htm index be92c42ec400dea7a9ecdbda0519294024727562..979e9d951cae30ce64e719e1b3f3a1898d0e2ca4 100644 --- a/interface/web/client/templates/client_edit_limits.htm +++ b/interface/web/client/templates/client_edit_limits.htm @@ -63,6 +63,33 @@ {tmpl_var name='limit_spamfilter_policy_txt'}: + +

Websites

+ + + {tmpl_var name='default_webserver_txt'}: + + + + + + {tmpl_var name='limit_web_domain_txt'}: + + + + {tmpl_var name='limit_web_subdomain_txt'}: + + + + {tmpl_var name='limit_web_aliasdomain_txt'}: + + + + {tmpl_var name='limit_ftp_user_txt'}: + +     diff --git a/interface/web/sites/ftp_user_edit.php b/interface/web/sites/ftp_user_edit.php index 4c90855b4c5413f0220148091ee4e4780dce51c1..2c704b67c8c07938a2a3858c78ba56dba33ad926 100644 --- a/interface/web/sites/ftp_user_edit.php +++ b/interface/web/sites/ftp_user_edit.php @@ -53,6 +53,27 @@ $app->load('tform_actions'); class page_action extends tform_actions { + function onShowNew() { + global $app, $conf; + + // we will check only users, not admins + if($_SESSION["s"]["user"]["typ"] == 'user') { + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT limit_ftp_user FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + // Check if the user may add another maildomain. + if($client["limit_ftp_user"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(ftp_user_id) as number FROM ftp_user WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_ftp_user"]) { + $app->error($app->tform->wordbook["limit_ftp_user_txt"]); + } + } + } + + parent::onShowNew(); + } function onAfterInsert() { global $app, $conf; diff --git a/interface/web/sites/lib/lang/en_ftp_user.lng b/interface/web/sites/lib/lang/en_ftp_user.lng index 45fb750908bfdbc383a124dc5b4929b1550296ce..ba63a9ab89b7c7812de4fe2ecc3f9f96b4bce8f7 100644 --- a/interface/web/sites/lib/lang/en_ftp_user.lng +++ b/interface/web/sites/lib/lang/en_ftp_user.lng @@ -15,4 +15,5 @@ $wb["username_txt"] = 'Username'; $wb["password_txt"] = 'Password'; $wb["quota_size_txt"] = 'Harddisk-Quota'; $wb["active_txt"] = 'Active'; +$wb["limit_ftp_user_txt"] = 'The max. number of FTP users for your account is reached.'; ?> \ No newline at end of file diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng index 38e0510f40c8e1d3f12a2d458b5276351435cc13..bdb41e26c8b4b7b89bc0687f74b6ecfdf0c7aa2d 100644 --- a/interface/web/sites/lib/lang/en_web_domain.lng +++ b/interface/web/sites/lib/lang/en_web_domain.lng @@ -1,23 +1,26 @@ - \ No newline at end of file diff --git a/interface/web/sites/web_aliasdomain_edit.php b/interface/web/sites/web_aliasdomain_edit.php index e7cef105329f1ee87706e8def7733285bf9dcab6..67e7421f1d82f99261e51c334c75909887b1df19 100644 --- a/interface/web/sites/web_aliasdomain_edit.php +++ b/interface/web/sites/web_aliasdomain_edit.php @@ -53,6 +53,28 @@ $app->load('tform_actions'); class page_action extends tform_actions { + function onShowNew() { + global $app, $conf; + + // we will check only users, not admins + if($_SESSION["s"]["user"]["typ"] == 'user') { + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT limit_web_aliasdomain FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + // Check if the user may add another maildomain. + if($client["limit_web_aliasdomain"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'alias'"); + if($tmp["number"] >= $client["limit_web_aliasdomain"]) { + $app->error($app->tform->wordbook["limit_web_aliasdomain_txt"]); + } + } + } + + parent::onShowNew(); + } + /* function onShowEnd() { global $app, $conf; diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index 5f208dbafc2d202182bd7f659c7c8cdf493b92f0..f925bd2a2604397813dfd688296ca85e77c18e99 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -53,6 +53,28 @@ $app->load('tform_actions'); class page_action extends tform_actions { + function onShowNew() { + global $app, $conf; + + // we will check only users, not admins + if($_SESSION["s"]["user"]["typ"] == 'user') { + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT limit_web_domain FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + // Check if the user may add another maildomain. + if($client["limit_web_domain"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'vhost'"); + if($tmp["number"] >= $client["limit_web_domain"]) { + $app->error($app->tform->wordbook["limit_web_domain_txt"]); + } + } + } + + parent::onShowNew(); + } + function onShowEnd() { global $app, $conf; @@ -123,7 +145,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] != 'admin') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT limit_maildomain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT limit_web_domain, default_webserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); // When the record is updated if($this->id > 0) { @@ -136,15 +158,15 @@ class page_action extends tform_actions { // set the server ID to the default mailserver of the client $this->dataRecord["server_id"] = $client["default_webserver"]; - /* - // Check if the user may add another mail_domain - if($client["limit_maildomain"] >= 0) { - $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE sys_groupid = $client_group_id"); - if($tmp["number"] >= $client["limit_maildomain"]) { - $app->error($app->tform->wordbook["limit_webdomain_txt"]); + + // Check if the user may add another web_domain + if($client["limit_web_domain"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'vhost'"); + if($tmp["number"] >= $client["limit_web_domain"]) { + $app->error($app->tform->wordbook["limit_web_domain_txt"]); } } - */ + } // Clients may not set the client_group_id, so we unset them if user is not a admin diff --git a/interface/web/sites/web_subdomain_edit.php b/interface/web/sites/web_subdomain_edit.php index e2aaca9e21798ae41eb31735ed711633d1940d08..0fb1cfe663dad9493d971893f866fa6567b55f0e 100644 --- a/interface/web/sites/web_subdomain_edit.php +++ b/interface/web/sites/web_subdomain_edit.php @@ -53,12 +53,35 @@ $app->load('tform_actions'); class page_action extends tform_actions { + function onShowNew() { + global $app, $conf; + + // we will check only users, not admins + if($_SESSION["s"]["user"]["typ"] == 'user') { + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT limit_web_subdomain FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + // Check if the user may add another maildomain. + if($client["limit_web_subdomain"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'subdomain'"); + if($tmp["number"] >= $client["limit_web_subdomain"]) { + $app->error($app->tform->wordbook["limit_web_subdomain_txt"]); + } + } + } + + parent::onShowNew(); + } + function onShowEnd() { global $app, $conf; // Get the record of the parent domain $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"])); + // remove the parent domain part of the domain name before we show it in the text field. $this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"],'',$this->dataRecord["domain"]); $app->tpl->setVar("domain",$this->dataRecord["domain"]); diff --git a/server/plugins-enabled/apache2_plugin.inc.php b/server/plugins-enabled/apache2_plugin.inc.php index 178ba044c3daab0eb6ab50636f046ff58aea6268..9b334678ba586c3c68e598ed90449719572bfbd6 100644 --- a/server/plugins-enabled/apache2_plugin.inc.php +++ b/server/plugins-enabled/apache2_plugin.inc.php @@ -68,7 +68,7 @@ class apache2_plugin { if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) { // This is not a vhost, so we need to update the parent record instead. $parent_domain_id = intval($data["new"]["parent_domain_id"]); - $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id." AND active = 'y'"); $data["new"] = $tmp; $data["old"] = $tmp; } @@ -150,7 +150,7 @@ class apache2_plugin { } // get alias domains (co-domains and subdomains) - $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]); + $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'"); $server_alias = ''; if(is_array($aliases)) { foreach($aliases as $alias) {