<?php
/**
 * Binance P2P Automation - Configuration
 * Separate configuration for Binance subdomain
 */

// Database configuration (Binance subdomain)
define('DB_HOST', 'localhost');
define('DB_NAME', 'dinrstbvmk_binancesapi'); // Change to your Binance database name
define('DB_USER', 'dinrstbvmk_binancesapi'); // Change to your Binance database user
define('DB_PASS', 'Q9hsaTh4JDTN'); // Change to your Binance database password

// Encryption key
define('ENCRYPTION_KEY', '1010199622062020');

// Site Configuration
define('SITE_NAME', 'Binance P2P Automation');
define('SITE_URL', 'https://binance.zatamtech.xyz'); // Change to your Binance subdomain

// Bridge.xyz API configuration (Separate for Binance)
define('BRIDGE_API_KEY', 'sk-live-bc98f3d4c2230d6c82949ddc52d46bfe'); // Change to your Binance Bridge API key
define('BRIDGE_API_URL', 'https://api.bridge.xyz');

// Binance API configuration
define('BINANCE_API_BASE_URL', 'https://api.binance.com');

// Alchemy API configuration (for Polygon)
define('ALCHEMY_API_KEY', '9VXCbzZfhIcqhZqf2dB1n'); // Change to your Alchemy API key
define('ALCHEMY_URL', 'https://polygon-mainnet.g.alchemy.com/v2/' . ALCHEMY_API_KEY);

// USDC Contract Address (Polygon)
define('USDC_CONTRACT', '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359');

// Set timezone to Nairobi (UTC+3)
date_default_timezone_set('Africa/Nairobi');

// Initialize PDO connection
try {
    $pdo = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4", DB_USER, DB_PASS);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
    
    // Set MySQL session timezone to UTC to ensure consistent storage
    // This ensures NOW() and other MySQL time functions use UTC
    $pdo->exec("SET time_zone = '+00:00'");
} catch (PDOException $e) {
    die("Database connection failed: " . $e->getMessage());
}

// Start session if not already started (only for web requests, not CLI)
// DO NOT start session in CLI mode to prevent headers
// Check if session auto-start is disabled (set by cron scripts to prevent headers)
// Also check if we're in CLI mode explicitly
if (php_sapi_name() !== 'cli' && 
    ini_get('session.auto_start') != '1' && 
    session_status() === PHP_SESSION_NONE &&
    !defined('STDIN')) {
    @session_start();
}
