PHP 8.2.29
Preview: wp-config.php Size: 10.97 KB
/home/medyaist/Secure/kardeslikvakti.com/wp-config.php
<?php
/**
 * WordPress Configuration File
 * Using Encrypted Environment Variables (.env)
 * Encryption: AES-256-CBC with Base64 encoding
 */

// Prevent any output before WordPress loads
if (ob_get_level() === 0) {
    ob_start();
}

// Suppress all errors and warnings during config loading
error_reporting(0);
ini_set('display_errors', 0);

// ===================================================
// ENCRYPTION FUNCTIONS
// ===================================================
function decrypt_value($encrypted_value, $encryption_key) {
    if (empty($encrypted_value) || empty($encryption_key)) {
        return $encrypted_value;
    }
    
    // If value doesn't look like base64, assume it's plain text
    if (!preg_match('/^[A-Za-z0-9+\/]+=*$/', $encrypted_value)) {
        return $encrypted_value;
    }
    
    // Decode from base64
    $data = @base64_decode($encrypted_value, true);
    if ($data === false || strlen($data) < 16) {
        // If not base64 or too short, return as is (plain text)
        return $encrypted_value;
    }
    
    // Ensure encryption key is 32 bytes for AES-256
    $key = hash('sha256', $encryption_key, true);
    
    // Extract IV and encrypted data
    $iv = substr($data, 0, 16);
    $encrypted = substr($data, 16);
    
    // Decrypt
    $decrypted = @openssl_decrypt($encrypted, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
    
    if ($decrypted === false || empty($decrypted)) {
        // If decryption fails, return original (might be plain text)
        return $encrypted_value;
    }
    
    return $decrypted;
}

// ===================================================
// LOAD ENVIRONMENT VARIABLES
// ===================================================
// .env dosyası konumu (önce gerçek konumu kontrol et, sonra fallback'ler)
$env_file = '/home/medyaist/.env-kardeslikvakti';
if (!file_exists($env_file)) {
    $env_file = '/home/medyaist/.env';
}
if (!file_exists($env_file)) {
    $env_file = __DIR__ . '/.env-kardeslikvakti';
}
if (!file_exists($env_file)) {
    $env_file = __DIR__ . '/.env';
}
$encryption_key = null;

// Load .env file in two passes: first get ENCRYPTION_KEY, then process other values
if (file_exists($env_file) && is_readable($env_file)) {
    $lines = @file($env_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    if ($lines !== false) {
        // First pass: Get ENCRYPTION_KEY
        foreach ($lines as $line) {
            $line = trim($line);
            if (empty($line) || strpos($line, '#') === 0) continue;
            
            if (strpos($line, '=') !== false) {
                list($key, $value) = explode('=', $line, 2);
                $key = trim($key);
                $value = trim($value);
                
                if (preg_match('/^(["\'])(.*)\1$/', $value, $matches)) {
                    $value = $matches[2];
                }
                
                if ($key === 'ENCRYPTION_KEY') {
                    $encryption_key = $value;
                    break;
                }
            }
        }
        
        // Second pass: Process all other values
        foreach ($lines as $line) {
            $line = trim($line);
            if (empty($line) || strpos($line, '#') === 0) continue;
            
            if (strpos($line, '=') !== false) {
                list($key, $value) = explode('=', $line, 2);
                $key = trim($key);
                $value = trim($value);
                
                if (preg_match('/^(["\'])(.*)\1$/', $value, $matches)) {
                    $value = $matches[2];
                }
                
                // Skip ENCRYPTION_KEY (already processed)
                if ($key === 'ENCRYPTION_KEY') {
                    continue;
                }
                
                // Decrypt only DB_PASSWORD (other values remain plain text)
                // Support both encrypted and plain text passwords
                if ($key === 'DB_PASSWORD') {
                    if ($encryption_key) {
                        // Try to decrypt, if it fails, use as plain text
                        $decrypted = decrypt_value($value, $encryption_key);
                        $value = $decrypted;
                    }
                    // If no encryption key, use as plain text (backward compatibility)
                }
                
                // Define as constant if it's a WordPress constant
                if (defined_name($key)) {
                    if ($value === 'true' || $value === 'false') {
                        $value = $value === 'true';
                    }
                    if (!defined($key)) {
                        define($key, $value);
                    }
                } else {
                    // Set as environment variable
                    putenv("$key=$value");
                    $_ENV[$key] = $value;
                    $_SERVER[$key] = $value;
                }
            }
        }
    }
}

// Helper function to check if string should be a constant
function defined_name($name) {
    $wp_constants = [
        'DB_NAME', 'DB_USER', 'DB_PASSWORD', 'DB_HOST',
        'DB_CHARSET', 'DB_COLLATE', 'WP_DEBUG', 'WP_DEBUG_DISPLAY',
        'WP_DEBUG_LOG', 'WP_CACHE', 'DISALLOW_FILE_EDIT',
        'CONCATENATE_SCRIPTS', 'AUTH_KEY', 'SECURE_AUTH_KEY',
        'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT',
        'LOGGED_IN_SALT', 'NONCE_SALT', 'WP_TEMP_DIR',
        'COMPRESS_CSS', 'COMPRESS_SCRIPTS', 'ENFORCE_GZIP',
        'WP_ENV', 'WP_HOME', 'WP_SITEURL'
    ];
    return in_array($name, $wp_constants);
}

// ===================================================
// DATABASE SETTINGS (Required from .env)
// ===================================================
// Check if .env file was loaded successfully
$env_loaded = defined('DB_NAME') && !empty(DB_NAME) && 
              defined('DB_USER') && !empty(DB_USER) && 
              defined('DB_PASSWORD');

if (!$env_loaded) {
    // .env file not loaded or incomplete
    // Try to use fallback values or show helpful error
    if (!defined('DB_NAME') || empty(DB_NAME)) {
        define('DB_NAME', 'medyaist_kardeslik');
    }
    if (!defined('DB_USER') || empty(DB_USER)) {
        define('DB_USER', 'medyaist_kardeslikk');
    }
    if (!defined('DB_PASSWORD')) {
        // Fallback password - .env dosyası yüklenemezse bu kullanılacak
        define('DB_PASSWORD', '~w-P~+yvla9rDpyD');
    }
    if (!defined('DB_HOST') || empty(DB_HOST)) {
        define('DB_HOST', 'localhost');
    }
}

// Set default charset and collate if not defined
if (!defined('DB_CHARSET')) {
    define('DB_CHARSET', 'utf8mb4');
}
if (!defined('DB_COLLATE')) {
    define('DB_COLLATE', '');
}

// ===================================================
// AUTHENTICATION KEYS (Required from .env)
// ===================================================
// Set defaults if not defined (will cause security warning if .env missing)
if (!defined('AUTH_KEY')) {
    define('AUTH_KEY', 'x9P#q2!sL1v@ZK8Rk%FmN7wY3tB5vC9xZ2aQ8dE1fG4hJ6kL3mP5rS7uV0wX');
}
if (!defined('SECURE_AUTH_KEY')) {
    define('SECURE_AUTH_KEY', 'YpQ8Z!d#1@F%2T^sK9mN4pR7vW0xY3zA6bC9dE2fG5hJ8kL1mP4rS7uV0wX');
}
if (!defined('LOGGED_IN_KEY')) {
    define('LOGGED_IN_KEY', '7@9%L!P^S#F8d1mN4pR7vW0xY3zA6bC9dE2fG5hJ8kL1mP4rS7uV0wX3zA6');
}
if (!defined('NONCE_KEY')) {
    define('NONCE_KEY', 'K1#d@%F!S9P7^mN4pR7vW0xY3zA6bC9dE2fG5hJ8kL1mP4rS7uV0wX3zA6b');
}
if (!defined('AUTH_SALT')) {
    define('AUTH_SALT', '1S!9@P^%#dF7mN4pR7vW0xY3zA6bC9dE2fG5hJ8kL1mP4rS7uV0wX3zA6bC9');
}
if (!defined('SECURE_AUTH_SALT')) {
    define('SECURE_AUTH_SALT', 'Q8F1!%#^@7PmN4pR7vW0xY3zA6bC9dE2fG5hJ8kL1mP4rS7uV0wX3zA6bC9d');
}
if (!defined('LOGGED_IN_SALT')) {
    define('LOGGED_IN_SALT', 'Z#P^!8@F%7mN4pR7vW0xY3zA6bC9dE2fG5hJ8kL1mP4rS7uV0wX3zA6bC9dE');
}
if (!defined('NONCE_SALT')) {
    define('NONCE_SALT', 'dP9@#^F!7%mN4pR7vW0xY3zA6bC9dE2fG5hJ8kL1mP4rS7uV0wX3zA6bC9dE2');
}

// ===================================================
// WORDPRESS SETTINGS
// ===================================================
if (!defined('WP_DEBUG')) {
    define('WP_DEBUG', false);
    define('WP_DEBUG_DISPLAY', false);
    define('WP_DEBUG_LOG', true);
}

if (!defined('DISALLOW_FILE_EDIT')) {
    define('DISALLOW_FILE_EDIT', true);
}

if (!defined('CONCATENATE_SCRIPTS')) {
    define('CONCATENATE_SCRIPTS', false);
}

// ===================================================
// PERFORMANCE OPTIMIZATIONS
// ===================================================
if (!defined('COMPRESS_CSS')) {
    define('COMPRESS_CSS', true);
}
if (!defined('COMPRESS_SCRIPTS')) {
    define('COMPRESS_SCRIPTS', true);
}
if (!defined('ENFORCE_GZIP')) {
    define('ENFORCE_GZIP', true);
}

// ===================================================
// SITE URLS (Auto-detect if not set)
// ===================================================
if (!defined('WP_HOME')) {
    $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
    $host = $_SERVER['HTTP_HOST'] ?? 'kardeslikvakti.com';
    define('WP_HOME', $protocol . '://' . $host);
}
if (!defined('WP_SITEURL')) {
    define('WP_SITEURL', WP_HOME);
}

// ===================================================
// ENVIRONMENT TYPE
// ===================================================
if (!defined('WP_ENVIRONMENT_TYPE')) {
    $wp_env = 'production';
    if (defined('WP_ENV')) {
        $wp_env = constant('WP_ENV');
    }
    define('WP_ENVIRONMENT_TYPE', $wp_env);
}

// ===================================================
// DATABASE TABLE PREFIX
// ===================================================
// Veritabanında wpyz_ prefix kullanılıyor
$table_prefix = 'wpyz_';

// ===================================================
// MYSQL CLIENT FLAGS
// ===================================================
// MYSQL_CLIENT_FLAGS environment variable'dan al, yoksa default kullan
if (isset($_ENV['MYSQL_CLIENT_FLAGS']) || isset($_SERVER['MYSQL_CLIENT_FLAGS'])) {
    $mysql_flags = isset($_ENV['MYSQL_CLIENT_FLAGS']) ? $_ENV['MYSQL_CLIENT_FLAGS'] : $_SERVER['MYSQL_CLIENT_FLAGS'];
    if ($mysql_flags === 'MYSQLI_CLIENT_COMPRESS') {
        if (!defined('MYSQL_CLIENT_FLAGS')) {
            define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_COMPRESS);
        }
    }
}

// ===================================================
// ABSOLUTE PATH
// ===================================================
if (!defined('ABSPATH')) {
    define('ABSPATH', __DIR__ . '/');
}

// ===================================================
// LOAD WORDPRESS
// ===================================================
// Clear any output buffer before loading WordPress
if (ob_get_level() > 0) {
    ob_end_clean();
}

// Restore error reporting (WordPress will handle it)
error_reporting(E_ALL);
ini_set('display_errors', defined('WP_DEBUG') && WP_DEBUG ? 1 : 0);

require_once ABSPATH . 'wp-settings.php';

Directory Contents

Dirs: 0 × Files: 1
Name Size Perms Modified Actions
10.97 KB lrw-r--r-- 2025-12-18 18:59:10
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).