Fix ask form and improve .env parsing

- Add AJAX handler to ask.md (same as plan.md)
- Improve load_env_file() to strip inline comments and spaces
- Create ERRORS_COLLECTION.md documenting all 7 error categories
- Fixes white page/JSON display issue in ask form
This commit is contained in:
Kirik
2025-10-27 16:35:59 +01:00
parent f902109b04
commit e26c35e488
4 changed files with 517 additions and 6 deletions
+16 -5
View File
@@ -11,17 +11,28 @@ function load_env_file($file_path = '../.env') {
if (!file_exists($file_path)) {
return false;
}
$lines = file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
// Пропускаем комментарии
if (strpos(trim($line), '#') === 0) {
continue; // Пропускаем комментарии
continue;
}
// Убираем inline комментарии (всё после #)
if (strpos($line, '#') !== false) {
$line = substr($line, 0, strpos($line, '#'));
}
// Проверяем что есть знак =
if (strpos($line, '=') === false) {
continue;
}
list($name, $value) = explode('=', $line, 2);
$name = trim($name);
$value = trim($value);
$value = trim($value); // ВАЖНО: убирает пробелы до и после значения
if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
putenv(sprintf('%s=%s', $name, $value));
$_ENV[$name] = $value;