Skip to content

Commit 830d119

Browse files
committed
- Added AAAA records to the DNS-Manager.
1 parent e6e4454 commit 830d119

File tree

6 files changed

+417
-83
lines changed

6 files changed

+417
-83
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/dns_aaaa.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once('../../lib/config.inc.php');
42+
require_once('../../lib/app.inc.php');
43+
44+
//* Check permissions for module
45+
$app->auth->check_module_permissions('dns');
46+
47+
// Loading classes
48+
$app->uses('tpl,tform,tform_actions,validate_dns');
49+
$app->load('tform_actions');
50+
51+
class page_action extends tform_actions {
52+
53+
function onShowNew() {
54+
global $app, $conf;
55+
56+
// we will check only users, not admins
57+
if($_SESSION["s"]["user"]["typ"] == 'user') {
58+
59+
// Get the limits of the client
60+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
61+
$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");
62+
63+
// Check if the user may add another mailbox.
64+
if($client["limit_dns_record"] >= 0) {
65+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
66+
if($tmp["number"] >= $client["limit_dns_record"]) {
67+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
68+
}
69+
}
70+
}
71+
72+
parent::onShowNew();
73+
}
74+
75+
function onSubmit() {
76+
global $app, $conf;
77+
78+
// Get the parent soa record of the domain
79+
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
80+
81+
// Check if Domain belongs to user
82+
if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
83+
84+
// Check the client limits, if user is not the admin
85+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
86+
// Get the limits of the client
87+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
88+
$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");
89+
90+
// Check if the user may add another mailbox.
91+
if($this->id == 0 && $client["limit_dns_record"] >= 0) {
92+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id");
93+
if($tmp["number"] >= $client["limit_dns_record"]) {
94+
$app->error($app->tform->wordbook["limit_dns_record_txt"]);
95+
}
96+
}
97+
} // end if user is not admin
98+
99+
100+
// Set the server ID of the rr record to the same server ID as the parent record.
101+
$this->dataRecord["server_id"] = $soa["server_id"];
102+
103+
parent::onSubmit();
104+
}
105+
106+
function onAfterInsert() {
107+
global $app, $conf;
108+
109+
//* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
110+
$soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
111+
$app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
112+
113+
//* Update the serial number of the SOA record
114+
$soa_id = intval($_POST["zone"]);
115+
$serial = $app->validate_dns->increase_serial($soa["serial"]);
116+
$app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
117+
}
118+
119+
function onAfterUpdate() {
120+
global $app, $conf;
121+
122+
//* Update the serial number of the SOA record
123+
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
124+
$soa_id = intval($_POST["zone"]);
125+
$serial = $app->validate_dns->increase_serial($soa["serial"]);
126+
$app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
127+
}
128+
129+
}
130+
131+
$page = new page_action;
132+
$page->onLoad();
133+
134+
?>
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
3+
/*
4+
Form Definition
5+
6+
Tabledefinition
7+
8+
Datatypes:
9+
- INTEGER (Forces the input to Int)
10+
- DOUBLE
11+
- CURRENCY (Formats the values to currency notation)
12+
- VARCHAR (no format check, maxlength: 255)
13+
- TEXT (no format check)
14+
- DATE (Dateformat, automatic conversion to timestamps)
15+
16+
Formtype:
17+
- TEXT (Textfield)
18+
- TEXTAREA (Textarea)
19+
- PASSWORD (Password textfield, input is not shown when edited)
20+
- SELECT (Select option field)
21+
- RADIO
22+
- CHECKBOX
23+
- CHECKBOXARRAY
24+
- FILE
25+
26+
VALUE:
27+
- Wert oder Array
28+
29+
Hint:
30+
The ID field of the database table is not part of the datafield definition.
31+
The ID field must be always auto incement (int or bigint).
32+
33+
34+
*/
35+
36+
$form["title"] = "DNS AAAA";
37+
$form["description"] = "";
38+
$form["name"] = "dns_aaaa";
39+
$form["action"] = "dns_aaaa_edit.php";
40+
$form["db_table"] = "dns_rr";
41+
$form["db_table_idx"] = "id";
42+
$form["db_history"] = "yes";
43+
$form["tab_default"] = "dns";
44+
$form["list_default"] = "dns_a_list.php";
45+
$form["auth"] = 'yes'; // yes / no
46+
47+
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
48+
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
49+
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
50+
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
51+
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
52+
53+
$form["tabs"]['dns'] = array (
54+
'title' => "DNS AAAA",
55+
'width' => 100,
56+
'template' => "templates/dns_aaaa_edit.htm",
57+
'fields' => array (
58+
##################################
59+
# Begin Datatable fields
60+
##################################
61+
'server_id' => array (
62+
'datatype' => 'INTEGER',
63+
'formtype' => 'SELECT',
64+
'default' => '',
65+
'value' => '',
66+
'width' => '30',
67+
'maxlength' => '255'
68+
),
69+
'zone' => array (
70+
'datatype' => 'INTEGER',
71+
'formtype' => 'TEXT',
72+
'default' => @intval($_REQUEST["zone"]),
73+
'value' => '',
74+
'width' => '30',
75+
'maxlength' => '255'
76+
),
77+
'name' => array (
78+
'datatype' => 'VARCHAR',
79+
'formtype' => 'TEXT',
80+
'validators' => array ( 0 => array ( 'type' => 'REGEX',
81+
'regex' => '/^[\w\.\-\*]{0,64}$/',
82+
'errmsg'=> 'name_error_regex'),
83+
),
84+
'default' => '',
85+
'value' => '',
86+
'width' => '30',
87+
'maxlength' => '255'
88+
),
89+
'type' => array (
90+
'datatype' => 'VARCHAR',
91+
'formtype' => 'TEXT',
92+
'default' => 'AAAA',
93+
'value' => '',
94+
'width' => '5',
95+
'maxlength' => '5'
96+
),
97+
'data' => array (
98+
'datatype' => 'VARCHAR',
99+
'formtype' => 'TEXT',
100+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
101+
'errmsg'=> 'data_error_empty'),
102+
1 => array ( 'type' => 'REGEX',
103+
'regex' => '/^\s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?\s*$/',
104+
'errmsg'=> 'data_error_regex'),
105+
),
106+
'default' => '',
107+
'value' => '',
108+
'width' => '30',
109+
'maxlength' => '255'
110+
),
111+
/*
112+
'aux' => array (
113+
'datatype' => 'INTEGER',
114+
'formtype' => 'TEXT',
115+
'default' => '0',
116+
'value' => '',
117+
'width' => '10',
118+
'maxlength' => '10'
119+
),
120+
*/
121+
'ttl' => array (
122+
'datatype' => 'INTEGER',
123+
'formtype' => 'TEXT',
124+
'default' => '86400',
125+
'value' => '',
126+
'width' => '10',
127+
'maxlength' => '10'
128+
),
129+
'active' => array (
130+
'datatype' => 'VARCHAR',
131+
'formtype' => 'CHECKBOX',
132+
'default' => 'Y',
133+
'value' => array(0 => 'N',1 => 'Y')
134+
),
135+
##################################
136+
# ENDE Datatable fields
137+
##################################
138+
)
139+
);
140+
141+
142+
143+
?>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
$wb["server_id_txt"] = 'Server';
3+
$wb["zone_txt"] = 'Zone';
4+
$wb["name_txt"] = 'Hostname';
5+
$wb["type_txt"] = 'type';
6+
$wb["data_txt"] = 'IPv6-Address';
7+
$wb["ttl_txt"] = 'TTL';
8+
$wb["active_txt"] = 'Active';
9+
$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.';
10+
$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.';
11+
$wb["name_error_empty"] = 'The hostname is empty.';
12+
$wb["name_error_regex"] = 'The hostname has the wrong format.';
13+
$wb["data_error_empty"] = 'IP-Address empty';
14+
$wb["data_error_regex"] = 'IP-Address format invalid';
15+
?>

interface/web/dns/list/dns_a.list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
'prefix' => "",
122122
'suffix' => "",
123123
'width' => "",
124-
'value' => array('A'=>'A','ALIAS'=>'ALIAS','CNAME'=>'CNAME','HINFO'=>'HINFO','MX'=>'MX','NS'=>'NS','PTR'=>'PTR','RP'=>'RP','SRV'=>'SRV','TXT'=>'TXT'));
124+
'value' => array('A'=>'A','AAAA' => 'AAAA','ALIAS'=>'ALIAS','CNAME'=>'CNAME','HINFO'=>'HINFO','MX'=>'MX','NS'=>'NS','PTR'=>'PTR','RP'=>'RP','SRV'=>'SRV','TXT'=>'TXT'));
125125

126126

127127
?>

0 commit comments

Comments
 (0)