diff --git a/public/installer/AdminConfig.php b/public/installer/AdminConfig.php index 00c0dae82..6bb38798c 100755 --- a/public/installer/AdminConfig.php +++ b/public/installer/AdminConfig.php @@ -41,17 +41,16 @@ $data = array(); $envFile = $desiredLocation . '/' . '.env'; // reading env content - $str= file_get_contents($envFile); - - // converting env content to key/value pair - $data = explode(PHP_EOL,$str); + $data = file($envFile); $databaseArray = ['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD', 'DB_CONNECTION']; - $key = $value = []; + if ($data) { foreach ($data as $line) { + $line = preg_replace('/\s+/', '', $line); $rowValues = explode('=', $line); - if (count($rowValues) === 2) { + + if (strlen($line) !== 0) { if (in_array($rowValues[0], $databaseArray)) { $key[] = $rowValues[0]; $value[] = $rowValues[1]; diff --git a/public/installer/EnvConfig.php b/public/installer/EnvConfig.php index 9f3e24bc2..27ffe01bb 100755 --- a/public/installer/EnvConfig.php +++ b/public/installer/EnvConfig.php @@ -24,9 +24,6 @@ $data = array(); if (empty($_POST['user_name'])) $errors['user_name'] = 'User Name is required.'; - if (empty($_POST['user_password'])) - $errors['user_password'] = 'User Password is required.'; - if (empty($_POST['port_name'])) $errors['port_name'] = 'Port Name is required.'; @@ -82,6 +79,21 @@ $data = array(); } } + // reading env content + $data = file($envFile); + $keyValueData = []; + + if ($data) { + foreach ($data as $line) { + $line = preg_replace('/\s+/', '', $line); + $rowValues = explode('=', $line); + + if (strlen($line) !== 0) { + $keyValueData[$rowValues[0]] = $rowValues[1]; + } + } + } + // inserting form data to empty array $keyValueData['DB_HOST'] = $_POST["host_name"]; $keyValueData['DB_DATABASE'] = $_POST["database_name"]; @@ -92,33 +104,6 @@ $data = array(); $keyValueData['DB_CONNECTION'] = $_POST["database_connection"]; $keyValueData['DB_PORT'] = $_POST["port_name"]; - $keyValueData['APP_ENV'] = $_POST["app_env"]; - $keyValueData['APP_KEY'] = $_POST["app_key"]; - $keyValueData['APP_DEBUG'] = $_POST["app_debug"]; - $keyValueData['LOG_CHANNEL'] = $_POST["log_channel"]; - - $keyValueData['BROADCAST_DRIVER'] = $_POST["broadcast_driver"]; - $keyValueData['CACHE_DRIVER'] = $_POST["cache_driver"]; - $keyValueData['SESSION_DRIVER'] = $_POST["session_driver"]; - $keyValueData['SESSION_LIFETIME'] = $_POST["session_lifetime"]; - $keyValueData['QUEUE_DRIVER'] = $_POST["queue_driver"]; - - $keyValueData['REDIS_HOST'] = $_POST["redis_host"]; - $keyValueData['REDIS_PASSWORD'] = $_POST["redis_password"]; - $keyValueData['REDIS_PORT'] = $_POST["redis_port"]; - - $keyValueData['MAIL_DRIVER'] = $_POST["mail_driver"]; - $keyValueData['MAIL_HOST'] = $_POST["mail_host"]; - $keyValueData['MAIL_PORT'] = $_POST["mail_port"]; - $keyValueData['MAIL_USERNAME'] = $_POST["mail_username"]; - $keyValueData['MAIL_PASSWORD'] = $_POST["mail_password"]; - $keyValueData['MAIL_ENCRYPTION'] = $_POST["mail_encryption"]; - - $keyValueData['PUSHER_APP_ID'] = $_POST["pusher_app_id"]; - $keyValueData['PUSHER_APP_KEY'] = $_POST["pusher_app_key"]; - $keyValueData['PUSHER_APP_SECRET'] = $_POST["pusher_app_secret"]; - $keyValueData['PUSHER_APP_CLUSTER'] = $_POST["pusher_app_cluster"]; - // making key/value pair with form-data for env $changedData = []; foreach ($keyValueData as $key => $value) { diff --git a/public/installer/Environment.php b/public/installer/Environment.php index 20f2a3453..74b9cbf60 100755 --- a/public/installer/Environment.php +++ b/public/installer/Environment.php @@ -69,37 +69,8 @@
+ placeholder="database password">
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -139,34 +110,6 @@ 'user_name' : $('input[name=user_name]').val(), 'user_password' : $('input[name=user_password]').val(), 'database_connection' : $("#database_connection" ).val(), - - - 'app_env' : $('input[name=app_env]').val(), - 'app_key' : $('input[name=app_key]').val(), - 'app_debug' : $('input[name=app_debug]').val(), - 'log_channel' : $('input[name=log_channel]').val(), - - 'broadcast_driver' : $('input[name=broadcast_driver]').val(), - 'cache_driver' : $('input[name=cache_driver]').val(), - 'session_driver' : $('input[name=session_driver]').val(), - 'session_lifetime' : $('input[name=session_lifetime]').val(), - 'queue_driver' : $('input[name=queue_driver]').val(), - - 'redis_host' : $('input[name=redis_host]').val(), - 'redis_password' : $('input[name=redis_password]').val(), - 'redis_port' : $('input[name=redis_port]').val(), - - 'mail_driver' : $('input[name=mail_driver]').val(), - 'mail_host' : $('input[name=mail_host]').val(), - 'mail_port' : $('input[name=mail_port]').val(), - 'mail_username' : $('input[name=mail_username]').val(), - 'mail_password' : $('input[name=mail_password]').val(), - 'mail_encryption' : $('input[name=mail_encryption]').val(), - - 'pusher_app_id' : $('input[name=pusher_app_id]').val(), - 'pusher_app_key' : $('input[name=pusher_app_key]').val(), - 'pusher_app_secret' : $('input[name=pusher_app_secret]').val(), - 'pusher_app_cluster' : $('input[name=pusher_app_cluster]').val(), }; var target = window.location.href.concat('/EnvConfig.php'); diff --git a/public/installer/index.php b/public/installer/index.php index 8916352f1..d4ca4af94 100755 --- a/public/installer/index.php +++ b/public/installer/index.php @@ -45,17 +45,16 @@ if (file_exists($envFile)) { // reading env content - $str= file_get_contents($envFile); - - // converting env content to key/value pair - $data = explode(PHP_EOL,$str); + $data = file($envFile); $databaseArray = ['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD', 'DB_CONNECTION','DB_PORT']; - $key = $value = []; + if ($data) { foreach ($data as $line) { + $line = preg_replace('/\s+/', '', $line); $rowValues = explode('=', $line); - if (count($rowValues) === 2) { + + if (strlen($line) !== 0) { if (in_array($rowValues[0], $databaseArray)) { $key[] = $rowValues[0]; $value[] = $rowValues[1]; diff --git a/public/installer/install.php b/public/installer/install.php index b597ab0a9..f7894c870 100755 --- a/public/installer/install.php +++ b/public/installer/install.php @@ -11,17 +11,16 @@ if (file_exists($envFile)) { // reading env content - $str = file_get_contents($envFile); - - // converting env content to key/value pair - $data = explode(PHP_EOL,$str); + $data = file($envFile); $databaseArray = ['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD', 'DB_CONNECTION','DB_PORT']; - $key = $value = []; + if ($data) { foreach ($data as $line) { + $line = preg_replace('/\s+/', '', $line); $rowValues = explode('=', $line); - if (count($rowValues) === 2) { + + if (strlen($line) !== 0) { if (in_array($rowValues[0], $databaseArray)) { $key[] = $rowValues[0]; $value[] = $rowValues[1];