<?php
define('APP_ROOT', __DIR__);
define('DatabaseDEBUG', true);
define('LogDEBUG', true);

// Pfad zum Apache-/PHP-Error-Log (leer = Standard /var/log/apache2/error.log)
if (!defined('DEBUG_ERROR_LOG_PATH')) {
    define('DEBUG_ERROR_LOG_PATH', '/var/log/apache2/error.log');
}

define('GITLAB_BASE_URL', 'https://gitlab.cylone-network.com');
define('GITLAB_CLIENT_ID', '4ce1e09aa4d5e2e295660d01feee699e6bd6065b8b29054180f7bd1bb1e938be');
define('GITLAB_CLIENT_SECRET', 'gloas-d40d171b70c04fe572a8d66075cb714be47df7dc07263dfe7745ea0f9aa25b0a');
define('GITLAB_REDIRECT_URI', 'http://10.201.100.215/debug/callback.php');

// Nur wer Zugriff auf Projekt 164 hat, darf ins Debug-Portal
define('GITLAB_REQUIRED_PROJECT_ID', 164);

// Update-Server für Debug-Update-Funktion (optional)
if (!defined('UPDATE_SERVER')) {
    define('UPDATE_SERVER', 'https://update.piclock.cylone-network.com');
}

// Alternativer Debug-Login per Passwort (leer = nur GitLab)
if (!defined('DEBUG_PASSWORD')) {
    define('DEBUG_PASSWORD', 'PiClock2025');
}

$dsn  = 'mysql:host=node03.team.the-network.cloud;port=3306;dbname=s199_Wecker;charset=utf8mb4';
$user = 'u199_EQoB44ynfW';
$pass = 'Fs.pT+CSlLrxkTi8f36eCKXf';

try {
    $pdo = new PDO(
        $dsn,
        $user,
        $pass,
        [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES   => false,
        ]
    );
} catch (Throwable $e) {
    error_log('[DB CONNECT ERROR] ' . $e->getMessage() . ' | DSN=' . $dsn);
    http_response_code(500);
    require APP_ROOT . '/errors/500.php';
    die;    
}
