mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Update install.php
This commit is contained in:
parent
3e92f9bb77
commit
de8bf97b52
1 changed files with 38 additions and 1 deletions
39
install.php
39
install.php
|
@ -111,6 +111,43 @@ if (is_file(ROOT . '.env.example') && !is_file(ROOT . '.env')) {
|
||||||
out("- Environment file created!\n", 'success');
|
out("- Environment file created!\n", 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function editEnvFile()
|
||||||
|
{
|
||||||
|
$envFile = ROOT . '.env';
|
||||||
|
|
||||||
|
if (!file_exists($envFile)) {
|
||||||
|
out('- .env file not found', 'error');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$envContent = file_get_contents($envFile);
|
||||||
|
$envLines = explode("\n", $envContent);
|
||||||
|
|
||||||
|
$editedLines = [];
|
||||||
|
foreach ($envLines as $line) {
|
||||||
|
if (trim($line) !== '' && !str_starts_with($line, '#')) {
|
||||||
|
$parts = explode('=', $line, 2);
|
||||||
|
$key = trim($parts[0]);
|
||||||
|
$value = isset($parts[1]) ? trim($parts[1]) : '';
|
||||||
|
|
||||||
|
out("Current value of $key: $value", 'success');
|
||||||
|
out("Enter a new value for $key (or leave empty to not change): ");
|
||||||
|
$newValue = readline();
|
||||||
|
|
||||||
|
if (!empty($newValue)) {
|
||||||
|
$line = "$key=$newValue";
|
||||||
|
}
|
||||||
|
|
||||||
|
$editedLines[] = $line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$newEnvContent = implode("\n", $editedLines);
|
||||||
|
if (file_put_contents($envFile, $newEnvContent)) {
|
||||||
|
out('- File .env successfully updated!', 'success');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Editing ENV file
|
// Editing ENV file
|
||||||
out('--- Configuring TorrentPier ---');
|
out('--- Configuring TorrentPier ---');
|
||||||
$text = readline('Question: ');
|
editEnvFile();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue