<?php
// config.php

ini_set('display_errors', 1);
error_reporting(E_ALL);

date_default_timezone_set('Asia/Dhaka');

const DB_HOST = 'localhost';
const DB_PORT = 3306;
const DB_NAME = 'takajesx_pk999';


const DB_USER = 'takajesx_pk999';

const DB_PASS = 'wt9pLkjHlIlG';
const DB_CHARSET = 'utf8mb4';

const SITE_NAME = 'PK999.COM';
const ADMIN_PASSWORD = 'admin123';

function db() {
    static $pdo = null;

    if ($pdo instanceof PDO) {
        return $pdo;
    }

    $dsn = 'mysql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME . ';charset=' . DB_CHARSET;

    try {
        $pdo = new PDO($dsn, DB_USER, DB_PASS, [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES => false,
        ]);

        return $pdo;
    } catch (PDOException $e) {
        die('Database connection failed: ' . htmlspecialchars($e->getMessage()));
    }
}