mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
add environment whitelist, move configuration example to examples folder
This commit is contained in:
parent
e9adc780ad
commit
82ce328866
3 changed files with 10 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
/src/config/*.php
|
/src/config/*.php
|
||||||
!/src/config/bootstrap.php
|
!/src/config/bootstrap.php
|
||||||
!/src/config/env.example.php
|
|
||||||
|
|
||||||
/src/public/api/manifest.json
|
/src/public/api/manifest.json
|
||||||
/src/public/api/users.json
|
/src/public/api/users.json
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,23 @@ if (empty($_SERVER['PHP_ENV']))
|
||||||
$_SERVER['PHP_ENV'] = 'default';
|
$_SERVER['PHP_ENV'] = 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate environment whitelist
|
||||||
|
if (!in_array($_SERVER['PHP_ENV'], ['default', 'mirror', 'dev', 'test', 'prod']))
|
||||||
|
{
|
||||||
|
exit (_('Environment not supported! Check /src/config/bootstrap.php to add exception.'));
|
||||||
|
}
|
||||||
|
|
||||||
// Generate configuration file if not exists
|
// Generate configuration file if not exists
|
||||||
if (!file_exists(sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV'])))
|
if (!file_exists(__DIR__ . '/../../env.' . $_SERVER['PHP_ENV'] . '.php'))
|
||||||
{
|
{
|
||||||
copy(
|
copy(
|
||||||
__DIR__ . '/env.example.php',
|
__DIR__ . '/../../example/environment/env.example.php',
|
||||||
sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV'])
|
__DIR__ . '/env.' . $_SERVER['PHP_ENV'] . '.php'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load environment configuration
|
// Load environment configuration
|
||||||
require_once sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV']);
|
require_once __DIR__ . '/env.' . $_SERVER['PHP_ENV'] . '.php';
|
||||||
|
|
||||||
// Local internal dependencies
|
// Local internal dependencies
|
||||||
require_once __DIR__ . '/../library/database.php';
|
require_once __DIR__ . '/../library/database.php';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue