52 lines
2.7 KiB
PHP
52 lines
2.7 KiB
PHP
<?php
|
|
// Application configuration. No credentials live in this file: they come from
|
|
// environment variables or from a secrets file. Template: database/secrets.example.php.
|
|
// Looked up in this order:
|
|
// 1. SERUBI_SECRETS_FILE (environment variable)
|
|
// 2. <parent of the app folder>/.serubi/secrets.php (outside the document root, preferred)
|
|
// 3. <app folder>/.serubi/secrets.php (hosting without access above the
|
|
// document root; the folder is denied over HTTP by .htaccess and .serubi/.htaccess)
|
|
$secretsFile = getenv('SERUBI_SECRETS_FILE') ?: '';
|
|
if ($secretsFile === '') {
|
|
foreach ([dirname(__DIR__) . '/.serubi/secrets.php', __DIR__ . '/.serubi/secrets.php'] as $candidate) {
|
|
if (is_file($candidate)) {
|
|
$secretsFile = $candidate;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
$secrets = $secretsFile !== '' && is_file($secretsFile) ? (array)require $secretsFile : [];
|
|
$env = function (string $name, $default) {
|
|
$v = getenv($name);
|
|
return $v !== false ? $v : $default;
|
|
};
|
|
|
|
return [
|
|
'db' => [
|
|
'host' => (string)$env('SERUBI_DB_HOST', $secrets['db_host'] ?? 'localhost'),
|
|
'port' => (int)$env('SERUBI_DB_PORT', $secrets['db_port'] ?? 3306),
|
|
'name' => (string)$env('SERUBI_DB_NAME', $secrets['db_name'] ?? 'k5551916_calcserubibppapua'),
|
|
'user' => (string)$env('SERUBI_DB_USER', $secrets['db_user'] ?? ''),
|
|
'password' => (string)$env('SERUBI_DB_PASS', $secrets['db_pass'] ?? ''),
|
|
],
|
|
'security' => [
|
|
// HTTP is redirected to HTTPS unless SERUBI_FORCE_HTTPS=0 (local development).
|
|
'force_https' => filter_var($env('SERUBI_FORCE_HTTPS', $secrets['force_https'] ?? '1'), FILTER_VALIDATE_BOOLEAN),
|
|
// IP reverse proxy / load balancer yang dipercaya untuk X-Forwarded-For/-Proto.
|
|
'trusted_proxies' => array_filter(explode(',', (string)$env('SERUBI_TRUSTED_PROXIES', $secrets['trusted_proxies'] ?? ''))),
|
|
// Kosong = form "buat admin pertama" dimatikan (pakai: php database/migrate.php --create-admin).
|
|
'setup_key' => (string)$env('SERUBI_SETUP_KEY', $secrets['setup_key'] ?? ''),
|
|
// 32-byte key (base64) that encrypts the admins' OTP secrets. Required for 2FA.
|
|
'app_key' => (string)$env('SERUBI_APP_KEY', $secrets['app_key'] ?? ''),
|
|
],
|
|
'app' => [
|
|
'name' => 'Kalkulator Cashback SERUBI',
|
|
// Naikkan saat rilis; ditambahkan ke URL JS/CSS (bersama waktu ubah file)
|
|
// sehingga browser klien langsung memuat versi terbaru.
|
|
'version' => '2.3.0',
|
|
'timezone' => 'Asia/Jayapura',
|
|
// Parameter cache (outside the document root). Empty = system temp directory.
|
|
'cache_dir' => (string)$env('SERUBI_CACHE_DIR', $secrets['cache_dir'] ?? ''),
|
|
],
|
|
];
|