<?php
/**
 * Ticketa - simple PHP/MySQL ticketing system
 * Copy this file to config.php and update values before upload/testing.
 */

// cPanel fallback: tajne mogu da stoje u /home/CPANEL_USER/sos-infrastruktura-secrets.php,
// izvan public_html. Server environment promenljive i dalje imaju prioritet.
$cpanelHome = getenv('HOME');
if ((!is_string($cpanelHome) || $cpanelHome === '') && isset($_SERVER['HOME']) && is_string($_SERVER['HOME'])) {
    $cpanelHome = $_SERVER['HOME'];
}
$externalSecretsCandidates = [];
if (is_string($cpanelHome) && $cpanelHome !== '') {
    $externalSecretsCandidates[] = rtrim($cpanelHome, '/\\') . DIRECTORY_SEPARATOR . 'sos-infrastruktura-secrets.php';
}
// Na cPanel domenima document root je često /home/USER/domain.tld, dok PHP
// ponekad ne prosledi HOME. Zato proveravamo i folder iznad document root-a.
$externalSecretsCandidates[] = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'sos-infrastruktura-secrets.php';
foreach (array_unique($externalSecretsCandidates) as $externalSecretsPath) {
    if (is_file($externalSecretsPath) && is_readable($externalSecretsPath)) {
        require_once $externalSecretsPath;
        break;
    }
}
unset($cpanelHome, $externalSecretsCandidates, $externalSecretsPath);

define('APP_NAME', 'Ticketa');

// Example values:
// - if installed in https://example.com/tickets, use '/tickets'
// - if installed directly in public_html, use ''
define('BASE_URL', '');

// Database settings from cPanel > MySQL Databases
define('DB_HOST', 'localhost');
define('DB_NAME', 'sosmthhg_staging');
define('DB_USER', 'sosmthhg_stageuser');
define('DB_PASS', 'QrAyXO5i?f!7v=oD');

// Public registration is OFF by default for internal/organizational use.
// Admin can create users from the Users page.
define('ALLOW_PUBLIC_REGISTRATION', false);
define('DEFAULT_REGISTERED_ROLE', 'user'); // user only recommended

// Security/session options
define('SESSION_NAME', 'ticketa_session');
define('APP_TIMEZONE', 'Europe/Belgrade');
define('APP_FORCE_SECURE_COOKIE', true);
define('TRUSTED_PROXY_IPS', []);

// Microsoft Entra ID vrednosti dolaze iz server environment-a.
defined('ENTRA_CLIENT_ID') || define('ENTRA_CLIENT_ID', getenv('ENTRA_CLIENT_ID') ?: '');
defined('ENTRA_TENANT_ID') || define('ENTRA_TENANT_ID', getenv('ENTRA_TENANT_ID') ?: '');
defined('ENTRA_CLIENT_SECRET') || define('ENTRA_CLIENT_SECRET', getenv('ENTRA_CLIENT_SECRET') ?: '');
defined('ENTRA_REDIRECT_URI') || define('ENTRA_REDIRECT_URI', getenv('ENTRA_REDIRECT_URI') ?: 'https://infrastruktura.sos-decijasela.rs/auth/entra/callback');

// Optional footer text
define('APP_FOOTER_TEXT', 'Internal ticketing system');
