```php
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    $db_host = trim($_POST['db_host']);
    $db_name = trim($_POST['db_name']);
    $db_user = trim($_POST['db_user']);
    $db_pass = trim($_POST['db_pass']);

    try {
        $pdo = new PDO(
            "mysql:host={$db_host};dbname={$db_name};charset=utf8mb4",
            $db_user,
            $db_pass,
            [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
        );
    } catch (PDOException $e) {
        die("Database connection failed: " . $e->getMessage());
    }

    $dirs = [
        'core',
        'modules/forum',
        'modules/business',
        'modules/events',
        'public',
        'assets/css',
        'assets/js',
        'storage/logs'
    ];

    foreach ($dirs as $dir) {
        if (!is_dir($dir)) {
            mkdir($dir, 0755, true);
        }
    }

    file_put_contents('core/config.php', <<<PHP
<?php
return [
    'db_host' => '{$db_host}',
    'db_name' => '{$db_name}',
    'db_user' => '{$db_user}',
    'db_pass' => '{$db_pass}',
];
PHP
    );

    $tables = [
        "CREATE TABLE IF NOT EXISTS users (
            id INT AUTO_INCREMENT PRIMARY KEY,
            username VARCHAR(50) UNIQUE NOT NULL,
            email VARCHAR(100) UNIQUE NOT NULL,
            password VARCHAR(255) NOT NULL,
            role ENUM('user','admin') DEFAULT 'user',
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )",
        "CREATE TABLE IF NOT EXISTS forum_categories (
            id INT AUTO_INCREMENT PRIMARY KEY,
            name VARCHAR(100) NOT NULL
        )",
        "CREATE TABLE IF NOT EXISTS forums (
            id INT AUTO_INCREMENT PRIMARY KEY,
            category_id INT NOT NULL,
            name VARCHAR(100) NOT NULL
        )",
        "CREATE TABLE IF NOT EXISTS threads (
            id INT AUTO_INCREMENT PRIMARY KEY,
            forum_id INT NOT NULL,
            user_id INT NOT NULL,
            title VARCHAR(255) NOT NULL,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )",
        "CREATE TABLE IF NOT EXISTS posts (
            id INT AUTO_INCREMENT PRIMARY KEY,
            thread_id INT NOT NULL,
            user_id INT NOT NULL,
            content TEXT NOT NULL,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )",
        "CREATE TABLE IF NOT EXISTS businesses (
            id INT AUTO_INCREMENT PRIMARY KEY,
            user_id INT NOT NULL,
            name VARCHAR(150) NOT NULL,
            description TEXT,
            location VARCHAR(100),
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )",
        "CREATE TABLE IF NOT EXISTS events (
            id INT AUTO_INCREMENT PRIMARY KEY,
            user_id INT NOT NULL,
            title VARCHAR(150) NOT NULL,
            description TEXT,
            event_date DATE,
            location VARCHAR(100),
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )"
    ];

    foreach ($tables as $sql) {
        $pdo->exec($sql);
    }

    file_put_contents('core/database.php', <<<'PHP'
<?php
$config = require __DIR__ . '/config.php';

$pdo = new PDO(
    "mysql:host={$config['db_host']};dbname={$config['db_name']};charset=utf8mb4",
    $config['db_user'],
    $config['db_pass'],
    [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
PHP
    );

    file_put_contents('core/auth.php', <<<'PHP'
<?php
session_start();

function isLoggedIn() {
    return isset($_SESSION['user_id']);
}
PHP
    );

    file_put_contents('public/index.php', <<<'PHP'
<?php
require __DIR__ . '/../core/auth.php';
?>
<!doctype html>
<html>
<head><title>Hoonhub</title></head>
<body>
<h1>Hoonhub</h1>
<?php if (isLoggedIn()): ?>
    <p>You are logged in. logout.phpLogout</a></p>
<?php else: ?>
    <p>login.phpLogin</a> | register.phpRegister</a></p>
<?php endif; ?>
</body>
</html>
PHP
    );

    file_put_contents('public/register.php', <<<'PHP'
<?php
require __DIR__ . '/../core/database.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $stmt = $pdo->prepare(
        'INSERT INTO users (username, email, password) VALUES (?, ?, ?)'
    );
    $stmt->execute([
        $_POST['username'],
        $_POST['email'],
        password_hash($_POST['password'], PASSWORD_DEFAULT)
    ]);
    header('Location: login.php');
    exit;
}
?>
<form method="post">
<input name="username" placeholder="Username" required><br>
<input name="email" placeholder="Email" required><br>
<input name="password" type="password" placeholder="Password" required><br>
<button>Register</button>
</form>
PHP
    );

    file_put_contents('public/login.php', <<<'PHP'
<?php
require __DIR__ . '/../core/database.php';
require __DIR__ . '/../core/auth.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $stmt = $pdo->prepare('SELECT * FROM users WHERE username = ?');
    $stmt->execute([$_POST['username']]);
    $user = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($user && password_verify($_POST['password'], $user['password'])) {
        $_SESSION['user_id'] = $user['id'];
        header('Location: index.php');
        exit;
    }
}
?>
<form method="post">
<input name="username" placeholder="Username" required><br>
<input name="password" type="password" placeholder="Password" required><br>
<button>Login</button>
</form>
PHP
    );

    file_put_contents('public/logout.php', <<<'PHP'
<?php
session_start();
session_destroy();
header('Location: index.php');
exit;
PHP
    );

    echo "<h2>Installation complete. Delete installer.php.</h2>";
    exit;
}
?>
<!doctype html>
<html>
<head><title>Hoonhub Installer</title></head>
<body>
<h2>Hoonhub Installer</h2>
<form method="post">
<input name="db_host" placeholder="DB Host" required><br>
<input name="db_name" placeholder="DB Name" required><br>
<input name="db_user" placeholder="DB User" required><br>
<input name="db_pass" placeholder="DB Password"><br><br>
<button>Install</button>
</form>
</body>
</html>
```