From c6b7c0b8e08610531fbda75c8cec83a19bcd3940 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Tue, 22 Jan 2013 03:00:33 +0200 Subject: [PATCH] i18n db --- web/add/db/index.php | 86 ++++---- web/edit/db/index.php | 113 +++++----- web/inc/i18n/en.php | 5 +- web/inc/i18n/ru.php | 6 +- web/list/db/index.php | 3 + web/templates/admin/add_db.html | 349 ++++++++++++++++--------------- web/templates/admin/edit_db.html | 12 +- web/templates/admin/list_db.html | 59 +++--- 8 files changed, 318 insertions(+), 315 deletions(-) diff --git a/web/add/db/index.php b/web/add/db/index.php index 9642aa2c5..ac6eaee31 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -12,8 +12,8 @@ include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); -// Are you admin? -//if ($_SESSION['user'] == 'admin') { +$v_db_email = $panel[$user]['CONTACT']; + if (!empty($_POST['ok'])) { // Check input if (empty($_POST['v_database'])) $errors[] = _('database'); @@ -22,13 +22,18 @@ if (!empty($_POST['ok'])) { if (empty($_POST['v_type'])) $errors[] = _('type'); if (empty($_POST['v_charset'])) $errors[] = _('charset'); - // Protect input - $v_database = escapeshellarg($_POST['v_database']); - $v_dbuser = escapeshellarg($_POST['v_dbuser']); - $v_password = escapeshellarg($_POST['v_password']); - $v_type = $_POST['v_type']; - $v_charset = $_POST['v_charset']; - if (empty($_POST['v_notify'])) $v_notify = 'off'; + // Validate email + if (!filter_var($_POST['v_db_email'], FILTER_VALIDATE_EMAIL)) { + $_SESSION['error_msg'] = _('Please enter valid email address.'); + } + + // Protect input + $v_database = escapeshellarg($_POST['v_database']); + $v_dbuser = escapeshellarg($_POST['v_dbuser']); + $v_password = escapeshellarg($_POST['v_password']); + $v_type = $_POST['v_type']; + $v_charset = $_POST['v_charset']; + $v_db_email = $_POST['v_db_email']; // Check for errors if (!empty($errors[0])) { @@ -53,48 +58,30 @@ if (!empty($_POST['ok'])) { $_SESSION['error_msg'] = $error; unset($v_password); unset($output); - } else { - // Add Database - $v_type = escapeshellarg($_POST['v_type']); - $v_charset = escapeshellarg($_POST['v_charset']); - exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); - $v_type = $_POST['v_type']; - $v_charset = $_POST['v_charset']; - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - unset($v_password); - unset($output); - } - else { - if (empty($v_notify)) { - list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]); - if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; - if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; - - $to = $panel[$user]['CONTACT']; - $subject = _("Database Credentials"); - $hostname = exec('hostname'); - $from = _('MAIL_FROM',$hostname); - $mailtext = _('DATABASE_READY',$panel[$user]['FNAME'],$panel[$user]['LNAME'],$_POST['v_type'],$user,$_POST['v_database'],$user,$_POST['v_dbuser'],$_POST['v_password']); - $mailtext .= $db_admin_link."\n\n"; - - $mailtext .= "--\n"._('Vesta Control Panel')."\n"; - send_email($to, $subject, $mailtext, $from); - - } - $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); - unset($v_database); - unset($v_dbuser); - unset($v_password); - unset($v_type); - unset($v_charset); - unset($output); } + if (!empty($v_db_email)) { + list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]); + if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; + if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; + $to = $v_db_email; + $subject = _("Database Credentials"); + $hostname = exec('hostname'); + $from = _('MAIL_FROM',$hostname); + $mailtext = _('DATABASE_READY',$user,$_POST['v_database'],$user,$_POST['v_dbuser'],$_POST['v_password']); + $mailtext .= $db_admin_link."\n\n"; + $mailtext .= "--\n"._('Vesta Control Panel')."\n"; + send_email($to, $subject, $mailtext, $from); + } + $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); + unset($v_database); + unset($v_dbuser); + unset($v_password); + unset($v_type); + unset($v_charset); + unset($output); } } -} + exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); $db_types = json_decode(implode('', $output), true); unset($output); @@ -102,8 +89,7 @@ unset($output); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); -//} // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); -?> \ No newline at end of file +?> diff --git a/web/edit/db/index.php b/web/edit/db/index.php index 85ee93b20..f952f9347 100644 --- a/web/edit/db/index.php +++ b/web/edit/db/index.php @@ -13,67 +13,68 @@ include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); - // Check user argument? - if (empty($_GET['database'])) { - header("Location: /list/db/"); - exit; - } +$lang = 'ru_RU.utf8'; +setlocale(LC_ALL, $lang); - // Edit as someone else? - if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { - $user=escapeshellarg($_GET['user']); - } +if (empty($_GET['database'])) { + header("Location: /list/db/"); + exit; +} - $v_database = escapeshellarg($_GET['database']); - exec (VESTA_CMD."v-list-database ".$user." ".$v_database." 'json'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; +// Edit as someone else? +if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) { + $user=escapeshellarg($_GET['user']); +} + +$v_database = escapeshellarg($_GET['database']); +exec (VESTA_CMD."v-list-database ".$user." ".$v_database." 'json'", $output, $return_var); +if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; +} else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_database = $_GET['database']; + $v_dbuser = $data[$v_database]['DBUSER']; + $v_password = "••••••••"; + $v_host = $data[$v_database]['HOST']; + $v_type = $data[$v_database]['TYPE']; + $v_charset = $data[$v_database]['CHARSET']; + $v_date = $data[$v_database]['DATE']; + $v_time = $data[$v_database]['TIME']; + $v_suspended = $data[$v_database]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_database = $_GET['database']; - $v_dbuser = $data[$v_database]['DBUSER']; - $v_password = "••••••••"; - $v_host = $data[$v_database]['HOST']; - $v_type = $data[$v_database]['TYPE']; - $v_charset = $data[$v_database]['CHARSET']; - $v_date = $data[$v_database]['DATE']; - $v_time = $data[$v_database]['TIME']; - $v_suspended = $data[$v_database]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - - // Action - if (!empty($_POST['save'])) { - $v_username = $user; - // Change password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $v_password = "••••••••"; - unset($output); - } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = _('OK: changes has been saved.'); - } - } + $v_status = 'active'; } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} + // Action + if (!empty($_POST['save'])) { + $v_username = $user; + // Change password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_password = "••••••••"; + unset($output); + } + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); + } + } +} + +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html'); +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); // Footer include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/inc/i18n/en.php b/web/inc/i18n/en.php index 7c80c8a5a..8f00aaaf8 100644 --- a/web/inc/i18n/en.php +++ b/web/inc/i18n/en.php @@ -8,11 +8,9 @@ if (!defined('LANGUAGE')) die('Direct access not allowed'); $LANG = array( - 'yes' => 'да', - 'no' => 'нет', - 'none' => 'нет', 'yes' => 'yes', 'no' => 'no', + 'none' => 'нет', 'Hour' => 'Hour', 'Min' => 'Min', 'pb' => 'pb', @@ -192,7 +190,6 @@ $LANG = array( 'traffic' => 'traffic', 'Database Credentials' => 'Database Credentials', 'DATABASE_READY'=>"Hello, %s %s,\nDatabase %s has been created successfully.\n\nDatabase: %s_%s\nUser: %s_%s\nPassword: %s\n\n", - 'Send credentials to' => 'Send credentials to', 'Adding DNS Record' => 'Adding DNS Record', 'Record' => 'Record / Subdomain', 'IP or Value' => 'IP-address or Valie', diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index c22b8ca1a..e8507ef2a 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -37,6 +37,8 @@ $LANG = array( 'charset' => 'кодировка', 'edit' => 'редактировать', 'DATABASE_CREATED_OK' => 'База данных %s успешно создана.', + 'User' => 'Пользователь', + 'Host' => 'Хост', 'domain' => 'домен', 'ip' => 'IP', 'DOMAIN_CREATED_OK' => 'Домен %s успешно создан.', @@ -192,8 +194,7 @@ $LANG = array( 'Disk' => 'Диск', 'traffic' => 'трафик', 'Database Credentials' => 'Данные для доступа к БД', - 'DATABASE_READY'=>"Здравствуйте %s %s,\nВаша %s база данных создана успешно.\n\nИмя БД: %s_%s\nПользователь: %s_%s\nПароль: %s\n\n", - 'Send credentials to' => 'Отправить данные для доступа к ', + 'DATABASE_READY'=>"База данных создана успешно.\n\nИмя БД: %s_%s\nПользователь: %s_%s\nПароль: %s\n\n", 'Adding DNS Record' => 'Добавление DNS записи', 'Record' => 'Запись / Поддомен', 'IP or Value' => 'IP-адрес или значение', @@ -349,7 +350,6 @@ $LANG = array( 'Load Average' => 'Нагрузка', 'Memory Usage' => 'Использование Памяти', 'Bandwidth Usage' => 'Использование Сети', - ); /*error_reporting(E_ALL); diff --git a/web/list/db/index.php b/web/list/db/index.php index 7179d48d4..74541b02f 100644 --- a/web/list/db/index.php +++ b/web/list/db/index.php @@ -12,6 +12,9 @@ include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); // Panel top_panel($user,$TAB); +$lang = 'ru_RU.utf8'; +setlocale(LC_ALL, $lang); + // Data if ($_SESSION['user'] == 'admin') { exec (VESTA_CMD."v-list-databases $user json", $output, $return_var); diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index bba9bb600..efab9c54b 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -1,184 +1,187 @@ - + ?> - - - + - - - - - + } else { + if (!empty($_SESSION['ok_msg'])) { + echo " → ".$_SESSION['ok_msg'].""; + } + } + ?> + + + + + + -
- - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - @@ -124,9 +124,13 @@ + diff --git a/web/templates/admin/list_db.html b/web/templates/admin/list_db.html index 8a5b45ee8..21af2267a 100644 --- a/web/templates/admin/list_db.html +++ b/web/templates/admin/list_db.html @@ -51,34 +51,43 @@
- -
- -
- - -
- - -
- -
- -
- + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + +
+
+ diff --git a/web/templates/admin/edit_db.html b/web/templates/admin/edit_db.html index 4b45ae520..d9d8d42a7 100644 --- a/web/templates/admin/edit_db.html +++ b/web/templates/admin/edit_db.html @@ -52,9 +52,9 @@
- + - +
@@ -76,7 +76,7 @@
- +
+ + -
- +
">
">
- - - - - - - - -
- - - " /> - - - - delete - " /> - -
+ + + + + " /> + + + + + + + + " /> + + + + + + + + + + + + + + +
@@ -150,7 +159,7 @@