📂 LapTH — File Browser

🏠 Root / Buoi 8 / lab8_4 / config / config.php
File: config.php — text/x-php

← Quay lại | ⬇️ Download | ▶️ Chạy file này (Tab mới)

Nội dung code:

<?php
// Prefer central project config when available (so labs can use host credentials)
$projectCfg = dirname(dirname(dirname(dirname(__DIR__)))) . '/config/config.php';
if (file_exists($projectCfg)) {
	require_once $projectCfg;
	$configDB = array();
	$configDB['host'] = defined('DB_HOST') ? DB_HOST : 'localhost';
	$configDB['database'] = defined('DB_NAME') ? DB_NAME : 'bookstore';
	$configDB['username'] = defined('DB_USER') ? DB_USER : 'root';
	$configDB['password'] = defined('DB_PASS') ? DB_PASS : '';
	if (!defined('HOST')) define('HOST', $configDB['host']);
	if (!defined('DB_NAME')) define('DB_NAME', $configDB['database']);
	if (!defined('DB_USER')) define('DB_USER', $configDB['username']);
	if (!defined('DB_PASS')) define('DB_PASS', $configDB['password']);
} else {
	// Fallback to local settings
	$configDB = array();
	$configDB['host'] = 'localhost';
	$configDB['database'] = 'bookstore';
	$configDB['username'] = 'root';
	$configDB['password'] = '';
	if (!defined('HOST')) define('HOST', 'localhost');
	if (!defined('DB_NAME')) define('DB_NAME', 'bookstore');
	if (!defined('DB_USER')) define('DB_USER', 'root');
	if (!defined('DB_PASS')) define('DB_PASS', '');
}
// Keep BASE_URL for lab links (optional override)
if (!defined('BASE_URL')) {
	define('BASE_URL', 'http://' . ($_SERVER['SERVER_NAME'] ?? 'localhost') . '/lab/');
}