<?php
/**
 * =====================================================================
 * Nadiplayer  -  cPanel PHP backend  -  Configuration
 * =====================================================================
 * Author     : Nadifi abdessamad  <nadiplayer@nadi.kr>
 * Website    : https://nadi.kr
 * Copyright  : (c) 2026 Nadi Player. All rights reserved.
 * Repository : https://github.com/ghizlanefit-cell/Nadiplayer-v1.2.5-ads
 * =====================================================================
 * Proprietary and confidential. Do NOT commit this file to a public
 * repo — it contains real database credentials.
 * =====================================================================
 */

// ── MySQL (read from Hostinger Environment Variables, with safe defaults) ─
// Set DB_HOST / DB_NAME / DB_USER / DB_PASS in hPanel → Website → Environment.
// The old hardcoded `koreama_nadiplayer` credentials have been removed.
$_ndp_env = function (string $key, string $default = ''): string {
    // Order matters: SetEnv in .htaccess populates $_SERVER reliably on
    // Hostinger's PHP-FPM. getenv() may return false depending on
    // variables_order, so check $_SERVER and $_ENV first.
    $v = $_SERVER[$key] ?? $_ENV[$key] ?? null;
    if ($v === null || $v === '') {
        $g = getenv($key);
        $v = ($g === false) ? $default : $g;
    }
    return (string) $v;
};
define('DB_HOST', $_ndp_env('DB_HOST', 'localhost'));
define('DB_PORT', (int) $_ndp_env('DB_PORT', '3306'));
define('DB_NAME', $_ndp_env('DB_NAME', 'koreama_nadiplayer'));
define('DB_USER', $_ndp_env('DB_USER', 'koreama_nadiplayer'));
define('DB_PASS', $_ndp_env('DB_PASS', 'NadiPlayer2026'));

// ── JWT secret  (used to sign auth tokens) ───────────────────────
define('JWT_SECRET', $_ndp_env('JWT_SECRET', 'YTObHcKYKI4UNlB2OZLPoJdIoQphTdUh5qDDGR2fRzh'));
define('JWT_TTL_SECONDS', 60 * 60 * 24); // 24h

// ── Admin seed (auto-created/re-synced on every request) ─────────
define('ADMIN_USERNAME', $_ndp_env('ADMIN_USERNAME', 'nadinadi'));
define('ADMIN_PASSWORD', $_ndp_env('ADMIN_PASSWORD', '0644782611'));

// ── Cron security key (cPanel cron job auth token) ───────────────
// Hit this URL from cPanel → Cron Jobs:
//   curl -fsS "https://prmtly.com/api/cron?key=YTObHcKYKI4UNlB2OZLPoJdIoQphTdUh5qDDGR2fRzh"
define('CRON_SECRET_KEY', $_ndp_env('CRON_SECRET_KEY', 'YTObHcKYKI4UNlB2OZLPoJdIoQphTdUh5qDDGR2fRzh'));

// ── Misc ─────────────────────────────────────────────────────────
date_default_timezone_set('UTC');
ini_set('display_errors', '0');         // never leak errors to JSON callers
error_reporting(E_ALL);
@ini_set('log_errors', '1');
@ini_set('error_log', __DIR__ . '/error.log');

// ── Build version (matches frontend/package.json + build.gradle) ─
define('NADIPLAY_BUILD_VERSION', '1.0.0');

// ── Payment provider credentials ─────────────────────────────────
// Stripe (get keys at https://dashboard.stripe.com/apikeys)
// Leave as '' to disable Stripe on /subscription page.
define('STRIPE_API_KEY', '');
// Optional: webhook secret (whsec_...) if you set up /api/payments/webhook/stripe
define('STRIPE_WEBHOOK_SECRET', '');

// PayPal (get keys at https://developer.paypal.com/dashboard/applications)
// PAYPAL_MODE: 'sandbox' for testing, 'live' for production.
define('PAYPAL_MODE', 'sandbox');
define('PAYPAL_CLIENT_ID', '');
define('PAYPAL_CLIENT_SECRET', '');

