Skip to content

Commit 4522e0b

Browse files
author
Kristan Kenney
committed
Enable changes to DNS record name/type after creation
1 parent 8cc7147 commit 4522e0b

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

bin/v-change-dns-record

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ user=$1
1414
domain=$2
1515
domain_idn=$2
1616
id=$3
17-
dvalue=$(idn -t --quiet -u "$4" )
18-
priority=$5
19-
restart=$6
17+
record=$4
18+
type=$5
19+
dvalue=$(idn -t --quiet -u "$6" )
20+
priority=$7
21+
restart=$8
2022

2123
# Includes
2224
source $HESTIA/func/main.sh
@@ -33,8 +35,8 @@ format_domain_idn
3335
# Verifications #
3436
#----------------------------------------------------------#
3537

36-
check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY] [RESTART]'
37-
is_format_valid 'user' 'domain' 'id' 'dvalue'
38+
check_args '6' "$#" 'USER DOMAIN ID RECORD TYPE VALUE [PRIORITY] [RESTART]'
39+
is_format_valid 'user' 'domain' 'id' 'record' 'type' 'dvalue'
3840
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
3941
is_object_valid 'user' 'USER' "$user"
4042
is_object_unsuspended 'user' 'USER' "$user"
@@ -77,7 +79,7 @@ time=$(echo "$time_n_date" |cut -f 1 -d \ )
7779
date=$(echo "$time_n_date" |cut -f 2 -d \ )
7880

7981
# Adding record
80-
dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'"
82+
dns_rec="ID='$id' RECORD='$record' TYPE='$type' PRIORITY='$priority'"
8183
dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$time' DATE='$date'"
8284
echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
8385

web/edit/dns/index.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,21 @@
156156
$v_record_id = escapeshellarg($_POST['v_record_id']);
157157

158158
// Change dns record
159-
if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) {
159+
if (($v_rec != $_POST['v_rec']) || ($v_type != $_POST['v_type']) || ($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) {
160+
$v_rec = escapeshellarg($_POST['v_rec']);
161+
$v_type = escapeshellarg($_POST['v_type']);
160162
$v_val = escapeshellarg($_POST['v_val']);
161163
$v_priority = escapeshellarg($_POST['v_priority']);
162-
exec (HESTIA_CMD."v-change-dns-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var);
164+
exec (HESTIA_CMD."v-change-dns-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var);
163165
check_return_code($return_var,$output);
166+
$v_rec = $_POST['v_rec'];
167+
$v_type = $_POST['v_type'];
164168
$v_val = $_POST['v_val'];
165169
unset($output);
166170
$restart_dns = 'yes';
167171
}
168172

173+
169174
// Change dns record id
170175
if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) {
171176
$v_old_record_id = escapeshellarg($_GET['record_id']);

web/templates/admin/edit_dns_rec.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</tr>
6969
<tr>
7070
<td>
71-
<input type="text" size="20" class="vst-input" name="v_rec" value="<?=htmlentities(trim($v_rec, "'"))?>" disabled>
71+
<input type="text" size="20" class="vst-input" name="v_rec" value="<?=htmlentities(trim($v_rec, "'"))?>">
7272
<input type="hidden" name="v_record_id" value="<?=htmlentities($v_record_id)?>">
7373
</td>
7474
</tr>
@@ -79,7 +79,22 @@
7979
</tr>
8080
<tr>
8181
<td>
82-
<input type="text" size="20" class="vst-input" name="v_type" value="<?=htmlentities(trim($v_type, "'"))?>" disabled>
82+
<select class="vst-list" name="v_type">
83+
<option value="A" <?php if ($v_type == 'A') echo selected; ?>>A</option>
84+
<option value="AAAA" <?php if ($v_type == 'AAAA') echo selected; ?>>AAAA</option>
85+
<option value="NS" <?php if ($v_type == 'NS') echo selected; ?>>NS</option>
86+
<option value="CNAME" <?php if ($v_type == 'CNAME') echo selected; ?>>CNAME</option>
87+
<option value="MX" <?php if ($v_type == 'MX') echo selected; ?>>MX</option>
88+
<option value="TXT" <?php if ($v_type == 'TXT') echo selected; ?>>TXT</option>
89+
<option value="SRV" <?php if ($v_type == 'SRV') echo selected; ?>>SRV</option>
90+
<option value="DNSKEY" <?php if ($v_type == 'DNSKEY') echo selected; ?>>DNSKEY</option>
91+
<option value="KEY" <?php if ($v_type == 'KEY') echo selected; ?>>KEY</option>
92+
<option value="IPSECKEY" <?php if ($v_type == 'IPSECKEY') echo selected; ?>>IPSECKEY</option>
93+
<option value="PTR" <?php if ($v_type == 'PTR') echo selected; ?>>PTR</option>
94+
<option value="SPF" <?php if ($v_type == 'SPF') echo selected; ?>>SPF</option>
95+
<option value="TLSA" <?php if ($v_type == 'TLSA') echo selected; ?>>TLSA</option>
96+
<option value="CAA" <?php if ($v_type == 'CAA') echo selected; ?>>CAA</option>
97+
</select>
8398
</td>
8499
</tr>
85100
<tr>

0 commit comments

Comments
 (0)