Skip to content

Commit 4fae7e2

Browse files
committed
Added limits for websites and FTP users.
1 parent 43434b9 commit 4fae7e2

File tree

10 files changed

+224
-32
lines changed

10 files changed

+224
-32
lines changed

interface/web/client/form/client.tform.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,73 @@
459459
'rows' => '',
460460
'cols' => ''
461461
),
462+
'default_webserver' => array (
463+
'datatype' => 'INTEGER',
464+
'formtype' => 'SELECT',
465+
'default' => '1',
466+
'datasource' => array ( 'type' => 'SQL',
467+
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
468+
'keyfield'=> 'server_id',
469+
'valuefield'=> 'server_name'
470+
),
471+
'value' => ''
472+
),
473+
'limit_web_domain' => array (
474+
'datatype' => 'INTEGER',
475+
'formtype' => 'TEXT',
476+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
477+
'errmsg'=> 'limit_web_domain_error_notint'),
478+
),
479+
'default' => '-1',
480+
'value' => '',
481+
'separator' => '',
482+
'width' => '10',
483+
'maxlength' => '10',
484+
'rows' => '',
485+
'cols' => ''
486+
),
487+
'limit_web_aliasdomain' => array (
488+
'datatype' => 'INTEGER',
489+
'formtype' => 'TEXT',
490+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
491+
'errmsg'=> 'limit_web_aliasdomain_error_notint'),
492+
),
493+
'default' => '-1',
494+
'value' => '',
495+
'separator' => '',
496+
'width' => '10',
497+
'maxlength' => '10',
498+
'rows' => '',
499+
'cols' => ''
500+
),
501+
'limit_web_subdomain' => array (
502+
'datatype' => 'INTEGER',
503+
'formtype' => 'TEXT',
504+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
505+
'errmsg'=> 'limit_web_subdomain_error_notint'),
506+
),
507+
'default' => '-1',
508+
'value' => '',
509+
'separator' => '',
510+
'width' => '10',
511+
'maxlength' => '10',
512+
'rows' => '',
513+
'cols' => ''
514+
),
515+
'limit_ftp_user' => array (
516+
'datatype' => 'INTEGER',
517+
'formtype' => 'TEXT',
518+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
519+
'errmsg'=> 'limit_ftp_user_error_notint'),
520+
),
521+
'default' => '-1',
522+
'value' => '',
523+
'separator' => '',
524+
'width' => '10',
525+
'maxlength' => '10',
526+
'rows' => '',
527+
'cols' => ''
528+
),
462529
##################################
463530
# END Datatable fields
464531
##################################

interface/web/client/lib/lang/en_client.lng

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,10 @@ $wb["ip_address_txt"] = 'ip_address';
4545
$wb["limit_client_error_notint"] = 'Client Limit is not a number.';
4646
$wb["firstname_error_empty"] = 'Firstname is empty.';
4747
$wb["contact_error_empty"] = 'Contact name is empty.';
48+
$wb["default_webserver_txt"] = 'Default Webserver';
49+
$wb["limit_web_domain_txt"] = 'Max. number of web domains';
50+
$wb["limit_web_aliasdomain_txt"] = 'Max. number of web aliasdomains';
51+
$wb["limit_web_subdomain_txt"] = 'Max. number of web subdomains';
52+
$wb["limit_ftp_user_txt"] = 'Max. number of FTP users';
53+
4854
?>

interface/web/client/templates/client_edit_limits.htm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,33 @@
6363
<td class="frmText11">{tmpl_var name='limit_spamfilter_policy_txt'}:</td>
6464
<td class="frmText11"><input name="limit_spamfilter_policy" type="text" class="text" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10"></td>
6565
</tr>
66+
<tr>
67+
<td><h2>Websites</h2></td>
68+
</tr>
69+
<tr>
70+
<td class="frmText11">{tmpl_var name='default_webserver_txt'}:</td>
71+
<td class="frmText11">
72+
<select name="default_webserver" class="text">
73+
{tmpl_var name='default_webserver'}
74+
</select>
75+
</td>
76+
</tr>
77+
<tr>
78+
<td class="frmText11" width="280">{tmpl_var name='limit_web_domain_txt'}:</td>
79+
<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>
80+
</tr>
81+
<tr>
82+
<td class="frmText11" width="280">{tmpl_var name='limit_web_subdomain_txt'}:</td>
83+
<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>
84+
</tr>
85+
<tr>
86+
<td class="frmText11" width="280">{tmpl_var name='limit_web_aliasdomain_txt'}:</td>
87+
<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>
88+
</tr>
89+
<tr>
90+
<td class="frmText11" width="280">{tmpl_var name='limit_ftp_user_txt'}:</td>
91+
<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>
92+
</tr>
6693
<tr>
6794
<td class="frmText11">&nbsp;</td>
6895
<td class="frmText11">&nbsp;</td>

interface/web/sites/ftp_user_edit.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@
5353

5454
class page_action extends tform_actions {
5555

56+
function onShowNew() {
57+
global $app, $conf;
58+
59+
// we will check only users, not admins
60+
if($_SESSION["s"]["user"]["typ"] == 'user') {
61+
62+
// Get the limits of the client
63+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
64+
$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");
65+
66+
// Check if the user may add another maildomain.
67+
if($client["limit_ftp_user"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(ftp_user_id) as number FROM ftp_user WHERE sys_groupid = $client_group_id");
69+
if($tmp["number"] >= $client["limit_ftp_user"]) {
70+
$app->error($app->tform->wordbook["limit_ftp_user_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
5677

5778
function onAfterInsert() {
5879
global $app, $conf;

interface/web/sites/lib/lang/en_ftp_user.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ $wb["username_txt"] = 'Username';
1515
$wb["password_txt"] = 'Password';
1616
$wb["quota_size_txt"] = 'Harddisk-Quota';
1717
$wb["active_txt"] = 'Active';
18+
$wb["limit_ftp_user_txt"] = 'The max. number of FTP users for your account is reached.';
1819
?>
Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
<?php
2-
$wb["server_id_txt"] = 'Server';
3-
$wb["domain_txt"] = 'Domain';
4-
$wb["type_txt"] = 'Type';
5-
$wb["parent_domain_id_txt"] = 'Parent Website';
6-
$wb["redirect_type_txt"] = 'Redirect Type';
7-
$wb["redirect_path_txt"] = 'Redirect Path';
8-
$wb["active_txt"] = 'Active';
9-
$wb["btn_save_txt"] = 'Save';
10-
$wb["btn_cancel_txt"] = 'Cancel';
11-
$wb["document_root_txt"] = 'Documentroot';
12-
$wb["system_user_txt"] = 'Linux User';
13-
$wb["system_group_txt"] = 'Linux Group';
14-
$wb["ip_address_txt"] = 'IP-Address';
15-
$wb["vhost_type_txt"] = 'VHost Type';
16-
$wb["hd_quota_txt"] = 'Harddisk Quota';
17-
$wb["traffic_quota_txt"] = 'Traffic Quaota';
18-
$wb["cgi_txt"] = 'CGI';
19-
$wb["ssi_txt"] = 'SSI';
20-
$wb["suexec_txt"] = 'SuEXEC';
21-
$wb["php_txt"] = 'PHP';
22-
$wb["client_txt"] = 'Client';
1+
<?php
2+
$wb["server_id_txt"] = 'Server';
3+
$wb["domain_txt"] = 'Domain';
4+
$wb["type_txt"] = 'Type';
5+
$wb["parent_domain_id_txt"] = 'Parent Website';
6+
$wb["redirect_type_txt"] = 'Redirect Type';
7+
$wb["redirect_path_txt"] = 'Redirect Path';
8+
$wb["active_txt"] = 'Active';
9+
$wb["btn_save_txt"] = 'Save';
10+
$wb["btn_cancel_txt"] = 'Cancel';
11+
$wb["document_root_txt"] = 'Documentroot';
12+
$wb["system_user_txt"] = 'Linux User';
13+
$wb["system_group_txt"] = 'Linux Group';
14+
$wb["ip_address_txt"] = 'IP-Address';
15+
$wb["vhost_type_txt"] = 'VHost Type';
16+
$wb["hd_quota_txt"] = 'Harddisk Quota';
17+
$wb["traffic_quota_txt"] = 'Traffic Quaota';
18+
$wb["cgi_txt"] = 'CGI';
19+
$wb["ssi_txt"] = 'SSI';
20+
$wb["suexec_txt"] = 'SuEXEC';
21+
$wb["php_txt"] = 'PHP';
22+
$wb["client_txt"] = 'Client';
23+
$wb["limit_web_domain_txt"] = 'The max. number of web domains for your account is reached.';
24+
$wb["limit_web_aliasdomain_txt"] = 'The max. number of aliasdomains for your account is reached.';
25+
$wb["limit_web_subdomain_txt"] = 'The max. number of web subdomains for your account is reached.';
2326
?>

interface/web/sites/web_aliasdomain_edit.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@
5353

5454
class page_action extends tform_actions {
5555

56+
function onShowNew() {
57+
global $app, $conf;
58+
59+
// we will check only users, not admins
60+
if($_SESSION["s"]["user"]["typ"] == 'user') {
61+
62+
// Get the limits of the client
63+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
64+
$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");
65+
66+
// Check if the user may add another maildomain.
67+
if($client["limit_web_aliasdomain"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'alias'");
69+
if($tmp["number"] >= $client["limit_web_aliasdomain"]) {
70+
$app->error($app->tform->wordbook["limit_web_aliasdomain_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
/*
5779
function onShowEnd() {
5880
global $app, $conf;

interface/web/sites/web_domain_edit.php

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@
5353

5454
class page_action extends tform_actions {
5555

56+
function onShowNew() {
57+
global $app, $conf;
58+
59+
// we will check only users, not admins
60+
if($_SESSION["s"]["user"]["typ"] == 'user') {
61+
62+
// Get the limits of the client
63+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
64+
$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");
65+
66+
// Check if the user may add another maildomain.
67+
if($client["limit_web_domain"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'vhost'");
69+
if($tmp["number"] >= $client["limit_web_domain"]) {
70+
$app->error($app->tform->wordbook["limit_web_domain_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
function onShowEnd() {
5779
global $app, $conf;
5880

@@ -123,7 +145,7 @@ function onSubmit() {
123145
if($_SESSION["s"]["user"]["typ"] != 'admin') {
124146
// Get the limits of the client
125147
$client_group_id = $_SESSION["s"]["user"]["default_group"];
126-
$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");
148+
$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");
127149

128150
// When the record is updated
129151
if($this->id > 0) {
@@ -136,15 +158,15 @@ function onSubmit() {
136158
// set the server ID to the default mailserver of the client
137159
$this->dataRecord["server_id"] = $client["default_webserver"];
138160

139-
/*
140-
// Check if the user may add another mail_domain
141-
if($client["limit_maildomain"] >= 0) {
142-
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE sys_groupid = $client_group_id");
143-
if($tmp["number"] >= $client["limit_maildomain"]) {
144-
$app->error($app->tform->wordbook["limit_webdomain_txt"]);
161+
162+
// Check if the user may add another web_domain
163+
if($client["limit_web_domain"] >= 0) {
164+
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'vhost'");
165+
if($tmp["number"] >= $client["limit_web_domain"]) {
166+
$app->error($app->tform->wordbook["limit_web_domain_txt"]);
145167
}
146168
}
147-
*/
169+
148170
}
149171

150172
// Clients may not set the client_group_id, so we unset them if user is not a admin

interface/web/sites/web_subdomain_edit.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,35 @@
5353

5454
class page_action extends tform_actions {
5555

56+
function onShowNew() {
57+
global $app, $conf;
58+
59+
// we will check only users, not admins
60+
if($_SESSION["s"]["user"]["typ"] == 'user') {
61+
62+
// Get the limits of the client
63+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
64+
$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");
65+
66+
// Check if the user may add another maildomain.
67+
if($client["limit_web_subdomain"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'subdomain'");
69+
if($tmp["number"] >= $client["limit_web_subdomain"]) {
70+
$app->error($app->tform->wordbook["limit_web_subdomain_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
function onShowEnd() {
5779
global $app, $conf;
5880

5981
// Get the record of the parent domain
6082
$parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
6183

84+
// remove the parent domain part of the domain name before we show it in the text field.
6285
$this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"],'',$this->dataRecord["domain"]);
6386
$app->tpl->setVar("domain",$this->dataRecord["domain"]);
6487

server/plugins-enabled/apache2_plugin.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function update($event_name,$data) {
6868
if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
6969
// This is not a vhost, so we need to update the parent record instead.
7070
$parent_domain_id = intval($data["new"]["parent_domain_id"]);
71-
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id);
71+
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id." AND active = 'y'");
7272
$data["new"] = $tmp;
7373
$data["old"] = $tmp;
7474
}
@@ -150,7 +150,7 @@ function update($event_name,$data) {
150150
}
151151

152152
// get alias domains (co-domains and subdomains)
153-
$aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]);
153+
$aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'");
154154
$server_alias = '';
155155
if(is_array($aliases)) {
156156
foreach($aliases as $alias) {

0 commit comments

Comments
 (0)