. */ require_once ROOT . '/php/session.php'; require_once ROOT . '/php/database.php'; const USER_STATUSES = ['none', 'member', 'mod', 'admin']; function find_user(string $username): ?array { $sql = "SELECT id, username, status FROM users WHERE username = :username"; return fetch_row($sql, ['username' => $username]); } function current_user(): ?array { $user_id = get_user_id(); if ($user_id === null) { return null; } $sql = "SELECT id, username, status FROM users WHERE id = :id"; return fetch_row($sql, ['id' => $user_id]); } function is_admin(): bool { $user = current_user(); return $user !== null && $user['status'] === 'admin'; } ?>