Skip to content
Snippets Groups Projects
Commit 4fae7e24 authored by tbrehm's avatar tbrehm
Browse files

Added limits for websites and FTP users.

parent 43434b99
No related branches found
No related tags found
No related merge requests found
...@@ -459,6 +459,73 @@ $form["tabs"]['limits'] = array ( ...@@ -459,6 +459,73 @@ $form["tabs"]['limits'] = array (
'rows' => '', 'rows' => '',
'cols' => '' '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 # END Datatable fields
################################## ##################################
......
...@@ -45,4 +45,10 @@ $wb["ip_address_txt"] = 'ip_address'; ...@@ -45,4 +45,10 @@ $wb["ip_address_txt"] = 'ip_address';
$wb["limit_client_error_notint"] = 'Client Limit is not a number.'; $wb["limit_client_error_notint"] = 'Client Limit is not a number.';
$wb["firstname_error_empty"] = 'Firstname is empty.'; $wb["firstname_error_empty"] = 'Firstname is empty.';
$wb["contact_error_empty"] = 'Contact name 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
...@@ -63,6 +63,33 @@ ...@@ -63,6 +63,33 @@
<td class="frmText11">{tmpl_var name='limit_spamfilter_policy_txt'}:</td> <td class="frmText11">{tmpl_var name='limit_spamfilter_policy_txt'}:</td>
<td class="frmText11"><input name="limit_spamfilter_policy" type="text" class="text" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10"></td> <td class="frmText11"><input name="limit_spamfilter_policy" type="text" class="text" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10"></td>
</tr> </tr>
<tr>
<td><h2>Websites</h2></td>
</tr>
<tr>
<td class="frmText11">{tmpl_var name='default_webserver_txt'}:</td>
<td class="frmText11">
<select name="default_webserver" class="text">
{tmpl_var name='default_webserver'}
</select>
</td>
</tr>
<tr>
<td class="frmText11" width="280">{tmpl_var name='limit_web_domain_txt'}:</td>
<td class="frmText11" width="220"><input name="limit_web_domain" type="text" class="text" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10"></td>
</tr>
<tr>
<td class="frmText11" width="280">{tmpl_var name='limit_web_subdomain_txt'}:</td>
<td class="frmText11" width="220"><input name="limit_web_subdomain" type="text" class="text" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10"></td>
</tr>
<tr>
<td class="frmText11" width="280">{tmpl_var name='limit_web_aliasdomain_txt'}:</td>
<td class="frmText11" width="220"><input name="limit_web_aliasdomain" type="text" class="text" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10"></td>
</tr>
<tr>
<td class="frmText11" width="280">{tmpl_var name='limit_ftp_user_txt'}:</td>
<td class="frmText11" width="220"><input name="limit_ftp_user" type="text" class="text" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10"></td>
</tr>
<tr> <tr>
<td class="frmText11">&nbsp;</td> <td class="frmText11">&nbsp;</td>
<td class="frmText11">&nbsp;</td> <td class="frmText11">&nbsp;</td>
......
...@@ -53,6 +53,27 @@ $app->load('tform_actions'); ...@@ -53,6 +53,27 @@ $app->load('tform_actions');
class page_action extends 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() { function onAfterInsert() {
global $app, $conf; global $app, $conf;
......
...@@ -15,4 +15,5 @@ $wb["username_txt"] = 'Username'; ...@@ -15,4 +15,5 @@ $wb["username_txt"] = 'Username';
$wb["password_txt"] = 'Password'; $wb["password_txt"] = 'Password';
$wb["quota_size_txt"] = 'Harddisk-Quota'; $wb["quota_size_txt"] = 'Harddisk-Quota';
$wb["active_txt"] = 'Active'; $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
<?php <?php
$wb["server_id_txt"] = 'Server'; $wb["server_id_txt"] = 'Server';
$wb["domain_txt"] = 'Domain'; $wb["domain_txt"] = 'Domain';
$wb["type_txt"] = 'Type'; $wb["type_txt"] = 'Type';
$wb["parent_domain_id_txt"] = 'Parent Website'; $wb["parent_domain_id_txt"] = 'Parent Website';
$wb["redirect_type_txt"] = 'Redirect Type'; $wb["redirect_type_txt"] = 'Redirect Type';
$wb["redirect_path_txt"] = 'Redirect Path'; $wb["redirect_path_txt"] = 'Redirect Path';
$wb["active_txt"] = 'Active'; $wb["active_txt"] = 'Active';
$wb["btn_save_txt"] = 'Save'; $wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel'; $wb["btn_cancel_txt"] = 'Cancel';
$wb["document_root_txt"] = 'Documentroot'; $wb["document_root_txt"] = 'Documentroot';
$wb["system_user_txt"] = 'Linux User'; $wb["system_user_txt"] = 'Linux User';
$wb["system_group_txt"] = 'Linux Group'; $wb["system_group_txt"] = 'Linux Group';
$wb["ip_address_txt"] = 'IP-Address'; $wb["ip_address_txt"] = 'IP-Address';
$wb["vhost_type_txt"] = 'VHost Type'; $wb["vhost_type_txt"] = 'VHost Type';
$wb["hd_quota_txt"] = 'Harddisk Quota'; $wb["hd_quota_txt"] = 'Harddisk Quota';
$wb["traffic_quota_txt"] = 'Traffic Quaota'; $wb["traffic_quota_txt"] = 'Traffic Quaota';
$wb["cgi_txt"] = 'CGI'; $wb["cgi_txt"] = 'CGI';
$wb["ssi_txt"] = 'SSI'; $wb["ssi_txt"] = 'SSI';
$wb["suexec_txt"] = 'SuEXEC'; $wb["suexec_txt"] = 'SuEXEC';
$wb["php_txt"] = 'PHP'; $wb["php_txt"] = 'PHP';
$wb["client_txt"] = 'Client'; $wb["client_txt"] = 'Client';
$wb["limit_web_domain_txt"] = 'The max. number of web domains for your account is reached.';
$wb["limit_web_aliasdomain_txt"] = 'The max. number of aliasdomains for your account is reached.';
$wb["limit_web_subdomain_txt"] = 'The max. number of web subdomains for your account is reached.';
?> ?>
\ No newline at end of file
...@@ -53,6 +53,28 @@ $app->load('tform_actions'); ...@@ -53,6 +53,28 @@ $app->load('tform_actions');
class page_action extends 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() { function onShowEnd() {
global $app, $conf; global $app, $conf;
......
...@@ -53,6 +53,28 @@ $app->load('tform_actions'); ...@@ -53,6 +53,28 @@ $app->load('tform_actions');
class page_action extends 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() { function onShowEnd() {
global $app, $conf; global $app, $conf;
...@@ -123,7 +145,7 @@ class page_action extends tform_actions { ...@@ -123,7 +145,7 @@ class page_action extends tform_actions {
if($_SESSION["s"]["user"]["typ"] != 'admin') { if($_SESSION["s"]["user"]["typ"] != 'admin') {
// Get the limits of the client // Get the limits of the client
$client_group_id = $_SESSION["s"]["user"]["default_group"]; $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 // When the record is updated
if($this->id > 0) { if($this->id > 0) {
...@@ -136,15 +158,15 @@ class page_action extends tform_actions { ...@@ -136,15 +158,15 @@ class page_action extends tform_actions {
// set the server ID to the default mailserver of the client // set the server ID to the default mailserver of the client
$this->dataRecord["server_id"] = $client["default_webserver"]; $this->dataRecord["server_id"] = $client["default_webserver"];
/*
// Check if the user may add another mail_domain // Check if the user may add another web_domain
if($client["limit_maildomain"] >= 0) { if($client["limit_web_domain"] >= 0) {
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE sys_groupid = $client_group_id"); $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_maildomain"]) { if($tmp["number"] >= $client["limit_web_domain"]) {
$app->error($app->tform->wordbook["limit_webdomain_txt"]); $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 // Clients may not set the client_group_id, so we unset them if user is not a admin
......
...@@ -53,12 +53,35 @@ $app->load('tform_actions'); ...@@ -53,12 +53,35 @@ $app->load('tform_actions');
class page_action extends 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() { function onShowEnd() {
global $app, $conf; global $app, $conf;
// Get the record of the parent domain // 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"])); $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"]); $this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"],'',$this->dataRecord["domain"]);
$app->tpl->setVar("domain",$this->dataRecord["domain"]); $app->tpl->setVar("domain",$this->dataRecord["domain"]);
......
...@@ -68,7 +68,7 @@ class apache2_plugin { ...@@ -68,7 +68,7 @@ class apache2_plugin {
if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) { 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. // This is not a vhost, so we need to update the parent record instead.
$parent_domain_id = intval($data["new"]["parent_domain_id"]); $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["new"] = $tmp;
$data["old"] = $tmp; $data["old"] = $tmp;
} }
...@@ -150,7 +150,7 @@ class apache2_plugin { ...@@ -150,7 +150,7 @@ class apache2_plugin {
} }
// get alias domains (co-domains and subdomains) // 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 = ''; $server_alias = '';
if(is_array($aliases)) { if(is_array($aliases)) {
foreach($aliases as $alias) { foreach($aliases as $alias) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment