From 57c98161357fcef7b2369c643cd4981294d0ae40 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Sun, 19 May 2013 15:00:08 +0300 Subject: [PATCH] record order change functionality --- bin/v-change-dns-domain-record-id | 67 +++++++++++++++++++++++++++ func/main.sh | 1 + web/edit/dns/index.php | 18 +++++++ web/inc/i18n/en.php | 2 + web/inc/i18n/es.php | 2 + web/inc/i18n/ro.php | 2 + web/inc/i18n/ru.php | 2 + web/inc/i18n/ua.php | 2 + web/templates/admin/edit_dns_rec.html | 11 +++++ 9 files changed, 107 insertions(+) create mode 100755 bin/v-change-dns-domain-record-id diff --git a/bin/v-change-dns-domain-record-id b/bin/v-change-dns-domain-record-id new file mode 100755 index 000000000..9a9b53585 --- /dev/null +++ b/bin/v-change-dns-domain-record-id @@ -0,0 +1,67 @@ +#!/bin/bash +# info: change dns domain record id +# options: USER DOMAIN ID NEWID +# +# The function for changing internal record id. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 +newid=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ID NEWID' +validate_format 'user' 'domain' 'id' 'newid' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" +is_object_new "dns/$domain" 'ID' "$newid" + + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Change id +sed -i "s/^ID='$id'/ID='$newid'/" $USER_DATA/dns/$domain.conf + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_history "changed dns record id on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/func/main.sh b/func/main.sh index b3658aa9b..fcaa553d4 100644 --- a/func/main.sh +++ b/func/main.sh @@ -784,6 +784,7 @@ validate_format(){ min) validate_format_mhdmw "$arg" $arg_name ;; month) validate_format_mhdmw "$arg" $arg_name ;; nat_ip) validate_format_ip "$arg" ;; + newid) validate_format_int "$arg" 'id' ;; ns1) validate_format_domain "$arg" 'name_server';; ns2) validate_format_domain "$arg" 'name_server';; ns3) validate_format_domain "$arg" 'name_server';; diff --git a/web/edit/dns/index.php b/web/edit/dns/index.php index 88152db3f..af7ed6a4b 100644 --- a/web/edit/dns/index.php +++ b/web/edit/dns/index.php @@ -195,9 +195,27 @@ if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) { $restart_dns = 'yes'; unset($output); } + + if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) { + $v_old_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-change-dns-domain-record-id ".$v_username." ".$v_domain." ".$v_old_record_id." ".$v_record_id, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = __('Error code:',$return_var); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { $_SESSION['ok_msg'] = __('Changes has been saved.'); } + + if ($_GET['record_id'] != $_POST['v_record_id']) { + header("Location: /edit/dns/?domain=".$_GET['domain']."&record_id=".$_POST['v_record_id']); + exit; + } } include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); diff --git a/web/inc/i18n/en.php b/web/inc/i18n/en.php index d65425646..097c16a65 100644 --- a/web/inc/i18n/en.php +++ b/web/inc/i18n/en.php @@ -239,6 +239,7 @@ $LANG['en'] = array( 'SSL Key' => 'SSL Key', 'SSL Certificate Authority / Intermediate' => 'SSL Certificate Authority / Intermediate', 'optional' => 'optional', + 'internal' => 'internal', 'Statistics Authorization' => 'Statistics Authorization', 'Statistics Auth' => 'Statistics Auth', 'Account' => 'Account', @@ -250,6 +251,7 @@ $LANG['en'] = array( 'Record' => 'Record', 'IP or Value' => 'IP or Value', 'Priority' => 'Priority', + 'Record Number' => 'Record Number', 'in megabytes' => 'in megabytes', 'Message' => 'Message', 'use local-part' => 'use local-part', diff --git a/web/inc/i18n/es.php b/web/inc/i18n/es.php index cc34446e2..eee982a9e 100644 --- a/web/inc/i18n/es.php +++ b/web/inc/i18n/es.php @@ -238,6 +238,7 @@ $LANG['es'] = array( 'SSL Key' => 'Llave SSL', 'SSL Certificate Authority / Intermediate' => 'Certificado SSL Autoridad / Intermedio', 'optional' => 'opcional', + 'internal' => 'interno', 'Statistics Authorization' => 'Autorización de Estadísticas', 'Statistics Auth' => 'Estadística Auth', 'Account' => 'Cuenta', @@ -249,6 +250,7 @@ $LANG['es'] = array( 'Record' => 'Registro', 'IP or Value' => 'IP o Valor', 'Priority' => 'Prioridad', + 'Record Number' => 'Número de registro', 'in megabytes' => 'en megabytes', 'Message' => 'Mensaje', 'use local-part' => 'usar parte-local', diff --git a/web/inc/i18n/ro.php b/web/inc/i18n/ro.php index 972ffd648..f5b43e81c 100644 --- a/web/inc/i18n/ro.php +++ b/web/inc/i18n/ro.php @@ -240,6 +240,7 @@ $LANG['ro'] = array( 'SSL Key' => 'Cheia SSL', 'SSL Certificate Authority / Intermediate' => 'SSL Intermediar / Certificate Authority', 'optional' => 'opțional', + 'internal' => 'intern', 'Statistics Authorization' => 'Autorizarea statistici', 'Statistics Auth' => 'Autorizarea statistici', 'Account' => 'Cont', @@ -251,6 +252,7 @@ $LANG['ro'] = array( 'Record' => 'Înregistrare / Subdomeniu', 'IP or Value' => 'IP adresa sau valoare', 'Priority' => 'Prioritate', + 'Record Number' => 'Numărul de înregistrare', 'in megabytes' => 'în mb.', 'Message' => 'Mesaj', 'use local-part' => 'doar nume de cont înainte de @', diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index ac4467737..0afa722ac 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -240,6 +240,7 @@ $LANG['ru'] = array( 'SSL Key' => 'Ключ SSL сертификата', 'SSL Certificate Authority / Intermediate' => 'Центр сертификации SSL / Intermediate', 'optional' => 'опционально', + 'internal' => 'внутренний', 'Statistics Authorization' => 'Ограниченный доступ к статистике', 'Statistics Auth' => 'Авторизация Статистики', 'Account' => 'Аккаунт', @@ -251,6 +252,7 @@ $LANG['ru'] = array( 'Record' => 'Запись / Поддомен', 'IP or Value' => 'IP адрес или значение', 'Priority' => 'Приоритет', + 'Record Number' => 'Порядковый номер', 'in megabytes' => 'в мегабайтах', 'Message' => 'Сообщение', 'use local-part' => 'используйте только имена аккаунтов', diff --git a/web/inc/i18n/ua.php b/web/inc/i18n/ua.php index 43b696310..85c80ee59 100644 --- a/web/inc/i18n/ua.php +++ b/web/inc/i18n/ua.php @@ -240,6 +240,7 @@ $LANG['ua'] = array( 'SSL Key' => 'Ключ SSL сертифікату', 'SSL Certificate Authority / Intermediate' => 'Центр сертифікації SSL / Intermediate', 'optional' => 'опційно', + 'internal' => 'внутрішній', 'Statistics Authorization' => 'Обмежений доступ до статистики', 'Statistics Auth' => 'Авторизація Статистики', 'Account' => 'Акаунт', @@ -251,6 +252,7 @@ $LANG['ua'] = array( 'Record' => 'запис / Піддомен', 'IP or Value' => 'IP адреса або Значення', 'Priority' => 'Пріоритет', + 'Record Number' => 'Порядковий номер', 'in megabytes' => 'в мегабайтах', 'Message' => 'Повідомлення', 'use local-part' => 'використовуйте тільки імена акаунтів', diff --git a/web/templates/admin/edit_dns_rec.html b/web/templates/admin/edit_dns_rec.html index 14bf72bcb..fa95bd5dd 100644 --- a/web/templates/admin/edit_dns_rec.html +++ b/web/templates/admin/edit_dns_rec.html @@ -98,6 +98,17 @@ + () + + + + +