Skip to content

Commit ea18723

Browse files
author
Kristan Kenney
committed
Merge branch 'fix/1286-fix_javascript_database_name' into staging/fixes
2 parents 648382c + cd195b5 commit ea18723

File tree

6 files changed

+11
-31
lines changed

6 files changed

+11
-31
lines changed

web/add/web/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
$v_ftp_user_data['is_new'] = 1;
343343
}
344344

345-
$v_ftp_username = preg_replace("/^".$user."_/", "", $v_ftp_user_data['v_ftp_user']);
345+
$v_ftp_username = $user.'_'.$v_ftp_user_data['v_ftp_user'];
346346
$v_ftp_users_updated[] = array(
347347
'is_new' => $v_ftp_user_data['is_new'],
348348
'v_ftp_user' => $return_var == 0 ? $v_ftp_username_full : $v_ftp_username,

web/edit/db/index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
// Parse database
2929
$v_username = $user;
30-
$v_dbuser = $data[$v_database]['DBUSER'];
30+
$v_dbuser = preg_replace("/^".$user."_/", "", $data[$v_database]['DBUSER']);
3131
$v_password = "";
3232
$v_host = $data[$v_database]['HOST'];
3333
$v_type = $data[$v_database]['TYPE'];
@@ -53,7 +53,6 @@
5353

5454
// Change database user
5555
if (($v_dbuser != $_POST['v_dbuser']) && (empty($_SESSION['error_msg']))) {
56-
$v_dbuser = preg_replace("/^".$user."_/", "", $_POST['v_dbuser']);
5756
$v_dbuser = escapeshellarg($v_dbuser);
5857
exec (HESTIA_CMD."v-change-database-user ".$v_username." ".escapeshellarg($v_database)." ".$v_dbuser, $output, $return_var);
5958
check_return_code($return_var,$output);

web/js/pages/add_db.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
55
if (hint.trim() == '') {
66
$(elm).parent().find('.hint').html('');
77
}
8-
// remove prefix from value in order to eliminate duplicates
9-
if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
10-
hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
11-
}
12-
138
$(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
149
}
1510

@@ -20,10 +15,6 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
2015
if (hint.trim() == '') {
2116
$(elm).parent().find('.hint').html('');
2217
}
23-
// remove prefix from value in order to eliminate duplicates
24-
if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
25-
hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
26-
}
2718
$(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
2819
}
2920

web/js/pages/add_web.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
4242
if (hint.trim() == '') {
4343
$(elm).parent().find('.hint').html('');
4444
}
45-
46-
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
47-
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
48-
}
45+
4946
hint = hint.replace(/[^\w\d]/gi, '');
5047

5148
$(elm).parent().find('.v-ftp-user').val(hint);

web/js/pages/edit_db.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
55
if (hint.trim() == '') {
66
$(elm).parent().find('.hint').html('');
77
}
8-
// remove prefix from value in order to eliminate duplicates
9-
if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
10-
hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
11-
}
12-
138
$(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
149
}
1510

@@ -20,10 +15,6 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
2015
if (hint.trim() == '') {
2116
$(elm).parent().find('.hint').html('');
2217
}
23-
// remove prefix from value in order to eliminate duplicates
24-
if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
25-
hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
26-
}
2718
$(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
2819
}
2920

@@ -34,7 +25,7 @@ App.Listeners.DB.keypress_db_username = function() {
3425
var current_val = ref.val();
3526
if (current_val.trim() != '') {
3627
App.Actions.DB.update_db_username_hint(ref, current_val);
37-
}
28+
}
3829

3930
ref.bind('keypress input', function(evt) {
4031
clearTimeout(window.frp_usr_tmt);
@@ -50,9 +41,13 @@ App.Listeners.DB.keypress_db_username = function() {
5041
App.Listeners.DB.keypress_db_databasename = function() {
5142
var ref = $('input[name="v_database"]');
5243
var current_val = ref.val();
53-
if (current_val.trim() != '') {
54-
App.Actions.DB.update_db_databasename_hint(ref, current_val);
44+
if (current_val.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
45+
current_val = current_val.slice(GLOBAL.DB_DBNAME_PREFIX.length, current_val.length);
46+
ref.val(current_val);
5547
}
48+
if (current_val.trim() != '') {
49+
App.Actions.DB.update_db_username_hint(ref, current_val);
50+
}
5651

5752
ref.bind('keypress input', function(evt) {
5853
clearTimeout(window.frp_dbn_tmt);
@@ -97,6 +92,7 @@ App.Listeners.DB.keypress_v_password();
9792
App.Listeners.DB.keypress_db_username();
9893
App.Listeners.DB.keypress_db_databasename();
9994

95+
10096
randomString = function(min_length = 16) {
10197
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
10298
var string_length = min_length;

web/js/pages/edit_web.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
4242
$(elm).parent().find('.hint').html('');
4343
}
4444

45-
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
46-
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
47-
}
4845
hint = hint.replace(/[^\w\d]/gi, '');
4946

5047
$(elm).parent().find('.v-ftp-user').val(hint);

0 commit comments

Comments
 (0)