Skip to content

Commit 59f8848

Browse files
author
thom
committed
Add DNAME record (#1848)
1 parent 488bbdd commit 59f8848

File tree

13 files changed

+297
-7
lines changed

13 files changed

+297
-7
lines changed

install/sql/incremental/upd_dev_collection.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ ALTER TABLE `mail_user` ADD `disablequota-status` ENUM('n','y') CHARACTER SET ut
3333
-- add disableindexer-worker for solr search
3434
ALTER TABLE `mail_user` ADD `disableindexer-worker` ENUM('n','y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'n' AFTER `disablequota-status`;
3535

36-
-- add SSHFP record
37-
ALTER TABLE `dns_rr` CHANGE `type` `type` ENUM('A','AAAA','ALIAS','CNAME', 'CAA','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','SSHFP','TXT','TLSA','DNSKEY') NULL DEFAULT NULL AFTER `name`;
36+
-- add SSHFP and DNAME record
37+
ALTER TABLE `dns_rr` CHANGE `type` `type` ENUM('A','AAAA','ALIAS','CNAME','DNAME','CAA','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','SSHFP','TXT','TLSA','DNSKEY') NULL DEFAULT NULL AFTER `name`;

install/sql/ispconfig3.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ CREATE TABLE `dns_rr` (
488488
`server_id` int(11) NOT NULL default '1',
489489
`zone` int(11) unsigned NOT NULL DEFAULT '0',
490490
`name` varchar(255) NOT NULL DEFAULT '',
491-
`type` enum('A','AAAA','ALIAS','CNAME','CAA','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','SSHFP','TXT','TLSA','DNSKEY') default NULL,
491+
`type` enum('A','AAAA','ALIAS','CNAME','DNAME','CAA','DS','HINFO','LOC','MX','NAPTR','NS','PTR','RP','SRV','SSHFP','TXT','TLSA','DNSKEY') default NULL,
492492
`data` TEXT NOT NULL,
493493
`aux` int(11) unsigned NOT NULL default '0',
494494
`ttl` int(11) unsigned NOT NULL default '3600',

interface/lib/classes/remote.d/dns.inc.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,28 @@ public function dns_cname_delete($session_id, $primary_id, $update_serial=false)
472472

473473
// ----------------------------------------------------------------------------------------------------------------
474474

475+
//* Get record details
476+
public function dns_cname_get($session_id, $primary_id) {
477+
return $this->dns_rr_get($session_id, $primary_id, 'DNAME');
478+
}
479+
480+
//* Add a record
481+
public function dns_dname_add($session_id, $client_id, $params, $update_serial=false) {
482+
return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'DNAME');
483+
}
484+
485+
//* Update a record
486+
public function dns_dname_update($session_id, $client_id, $primary_id, $params, $update_serial=false) {
487+
return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'DNAME');
488+
}
489+
490+
//* Delete a record
491+
public function dns_dname_delete($session_id, $primary_id, $update_serial=false) {
492+
return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'DNAME');
493+
}
494+
495+
// ----------------------------------------------------------------------------------------------------------------
496+
475497
//* Get record details
476498
public function dns_hinfo_get($session_id, $primary_id) {
477499
return $this->dns_rr_get($session_id, $primary_id, 'HINFO');

interface/web/dns/dns_a_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class page_action extends dns_page_action {
4848
protected function checkDuplicate() {
4949
global $app;
5050
//* Check for duplicates where IP and hostname are the same
51-
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'A' AND name = ? AND zone = ? and data = ? and id != ?) OR (type = 'CNAME' AND name = ? AND zone = ? and id != ?)", $this->dataRecord["name"], $this->dataRecord["zone"], $this->dataRecord["data"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id);
51+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'A' AND name = ? AND zone = ? and data = ? and id != ?) OR (type = 'CNAME' AND name = ? AND zone = ? and id != ?) OR (type = 'DNAME' AND name = ? AND zone = ? and id != ?)", $this->dataRecord["name"], $this->dataRecord["zone"], $this->dataRecord["data"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id);
5252
if($tmp['number'] > 0) return true;
5353
return false;
5454
}

interface/web/dns/dns_aaaa_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class page_action extends dns_page_action {
4848
protected function checkDuplicate() {
4949
global $app;
5050
//* Check for duplicates where IP and hostname are the same
51-
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'AAAA' AND name = ? AND zone = ? and data = ? and id != ?) OR (type = 'CNAME' AND name = ? AND zone = ? and id != ?)", $this->dataRecord["name"], $this->dataRecord["zone"], $this->dataRecord["data"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id);
51+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'AAAA' AND name = ? AND zone = ? and data = ? and id != ?) OR (type = 'CNAME' AND name = ? AND zone = ? and id != ?) OR (type = 'DNAME' AND name = ? AND zone = ? and id != ?)", $this->dataRecord["name"], $this->dataRecord["zone"], $this->dataRecord["data"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id);
5252
if($tmp['number'] > 0) return true;
5353
return false;
5454
}

interface/web/dns/dns_cname_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class page_action extends dns_page_action {
4848
protected function checkDuplicate() {
4949
global $app;
5050
//* Check for duplicates where IP and hostname are the same
51-
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'A' AND name = ? AND zone = ? and id != ?) OR (type = 'AAAA' AND name = ? AND zone = ? and id != ?) OR (type = 'CNAME' AND name = ? AND zone = ? and id != ?)", $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id);
51+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'A' AND name = ? AND zone = ? and id != ?) OR (type = 'AAAA' AND name = ? AND zone = ? and id != ?) OR (type = 'CNAME' AND name = ? AND zone = ? and id != ?) OR (type = 'DNAME' AND name = ? AND zone = ? and id != ?)", $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id);
5252
if($tmp['number'] > 0) return true;
5353
return false;
5454
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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_dname.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+
require_once './dns_edit_base.php';
44+
45+
// Loading classes
46+
class page_action extends dns_page_action {
47+
48+
protected function checkDuplicate() {
49+
global $app;
50+
//* Check for duplicates where IP and hostname are the same
51+
$tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'A' AND name = ? AND zone = ? and id != ?) OR (type = 'AAAA' AND name = ? AND zone = ? and id != ?) OR (type = 'CNAME' AND name = ? AND zone = ? and id != ?) OR (type = 'DNAME' AND name = ? AND zone = ? and id != ?)", $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id, $this->dataRecord["name"], $this->dataRecord["zone"], $this->id);
52+
if($tmp['number'] > 0) return true;
53+
return false;
54+
}
55+
}
56+
57+
$page = new page_action;
58+
$page->onLoad();
59+
60+
?>
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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+
global $app;
36+
37+
$form["title"] = "DNS DNAME";
38+
$form["description"] = "";
39+
$form["name"] = "dns_dname";
40+
$form["action"] = "dns_dname_edit.php";
41+
$form["db_table"] = "dns_rr";
42+
$form["db_table_idx"] = "id";
43+
$form["db_history"] = "yes";
44+
$form["tab_default"] = "dns";
45+
$form["list_default"] = "dns_a_list.php";
46+
$form["auth"] = 'yes'; // yes / no
47+
48+
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
49+
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
50+
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
51+
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
52+
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
53+
54+
$form["tabs"]['dns'] = array (
55+
'title' => "DNS DNAME",
56+
'width' => 100,
57+
'template' => "templates/dns_dname_edit.htm",
58+
'fields' => array (
59+
//#################################
60+
// Begin Datatable fields
61+
//#################################
62+
'server_id' => array (
63+
'datatype' => 'INTEGER',
64+
'formtype' => 'SELECT',
65+
'default' => '',
66+
'value' => '',
67+
'width' => '30',
68+
'maxlength' => '255'
69+
),
70+
'zone' => array (
71+
'datatype' => 'INTEGER',
72+
'formtype' => 'TEXT',
73+
'default' => @$app->functions->intval($_REQUEST["zone"]),
74+
'value' => '',
75+
'width' => '30',
76+
'maxlength' => '255'
77+
),
78+
'name' => array (
79+
'datatype' => 'VARCHAR',
80+
'formtype' => 'TEXT',
81+
'filters' => array( 0 => array( 'event' => 'SAVE',
82+
'type' => 'IDNTOASCII'),
83+
1 => array( 'event' => 'SHOW',
84+
'type' => 'IDNTOUTF8'),
85+
2 => array( 'event' => 'SAVE',
86+
'type' => 'TOLOWER')
87+
),
88+
'validators' => array ( 0 => array ( 'type' => 'REGEX',
89+
'regex' => '/^[a-zA-Z0-9\.\-\*\_]{0,255}$/',
90+
'errmsg'=> 'name_error_regex'),
91+
),
92+
'default' => '',
93+
'value' => '',
94+
'width' => '30',
95+
'maxlength' => '255'
96+
),
97+
'type' => array (
98+
'datatype' => 'VARCHAR',
99+
'formtype' => 'TEXT',
100+
'default' => 'DNAME',
101+
'value' => '',
102+
'width' => '5',
103+
'maxlength' => '5'
104+
),
105+
'data' => array (
106+
'datatype' => 'VARCHAR',
107+
'formtype' => 'TEXT',
108+
'filters' => array( 0 => array( 'event' => 'SAVE',
109+
'type' => 'IDNTOASCII'),
110+
1 => array( 'event' => 'SHOW',
111+
'type' => 'IDNTOUTF8'),
112+
2 => array( 'event' => 'SAVE',
113+
'type' => 'TOLOWER')
114+
),
115+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
116+
'errmsg'=> 'data_error_empty'),
117+
1 => array ( 'type' => 'REGEX',
118+
'regex' => '/^[a-zA-Z0-9\.\-\_]{1,255}$/',
119+
'errmsg'=> 'data_error_regex'),
120+
),
121+
'default' => '',
122+
'value' => '',
123+
'width' => '30',
124+
'maxlength' => '255'
125+
),
126+
/*
127+
'aux' => array (
128+
'datatype' => 'INTEGER',
129+
'formtype' => 'TEXT',
130+
'default' => '0',
131+
'value' => '',
132+
'width' => '10',
133+
'maxlength' => '10'
134+
),
135+
*/
136+
'ttl' => array (
137+
'datatype' => 'INTEGER',
138+
'formtype' => 'TEXT',
139+
'validators' => array ( 0 => array ( 'type' => 'RANGE',
140+
'range' => '60:',
141+
'errmsg'=> 'ttl_range_error'),
142+
),
143+
'default' => '3600',
144+
'value' => '',
145+
'width' => '10',
146+
'maxlength' => '10'
147+
),
148+
'active' => array (
149+
'datatype' => 'VARCHAR',
150+
'formtype' => 'CHECKBOX',
151+
'default' => 'Y',
152+
'value' => array(0 => 'N', 1 => 'Y')
153+
),
154+
'stamp' => array (
155+
'datatype' => 'VARCHAR',
156+
'formtype' => 'TEXT',
157+
'default' => '',
158+
'value' => '',
159+
'width' => '30',
160+
'maxlength' => '255'
161+
),
162+
'serial' => array (
163+
'datatype' => 'INTEGER',
164+
'formtype' => 'TEXT',
165+
'default' => '',
166+
'value' => '',
167+
'width' => '10',
168+
'maxlength' => '10'
169+
),
170+
//#################################
171+
// END Datatable fields
172+
//#################################
173+
)
174+
);
175+
176+
177+
178+
?>

interface/web/dns/lib/remote.conf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
$function_list['dns_alias_get,dns_alias_add,dns_alias_update,dns_alias_delete'] = 'DNS alias functions';
77
$function_list['dns_caa_get,dns_caa_add,dns_caa_update,dns_caa_delete'] = 'DNS caa functions';
88
$function_list['dns_cname_get,dns_cname_add,dns_cname_update,dns_cname_delete'] = 'DNS cname functions';
9+
$function_list['dns_dname_get,dns_dname_add,dns_dname_update,dns_dname_delete'] = 'DNS dname functions';
910
$function_list['dns_ds_get,dns_ds_add,dns_ds_update,dns_ds_delete'] = 'DNS ds functions';
1011
$function_list['dns_hinfo_get,dns_hinfo_add,dns_hinfo_update,dns_hinfo_delete'] = 'DNS hinfo functions';
1112
$function_list['dns_loc_get,dns_loc_add,dns_loc_update,dns_loc_delete'] = 'DNS loc functions';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
'prefix' => "",
133133
'suffix' => "",
134134
'width' => "",
135-
'value' => array('A'=>'A', 'AAAA' => 'AAAA', 'ALIAS'=>'ALIAS', 'CAA'=>'CAA', 'CNAME'=>'CNAME', 'DS'=>'DS', 'HINFO'=>'HINFO', 'LOC'=>'LOC', 'MX'=>'MX', 'NAPTR'=>'NAPTR', 'NS'=>'NS', 'PTR'=>'PTR', 'RP'=>'RP', 'SRV'=>'SRV', 'SSHFP'=>'SSHFP', 'TLSA'=>'TLSA', 'TXT'=>'TXT'));
135+
'value' => array('A'=>'A', 'AAAA' => 'AAAA', 'ALIAS'=>'ALIAS', 'CAA'=>'CAA', 'CNAME'=>'CNAME', 'DNAME'=>'DNAME', 'DS'=>'DS', 'HINFO'=>'HINFO', 'LOC'=>'LOC', 'MX'=>'MX', 'NAPTR'=>'NAPTR', 'NS'=>'NS', 'PTR'=>'PTR', 'RP'=>'RP', 'SRV'=>'SRV', 'SSHFP'=>'SSHFP', 'TLSA'=>'TLSA', 'TXT'=>'TXT'));
136136

137137

138138
?>

0 commit comments

Comments
 (0)