<?php
// Definiciones de base de datos
define('DB_HOST', 'localhost');
define('DB_USER', 'jkeas');
define('DB_PASS', 'user_jkeas');
define('DB_NAME', 'jkeas');

/* define('DB_HOST', 'localhost');
define('DB_USER', 'demo');
define('DB_PASS', 'user_demo');
define('DB_NAME', 'demo'); */

// Conectar y obtener zona horaria usando PDO
try {
    $pdo = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASS,
        array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    $stmt = $pdo->query("SELECT timezone FROM configuracion LIMIT 1");
    if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        date_default_timezone_set($row['timezone']);
    }
} catch(PDOException $e) {
    die("Error de conexión: " . $e->getMessage());
}

define('SITE_URL', 'http://localhost/jk');
define('UPLOAD_PATH', $_SERVER['DOCUMENT_ROOT'] . '/jk/uploads/');
define('ALLOWED_EXTENSIONS', ['jpg', 'jpeg', 'png', 'gif']);
define('MAX_FILE_SIZE', 5242880); // 5MB

function hex2rgb($hex) {
    $hex = str_replace('#', '', $hex);
    if (strlen($hex) == 3) {
        $r = hexdec(substr($hex,0,1).substr($hex,0,1));
        $g = hexdec(substr($hex,1,1).substr($hex,1,1));
        $b = hexdec(substr($hex,2,1).substr($hex,2,1));
    } else {
        $r = hexdec(substr($hex,0,2));
        $g = hexdec(substr($hex,2,2));
        $b = hexdec(substr($hex,4,2));
    }
    return "$r,$g,$b";
}
?>
