Uncaught TypeError

Argument 1 passed to AvatarSource::getAvatarFromUUID() must be of the type string, null given, called in /var/www/html/divinerealms.org/core/classes/Avatars/AvatarSource.php on line 86

(File: /var/www/html/divinerealms.org/core/classes/Avatars/AvatarSource.php)

https://divinerealms.org/profile/Neeonn/


File: /var/www/html/divinerealms.org/core/classes/Avatars/AvatarSource.php
 * @package NamelessMC\Avatars
 * @author Aberdeener
 * @version 2.0.0-pr10
 * @license MIT
 */
class AvatarSource {

    protected static array $_sources = [];

    protected static AvatarSourceBase $_active_source;

    /**
     * Main usage of this class.
     * Uses active avatar source to get the URL of their Minecraft avatar.
     *
     * @param string $uuid UUID of avatar to get.
     * @param int $size Size in pixels to render avatar at. Default 128
     *
     * @return string Compiled URL of avatar image.
     */
    public static function getAvatarFromUUID(string $uuid, int $size = 128): string {
        return self::getActiveSource()->getAvatar($uuid, self::getDefaultPerspective(), $size);
    }

    /**
     * Get a user's avatar from their raw data object.
     * Used by the API for TinyMCE mention avatars to avoid reloading the user from the database.
     *
     * @param object $data User data to use
     * @param bool $allow_gifs Whether to allow GIFs or not ()
     * @param int $size Size in pixels to render avatar at. Default 128
     * @param bool $full Whether to return the full URL or just the path
     *
     * @return string Full URL of avatar image.
     */
    public static function getAvatarFromUserData(object $data, bool $allow_gifs = false, int $size = 128, bool $full = false): string {
        // If custom avatars are enabled, first check if they have gravatar enabled, and then fallback to normal image
        if (defined('CUSTOM_AVATARS')) {
            if ($data->gravatar) {
                return 'https://secure.gravatar.com/avatar/' . md5(strtolower(trim($data->email))) . '?s=' . $size;
            }
File: /var/www/html/divinerealms.org/core/classes/Avatars/AvatarSource.php
        // Fallback to default avatar image if it is set and the avatar type is custom
        if (defined('DEFAULT_AVATAR_TYPE') && DEFAULT_AVATAR_TYPE == 'custom' && DEFAULT_AVATAR_IMAGE !== '') {
            if (file_exists(ROOT_PATH . '/uploads/avatars/defaults/' . DEFAULT_AVATAR_IMAGE)) {
                // We don't check the validity here since we know the file exists for sure
                return ($full ? rtrim(Util::getSelfURL(), '/') : '') . ((defined('CONFIG_PATH')) ? CONFIG_PATH . '/' : '/') . 'uploads/avatars/defaults/' . DEFAULT_AVATAR_IMAGE;
            }
        }

        // Attempt to get their MC avatar if Minecraft integration is enabled
        if (MINECRAFT) {
            if ($data->uuid != null && $data->uuid != 'none') {
                $uuid = $data->uuid;
            } else {
                $uuid = $data->username;
                // Fallback to steve avatar if they have an invalid username
                if (preg_match('#[^][_A-Za-z0-9]#', $uuid)) {
                    $uuid = 'Steve';
                }
            }

            $url = self::getAvatarFromUUID($uuid, $size);
            // The avatar might be invalid if they are using
            // an MC avatar service that uses only UUIDs
            // and this user doesn't have one
            if (self::validImageUrl($url)) {
                return $url;
            }
        }

        return "https://avatars.dicebear.com/api/initials/{$data->username}.svg?size={$size}";
    }

    /**
     * Determine if a URL is a valid image URL for avatars.
     *
     * @param string $url URL to check
     * @return bool Whether the URL is a valid image URL
     */
    private static function validImageUrl(string $url): bool {
        $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']);
        $cache->setCache('avatar_validity');
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get this user's avatar.
     *
     * @param int $size Size of image to render in pixels.
     * @param bool $full Whether to use full site URL or not, for external loading - ie discord webhooks.
     *
     * @return string URL to their avatar image.
     */
    public function getAvatar(int $size = 128, bool $full = false): string {
        $data_obj = (object) $this->data();

        $integrationUser = $this->getIntegration('Minecraft');
        if ($integrationUser != null) {
            $data_obj->uuid = $integrationUser->data()->identifier;
        } else {
            $data_obj->uuid = '';
        }

        return AvatarSource::getAvatarFromUserData($data_obj, $this->hasPermission('usercp.gif_avatar'), $size, $full);
    }

    /**
     * Does the user have a specific permission in any of their groups?
     *
     * @param string $permission Permission node to check recursively for.
     *
     * @return bool Whether they inherit this permission or not.
     */
    public function hasPermission(string $permission): bool {
        $groups = $this->_groups;

        if (!$groups || !$this->exists()) {
            return false;
        }

        foreach ($groups as $group) {
            $permissions = json_decode($group->permissions, true) ?? [];

            if (isset($permissions['administrator']) && $permissions['administrator'] == 1) {
File: /var/www/html/divinerealms.org/modules/Friends/profile_tab.php
**/

$profileUser = explode('/', trim($_GET['route'], '/'));
$profileUser = $profileUser[1];
$profileUser = DB::getInstance()->get('users', ['username', '=', $profileUser])->results();
$profileUser = $profileUser[0];

require(__DIR__ . '/classes/Friends.php');
$friends = new Friends($user, $profileUser, $language, $friendsLanguage, $smarty);
$friends->processPost();

$friendsList = [];
$friendsQuery = $friends->query($profileUser->id);
if (!empty($friendsQuery)) {
    foreach ($friendsQuery as $friend) {
        $friendID = (($friend->user_id == $profileUser->id) ? $friend->friend_id : $friend->user_id);
        $friendUser = new User($friendID);
        $friendsList[] = [
            'id' => $friendUser->data()->id,
            'uuid' => $friendUser->data()->uuid,
            'avatar' => $friendUser->getAvatar(),
            'profile' => $friendUser->getProfileURL(),
            'username' => $friendUser->getDisplayname(true),
            'nickname' => $friendUser->getDisplayname(),
            'style' => $friendUser->getGroupStyle(),
            'title' => Output::getClean($friendUser->data()->user_title),
        ];
    }
}

$smarty->assign('FRIENDS', [
    'title' => FriendsModule::getLanguage('general', 'title'),
    'button' => $friends->generateButton(),
    'list' => $friendsList,
    'no_friends' => FriendsModule::getLanguage('general', 'no_friends'),
]);
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
        'type' => 'text',
        'value' => $timeago->inWords($query->last_online, $language),
        'tooltip' => date(DATE_FORMAT, $query->last_online)
    ];

    // Add Profile views
    $fields['profile_views'] = [
        'title' => $language->get('user', 'views'),
        'type' => 'text',
        'value' => $query->profile_views
    ];

    $smarty->assign('ABOUT_FIELDS', $fields);

    // Custom tabs
    $tabs = [];
    if (isset($profile_tabs) && count($profile_tabs)) {
        foreach ($profile_tabs as $key => $tab) {
            $tabs[$key] = ['title' => $tab['title'], 'include' => $tab['smarty_template']];
            if (is_file($tab['require'])) {
                require($tab['require']);
            }
        }
    }

    // Assign profile tabs
    $smarty->assign('TABS', $tabs);

    if (isset($directories[1]) && !empty($directories[1]) && !isset($_GET['error']) && $user->isLoggedIn() && $user->data()->username == $profile) {
        // Script for banner selector
        $template->assets()->include([
            AssetTree::IMAGE_PICKER,
        ]);
    }

    if (Session::exists('profile_banner_error')) {
        $smarty->assign('ERROR', Session::flash('profile_banner_error'));
    }

    // Load modules + template
    Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);
File: /var/www/html/divinerealms.org/index.php
        die();
    }
} else {
    // Use recursion to check - might have URL parameters in path
    $path_array = explode('/', $route);

    for ($i = count($path_array) - 2; $i > 0; $i--) {

        $new_path = '/';
        for ($n = 1; $n <= $i; $n++) {
            $new_path .= $path_array[$n] . '/';
        }

        $new_path = rtrim($new_path, '/');

        if (array_key_exists($new_path, $all_pages)) {
            $path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', $all_pages[$new_path]['module'], $all_pages[$new_path]['file']]);

            if (file_exists($path)) {
                $pages->setActivePage($all_pages[$new_path]);
                require($path);
                die();
            }
        }
    }
}

require(ROOT_PATH . '/404.php');
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id =;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_users WHERE `id` = '16';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '21';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '7';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '4';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '2';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_friends WHERE (user_id = 1 AND accepted = 1) OR (friend_id = 1 AND accepted = 1);
File: /var/www/html/divinerealms.org/modules/Friends/classes/Friends.php
 *    FRIENDS MODULE
 *    By Xemah | https://xemah.com
 *
**/
 
class Friends
{
    public function __construct($user, $profileUser, $language, $friendsLanguage, $smarty)
    {
        $this->_db = DB::getInstance();
        $this->_user = $user;
        $this->_profileUser = $profileUser;
        $this->_language = $language;
        $this->_friendsLanguage = $friendsLanguage;
        $this->_smarty = $smarty;
        $this->_modulePath = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..'); 
    }
    
    public function query($user)
    {
        $query = $this->_db->query("SELECT * FROM nl2_friends WHERE (user_id = $user AND accepted = 1) OR (friend_id = $user AND accepted = 1)");
        $data = $query->results();

        return ($data ? $data : []);
    }

    public function queryFriend($user1, $user2, $reversible = 1)
    {
        $query = $this->_db->query("SELECT * FROM nl2_friends WHERE user_id = $user1 AND friend_id = $user2");
        $data = $query->results();

        if (empty($data) && $reversible) {
            $query = $this->_db->query("SELECT * FROM nl2_friends WHERE user_id = $user2 AND friend_id = $user1");
            $data = $query->results();
        }

        return (!empty($data) ? $data[0] : null);
    }

    private function addFriend($user1, $user2)
    {
SQL query:
SELECT * FROM nl2_users WHERE `username` = 'Neeonn';
File: /var/www/html/divinerealms.org/modules/Friends/profile_tab.php
<?php

/**
 *	FRIENDS MODULE
 *	By Xemah | https://xemah.com
 *
**/

$profileUser = explode('/', trim($_GET['route'], '/'));
$profileUser = $profileUser[1];
$profileUser = DB::getInstance()->get('users', ['username', '=', $profileUser])->results();
$profileUser = $profileUser[0];

require(__DIR__ . '/classes/Friends.php');
$friends = new Friends($user, $profileUser, $language, $friendsLanguage, $smarty);
$friends->processPost();

$friendsList = [];
$friendsQuery = $friends->query($profileUser->id);
if (!empty($friendsQuery)) {
    foreach ($friendsQuery as $friend) {
        $friendID = (($friend->user_id == $profileUser->id) ? $friend->friend_id : $friend->user_id);
        $friendUser = new User($friendID);
        $friendsList[] = [
            'id' => $friendUser->data()->id,
            'uuid' => $friendUser->data()->uuid,
            'avatar' => $friendUser->getAvatar(),
            'profile' => $friendUser->getProfileURL(),
            'username' => $friendUser->getDisplayname(true),
            'nickname' => $friendUser->getDisplayname(),
            'style' => $friendUser->getGroupStyle(),
SQL query:
SELECT * FROM nl2_users_placeholders up JOIN nl2_placeholders_settings ps ON up.name = ps.name AND up.server_id = ps.server_id WHERE up.uuid = ;
File: /var/www/html/divinerealms.org/core/classes/Misc/Placeholders.php
     * Create a new row in nl2_placeholders_settings if a row with the "server_id" of $server_id and "name" of $name does not exist (this lets the same placeholder name be used across multiple NamelessMC plugin servers).
     *
     * @param int $server_id ID of the server this placeholder resides on
     *
     * @param string $name Name of placeholder
     */
    public function registerPlaceholder(int $server_id, string $name): void {
        $this->_db->query('INSERT IGNORE INTO nl2_placeholders_settings (server_id, name) VALUES (?, ?)', [$server_id, $name]);
    }

    /**
     * Load placeholders for a specific user.
     *
     * @param string $uuid Their valid Minecraft uuid to use for lookup.
     *
     * @return array Their placeholders.
     */
    public function loadUserPlaceholders(string $uuid): array {
        $binUuid = hex2bin(str_replace('-', '', $uuid));

        $placeholder_query = $this->_db->query('SELECT * FROM nl2_users_placeholders up JOIN nl2_placeholders_settings ps ON up.name = ps.name AND up.server_id = ps.server_id WHERE up.uuid = ?', [$binUuid]);

        if (!$placeholder_query->count()) {
            return [];
        }

        $user_placeholders = [];

        $placeholders = $placeholder_query->results();
        foreach ($placeholders as $placeholder) {
            $data = new stdClass();

            $data->server_id = $placeholder->server_id;
            $data->name = Output::getClean($placeholder->name);
            $data->friendly_name = isset($placeholder->friendly_name) ? Output::getClean($placeholder->friendly_name) : Output::getClean($placeholder->name);
            $data->value = Output::getClean($placeholder->value);
            $data->last_updated = $placeholder->last_updated;
            $data->show_on_profile = $placeholder->show_on_profile;
            $data->show_on_forum = $placeholder->show_on_forum;

            $user_placeholders[$data->name] = $data;
SQL query:
SELECT * FROM nl2_placeholders_settings WHERE `name` <> '';
File: /var/www/html/divinerealms.org/core/classes/Misc/Placeholders.php
<?php
/**
 * Manages registering and retrieving PAPI placeholders.
 *
 * @package NamelessMC\Misc
 * @author Aberdeener
 * @version 2.0.0-pr12
 * @license MIT
 */
class Placeholders extends Instanceable {

    private DB $_db;

    private array $_all_placeholders;

    public function __construct() {
        $this->_db = DB::getInstance();

        $placeholders_query = $this->_db->get('placeholders_settings', ['name', '<>', ''])->results();
        $placeholders = [];

        foreach ($placeholders_query as $placeholder) {
            $data = new stdClass();

            $sort = $placeholder->leaderboard_sort;

            if (!in_array($sort, ['ASC', 'DESC'])) {
                $sort = 'DESC';
            }

            $data->server_id = $placeholder->server_id;
            $data->name = $placeholder->name;
            $data->safe_name = sha1($placeholder->name);
            $data->friendly_name = $placeholder->friendly_name ?? $placeholder->name;
            $data->show_on_profile = $placeholder->show_on_profile;
            $data->show_on_forum = $placeholder->show_on_forum;
            $data->leaderboard = $placeholder->leaderboard;
            $data->leaderboard_title = $placeholder->leaderboard_title ?? $data->friendly_name;
            $data->leaderboard_sort = $sort;
SQL query:
SELECT pf.*, upf.id as upf_id, upf.value, upf.updated FROM nl2_profile_fields pf LEFT JOIN nl2_users_profile_fields upf ON (pf.id = upf.field_id AND upf.user_id = '1');
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Get if the current user is authenticated as an administrator.
     *
     * @return bool Whether they're logged in as admin.
     */
    public function isAdmLoggedIn(): bool {
        return $this->_isAdmLoggedIn;
    }

    /**
     * Get profile fields for this user
     *
     * @param bool $show_private Whether to only return public fields or not (default `true`).
     * @param bool $only_forum Whether to only return fields which display on forum posts, only if $public is true (default `false`).
     *
     * @return array<int, UserProfileField> Array of profile fields.
     */
    public function getProfileFields(bool $show_private = false, bool $only_forum = false): array {
        $rows = DB::getInstance()->query('SELECT pf.*, upf.id as upf_id, upf.value, upf.updated FROM nl2_profile_fields pf LEFT JOIN nl2_users_profile_fields upf ON (pf.id = upf.field_id AND upf.user_id = ?)', [
            $this->data()->id,
        ])->results();

        $fields = [];

        foreach ($rows as $row) {
            $field = new UserProfileField($row);
            // Check that the field is public, or they are viewing private fields
            // also if they're checking forum fields, check that the field is a forum field
            // TODO: ideally within the query
            if (($field->public || $show_private) && (!$only_forum || $field->forum_posts)) {
                $fields[$row->id] = $field;
            }
        }

        return $fields;
    }

    /**
     * Is a user blocked?
     *
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '2';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '2' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '2';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 2 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '2';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '2';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '4';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '4' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '4';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 5 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '5';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '4';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '5';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '5' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '5';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 7 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '7';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '5';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '17';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 8 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '8';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '17';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '17';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '17' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '17';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 9 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '9';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '17';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '7';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '7' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '7';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 10 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '10';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '7';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '10';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '10' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '10';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 11 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '11';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '10';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '21';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '21' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '21';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 13 ORDER BY time ASC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
                        'user_id' => Output::getClean($reaction->user_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        //'reaction_name' => $reaction_name,
                        //'reaction_html' => $reaction_html
                    ];
                }
            } else {
                $reactions['count'] = $language->get('user', 'x_reactions', ['count' => 0]);
            }
            $reactions_query = null;

            $replies_query = DB::getInstance()->orderWhere('user_profile_wall_posts_replies', 'post_id = ' . $nValue->id, 'time', 'ASC')->results();
            if (count($replies_query)) {
                if (count($replies_query) == 1) {
                    $replies['count'] = $language->get('user', '1_reply');
                } else {
                    $replies['count'] = $language->get('user', 'x_replies', ['count' => count($replies_query)]);
                }

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '1' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `id` = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '13';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
                    /*
                    $reaction_name = DB::getInstance()->get('reactions', array('id', $reaction->reaction_id))->results();

                    if (!count($reaction_name) || $reaction_name[0]->enabled == 0) continue;
                    $reaction_html = $reaction_name[0]->html;
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '21';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }

            // Get reactions/replies
            $reactions = [];
            $replies = [];

            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                if (count($reactions_query) == 1) {
                    $reactions['count'] = $language->get('user', '1_reaction');
                } else {
                    $reactions['count'] = $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);
                }

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT * FROM nl2_user_profile_wall_posts WHERE user_id = 1 ORDER BY time DESC;
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
        'FEED' => $language->get('user', 'feed'),
        'ABOUT' => $language->get('user', 'about'),
        'REACTIONS_TITLE' => $language->get('user', 'likes'),
        //'REACTIONS' => $reactions,
        'CLOSE' => $language->get('general', 'close'),
        'REPLIES_TITLE' => $language->get('user', 'replies'),
        'NO_REPLIES' => $language->get('user', 'no_replies_yet'),
        'NEW_REPLY' => $language->get('user', 'new_reply'),
        'DELETE' => $language->get('general', 'delete'),
        'CONFIRM_DELETE' => $language->get('general', 'confirm_deletion'),
        'EDIT' => $language->get('general', 'edit'),
        'SUCCESS_TITLE' => $language->get('general', 'success'),
        'ERROR_TITLE' => $language->get('general', 'error'),
        'REPLY' => $language->get('user', 'reply'),
        'EDIT_POST' => $language->get('general', 'edit'),
        'VIEWER_ID' => $user->isLoggedIn() ? $user->data()->id : 0,
    ]);

    // Wall posts
    $wall_posts = [];
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    if (count($wall_posts_query)) {
        // Pagination
        $paginator = new Paginator(
            $template_pagination ?? null,
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

        $smarty->assign('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            $post_user = DB::getInstance()->get('users', ['id', $nValue->author_id])->results();

            if (!count($post_user)) {
                continue;
            }
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
    }

    /**
     * Get the user's groups.
     *
     * @return array Their groups.
     */
    public function getGroups(): array {
        return $this->_groups;
    }

    /**
     * Get the user's integrations.
     *
     * @return IntegrationUser[] Their integrations.
     */
    public function getIntegrations(): array {
        return $this->_integrations ??= (function (): array {
            $integrations = Integrations::getInstance();

            $integrations_query = $this->_db->query('SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = ?', [$this->data()->id]);
            if ($integrations_query->count()) {
                $integrations_query = $integrations_query->results();

                $integrations_list = [];
                foreach ($integrations_query as $item) {
                    $integration = $integrations->getIntegration($item->integration_name);
                    if ($integration != null) {
                        $integrationUser = new IntegrationUser($integration, $this->data()->id, 'user_id', $item);

                        $integrations_list[$item->integration_name] = $integrationUser;
                    }
                }

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
UPDATE nl2_users SET profile_views = profile_views + 1 WHERE id = '1';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
            // Avoid bug in pagination class
            Redirect::to($profile_user->getProfileURL());
        }
        $p = $_GET['p'];
    } else {
        $p = 1;
    }

    // View count
    // Check if user is logged in and the viewer is not the owner of this profile.
    if (($user->isLoggedIn() && $user->data()->id != $query->id)
        // If no one is logged in check if they have accepted the cookies.
        || (!$user->isLoggedIn() && (defined('COOKIE_CHECK') && COOKIES_ALLOWED))
    ) {
        if (!Cookie::exists('nl-profile-' . $query->id)) {
            DB::getInstance()->increment('users', $query->id, 'profile_views');
            Cookie::put('nl-profile-' . $query->id, 'true', 3600);
        }
    } else {
        if (!Session::exists('nl-profile-' . $query->id)) {
            DB::getInstance()->increment('users', $query->id, 'profile_views');
            Session::put('nl-profile-' . $query->id, 'true');
        }
    }

    // Set Can view
    if ($profile_user->isPrivateProfile() && $user->canPrivateProfile()) {
        $smarty->assign([
            'PRIVATE_PROFILE' => $language->get('user', 'private_profile_page'),
            'CAN_VIEW' => false
        ]);
    } else {
        $smarty->assign([
            'CAN_VIEW' => true
        ]);
    }

    // Generate Smarty variables to pass to template
    if ($user->isLoggedIn()) {
        // Form token
        $smarty->assign([
SQL query:
SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = '1' AND deleted = 0 ORDER BY `order`;
File: /var/www/html/divinerealms.org/core/classes/Core/User.php
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
                    ];

                } else {
                    // Get default group
                    // TODO: Use PRE_VALIDATED_DEFAULT ?
                    $default_group = $this->_db->query('SELECT * FROM nl2_groups WHERE default_group = 1', [])->first();
                    if ($default_group) {
                        $default_group_id = $default_group->id;
                    } else {
SQL query:
SELECT * FROM nl2_users WHERE `username` = 'Neeonn';
File: /var/www/html/divinerealms.org/core/classes/Core/User.php

    /**
     * Find a user by unique identifier (username, ID, email, etc).
     * Loads instance variables for this class.
     *
     * @param string|null $value Unique identifier.
     * @param string $field What column to check for their unique identifier in.
     *
     * @return bool True/false on success or failure respectfully.
     */
    public function find(string $value = null, string $field = 'id'): bool {
        if ($value) {
            if (isset(self::$_user_cache["$value.$field"])) {
                $cache = self::$_user_cache["$value.$field"];
                $this->_data = $cache['data'];
                $this->_groups = $cache['groups'];
                return true;
            }

            if ($field != 'hash') {
                $data = $this->_db->get('users', [$field, $value]);
            } else {
                $data = $this->_db->query('SELECT nl2_users.* FROM nl2_users LEFT JOIN nl2_users_session ON nl2_users.id = user_id WHERE hash = ? AND nl2_users_session.active = 1', [$value]);
            }

            if ($data->count()) {
                $this->_data = new UserData($data->first());

                // Get user groups
                $groups_query = $this->_db->query('SELECT nl2_groups.* FROM nl2_users_groups INNER JOIN nl2_groups ON group_id = nl2_groups.id WHERE user_id = ? AND deleted = 0 ORDER BY `order`;', [$this->data()->id]);

                if ($groups_query->count()) {

                    $groups_query = $groups_query->results();
                    foreach ($groups_query as $item) {
                        $this->_groups[$item->id] = new Group($item);
                    }

                    self::$_user_cache["$value.$field"] = [
                        'data' => $this->_data,
                        'groups' => $this->_groups,
SQL query:
SELECT * FROM nl2_page_descriptions WHERE `page` = '/profile/Neeonn';
File: /var/www/html/divinerealms.org/core/templates/frontend_init.php
        $default_group = $cache->retrieve('default_group');
    } else {
        try {
            $default_group = Group::find(1, 'default_group')->id;
        } catch (Exception $e) {
            $default_group = 1;
        }

        $cache->store('default_group', $default_group);
    }
}

// Page metadata
if (isset($_GET['route']) && $_GET['route'] != '/') {
    $route = rtrim($_GET['route'], '/');
} else {
    $route = '/';
}

if (!defined('PAGE_DESCRIPTION')) {
    $page_metadata = DB::getInstance()->get('page_descriptions', ['page', $route])->results();
    if (count($page_metadata)) {
        $smarty->assign([
            'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), $page_metadata[0]->description),
            'PAGE_KEYWORDS' => $page_metadata[0]->tags
        ]);
    }
} else {
    $smarty->assign([
        'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), PAGE_DESCRIPTION),
        'PAGE_KEYWORDS' => (defined('PAGE_KEYWORDS') ? PAGE_KEYWORDS : '')
    ]);
}

$smarty->assign('TITLE', $page_title);

$cache->setCache('backgroundcache');

$banner_image = $cache->retrieve('banner_image');

if (!empty($banner_image)) {
SQL query:
SELECT * FROM nl2_page_descriptions WHERE `page` = '/profile';
File: /var/www/html/divinerealms.org/modules/Core/pages/profile.php
/*
 *	Made by Samerton
 *  https://github.com/NamelessMC/Nameless/
 *  NamelessMC version 2.0.0-pr13
 *
 *  License: MIT
 *
 *  User profile page
 */

// Always define page name
const PAGE = 'profile';

$timeago = new TimeAgo(TIMEZONE);

$profile = explode('/', rtrim($_GET['route'], '/'));
if (count($profile) >= 3 && ($profile[count($profile) - 1] != 'profile' || $profile[count($profile) - 2] == 'profile') && !isset($_GET['error'])) {
    // User specified
    $md_profile = $profile[count($profile) - 1];

    $page_metadata = DB::getInstance()->get('page_descriptions', ['page', '/profile'])->results();
    if (count($page_metadata)) {
        define('PAGE_DESCRIPTION', str_replace(['{site}', '{profile}'], [Output::getClean(SITE_NAME), Output::getClean($md_profile)], $page_metadata[0]->description));
        define('PAGE_KEYWORDS', $page_metadata[0]->tags);
    }

    $page_title = $language->get('user', 'profile') . ' - ' . Output::getClean($md_profile);
} else {
    $page_title = $language->get('user', 'profile');
}

require_once(ROOT_PATH . '/core/templates/frontend_init.php');

$template->assets()->include([
    DARK_MODE
        ? AssetTree::PRISM_DARK
        : AssetTree::PRISM_LIGHT,
    AssetTree::TINYMCE_SPOILER,
]);

$template->addCSSStyle(
SQL query:
UPDATE nl2_online_guests SET `last_seen` = '1789' WHERE `id` =;
File: /var/www/html/divinerealms.org/core/init.php
            'user_title' => Output::getClean($user->data()->user_title),
            'avatar' => $user->getAvatar(),
            'integrations' => $user_integrations
        ]);

        // Panel access?
        if ($user->canViewStaffCP()) {
            $smarty->assign([
                'PANEL_LINK' => URL::build('/panel'),
                'PANEL' => $language->get('moderator', 'staff_cp')
            ]);
        }
    } else {
        // Perform tasks for guests
        if (!$_SESSION['checked'] || (isset($_SESSION['checked']) && $_SESSION['checked'] <= strtotime('-5 minutes'))) {
            $already_online = DB::getInstance()->get('online_guests', ['ip', $ip])->results();

            $date = date('U');

            if (count($already_online)) {
                DB::getInstance()->update('online_guests', $already_online[0]->id, ['last_seen' => $date]);
            } else {
                DB::getInstance()->insert('online_guests', ['ip' => $ip, 'last_seen' => $date]);
            }

            $_SESSION['checked'] = $date;
        }
    }

    // Dark mode
    $cache->setCache('template_settings');
    $darkMode = $cache->isCached('darkMode') ? $cache->retrieve('darkMode') : '0';
    if ($user->isLoggedIn()) {
        $darkMode = $user->data()->night_mode !== null ? $user->data()->night_mode : $darkMode;
    } else {
        if (Cookie::exists('night_mode')) {
            $darkMode = Cookie::get('night_mode');
        }
    }

    define('DARK_MODE', $darkMode);
SQL query:
SELECT * FROM nl2_online_guests WHERE `ip` = '172.70.135.27';
File: /var/www/html/divinerealms.org/core/init.php
            'username' => $user->getDisplayname(true),
            'nickname' => $user->getDisplayname(),
            'profile' => $user->getProfileURL(),
            'panel_profile' => URL::build('/panel/user/' . urlencode($user->data()->id) . '-' . urlencode($user->data()->username)),
            'username_style' => $user->getGroupStyle(),
            'user_title' => Output::getClean($user->data()->user_title),
            'avatar' => $user->getAvatar(),
            'integrations' => $user_integrations
        ]);

        // Panel access?
        if ($user->canViewStaffCP()) {
            $smarty->assign([
                'PANEL_LINK' => URL::build('/panel'),
                'PANEL' => $language->get('moderator', 'staff_cp')
            ]);
        }
    } else {
        // Perform tasks for guests
        if (!$_SESSION['checked'] || (isset($_SESSION['checked']) && $_SESSION['checked'] <= strtotime('-5 minutes'))) {
            $already_online = DB::getInstance()->get('online_guests', ['ip', $ip])->results();

            $date = date('U');

            if (count($already_online)) {
                DB::getInstance()->update('online_guests', $already_online[0]->id, ['last_seen' => $date]);
            } else {
                DB::getInstance()->insert('online_guests', ['ip' => $ip, 'last_seen' => $date]);
            }

            $_SESSION['checked'] = $date;
        }
    }

    // Dark mode
    $cache->setCache('template_settings');
    $darkMode = $cache->isCached('darkMode') ? $cache->retrieve('darkMode') : '0';
    if ($user->isLoggedIn()) {
        $darkMode = $user->data()->night_mode !== null ? $user->data()->night_mode : $darkMode;
    } else {
        if (Cookie::exists('night_mode')) {
SQL query:
SELECT * FROM nl2_integrations WHERE name = 'Discord';
File: /var/www/html/divinerealms.org/core/classes/Integrations/IntegrationBase.php
 * @package NamelessMC\Integrations
 * @author Partydragen
 * @version 2.0.0-pr13
 * @license MIT
 */

abstract class IntegrationBase {

    private DB $_db;
    private IntegrationData $_data;
    protected string $_icon;
    private array $_errors = [];
    protected Language $_language;

    protected string $_name;
    protected ?int $_order;

    public function __construct() {
        $this->_db = DB::getInstance();

        $integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name]);
        if ($integration->count()) {
            $integration = $integration->first();

            $this->_data = new IntegrationData($integration);
            $this->_order = $integration->order;
        } else {
            // Register integration to database
            $this->_db->query('INSERT INTO nl2_integrations (name) VALUES (?)', [
                $this->_name
            ]);

            $integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name])->first();

            $this->_data = new IntegrationData($integration);
            $this->_order = $integration->order;
        }
    }

    /**
     * Get the name of this integration.
SQL query:
SELECT form_id FROM nl2_forms_permissions WHERE form_id = '3' AND post = 1 AND group_id IN(0);
File: /var/www/html/divinerealms.org/modules/Forms/module.php

        try {
            $forms = $this->_db->query('SELECT id, link_location, url, icon, title, guest FROM nl2_forms')->results();
            if (count($forms)) {
                if ($user->isLoggedIn()) {
                    $group_ids = implode(',', $user->getAllGroupIds());
                } else {
                    $group_ids = implode(',', array(0));
                }

                foreach ($forms as $form) {
                    // Register form page
                    $pages->add('Forms', $form->url, 'pages/form.php', 'form-' . $form->id, true);

                    $perm = false;
                    if (!$user->isLoggedIn() && $form->guest == 1) {
                        $perm = true;
                    }

                    if (!$perm) {
                        $hasperm = $this->_db->query('SELECT form_id FROM nl2_forms_permissions WHERE form_id = ? AND post = 1 AND group_id IN('.$group_ids.')', array($form->id));
                        if ($hasperm->count()) {
                            $perm = true;
                        }
                    }

                    // Add link location to navigation if user have permission
                    if ($perm) {
                        switch ($form->link_location) {
                            case 1:
                                // Navbar
                                // Check cache first
                                $cache->setCache('navbar_order');
                                if (!$cache->isCached('form-' . $form->id . '_order')) {
                                    // Create cache entry now
                                    $form_order = 5;
                                    $cache->store('form-' . $form->id . '_order', 5);
                                } else {
                                    $form_order = $cache->retrieve('form-' . $form->id . '_order');
                                }
                                $navigation->add('form-' . $form->id, Output::getClean($form->title), URL::build(Output::getClean($form->url)), 'top', null, $form_order, $form->icon);
SQL query:
SELECT id, link_location, url, icon, title, guest FROM nl2_forms;
File: /var/www/html/divinerealms.org/modules/Forms/module.php
        $pages->add('Forms', '/user/submissions', 'pages/user/submissions.php');

        // Check if module version changed
        $cache->setCache('forms_module_cache');
        if (!$cache->isCached('module_version')) {
            $cache->store('module_version', $module_version);
        } else {
            if ($module_version != $cache->retrieve('module_version')) {
                // Version have changed, Perform actions
                $this->initialiseUpdate($cache->retrieve('module_version'));

                $cache->store('module_version', $module_version);

                if ($cache->isCached('update_check')) {
                    $cache->erase('update_check');
                }
            }
        }

        try {
            $forms = $this->_db->query('SELECT id, link_location, url, icon, title, guest FROM nl2_forms')->results();
            if (count($forms)) {
                if ($user->isLoggedIn()) {
                    $group_ids = implode(',', $user->getAllGroupIds());
                } else {
                    $group_ids = implode(',', array(0));
                }

                foreach ($forms as $form) {
                    // Register form page
                    $pages->add('Forms', $form->url, 'pages/form.php', 'form-' . $form->id, true);

                    $perm = false;
                    if (!$user->isLoggedIn() && $form->guest == 1) {
                        $perm = true;
                    }

                    if (!$perm) {
                        $hasperm = $this->_db->query('SELECT form_id FROM nl2_forms_permissions WHERE form_id = ? AND post = 1 AND group_id IN('.$group_ids.')', array($form->id));
                        if ($hasperm->count()) {
                            $perm = true;
SQL query:
SELECT * FROM nl2_integrations WHERE name = 'Minecraft';
File: /var/www/html/divinerealms.org/core/classes/Integrations/IntegrationBase.php
 * @package NamelessMC\Integrations
 * @author Partydragen
 * @version 2.0.0-pr13
 * @license MIT
 */

abstract class IntegrationBase {

    private DB $_db;
    private IntegrationData $_data;
    protected string $_icon;
    private array $_errors = [];
    protected Language $_language;

    protected string $_name;
    protected ?int $_order;

    public function __construct() {
        $this->_db = DB::getInstance();

        $integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name]);
        if ($integration->count()) {
            $integration = $integration->first();

            $this->_data = new IntegrationData($integration);
            $this->_order = $integration->order;
        } else {
            // Register integration to database
            $this->_db->query('INSERT INTO nl2_integrations (name) VALUES (?)', [
                $this->_name
            ]);

            $integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name])->first();

            $this->_data = new IntegrationData($integration);
            $this->_order = $integration->order;
        }
    }

    /**
     * Get the name of this integration.
SQL query:
SELECT * FROM nl2_custom_pages_permissions WHERE `group_id` = '0';
File: /var/www/html/divinerealms.org/modules/Core/module.php
                                                $navigation->add(
                                                    $custom_page->id,
                                                    Output::getClean($custom_page->title),
                                                    (is_null($redirect)) ? URL::build(Output::urlEncodeAllowSlashes($custom_page->url)) : $redirect,
                                                    'footer', $custom_page->target ? '_blank' : null,
                                                    2000,
                                                    $custom_page->icon
                                                );
                                                break;
                                        }
                                        break 2;
                                    }

                                    break;
                                }
                            }
                        }
                    }
                }
            } else {
                $custom_page_permissions = DB::getInstance()->get('custom_pages_permissions', ['group_id', 0])->results();
                if (count($custom_page_permissions)) {
                    foreach ($custom_pages as $custom_page) {
                        $redirect = null;

                        if ($custom_page->redirect == 1) {
                            $redirect = Output::getClean($custom_page->link);
                        }

                        $pages->addCustom(Output::urlEncodeAllowSlashes($custom_page->url), Output::getClean($custom_page->title), !$custom_page->basic);

                        foreach ($custom_page_permissions as $permission) {
                            if ($permission->page_id == $custom_page->id) {
                                if ($permission->view == 1) {
                                    // Check cache for order
                                    if (!$cache->isCached($custom_page->id . '_order')) {
                                        // Create cache entry now
                                        $page_order = 200;
                                        $cache->store($custom_page->id . '_order', 200);
                                    } else {
                                        $page_order = $cache->retrieve($custom_page->id . '_order');
SQL query:
SELECT * FROM nl2_custom_pages WHERE `id` <> '0';
File: /var/www/html/divinerealms.org/modules/Core/module.php
        $pages->addAjaxScript(URL::build('/queries/servers'));

        // "More" dropdown
        $cache->setCache('navbar_icons');
        if ($cache->isCached('more_dropdown_icon')) {
            $icon = $cache->retrieve('more_dropdown_icon');
        } else {
            $icon = '';
        }

        $cache->setCache('navbar_order');
        if ($cache->isCached('more_dropdown_order')) {
            $order = $cache->retrieve('more_dropdown_order');
        } else {
            $order = 2500;
        }

        $navigation->addDropdown('more_dropdown', $language->get('general', 'more'), 'top', $order, $icon);

        // Custom pages
        $custom_pages = DB::getInstance()->get('custom_pages', ['id', '<>', 0])->results();
        if (count($custom_pages)) {
            $more = [];
            $cache->setCache('navbar_order');

            if ($user->isLoggedIn()) {
                // Check all groups
                $user_groups = $user->getAllGroupIds();

                foreach ($custom_pages as $custom_page) {
                    $redirect = null;

                    // Get redirect URL if enabled
                    if ($custom_page->redirect == 1) {
                        $redirect = $custom_page->link;
                    }

                    $pages->addCustom(Output::urlEncodeAllowSlashes($custom_page->url), Output::getClean($custom_page->title), !$custom_page->basic);

                    foreach ($user_groups as $user_group) {
                        $custom_page_permissions = DB::getInstance()->get('custom_pages_permissions', ['group_id', $user_group])->results();
SQL query:
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` IS NULL;
File: /var/www/html/divinerealms.org/core/classes/Core/Util.php
    private static function setSettingsCache(?string $module, array $cache): void {
        $cache_name = $module !== null ? $module : 'core';
        self::$_cached_settings[$cache_name] = $cache;
    }

    /**
     * Get a setting from the database table `nl2_settings`.
     *
     * @param string $setting Setting to check.
     * @param ?string $fallback Fallback to return if $setting is not set in DB. Defaults to null.
     * @param string $module Module name to keep settings separate from other modules. Set module
     *                       to 'Core' for global settings.
     * @return ?string Setting from DB or $fallback.
     */
    public static function getSetting(string $setting, ?string $fallback = null, string $module = 'core'): ?string {
        $cache = self::getSettingsCache($module);

        if ($cache === null) {
            // Load all settings for this module and store it as a dictionary
            if ($module === 'core') {
                $result = DB::getInstance()->query('SELECT `name`, `value` FROM `nl2_settings` WHERE `module` IS NULL')->results();
            } else {
                $result = DB::getInstance()->query('SELECT `name`, `value` FROM `nl2_settings` WHERE `module` = ?', [$module])->results();
            }

            $cache = [];
            foreach ($result as $row) {
                $cache[$row->name] = $row->value;
            }
            self::setSettingsCache($module, $cache);
        }

        return $cache[$setting] ?? $fallback;
    }

    /**
     * Modify a setting in the database table `nl2_settings`.
     *
     * @param string $setting Setting name.
     * @param string|null $new_value New setting value, or null to delete
     * @param string $module Module name to keep settings separate from other modules. Set module
SQL query:
SELECT version, migration_name FROM nl2_phinxlog;
File: /var/www/html/divinerealms.org/core/classes/Database/PhinxAdapter.php
    /**
     * Checks the number of existing migration files compared to executed migrations in the database.
     * Alternatively we could check the output of a Phinx command, but that takes ~8x as long to execute.
     *
     * @throws RuntimeException If these numbers don't match.
     */
    public static function ensureUpToDate(): void {
        $migration_files = array_map(
            static function ($file_name) {
                [$version, $migration_name] = explode('_', $file_name, 2);
                $migration_name = str_replace(['.php', '_'], '', ucwords($migration_name, '_'));
                return $version . '_' . $migration_name;
            },
            array_filter(scandir(__DIR__ . '/../../migrations'), static function ($file_name) {
                return !in_array($file_name, ['.', '..', 'phinx.php']);
            }),
        );

        $migration_database_entries = array_map(static function ($row) {
            return $row->version . '_' . $row->migration_name;
        }, DB::getInstance()->query('SELECT version, migration_name FROM nl2_phinxlog')->results());

        $missing = array_diff($migration_files, $migration_database_entries);
        $extra = array_diff($migration_database_entries, $migration_files);

        // Likely a pull from the repo dev branch or migrations
        // weren't run during an upgrade script.
        if (($missing_count = count($missing)) > 0) {
            echo "There are $missing_count migrations files which have not been executed:" . '<br>';
            foreach ($missing as $missing_migration) {
                echo " - $missing_migration" . '<br>';
            }
        }

        // Something went wonky, either they've deleted migration files,
        // or they've added stuff to the nl2_phinxlog table.
        if (($extra_count = count($extra)) > 0) {
            if ($missing_count > 0) {
                echo '<br>';
            }
            echo "There are $extra_count executed migrations which do not have migration files associated:" . '<br>';