Skip to content

Commit ea37961

Browse files
committed
Added client limits to the DNS module.
1 parent 15e7707 commit ea37961

31 files changed

+631
-21
lines changed

interface/web/client/client_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function onAfterInsert() {
6666

6767
$username = addslashes($this->dataRecord["username"]);
6868
$password = addslashes($this->dataRecord["password"]);
69-
$modules = 'mail,sites';
69+
$modules = 'mail,sites,dns';
7070
$startmodule = 'mail';
7171
$usertheme = addslashes($this->dataRecord["usertheme"]);
7272
$type = 'user';

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
'formtype' => 'SELECT',
286286
'default' => '1',
287287
'datasource' => array ( 'type' => 'SQL',
288-
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
288+
'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
289289
'keyfield'=> 'server_id',
290290
'valuefield'=> 'server_name'
291291
),
@@ -464,7 +464,7 @@
464464
'formtype' => 'SELECT',
465465
'default' => '1',
466466
'datasource' => array ( 'type' => 'SQL',
467-
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
467+
'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
468468
'keyfield'=> 'server_id',
469469
'valuefield'=> 'server_name'
470470
),
@@ -526,6 +526,45 @@
526526
'rows' => '',
527527
'cols' => ''
528528
),
529+
'default_dnsserver' => array (
530+
'datatype' => 'INTEGER',
531+
'formtype' => 'SELECT',
532+
'default' => '1',
533+
'datasource' => array ( 'type' => 'SQL',
534+
'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
535+
'keyfield'=> 'server_id',
536+
'valuefield'=> 'server_name'
537+
),
538+
'value' => ''
539+
),
540+
'limit_dns_zone' => array (
541+
'datatype' => 'INTEGER',
542+
'formtype' => 'TEXT',
543+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
544+
'errmsg'=> 'limit_dns_zone_error_notint'),
545+
),
546+
'default' => '-1',
547+
'value' => '',
548+
'separator' => '',
549+
'width' => '10',
550+
'maxlength' => '10',
551+
'rows' => '',
552+
'cols' => ''
553+
),
554+
'limit_dns_record' => array (
555+
'datatype' => 'INTEGER',
556+
'formtype' => 'TEXT',
557+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
558+
'errmsg'=> 'limit_dns_zone_error_notint'),
559+
),
560+
'default' => '-1',
561+
'value' => '',
562+
'separator' => '',
563+
'width' => '10',
564+
'maxlength' => '10',
565+
'rows' => '',
566+
'cols' => ''
567+
),
529568
##################################
530569
# END Datatable fields
531570
##################################

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@ $wb["limit_web_domain_txt"] = 'Max. number of web domains';
5050
$wb["limit_web_aliasdomain_txt"] = 'Max. number of web aliasdomains';
5151
$wb["limit_web_subdomain_txt"] = 'Max. number of web subdomains';
5252
$wb["limit_ftp_user_txt"] = 'Max. number of FTP users';
53+
$wb["default_dnsserver_txt"] = 'Default DNS Server';
54+
$wb["limit_dns_zone_txt"] = 'Max. number of DNS zones';
55+
$wb["limit_dns_record_txt"] = 'Max. number DNS records';
56+
5357

5458
?>

interface/web/client/templates/client_edit_limits.htm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@
9090
<td class="frmText11" width="280">{tmpl_var name='limit_ftp_user_txt'}:</td>
9191
<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>
9292
</tr>
93+
<tr>
94+
<td><h2>DNS</h2></td>
95+
</tr>
96+
<tr>
97+
<td class="frmText11">{tmpl_var name='default_dnsserver_txt'}:</td>
98+
<td class="frmText11">
99+
<select name="default_dnsserver" class="text">
100+
{tmpl_var name='default_dnsserver'}
101+
</select>
102+
</td>
103+
</tr>
104+
<tr>
105+
<td class="frmText11" width="280">{tmpl_var name='limit_dns_zone_txt'}:</td>
106+
<td class="frmText11" width="220"><input name="limit_dns_zone" type="text" class="text" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10"></td>
107+
</tr>
108+
<tr>
109+
<td class="frmText11" width="280">{tmpl_var name='limit_dns_record_txt'}:</td>
110+
<td class="frmText11" width="220"><input name="limit_dns_record" type="text" class="text" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10"></td>
111+
</tr>
93112
<tr>
94113
<td class="frmText11">&nbsp;</td>
95114
<td class="frmText11">&nbsp;</td>

interface/web/dns/dns_a_edit.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,52 @@
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_dns_record 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 mailbox.
67+
if($client["limit_dns_record"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
69+
if($tmp["number"] >= $client["limit_dns_record"]) {
70+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
function onSubmit() {
5779
global $app, $conf;
5880

5981
// Get the parent soa record of the domain
6082
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
83+
84+
// Check if Domain belongs to user
85+
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
86+
87+
// Check the client limits, if user is not the admin
88+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
89+
// Get the limits of the client
90+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
91+
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
92+
93+
// Check if the user may add another mailbox.
94+
if($this->id == 0 && $client["limit_dns_record"] >= 0) {
95+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
96+
if($tmp["number"] >= $client["limit_dns_record"]) {
97+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
98+
}
99+
}
100+
} // end if user is not admin
101+
61102

62103
// Set the server ID of the rr record to the same server ID as the parent record.
63104
$this->dataRecord["server_id"] = $soa["server_id"];

interface/web/dns/dns_alias_edit.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,52 @@
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_dns_record 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 mailbox.
67+
if($client["limit_dns_record"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
69+
if($tmp["number"] >= $client["limit_dns_record"]) {
70+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
function onSubmit() {
5779
global $app, $conf;
5880

5981
// Get the parent soa record of the domain
6082
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
83+
84+
// Check if Domain belongs to user
85+
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
86+
87+
// Check the client limits, if user is not the admin
88+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
89+
// Get the limits of the client
90+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
91+
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
92+
93+
// Check if the user may add another mailbox.
94+
if($client["limit_dns_record"] >= 0) {
95+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
96+
if($tmp["number"] >= $client["limit_dns_record"]) {
97+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
98+
}
99+
}
100+
} // end if user is not admin
101+
61102

62103
// Set the server ID of the rr record to the same server ID as the parent record.
63104
$this->dataRecord["server_id"] = $soa["server_id"];

interface/web/dns/dns_cname_edit.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,52 @@
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_dns_record 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 mailbox.
67+
if($client["limit_dns_record"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
69+
if($tmp["number"] >= $client["limit_dns_record"]) {
70+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
function onSubmit() {
5779
global $app, $conf;
5880

5981
// Get the parent soa record of the domain
6082
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
83+
84+
// Check if Domain belongs to user
85+
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
86+
87+
// Check the client limits, if user is not the admin
88+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
89+
// Get the limits of the client
90+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
91+
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
92+
93+
// Check if the user may add another mailbox.
94+
if($this->id == 0 && $client["limit_dns_record"] >= 0) {
95+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
96+
if($tmp["number"] >= $client["limit_dns_record"]) {
97+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
98+
}
99+
}
100+
} // end if user is not admin
101+
61102

62103
// Set the server ID of the rr record to the same server ID as the parent record.
63104
$this->dataRecord["server_id"] = $soa["server_id"];

interface/web/dns/dns_hinfo_edit.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,52 @@
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_dns_record 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 mailbox.
67+
if($client["limit_dns_record"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
69+
if($tmp["number"] >= $client["limit_dns_record"]) {
70+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
function onSubmit() {
5779
global $app, $conf;
5880

5981
// Get the parent soa record of the domain
6082
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
83+
84+
// Check if Domain belongs to user
85+
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
86+
87+
// Check the client limits, if user is not the admin
88+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
89+
// Get the limits of the client
90+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
91+
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
92+
93+
// Check if the user may add another mailbox.
94+
if($this->id == 0 && $client["limit_dns_record"] >= 0) {
95+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
96+
if($tmp["number"] >= $client["limit_dns_record"]) {
97+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
98+
}
99+
}
100+
} // end if user is not admin
101+
61102

62103
// Set the server ID of the rr record to the same server ID as the parent record.
63104
$this->dataRecord["server_id"] = $soa["server_id"];

interface/web/dns/dns_mx_edit.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,52 @@
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_dns_record 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 mailbox.
67+
if($client["limit_dns_record"] >= 0) {
68+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
69+
if($tmp["number"] >= $client["limit_dns_record"]) {
70+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
71+
}
72+
}
73+
}
74+
75+
parent::onShowNew();
76+
}
77+
5678
function onSubmit() {
5779
global $app, $conf;
5880

5981
// Get the parent soa record of the domain
6082
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
83+
84+
// Check if Domain belongs to user
85+
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
86+
87+
// Check the client limits, if user is not the admin
88+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
89+
// Get the limits of the client
90+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
91+
$client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
92+
93+
// Check if the user may add another mailbox.
94+
if($this->id == 0 && $client["limit_dns_record"] >= 0) {
95+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
96+
if($tmp["number"] >= $client["limit_dns_record"]) {
97+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
98+
}
99+
}
100+
} // end if user is not admin
101+
61102

62103
// Set the server ID of the rr record to the same server ID as the parent record.
63104
$this->dataRecord["server_id"] = $soa["server_id"];

0 commit comments

Comments
 (0)