Browse Source

Enable changes to DNS record name/type after creation

Kristan Kenney 6 years ago
parent
commit
acad134833
3 changed files with 32 additions and 10 deletions
  1. 8 6
      bin/v-change-dns-record
  2. 7 2
      web/edit/dns/index.php
  3. 17 2
      web/templates/admin/edit_dns_rec.html

+ 8 - 6
bin/v-change-dns-record

@@ -14,9 +14,11 @@ user=$1
 domain=$2
 domain=$2
 domain_idn=$2
 domain_idn=$2
 id=$3
 id=$3
-dvalue=$(idn -t --quiet -u "$4" )
-priority=$5
-restart=$6
+record=$4
+type=$5
+dvalue=$(idn -t --quiet -u "$6" )
+priority=$7
+restart=$8
 
 
 # Includes
 # Includes
 source $HESTIA/func/main.sh
 source $HESTIA/func/main.sh
@@ -33,8 +35,8 @@ format_domain_idn
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY] [RESTART]'
-is_format_valid 'user' 'domain' 'id' 'dvalue'
+check_args '6' "$#" 'USER DOMAIN ID RECORD TYPE VALUE [PRIORITY] [RESTART]'
+is_format_valid 'user' 'domain' 'id' 'record' 'type' 'dvalue'
 is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
 is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
@@ -77,7 +79,7 @@ time=$(echo "$time_n_date" |cut -f 1 -d \ )
 date=$(echo "$time_n_date" |cut -f 2 -d \ )
 date=$(echo "$time_n_date" |cut -f 2 -d \ )
 
 
 # Adding record
 # Adding record
-dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'"
+dns_rec="ID='$id' RECORD='$record' TYPE='$type' PRIORITY='$priority'"
 dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$time' DATE='$date'"
 dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$time' DATE='$date'"
 echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
 echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
 
 

+ 7 - 2
web/edit/dns/index.php

@@ -156,16 +156,21 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['reco
     $v_record_id = escapeshellarg($_POST['v_record_id']);
     $v_record_id = escapeshellarg($_POST['v_record_id']);
 
 
     // Change dns record
     // Change dns record
-    if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) {
+    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']))) {
+        $v_rec = escapeshellarg($_POST['v_rec']);
+        $v_type = escapeshellarg($_POST['v_type']);
         $v_val = escapeshellarg($_POST['v_val']);
         $v_val = escapeshellarg($_POST['v_val']);
         $v_priority = escapeshellarg($_POST['v_priority']);
         $v_priority = escapeshellarg($_POST['v_priority']);
-        exec (HESTIA_CMD."v-change-dns-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var);
+        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);
         check_return_code($return_var,$output);
         check_return_code($return_var,$output);
+        $v_rec = $_POST['v_rec'];
+        $v_type = $_POST['v_type'];
         $v_val = $_POST['v_val'];
         $v_val = $_POST['v_val'];
         unset($output);
         unset($output);
         $restart_dns = 'yes';
         $restart_dns = 'yes';
     }
     }
 
 
+
     // Change dns record id
     // Change dns record id
     if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) {
     if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) {
         $v_old_record_id = escapeshellarg($_GET['record_id']);
         $v_old_record_id = escapeshellarg($_GET['record_id']);

+ 17 - 2
web/templates/admin/edit_dns_rec.html

@@ -68,7 +68,7 @@
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <td>
                                 <td>
-                                  <input type="text" size="20" class="vst-input" name="v_rec" value="<?=htmlentities(trim($v_rec, "'"))?>" disabled>
+                                  <input type="text" size="20" class="vst-input" name="v_rec" value="<?=htmlentities(trim($v_rec, "'"))?>">
                                   <input type="hidden" name="v_record_id" value="<?=htmlentities($v_record_id)?>">
                                   <input type="hidden" name="v_record_id" value="<?=htmlentities($v_record_id)?>">
                                 </td>
                                 </td>
                             </tr>
                             </tr>
@@ -79,7 +79,22 @@
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <td>
                                 <td>
-                                    <input type="text" size="20" class="vst-input" name="v_type" value="<?=htmlentities(trim($v_type, "'"))?>" disabled>
+                                    <select class="vst-list" name="v_type">
+                                        <option value="A" <?php if ($v_type == 'A') echo selected; ?>>A</option>
+                                        <option value="AAAA" <?php if ($v_type == 'AAAA') echo selected; ?>>AAAA</option>
+                                        <option value="NS" <?php if ($v_type == 'NS') echo selected; ?>>NS</option>
+                                        <option value="CNAME" <?php if ($v_type == 'CNAME') echo selected; ?>>CNAME</option>
+                                        <option value="MX" <?php if ($v_type == 'MX') echo selected; ?>>MX</option>
+                                        <option value="TXT" <?php if ($v_type == 'TXT') echo selected; ?>>TXT</option>
+                                        <option value="SRV" <?php if ($v_type == 'SRV') echo selected; ?>>SRV</option>
+                                        <option value="DNSKEY" <?php if ($v_type == 'DNSKEY') echo selected; ?>>DNSKEY</option>
+                                        <option value="KEY" <?php if ($v_type == 'KEY') echo selected; ?>>KEY</option>
+                                        <option value="IPSECKEY" <?php if ($v_type == 'IPSECKEY') echo selected; ?>>IPSECKEY</option>
+                                        <option value="PTR" <?php if ($v_type == 'PTR') echo selected; ?>>PTR</option>
+                                        <option value="SPF" <?php if ($v_type == 'SPF') echo selected; ?>>SPF</option>
+                                        <option value="TLSA" <?php if ($v_type == 'TLSA') echo selected; ?>>TLSA</option>
+                                        <option value="CAA" <?php if ($v_type == 'CAA') echo selected; ?>>CAA</option>
+                                    </select>
                                 </td>
                                 </td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>