<?php
/**
 * EduTrack Setup Tool — Credentials
 * SETUP_SECRET is loaded from the project's .env file.
 * To change it, edit .env (SETUP_SECRET=your_new_secret).
 */

// Load .env from the project root (one level up from setup/)
(static function (): void {
    $envFile = dirname(__DIR__) . '/.env';
    if (!is_file($envFile)) return;
    $vars = parse_ini_file($envFile, false, INI_SCANNER_RAW);
    if (!is_array($vars)) return;
    foreach ($vars as $key => $value) {
        $key = (string) $key; $value = (string) $value;
        if (!array_key_exists($key, $_ENV)) { $_ENV[$key] = $value; putenv("{$key}={$value}"); }
    }
})();

// Error tracking (Sentry) — shares the same DSN as the main EduTrack app.
require_once __DIR__ . '/../sentry/sentry.php';

define('SETUP_SECRET',       $_ENV['SETUP_SECRET'] ?? 'change_me');
define('SETUP_TEMPLATE_DIR', dirname(__DIR__));           // Path to a clean EduTrack install
define('SETUP_HTDOCS',       dirname(dirname(__DIR__)));  // e.g. /var/www/html or C:/xampp/htdocs

// License server connection (for registering the school).
// Reads LICENSE_SERVER_URL from the project .env so the live server uses the real URL.
define('SETUP_LS_URL', $_ENV['LICENSE_SERVER_URL'] ?? 'https://license.oricnetwork.com/api.php');

// Default DB host
define('SETUP_DB_HOST', 'localhost');
define('SETUP_DB_PORT', '3306');
