<?php
// config/config.php - Main Configuration File


// Load .env file if it exists
if (file_exists(__DIR__ . '/../.env')) {
    $lines = file(__DIR__ . '/../.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    foreach ($lines as $line) {
        // Skip comments
        if (strpos(trim($line), '#') === 0) continue;
        
        // Parse line
        if (strpos($line, '=') !== false) {
            list($name, $value) = explode('=', $line, 2);
            $name = trim($name);
            $value = trim($value);
            
            // Remove quotes if present
            if (preg_match('/^(["\'])(.*)\\1$/', $value, $matches)) {
                $value = $matches[2];
            }
            
            // Define constant
            if (!defined($name)) {
                define($name, $value);
            }
        }
    }
}

// Application Settings
if (!defined('APP_NAME')) define('APP_NAME', 'rentidium');
if (!defined('APP_URL')) define('APP_URL', 'http://localhost/rentidium');
if (!defined('APP_DEBUG')) define('APP_DEBUG', true);
if (!defined('APP_ENV')) define('APP_ENV', 'development');

// Database Configuration
if (!defined('DB_HOST')) define('DB_HOST', 'localhost');
if (!defined('DB_NAME')) define('DB_NAME', 'rentidium');
if (!defined('DB_USER')) define('DB_USER', 'root');
if (!defined('DB_PASS')) define('DB_PASS', '');
if (!defined('DB_CHARSET')) define('DB_CHARSET', 'utf8mb4');

// Security Settings
if (!defined('ENCRYPTION_KEY')) define('ENCRYPTION_KEY', 'your-32-character-encryption-key-here');
if (!defined('SESSION_LIFETIME')) define('SESSION_LIFETIME', 1800);

// Payment Gateway Settings - Paystack
if (!defined('PAYSTACK_PUBLIC_KEY')) define('PAYSTACK_PUBLIC_KEY', 'pk_test_xxxxxxxxxxxxxxxxxxxxx');
if (!defined('PAYSTACK_SECRET_KEY')) define('PAYSTACK_SECRET_KEY', 'sk_test_xxxxxxxxxxxxxxxxxxxxx');
if (!defined('PAYSTACK_CALLBACK_URL')) define('PAYSTACK_CALLBACK_URL', APP_URL . '/customer/payment-callback.php');

// Payment Gateway Settings - Flutterwave
if (!defined('FLW_PUBLIC_KEY')) define('FLW_PUBLIC_KEY', 'FLWPUBK_TEST-xxxxxxxxxxxxxxxxxxxxx');
if (!defined('FLW_SECRET_KEY')) define('FLW_SECRET_KEY', 'FLWSECK_TEST-xxxxxxxxxxxxxxxxxxxxx');
if (!defined('FLW_ENCRYPTION_KEY')) define('FLW_ENCRYPTION_KEY', 'FLWSECK_TESTxxxxxxxxxx');

// Email Configuration
if (!defined('MAIL_HOST')) define('MAIL_HOST', 'sandbox.smtp.mailtrap.io');
if (!defined('MAIL_PORT')) define('MAIL_PORT', 587);
if (!defined('MAIL_USERNAME')) define('MAIL_USERNAME', '5a11dcb935bd2b');
if (!defined('MAIL_PASSWORD')) define('MAIL_PASSWORD', 'f908b1c7c46309');
if (!defined('MAIL_FROM_EMAIL')) define('MAIL_FROM_EMAIL', 'noreply@rentidium.ng');
if (!defined('MAIL_FROM_NAME')) define('MAIL_FROM_NAME', APP_NAME);

// File Upload Settings
if (!defined('MAX_FILE_SIZE')) define('MAX_FILE_SIZE', 5242880); // 5MB
if (!defined('ALLOWED_IMAGE_TYPES')) define('ALLOWED_IMAGE_TYPES', 'jpg,jpeg,png,gif,webp');
if (!defined('ALLOWED_DOCUMENT_TYPES')) define('ALLOWED_DOCUMENT_TYPES', 'pdf,doc,docx');

// Pagination
if (!defined('ITEMS_PER_PAGE')) define('ITEMS_PER_PAGE', 12);
if (!defined('ADMIN_ITEMS_PER_PAGE')) define('ADMIN_ITEMS_PER_PAGE', 20);

// Commission Settings
if (!defined('PLATFORM_COMMISSION')) define('PLATFORM_COMMISSION', 10);
if (!defined('MIN_WITHDRAWAL_AMOUNT')) define('MIN_WITHDRAWAL_AMOUNT', 1000);

// Verification Settings
if (!defined('REQUIRE_EMAIL_VERIFICATION')) define('REQUIRE_EMAIL_VERIFICATION', true);
if (!defined('REQUIRE_VENDOR_APPROVAL')) define('REQUIRE_VENDOR_APPROVAL', true);

// Currency
if (!defined('CURRENCY_SYMBOL')) define('CURRENCY_SYMBOL', '₦');
if (!defined('CURRENCY_CODE')) define('CURRENCY_CODE', 'NGN');

// Contact Information
if (!defined('CONTACT_EMAIL')) define('CONTACT_EMAIL', 'support@rentidium.com');
if (!defined('CONTACT_PHONE')) define('CONTACT_PHONE', '+234 xxx xxxx xxxx');

// Cache Settings
if (!defined('ENABLE_CACHE')) define('ENABLE_CACHE', false);
if (!defined('CACHE_LIFETIME')) define('CACHE_LIFETIME', 3600);


// config/database.php - Database configuration (assuming similar structure to existing project)

// This file assumes your existing database connection structure
// Adjust based on your actual Database class implementation

