Skip to content

Commit 57c9816

Browse files
committed
record order change functionality
1 parent 11eef69 commit 57c9816

File tree

9 files changed

+107
-0
lines changed

9 files changed

+107
-0
lines changed

bin/v-change-dns-domain-record-id

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
# info: change dns domain record id
3+
# options: USER DOMAIN ID NEWID
4+
#
5+
# The function for changing internal record id.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$(idn -t --quiet -u "$2" )
15+
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
16+
domain_idn=$(idn -t --quiet -a "$domain")
17+
id=$3
18+
newid=$4
19+
20+
# Includes
21+
source $VESTA/conf/vesta.conf
22+
source $VESTA/func/main.sh
23+
source $VESTA/func/domain.sh
24+
25+
26+
#----------------------------------------------------------#
27+
# Verifications #
28+
#----------------------------------------------------------#
29+
30+
check_args '4' "$#" 'USER DOMAIN ID NEWID'
31+
validate_format 'user' 'domain' 'id' 'newid'
32+
is_system_enabled "$DNS_SYSTEM"
33+
is_object_valid 'user' 'USER' "$user"
34+
is_object_unsuspended 'user' 'USER' "$user"
35+
is_object_valid 'dns' 'DOMAIN' "$domain"
36+
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
37+
is_object_valid "dns/$domain" 'ID' "$id"
38+
is_object_new "dns/$domain" 'ID' "$newid"
39+
40+
41+
42+
#----------------------------------------------------------#
43+
# Action #
44+
#----------------------------------------------------------#
45+
46+
# Change id
47+
sed -i "s/^ID='$id'/ID='$newid'/" $USER_DATA/dns/$domain.conf
48+
49+
# Sorting records
50+
sort_dns_records
51+
52+
# Updating zone
53+
update_domain_zone
54+
55+
56+
#----------------------------------------------------------#
57+
# Vesta #
58+
#----------------------------------------------------------#
59+
60+
# Restart named
61+
$BIN/v-restart-dns "$EVENT"
62+
63+
# Logging
64+
log_history "changed dns record id on $domain"
65+
log_event "$OK" "$EVENT"
66+
67+
exit

func/main.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ validate_format(){
784784
min) validate_format_mhdmw "$arg" $arg_name ;;
785785
month) validate_format_mhdmw "$arg" $arg_name ;;
786786
nat_ip) validate_format_ip "$arg" ;;
787+
newid) validate_format_int "$arg" 'id' ;;
787788
ns1) validate_format_domain "$arg" 'name_server';;
788789
ns2) validate_format_domain "$arg" 'name_server';;
789790
ns3) validate_format_domain "$arg" 'name_server';;

web/edit/dns/index.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,27 @@
195195
$restart_dns = 'yes';
196196
unset($output);
197197
}
198+
199+
if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) {
200+
$v_old_record_id = escapeshellarg($_GET['record_id']);
201+
exec (VESTA_CMD."v-change-dns-domain-record-id ".$v_username." ".$v_domain." ".$v_old_record_id." ".$v_record_id, $output, $return_var);
202+
if ($return_var != 0) {
203+
$error = implode('<br>', $output);
204+
if (empty($error)) $error = __('Error code:',$return_var);
205+
$_SESSION['error_msg'] = $error;
206+
}
207+
unset($output);
208+
}
209+
210+
198211
if (empty($_SESSION['error_msg'])) {
199212
$_SESSION['ok_msg'] = __('Changes has been saved.');
200213
}
214+
215+
if ($_GET['record_id'] != $_POST['v_record_id']) {
216+
header("Location: /edit/dns/?domain=".$_GET['domain']."&record_id=".$_POST['v_record_id']);
217+
exit;
218+
}
201219
}
202220

203221
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html');

web/inc/i18n/en.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
'SSL Key' => 'SSL Key',
240240
'SSL Certificate Authority / Intermediate' => 'SSL Certificate Authority / Intermediate',
241241
'optional' => 'optional',
242+
'internal' => 'internal',
242243
'Statistics Authorization' => 'Statistics Authorization',
243244
'Statistics Auth' => 'Statistics Auth',
244245
'Account' => 'Account',
@@ -250,6 +251,7 @@
250251
'Record' => 'Record',
251252
'IP or Value' => 'IP or Value',
252253
'Priority' => 'Priority',
254+
'Record Number' => 'Record Number',
253255
'in megabytes' => 'in megabytes',
254256
'Message' => 'Message',
255257
'use local-part' => 'use local-part',

web/inc/i18n/es.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
'SSL Key' => 'Llave SSL',
239239
'SSL Certificate Authority / Intermediate' => 'Certificado SSL Autoridad / Intermedio',
240240
'optional' => 'opcional',
241+
'internal' => 'interno',
241242
'Statistics Authorization' => 'Autorización de Estadísticas',
242243
'Statistics Auth' => 'Estadística Auth',
243244
'Account' => 'Cuenta',
@@ -249,6 +250,7 @@
249250
'Record' => 'Registro',
250251
'IP or Value' => 'IP o Valor',
251252
'Priority' => 'Prioridad',
253+
'Record Number' => 'Número de registro',
252254
'in megabytes' => 'en megabytes',
253255
'Message' => 'Mensaje',
254256
'use local-part' => 'usar parte-local',

web/inc/i18n/ro.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
'SSL Key' => 'Cheia SSL',
241241
'SSL Certificate Authority / Intermediate' => 'SSL Intermediar / Certificate Authority',
242242
'optional' => 'opțional',
243+
'internal' => 'intern',
243244
'Statistics Authorization' => 'Autorizarea statistici',
244245
'Statistics Auth' => 'Autorizarea statistici',
245246
'Account' => 'Cont',
@@ -251,6 +252,7 @@
251252
'Record' => 'Înregistrare / Subdomeniu',
252253
'IP or Value' => 'IP adresa sau valoare',
253254
'Priority' => 'Prioritate',
255+
'Record Number' => 'Numărul de înregistrare',
254256
'in megabytes' => 'în mb.',
255257
'Message' => 'Mesaj',
256258
'use local-part' => 'doar nume de cont înainte de @',

web/inc/i18n/ru.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
'SSL Key' => 'Ключ SSL сертификата',
241241
'SSL Certificate Authority / Intermediate' => 'Центр сертификации SSL / Intermediate',
242242
'optional' => 'опционально',
243+
'internal' => 'внутренний',
243244
'Statistics Authorization' => 'Ограниченный доступ к статистике',
244245
'Statistics Auth' => 'Авторизация Статистики',
245246
'Account' => 'Аккаунт',
@@ -251,6 +252,7 @@
251252
'Record' => 'Запись / Поддомен',
252253
'IP or Value' => 'IP адрес или значение',
253254
'Priority' => 'Приоритет',
255+
'Record Number' => 'Порядковый номер',
254256
'in megabytes' => 'в мегабайтах',
255257
'Message' => 'Сообщение',
256258
'use local-part' => 'используйте только имена аккаунтов',

web/inc/i18n/ua.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
'SSL Key' => 'Ключ SSL сертифікату',
241241
'SSL Certificate Authority / Intermediate' => 'Центр сертифікації SSL / Intermediate',
242242
'optional' => 'опційно',
243+
'internal' => 'внутрішній',
243244
'Statistics Authorization' => 'Обмежений доступ до статистики',
244245
'Statistics Auth' => 'Авторизація Статистики',
245246
'Account' => 'Акаунт',
@@ -251,6 +252,7 @@
251252
'Record' => 'запис / Піддомен',
252253
'IP or Value' => 'IP адреса або Значення',
253254
'Priority' => 'Пріоритет',
255+
'Record Number' => 'Порядковий номер',
254256
'in megabytes' => 'в мегабайтах',
255257
'Message' => 'Повідомлення',
256258
'use local-part' => 'використовуйте тільки імена акаунтів',

web/templates/admin/edit_dns_rec.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@
9898
<input type="text" size="20" class="vst-input" name="v_priority" <?php if (!empty($v_priority)) echo "value=".$v_priority; ?>>
9999
</td>
100100
</tr>
101+
<tr>
102+
<td class="vst-text" style="padding: 10px 0 0 2px;">
103+
<?php print __('Record Number');?> <span style="padding:0 0 0 6px; font-size: 10pt; color:#555;">(<?php print __('internal');?>)</span>
104+
</td>
105+
</tr>
106+
<tr>
107+
<td>
108+
<input type="text" size="20" class="vst-input" name="v_record_id" <?php if (!empty($v_record_id)) echo "value=".$v_record_id; ?>>
109+
</td>
110+
</tr>
111+
101112
</table>
102113
<table class="data-col2">
103114
<tr>

0 commit comments

Comments
 (0)