diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index b7e9cfd6794258359932a2cc2182c4cd557c1d9e..473de4b7ad1b4a1a9061f2a0734f2038e9ac260a 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 6aba152b8835e8613ad7079c260e391e6498754e..d87e2f9d9a6adbfa4780799624b69e160dbfa758 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 90472f60c65faa77511124e7c3c63951fd1adff4..435a2908d2381285692dacde44cd0d902f376727 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 979e9d951cae30ce64e719e1b3f3a1898d0e2ca4..e33d0b323367f844cabf9a36fc62099c344e7b65 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 03609bd346e157841c15b8e5acd52d4792d30029..ed143424ec1663495a98e507a9bc26cd6c76f0f9 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 8f8e0ecc48cd160023f96a8afd77ac1ea94393f5..f08280de6513d6bd6de3dcf100ea57409db6ae72 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 a9a6c32608f5eb7e3fb2973d830ec2b187296e03..7ea775cbeaeff28d76c67deca952525f02419e3a 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 891069e8436d7fa76ddc4b30248c4e66d8081476..b2286c206761fac46a62898e92acc9995fc1f5dc 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 0dc6b91821f3b083dcb06de13fd0aba2b729e9c8..d21a99f3516986f467bb6ad6d3f0c269c3af08b1 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 a7889ae2bd4cf35f8dffe545ac68a4b5105d230b..17e466777c9507087b53ad14be54cc19ea17d32c 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 e353c7ad00738ad2b3cb058b97fa226f1d8728c0..12505231975402f2fb009f794f2edfe56480874d 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 1ed15825be1c592db4e703fadea1e069072fe457..a97574a1390afdf09008c03b231e3647fd89b138 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 1a7bfa5e2b6d378f15d721ed949ec5740518f12c..f78e9aa65acec855b6a6e99b645878dcbb743e1a 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 a98733db40633850ea213897d5b5d2dd4282e247..200c03ce0e091734b0b8ebc3ae75b7adbdc59c55 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 2d3ec80981bd1576f59345d96d1a6037c3c10e00..d8e7da1e7fb885723165722b4cbc6931c83b35d3 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 cf5f0d1d232998e2ab0de771f8dc60988c7914c3..89ff4f9220de85b8abe85e86e5eedc6d754057fe 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 ca96ae5846ac8aef1ee19ad9f8b830ca81b043a4..57ce73dd79355b7cfd9e36a3d4e6ff59e5ae29e4 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 cabd47889972ff2ad4a4769dde8ec822735cd814..da211f76937690af63cea2029fd9814ab6be7b05 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 187a110339903a1bf88078bfdf4dcf8c364bec7c..d3a1b0abd1667549b8c4131c7ae115d638f205d8 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 187a110339903a1bf88078bfdf4dcf8c364bec7c..d3a1b0abd1667549b8c4131c7ae115d638f205d8 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 5b4a20463297fffff0ca4ebbc9d2d69083af9df7..e5eae739aeb1d3fa2af148382deb33ec03871966 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 55ebd0a99c940cd62d6d9584417f3be0ecb07658..ca65b42b4d2b19512afab3626e32829c42234131 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 c430cdd20fbd561913e7b79afbaed4c4116df51b..5c2792dc0443ce575e8b168b16711370fa81e0c6 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 5e7f86d2657989f1070021e4a9174a4d0cd74a93..5edf14c3164a2d9a8406a57efdbcf9239629ac70 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 2f541761d3eb871825677752a967d3fa28a46016..def925f6436ff529d0793f8cdefab5d461481c39 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 4955dff1ab78f6377544a9a8f18e12e06b5d59a1..573c795e1f43e622f5551cee5fdb5f987874198b 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 9c16bdca8bf79c2249b857fed4fb0746d4922027..92110deee11044380736e0185524cad5cc8520cb 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 89b4cc4ee6997f1e1d612dfee657515a02558796..be403445bb8208d7ded08ebebd9c78650b6d2cc9 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 7c9511a4b391a4ea35d2e2c3d03708f17dbebb19..9e6ed6c99e7321597c2a15f71b809d5ecb20a6ec 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 e5184be5508a6bcbd7f54903c718201288bf7e3a..38a22ec061908115bd991c26c3c77b8620c9fd68 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 c78e69260eeb3dfe6942c8ede58d9d801389e292..03d3ab06054cf5af6c7521a04051e5ca9c85bac2 100644 --- a/interface/web/dns/templates/dns_soa_edit.htm +++ b/interface/web/dns/templates/dns_soa_edit.htm @@ -1,4 +1,5 @@ + + + + + +
{tmpl_var name='server_id_txt'}: @@ -7,6 +8,15 @@
{tmpl_var name='client_txt'}: + +
{tmpl_var name='origin_txt'}: e.g. mydomain.com.