<?php
// Database configuration for mph_v3
// Automatically detects local or cPanel environment

// Detect if running on cPanel or localhost
$hostname = $_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? 'localhost';
$is_local = (strpos($hostname, 'localhost') !== false || strpos($hostname, '127.0.0.1') !== false);
$is_cpanel = !$is_local;  // If not local, then it's cPanel

if ($is_cpanel) {
    // cPanel Database Configuration
    $DB_HOST = 'localhost';  // Change to remote host if needed (check cPanel)
    $DB_USER = 'mahamusa';  // Might need prefix: cpaneluser_mahamusa (check cPanel)
    $DB_PASS = 'tCG!c&lpxW8Q';
    $DB_NAME = 'mahamusa_db';  // Might need prefix: cpaneluser_mahamusa_db (check cPanel)
} else {
    // Local XAMPP Configuration (for development)
    $DB_HOST = 'localhost';
    $DB_USER = 'root';
    $DB_PASS = '';
    $DB_NAME = 'login-table';
}

$conn = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if ($conn->connect_error) {
    die('DB connection error: ' . $conn->connect_error . ' (Host: ' . $DB_HOST . ', User: ' . $DB_USER . ', DB: ' . $DB_NAME . ')');
}
$conn->set_charset('utf8mb4');

// DEV OPTION: if true, passwords will be stored and compared in plain text.
// WARNING: Storing plain-text passwords is insecure and strongly discouraged for production.
// Set to true only for local/dev testing if you understand the risks.
$STORE_PLAINTEXT_PASSWORDS = true;

?>
