From 4d00a7321a382beea7d84b4dc01e572604e7ab76 Mon Sep 17 00:00:00 2001 From: devansh bawari Date: Mon, 13 Sep 2021 13:26:47 +0530 Subject: [PATCH] DB Prefix Added In GUI Installer --- public/installer/EnvConfig.php | 209 +++++++++---------- public/installer/Views/environment.blade.php | 51 +++-- 2 files changed, 131 insertions(+), 129 deletions(-) diff --git a/public/installer/EnvConfig.php b/public/installer/EnvConfig.php index 064dfe980..7ab0df389 100755 --- a/public/installer/EnvConfig.php +++ b/public/installer/EnvConfig.php @@ -1,152 +1,143 @@ $value) { + $changedData[] = $key . '=' . $value; + } - if (strlen($line) !== 0) { - $keyValueData[$rowValues[0]] = $rowValues[1]; - } - } - } + // inserting new form-data to env + $changedData = implode(PHP_EOL, $changedData); + file_put_contents($envFile, $changedData); - // inserting form data to empty array - $keyValueData['DB_HOST'] = $_POST["host_name"]; - $keyValueData['DB_DATABASE'] = $_POST["database_name"]; - $keyValueData['DB_USERNAME'] = $_POST["user_name"]; - $keyValueData['DB_PASSWORD'] = $_POST["user_password"]; - $keyValueData['APP_NAME'] = $_POST["app_name"]; - $keyValueData['APP_URL'] = $_POST["app_url"]; - $keyValueData['APP_CURRENCY'] = $_POST["app_currency"]; - $keyValueData['APP_LOCALE'] = $_POST["app_locale"]; - $keyValueData['APP_TIMEZONE'] = $_POST["app_timezone"]; - $keyValueData['DB_CONNECTION'] = $_POST["database_connection"]; - $keyValueData['DB_PORT'] = $_POST["port_name"]; + // checking database connection(mysql only) + if ($_POST["database_connection"] == 'mysql') { + // create connection + @$conn = new mysqli($_POST["host_name"], $_POST["user_name"], $_POST["user_password"], $_POST["database_name"], $_POST['port_name']); - // making key/value pair with form-data for env - $changedData = []; - foreach ($keyValueData as $key => $value) { - $changedData[] = $key . '=' . $value; - } - - // inserting new form-data to env - $changedData = implode(PHP_EOL, $changedData); - file_put_contents($envFile, $changedData); - - // checking database connection(mysql only) - if ($_POST["database_connection"] == 'mysql') { - // Create connection - @$conn = new mysqli($_POST["host_name"], $_POST["user_name"], $_POST["user_password"], $_POST["database_name"], $_POST['port_name']); - - // check connection - if ($conn->connect_error) { - $errors['database_error'] = $conn->connect_error; - $data['errors'] = $errors; - $data['success'] = false; - } else { - $data['success'] = true; - $data['message'] = 'Success!'; - } + // check connection + if ($conn->connect_error) { + $errors['database_error'] = $conn->connect_error; + $data['errors'] = $errors; + $data['success'] = false; } else { $data['success'] = true; $data['message'] = 'Success!'; } - - // show a message of success and provide a true success variable + } else { + $data['success'] = true; + $data['message'] = 'Success!'; } +} - // return all our data to an AJAX call - echo json_encode($data); +// return all our data to an AJAX call +echo json_encode($data); diff --git a/public/installer/Views/environment.blade.php b/public/installer/Views/environment.blade.php index 81cb5dcdb..d8aa96a55 100644 --- a/public/installer/Views/environment.blade.php +++ b/public/installer/Views/environment.blade.php @@ -11,16 +11,16 @@
-
- +
-
- +
- +
- +
@@ -80,26 +80,32 @@
-
- +
-
-
+
+ + +
+
-
@@ -130,12 +136,12 @@ $('#database-settings').hide(); $('#environment-next').click(function() { $('#app-settings').hide(); - $('#database-settings').show(); + $('#database-settings').show(); }); $('#environment-first').click(function() { $('#app-settings').show(); - $('#database-settings').hide(); + $('#database-settings').hide(); }); // process the form @@ -144,7 +150,7 @@ $('.form-error').remove(); // remove the error text // get the form data - var formData = { + let formData = { 'app_name' : $('input[name=app_name]').val(), 'app_url' : $('input[name=app_url]').val(), 'app_currency' : $('select[name=app_currency]').val(), @@ -154,11 +160,12 @@ 'port_name' : $('input[name=port_name]').val(), 'database_connection' : $("select[name=database_connection]" ).val(), 'database_name' : $('input[name=database_name]').val(), + 'database_prefix' : $('input[name=database_prefix]').val(), 'user_name' : $('input[name=user_name]').val(), 'user_password' : $('input[name=user_password]').val(), }; - var target = window.location.href.concat('/EnvConfig.php'); + let target = window.location.href.concat('/EnvConfig.php'); // process the form $.ajax({ @@ -171,7 +178,7 @@ // using the done promise callback .done(function(data) { if (!data.success) { - // handle errors + // handle errors if (data.errors.app_name) { $('#app_name').addClass('has-error'); $('#app_name').append('
' + data.errors.app_name + '
'); @@ -183,7 +190,7 @@ if (data.errors.app_timezone) { $('#app_timezone').addClass('has-error'); $('#app_timezone').append('
' + data.errors.app_timezone + '
'); - } + } if (data.errors.host_name) { $('#host_name').addClass('has-error'); $('#host_name').append('
' + data.errors.host_name + '
'); @@ -228,6 +235,10 @@ $('#database_name').addClass('has-error'); $('#database_name').append('
' + data.errors.database_name_space + '
'); } + if (data.errors.database_prefix_space) { + $('#database_prefix').addClass('has-error'); + $('#database_prefix').append('
' + data.errors.database_prefix_space + '
'); + } if (data.errors.user_password_space) { $('#user_password').addClass('has-error'); $('#user_password').append('
' + data.errors.user_password_space + '
');