From ea379616f044da73c8f927e2ed4bbb23516c8fdb Mon Sep 17 00:00:00 2001 From: tbrehm Date: Thu, 2 Aug 2007 12:20:10 +0000 Subject: [PATCH] Added client limits to the DNS module. --- interface/web/client/client_edit.php | 2 +- interface/web/client/form/client.tform.php | 43 ++++++++- interface/web/client/lib/lang/en_client.lng | 4 + .../client/templates/client_edit_limits.htm | 19 ++++ interface/web/dns/dns_a_edit.php | 41 +++++++++ interface/web/dns/dns_alias_edit.php | 41 +++++++++ interface/web/dns/dns_cname_edit.php | 41 +++++++++ interface/web/dns/dns_hinfo_edit.php | 41 +++++++++ interface/web/dns/dns_mx_edit.php | 41 +++++++++ interface/web/dns/dns_ns_edit.php | 41 +++++++++ interface/web/dns/dns_ptr_edit.php | 41 +++++++++ interface/web/dns/dns_rp_edit.php | 41 +++++++++ interface/web/dns/dns_soa_edit.php | 91 +++++++++++++++++++ interface/web/dns/dns_srv_edit.php | 41 +++++++++ interface/web/dns/dns_txt_edit.php | 41 +++++++++ interface/web/dns/form/dns_soa.tform.php | 3 +- interface/web/dns/lib/lang/en_dns_a.lng | 2 + interface/web/dns/lib/lang/en_dns_a_list.lng | 1 + interface/web/dns/lib/lang/en_dns_alias.lng | 2 + interface/web/dns/lib/lang/en_dns_cname.lng | 2 + interface/web/dns/lib/lang/en_dns_hinfo.lng | 2 + interface/web/dns/lib/lang/en_dns_mx.lng | 2 + interface/web/dns/lib/lang/en_dns_ns.lng | 2 + interface/web/dns/lib/lang/en_dns_ptr.lng | 2 + interface/web/dns/lib/lang/en_dns_rp.lng | 2 + interface/web/dns/lib/lang/en_dns_soa.lng | 33 ++++--- interface/web/dns/lib/lang/en_dns_srv.lng | 2 + interface/web/dns/lib/lang/en_dns_txt.lng | 2 + interface/web/dns/list/dns_a.list.php | 9 ++ interface/web/dns/templates/dns_a_list.htm | 7 +- interface/web/dns/templates/dns_soa_edit.htm | 10 ++ 31 files changed, 631 insertions(+), 21 deletions(-) diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index b7e9cfd67..473de4b7a 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -66,7 +66,7 @@ class page_action extends tform_actions { $username = addslashes($this->dataRecord["username"]); $password = addslashes($this->dataRecord["password"]); - $modules = 'mail,sites'; + $modules = 'mail,sites,dns'; $startmodule = 'mail'; $usertheme = addslashes($this->dataRecord["usertheme"]); $type = 'user'; diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 6aba152b8..d87e2f9d9 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -285,7 +285,7 @@ $form["tabs"]['limits'] = array ( 'formtype' => 'SELECT', 'default' => '1', 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name', 'keyfield'=> 'server_id', 'valuefield'=> 'server_name' ), @@ -464,7 +464,7 @@ $form["tabs"]['limits'] = array ( 'formtype' => 'SELECT', 'default' => '1', 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name', 'keyfield'=> 'server_id', 'valuefield'=> 'server_name' ), @@ -526,6 +526,45 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'default_dnsserver' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'value' => '' + ), + 'limit_dns_zone' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_dns_zone_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_dns_record' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_dns_zone_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 90472f60c..435a2908d 100644 --- a/interface/web/client/lib/lang/en_client.lng +++ b/interface/web/client/lib/lang/en_client.lng @@ -50,5 +50,9 @@ $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'; +$wb["default_dnsserver_txt"] = 'Default DNS Server'; +$wb["limit_dns_zone_txt"] = 'Max. number of DNS zones'; +$wb["limit_dns_record_txt"] = 'Max. number DNS records'; + ?> \ 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 979e9d951..e33d0b323 100644 --- a/interface/web/client/templates/client_edit_limits.htm +++ b/interface/web/client/templates/client_edit_limits.htm @@ -90,6 +90,25 @@ {tmpl_var name='limit_ftp_user_txt'}: + +

DNS

+ + + {tmpl_var name='default_dnsserver_txt'}: + + + + + + {tmpl_var name='limit_dns_zone_txt'}: + + + + {tmpl_var name='limit_dns_record_txt'}: + +     diff --git a/interface/web/dns/dns_a_edit.php b/interface/web/dns/dns_a_edit.php index 03609bd34..ed143424e 100644 --- a/interface/web/dns/dns_a_edit.php +++ b/interface/web/dns/dns_a_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_alias_edit.php b/interface/web/dns/dns_alias_edit.php index 8f8e0ecc4..f08280de6 100644 --- a/interface/web/dns/dns_alias_edit.php +++ b/interface/web/dns/dns_alias_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_cname_edit.php b/interface/web/dns/dns_cname_edit.php index a9a6c3260..7ea775cbe 100644 --- a/interface/web/dns/dns_cname_edit.php +++ b/interface/web/dns/dns_cname_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_hinfo_edit.php b/interface/web/dns/dns_hinfo_edit.php index 891069e84..b2286c206 100644 --- a/interface/web/dns/dns_hinfo_edit.php +++ b/interface/web/dns/dns_hinfo_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_mx_edit.php b/interface/web/dns/dns_mx_edit.php index 0dc6b9182..d21a99f35 100644 --- a/interface/web/dns/dns_mx_edit.php +++ b/interface/web/dns/dns_mx_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_ns_edit.php b/interface/web/dns/dns_ns_edit.php index a7889ae2b..17e466777 100644 --- a/interface/web/dns/dns_ns_edit.php +++ b/interface/web/dns/dns_ns_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_ptr_edit.php b/interface/web/dns/dns_ptr_edit.php index e353c7ad0..125052319 100644 --- a/interface/web/dns/dns_ptr_edit.php +++ b/interface/web/dns/dns_ptr_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_rp_edit.php b/interface/web/dns/dns_rp_edit.php index 1ed15825b..a97574a13 100644 --- a/interface/web/dns/dns_rp_edit.php +++ b/interface/web/dns/dns_rp_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_soa_edit.php b/interface/web/dns/dns_soa_edit.php index 1a7bfa5e2..f78e9aa65 100644 --- a/interface/web/dns/dns_soa_edit.php +++ b/interface/web/dns/dns_soa_edit.php @@ -53,15 +53,106 @@ $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_dns_zone 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_dns_zone"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_soa WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_zone"]) { + $app->error($app->tform->wordbook["limit_dns_zone_txt"]); + } + } + } + + parent::onShowNew(); + } + + function onShowEnd() { + global $app, $conf; + + // If user is admin, we will allow him to select to whom this record belongs + if($_SESSION["s"]["user"]["typ"] == 'admin') { + // Getting Domains of the user + $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0"; + $clients = $app->db->queryAllRecords($sql); + $client_select = ""; + if(is_array($clients)) { + foreach( $clients as $client) { + $selected = ($client["groupid"] == $this->dataRecord["sys_groupid"])?'SELECTED':''; + $client_select .= "\r\n"; + } + } + $app->tpl->setVar("client_group_id",$client_select); + } + + parent::onShowEnd(); + } + function onSubmit() { global $app, $conf; + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT limit_dns_zone, default_dnsserver 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) { + // restore the server ID if the user is not admin and record is edited + $tmp = $app->db->queryOneRecord("SELECT server_id FROM dns_soa WHERE id = ".intval($this->id)); + $this->dataRecord["server_id"] = $tmp["server_id"]; + unset($tmp); + // When the record is inserted + } else { + // set the server ID to the default mailserver of the client + $this->dataRecord["server_id"] = $client["default_dnsserver"]; + + // Check if the user may add another maildomain. + if($client["limit_dns_zone"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_soa WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_zone"]) { + $app->error($app->tform->wordbook["limit_dns_zone_txt"]); + } + } + } + // Set the serial $this->dataRecord["serial"] = time(); parent::onSubmit(); } + function onAfterInsert() { + global $app, $conf; + + // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it + if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { + $client_group_id = intval($this->dataRecord["client_group_id"]); + $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id); + // And we want to update all rr records too, that belong to this record + $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id); + } + } + + function onAfterUpdate() { + global $app, $conf; + + // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it + if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { + $client_group_id = intval($this->dataRecord["client_group_id"]); + $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id); + // And we want to update all rr records too, that belong to this record + $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id); + } + } + } $page = new page_action; diff --git a/interface/web/dns/dns_srv_edit.php b/interface/web/dns/dns_srv_edit.php index a98733db4..200c03ce0 100644 --- a/interface/web/dns/dns_srv_edit.php +++ b/interface/web/dns/dns_srv_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/dns_txt_edit.php b/interface/web/dns/dns_txt_edit.php index 2d3ec8098..d8e7da1e7 100644 --- a/interface/web/dns/dns_txt_edit.php +++ b/interface/web/dns/dns_txt_edit.php @@ -53,11 +53,52 @@ $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_dns_record 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 mailbox. + if($client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } + + parent::onShowNew(); + } + function onSubmit() { global $app, $conf; // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); + + // Check if Domain belongs to user + if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; + + // Check the client limits, if user is not the admin + if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $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"); + + // Check if the user may add another mailbox. + if($this->id == 0 && $client["limit_dns_record"] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); + if($tmp["number"] >= $client["limit_dns_record"]) { + $app->error($app->tform->wordbook["limit_dns_record_txt"]); + } + } + } // end if user is not admin + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; diff --git a/interface/web/dns/form/dns_soa.tform.php b/interface/web/dns/form/dns_soa.tform.php index cf5f0d1d2..89ff4f922 100644 --- a/interface/web/dns/form/dns_soa.tform.php +++ b/interface/web/dns/form/dns_soa.tform.php @@ -107,7 +107,8 @@ $form["tabs"]['dns_soa'] = array ( 'formtype' => 'TEXT', 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', 'errmsg'=> 'mbox_error_empty'), - 1 => array ( 'type' => 'ISEMAIL', + 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,64}$/', 'errmsg'=> 'mbox_error_regex'), ), 'default' => '', diff --git a/interface/web/dns/lib/lang/en_dns_a.lng b/interface/web/dns/lib/lang/en_dns_a.lng index ca96ae584..57ce73dd7 100644 --- a/interface/web/dns/lib/lang/en_dns_a.lng +++ b/interface/web/dns/lib/lang/en_dns_a.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_a_list.lng b/interface/web/dns/lib/lang/en_dns_a_list.lng index cabd47889..da211f769 100644 --- a/interface/web/dns/lib/lang/en_dns_a_list.lng +++ b/interface/web/dns/lib/lang/en_dns_a_list.lng @@ -4,6 +4,7 @@ $wb["active_txt"] = 'Active'; $wb["server_id_txt"] = 'Server'; $wb["zone_txt"] = 'Zone'; $wb["name_txt"] = 'Name'; +$wb["data_txt"] = 'Data'; $wb["type_txt"] = 'Type'; $wb["page_txt"] = 'Page'; $wb["page_of_txt"] = 'of'; diff --git a/interface/web/dns/lib/lang/en_dns_alias.lng b/interface/web/dns/lib/lang/en_dns_alias.lng index 187a11033..d3a1b0abd 100644 --- a/interface/web/dns/lib/lang/en_dns_alias.lng +++ b/interface/web/dns/lib/lang/en_dns_alias.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_cname.lng b/interface/web/dns/lib/lang/en_dns_cname.lng index 187a11033..d3a1b0abd 100644 --- a/interface/web/dns/lib/lang/en_dns_cname.lng +++ b/interface/web/dns/lib/lang/en_dns_cname.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_hinfo.lng b/interface/web/dns/lib/lang/en_dns_hinfo.lng index 5b4a20463..e5eae739a 100644 --- a/interface/web/dns/lib/lang/en_dns_hinfo.lng +++ b/interface/web/dns/lib/lang/en_dns_hinfo.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_mx.lng b/interface/web/dns/lib/lang/en_dns_mx.lng index 55ebd0a99..ca65b42b4 100644 --- a/interface/web/dns/lib/lang/en_dns_mx.lng +++ b/interface/web/dns/lib/lang/en_dns_mx.lng @@ -9,4 +9,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_ns.lng b/interface/web/dns/lib/lang/en_dns_ns.lng index c430cdd20..5c2792dc0 100644 --- a/interface/web/dns/lib/lang/en_dns_ns.lng +++ b/interface/web/dns/lib/lang/en_dns_ns.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_ptr.lng b/interface/web/dns/lib/lang/en_dns_ptr.lng index 5e7f86d26..5edf14c31 100644 --- a/interface/web/dns/lib/lang/en_dns_ptr.lng +++ b/interface/web/dns/lib/lang/en_dns_ptr.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_rp.lng b/interface/web/dns/lib/lang/en_dns_rp.lng index 2f541761d..def925f64 100644 --- a/interface/web/dns/lib/lang/en_dns_rp.lng +++ b/interface/web/dns/lib/lang/en_dns_rp.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_soa.lng b/interface/web/dns/lib/lang/en_dns_soa.lng index 4955dff1a..573c795e1 100644 --- a/interface/web/dns/lib/lang/en_dns_soa.lng +++ b/interface/web/dns/lib/lang/en_dns_soa.lng @@ -1,16 +1,19 @@ - \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_srv.lng b/interface/web/dns/lib/lang/en_dns_srv.lng index 9c16bdca8..92110deee 100644 --- a/interface/web/dns/lib/lang/en_dns_srv.lng +++ b/interface/web/dns/lib/lang/en_dns_srv.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/lib/lang/en_dns_txt.lng b/interface/web/dns/lib/lang/en_dns_txt.lng index 89b4cc4ee..be403445b 100644 --- a/interface/web/dns/lib/lang/en_dns_txt.lng +++ b/interface/web/dns/lib/lang/en_dns_txt.lng @@ -8,4 +8,6 @@ $wb["ttl_txt"] = 'TTL'; $wb["active_txt"] = 'Active'; $wb["btn_save_txt"] = 'Save'; $wb["btn_cancel_txt"] = 'Cancel'; +$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; +$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; ?> \ No newline at end of file diff --git a/interface/web/dns/list/dns_a.list.php b/interface/web/dns/list/dns_a.list.php index 7c9511a4b..9e6ed6c99 100644 --- a/interface/web/dns/list/dns_a.list.php +++ b/interface/web/dns/list/dns_a.list.php @@ -95,6 +95,15 @@ $liste["item"][] = array( 'field' => "name", 'width' => "", 'value' => ""); +$liste["item"][] = array( 'field' => "data", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + $liste["item"][] = array( 'field' => "type", 'datatype' => "VARCHAR", diff --git a/interface/web/dns/templates/dns_a_list.htm b/interface/web/dns/templates/dns_a_list.htm index e5184be55..38a22ec06 100644 --- a/interface/web/dns/templates/dns_a_list.htm +++ b/interface/web/dns/templates/dns_a_list.htm @@ -14,12 +14,14 @@ Add: +   - + +
@@ -27,10 +29,11 @@ Add: {tmpl_var name="active"} {tmpl_var name="type"} {tmpl_var name="name"} + {tmpl_var name="data"} [{tmpl_var name='delete_txt'}] - + \ No newline at end of file diff --git a/interface/web/dns/templates/dns_soa_edit.htm b/interface/web/dns/templates/dns_soa_edit.htm index c78e69260..03d3ab060 100644 --- a/interface/web/dns/templates/dns_soa_edit.htm +++ b/interface/web/dns/templates/dns_soa_edit.htm @@ -1,4 +1,5 @@ + + + + + + -- GitLab
{tmpl_var name='server_id_txt'}: @@ -7,6 +8,15 @@
{tmpl_var name='client_txt'}: + +
{tmpl_var name='origin_txt'}: e.g. mydomain.com.