Uncaught Error

Class "RenderContentEvent" not found

/data/modules/Forum/profile_tab.php

https://dev.partydragen.com/profile/Partydragen
/data/modules/Forum/profile_tab.php
        // Get topic title
        if (!isset($topic_titles[$latest_post->topic_id])) {
            $topic_title = DB::getInstance()->get('topics', ['id', $latest_post->topic_id])->results();
            if (!count($topic_title)) {
                continue;
            }
            $topic_title = Output::getClean($topic_title[0]->topic_title);
            $topic_titles[$latest_post->topic_id] = $topic_title;
        } else {
            $topic_title = $topic_titles[$latest_post->topic_id];
        }

        if (is_null($latest_post->created)) {
            $date_friendly = $timeago->inWords($latest_post->post_date, $language);
            $date_full = date(DATE_FORMAT, strtotime($latest_post->post_date));
        } else {
            $date_friendly = $timeago->inWords($latest_post->created, $language);
            $date_full = date(DATE_FORMAT, $latest_post->created);
        }

        $render_event = new RenderContentEvent($latest_post->post_content);
        EventHandler::executeEvent($render_event);

        $posts[] = [
            'link' => URL::build('/forum/topic/' . $latest_post->topic_id . '-' . $forum->titleToURL($topic_title), 'pid=' . $latest_post->id),
            'title' => $topic_title,
            'content' => $render_event->content,
            'date_friendly' => $date_friendly,
            'date_full' => $date_full
        ];

        $n++;
    }
}

// Smarty
$smarty->assign([
    'PF_LATEST_POSTS' => (isset($posts)) ? $posts : [],
    'PF_LATEST_POSTS_TITLE' => $forum_language->get('forum', 'latest_posts'),
    'FORUM_TAB_TITLE' => $forum_language->get('forum', 'forum')
]);
/data/modules/Core/pages/profile.php
        'value' => $query->profile_views
    ];

    $template->getEngine()->addVariable('ABOUT_FIELDS', $fields);

    $template->getEngine()->addVariables([
        'CAN_PROFILE_POST' => $user->isLoggedIn() && $user->hasPermission('profile.post'),
        'REACTIONS' => $all_reactions,
        'REACTIONS_BY_USER' => $reactions_by_user,
        'REACTIONS_TEXT' => $language->get('user', 'reactions'),
        'REACTIONS_URL' => URL::build('/queries/reactions'),
        'USER_ID' => (($user->isLoggedIn()) ? $user->data()->id : 0),
    ]);

    // 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
    $template->getEngine()->addVariable('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')) {
        $template->getEngine()->addVariable('ERROR', Session::flash('profile_banner_error'));
    }

    // Load modules + template
    Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);
/data/index.php
        require($path);
        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');
/data/modules/Forum/profile_tab.php
SELECT * FROM nl2_topics WHERE `id` = '1';
                        break;
                    }
                }
            }
            $permissions[$latest_post->forum_id] = $permission;
        } else {
            $permission = $permissions[$latest_post->forum_id];
        }

        if ($permission != true) {
            continue;
        }

        // Check the post isn't deleted
        if ($latest_post->deleted == 1) {
            continue;
        }

        // Get topic title
        if (!isset($topic_titles[$latest_post->topic_id])) {
            $topic_title = DB::getInstance()->get('topics', ['id', $latest_post->topic_id])->results();
            if (!count($topic_title)) {
                continue;
            }
            $topic_title = Output::getClean($topic_title[0]->topic_title);
            $topic_titles[$latest_post->topic_id] = $topic_title;
        } else {
            $topic_title = $topic_titles[$latest_post->topic_id];
        }

        if (is_null($latest_post->created)) {
            $date_friendly = $timeago->inWords($latest_post->post_date, $language);
            $date_full = date(DATE_FORMAT, strtotime($latest_post->post_date));
        } else {
            $date_friendly = $timeago->inWords($latest_post->created, $language);
            $date_full = date(DATE_FORMAT, $latest_post->created);
        }

        $render_event = new RenderContentEvent($latest_post->post_content);
        EventHandler::executeEvent($render_event);

/data/modules/Forum/profile_tab.php
SELECT * FROM nl2_forums_permissions WHERE `forum_id` = '2';

    if (!$user->isLoggedIn()) {
        $groups = [0];
    } else {
        $groups = $user->getAllGroupIds();
    }

    // Array to assign posts to
    $posts = [];

    $permissions = [];
    $topic_titles = [];
    foreach ($latest_posts as $latest_post) {
        if ($n == 5) {
            break;
        }

        // Is the post somewhere the user can view?
        if (!isset($permissions[$latest_post->forum_id])) {
            $permission = false;
            $forum_permissions = DB::getInstance()->get('forums_permissions', ['forum_id', $latest_post->forum_id])->results();
            foreach ($forum_permissions as $forum_permission) {
                if (in_array($forum_permission->group_id, $groups)) {
                    if ($forum_permission->view == 1 && $forum_permission->view_other_topics == 1) {
                        $permission = true;
                        break;
                    }
                }
            }
            $permissions[$latest_post->forum_id] = $permission;
        } else {
            $permission = $permissions[$latest_post->forum_id];
        }

        if ($permission != true) {
            continue;
        }

        // Check the post isn't deleted
        if ($latest_post->deleted == 1) {
            continue;
/data/modules/Forum/profile_tab.php
SELECT * FROM nl2_posts WHERE post_creator = 1 AND deleted = 0 ORDER BY post_date DESC LIMIT 15;
<?php
/*
 *  Made by Samerton
 *  https://github.com/NamelessMC/Nameless/
 *  NamelessMC version 2.3.0
 *
 *  License: MIT
 *
 *  Forum module - forum profile tab
 */

if (!isset($forum) || (!$forum instanceof Forum)) {
    $forum = new Forum();
}

// Get latest posts
$latest_posts = DB::getInstance()->orderWhere('posts', 'post_creator = ' . $query->id . ' AND deleted = 0', 'post_date', 'DESC LIMIT 15')->results();
if (!count($latest_posts)) {
    $smarty->assign('NO_POSTS', $forum_language->get('forum', 'user_no_posts'));
} else {
    // Check permissions
    $n = 0;

    if (!$user->isLoggedIn()) {
        $groups = [0];
    } else {
        $groups = $user->getAllGroupIds();
    }

    // Array to assign posts to
    $posts = [];

    $permissions = [];
    $topic_titles = [];
    foreach ($latest_posts as $latest_post) {
        if ($n == 5) {
            break;
/data/core/classes/Misc/Placeholders.php
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 =  ORDER BY ps.`order`;
     * @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 = ? ORDER BY ps.`order`', [$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;
/data/core/classes/Misc/Placeholders.php
SELECT *
    FROM nl2_placeholders_settings
    ORDER BY `order`;
<?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->query(
            <<<'SQL'
                SELECT *
                FROM nl2_placeholders_settings
                ORDER BY `order`
            SQL
        )->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/core/classes/Core/User.php
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');
    /**
     * 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?
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 1 ORDER BY time ASC;
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
                    } else {
                        $post_reactions[$reaction->id]['count']++;
                    }
                }
            }

            // Sort reactions by their order
            usort($post_reactions, static function ($a, $b) {
                return $a['order'] - $b['order'];
            });

            // Get replies
            $replies = [];
            $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) {
                    $reply_user = new User($reply->author_id);
                    $content = EventHandler::executeEvent('renderProfilePost', ['content' => $reply->content])['content'];

                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $reply_user->getDisplayname(true),
                        'nickname' => $reply_user->getDisplayname(),
                        'style' => $reply_user->getGroupStyle(),
                        'profile' => $reply_user->getProfileURL(),
                        'avatar' => $reply_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '1';
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    $reactions_by_user = [];
    $all_reactions = Reaction::find(true, 'enabled');
    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) . '/'));

        $template->getEngine()->addVariable('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            // Get reactions
            $post_reactions = [];
            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                $reactions['count'] = count($reactions_query) === 1
                    ? $language->get('user', '1_reaction')
                    : $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);

                foreach ($reactions_query as $wall_post_reaction) {
                    if ($wall_post_reaction->user_id == $user->data()->id) {
                        $reactions_by_user[$nValue->id][] = $wall_post_reaction->reaction_id;
                    }

                    // Get reaction name and icon
                    $reaction = $all_reactions[$wall_post_reaction->reaction_id];
                    if (!isset($post_reactions[$reaction->id])) {
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 2 ORDER BY time ASC;
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
                    } else {
                        $post_reactions[$reaction->id]['count']++;
                    }
                }
            }

            // Sort reactions by their order
            usort($post_reactions, static function ($a, $b) {
                return $a['order'] - $b['order'];
            });

            // Get replies
            $replies = [];
            $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) {
                    $reply_user = new User($reply->author_id);
                    $content = EventHandler::executeEvent('renderProfilePost', ['content' => $reply->content])['content'];

                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $reply_user->getDisplayname(true),
                        'nickname' => $reply_user->getDisplayname(),
                        'style' => $reply_user->getGroupStyle(),
                        'profile' => $reply_user->getProfileURL(),
                        'avatar' => $reply_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '2';
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    $reactions_by_user = [];
    $all_reactions = Reaction::find(true, 'enabled');
    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) . '/'));

        $template->getEngine()->addVariable('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            // Get reactions
            $post_reactions = [];
            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                $reactions['count'] = count($reactions_query) === 1
                    ? $language->get('user', '1_reaction')
                    : $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);

                foreach ($reactions_query as $wall_post_reaction) {
                    if ($wall_post_reaction->user_id == $user->data()->id) {
                        $reactions_by_user[$nValue->id][] = $wall_post_reaction->reaction_id;
                    }

                    // Get reaction name and icon
                    $reaction = $all_reactions[$wall_post_reaction->reaction_id];
                    if (!isset($post_reactions[$reaction->id])) {
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 3 ORDER BY time ASC;
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
                    } else {
                        $post_reactions[$reaction->id]['count']++;
                    }
                }
            }

            // Sort reactions by their order
            usort($post_reactions, static function ($a, $b) {
                return $a['order'] - $b['order'];
            });

            // Get replies
            $replies = [];
            $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) {
                    $reply_user = new User($reply->author_id);
                    $content = EventHandler::executeEvent('renderProfilePost', ['content' => $reply->content])['content'];

                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $reply_user->getDisplayname(true),
                        'nickname' => $reply_user->getDisplayname(),
                        'style' => $reply_user->getGroupStyle(),
                        'profile' => $reply_user->getProfileURL(),
                        'avatar' => $reply_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '3';
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    $reactions_by_user = [];
    $all_reactions = Reaction::find(true, 'enabled');
    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) . '/'));

        $template->getEngine()->addVariable('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            // Get reactions
            $post_reactions = [];
            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                $reactions['count'] = count($reactions_query) === 1
                    ? $language->get('user', '1_reaction')
                    : $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);

                foreach ($reactions_query as $wall_post_reaction) {
                    if ($wall_post_reaction->user_id == $user->data()->id) {
                        $reactions_by_user[$nValue->id][] = $wall_post_reaction->reaction_id;
                    }

                    // Get reaction name and icon
                    $reaction = $all_reactions[$wall_post_reaction->reaction_id];
                    if (!isset($post_reactions[$reaction->id])) {
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
/data/core/classes/Core/User.php
SELECT * FROM nl2_users WHERE `id` = '1';
    }

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

            return true;
        }

        if ($field !== 'hash') {
            $data = $this->_db->get('users', [$field, $value]);
        } else {
            $data = $this->_db->query(
                <<<'SQL'
                SELECT
                    nl2_users.*
                FROM nl2_users
                    LEFT JOIN nl2_users_session
                    ON nl2_users.id = nl2_users_session.user_id
                WHERE
                    nl2_users_session.hash = ?
                    AND nl2_users_session.active = 1
                    AND (
                        nl2_users_session.expires_at IS NULL
                        OR nl2_users_session.expires_at > ?
                    )
                SQL,
                [
                    $value,
                    time(),
                ]
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 6 ORDER BY time ASC;
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
                    } else {
                        $post_reactions[$reaction->id]['count']++;
                    }
                }
            }

            // Sort reactions by their order
            usort($post_reactions, static function ($a, $b) {
                return $a['order'] - $b['order'];
            });

            // Get replies
            $replies = [];
            $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) {
                    $reply_user = new User($reply->author_id);
                    $content = EventHandler::executeEvent('renderProfilePost', ['content' => $reply->content])['content'];

                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $reply_user->getDisplayname(true),
                        'nickname' => $reply_user->getDisplayname(),
                        'style' => $reply_user->getGroupStyle(),
                        'profile' => $reply_user->getProfileURL(),
                        'avatar' => $reply_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '6';
    $wall_posts_query = DB::getInstance()->orderWhere('user_profile_wall_posts', 'user_id = ' . $query->id, 'time', 'DESC')->results();

    $reactions_by_user = [];
    $all_reactions = Reaction::find(true, 'enabled');
    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) . '/'));

        $template->getEngine()->addVariable('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            // Get reactions
            $post_reactions = [];
            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
            if (count($reactions_query)) {
                $reactions['count'] = count($reactions_query) === 1
                    ? $language->get('user', '1_reaction')
                    : $language->get('user', 'x_reactions', ['count' => count($reactions_query)]);

                foreach ($reactions_query as $wall_post_reaction) {
                    if ($wall_post_reaction->user_id == $user->data()->id) {
                        $reactions_by_user[$nValue->id][] = $wall_post_reaction->reaction_id;
                    }

                    // Get reaction name and icon
                    $reaction = $all_reactions[$wall_post_reaction->reaction_id];
                    if (!isset($post_reactions[$reaction->id])) {
                        $post_reactions[$reaction->id] = [
                            'id' => $reaction->id,
                            'name' => $reaction->name,
                            'html' => $reaction->html,
                            'order' => $reaction->order,
                            'count' => 1,
                        ];
/data/core/classes/DTO/Reaction.php
SELECT * FROM nl2_reactions WHERE `enabled` = '1' ORDER BY `order`;
     * @return array<int, Reaction>
     */
    public static function all(): array
    {
        $rows = DB::getInstance()->query('SELECT * FROM nl2_reactions ORDER BY `order`')->results();
        $fields = [];
        foreach ($rows as $row) {
            $fields[$row->id] = new Reaction($row);
        }

        return $fields;
    }

    /**
     * @param  string                        $value
     * @param  string                        $column
     * @return array<int, Reaction>|Reaction
     */
    public static function find(string $value, string $column = 'id')
    {
        $rows = DB::getInstance()->query("SELECT * FROM nl2_reactions WHERE `$column` = ? ORDER BY `order`", [$value]);
        if (!$rows->count()) {
            return [];
        }

        if ($rows->count() === 1) {
            return new Reaction($rows->first());
        }

        $fields = [];
        foreach ($rows->results() as $row) {
            $fields[$row->id] = new Reaction($row);
        }

        return $fields;
    }
}
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_user_profile_wall_posts WHERE user_id = 1 ORDER BY time DESC;
        'POST_ON_WALL' => $language->get('user', 'post_on_wall', ['user' => Output::getClean($profile_user->getDisplayname())]),
        'FEED' => $language->get('user', 'feed'),
        'ABOUT' => $language->get('user', 'about'),
        'LIKE' => $language->get('user', 'like'),
        '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();

    $reactions_by_user = [];
    $all_reactions = Reaction::find(true, 'enabled');
    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) . '/'));

        $template->getEngine()->addVariable('PAGINATION', $pagination);

        // Display the correct number of posts
        foreach ($results->data as $nValue) {
            // Get reactions
            $post_reactions = [];
            $reactions_query = DB::getInstance()->get('user_profile_wall_posts_reactions', ['post_id', $nValue->id])->results();
/data/core/classes/Core/User.php
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';

        return $this->_groups;
    }

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

        $integrations = Integrations::getInstance();

        if (isset(self::$_integration_cache[$this->data()->id])) {
            $integrations_query = self::$_integration_cache[$this->data()->id];
        } else {
            $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();
            } else {
                $integrations_query = [];
            }
            self::$_integration_cache[$this->data()->id] = $integrations_query;
        }

        $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 $this->_integrations = $integrations_list;
    }
/data/core/classes/Core/User.php
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`;
        ]);

        Session::delete($this->_admSessionName);
        Cookie::delete($this->_cookieName . '_adm');
    }

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

        if (isset(self::$_group_cache[$this->data()->id])) {
            $this->_groups = self::$_group_cache[$this->data()->id];
        } else {
            $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()) {
                foreach ($groups_query->results() as $item) {
                    $this->_groups[$item->id] = new Group($item);
                }
            } else {
                $this->_groups = [];
            }

            self::$_group_cache[$this->data()->id] = $this->_groups;
        }

        if (!count($this->_groups)) {
            // Get default group
            // TODO: Use PRE_VALIDATED_DEFAULT ?
            $default_group = Group::find(1, 'default_group');
            $default_group_id = $default_group->id ?? 1;

            $this->addGroup($default_group_id);
        }

/data/modules/Core/pages/profile.php
UPDATE nl2_users SET profile_views = profile_views + 1 WHERE id = '1';
            // 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 ($user->isLoggedIn() && $profile_user->isBlocked($query->id, $user->data()->id)) {
        $template->getEngine()->addVariables([
            'BLOCKED' => $language->get('user', 'blocked_profile_page'),
            'CAN_VIEW' => false
        ]);
    } else if ($profile_user->isPrivateProfile() && !$user->canBypassPrivateProfile()) {
        $template->getEngine()->addVariables([
            'PRIVATE_PROFILE' => $language->get('user', 'private_profile_page'),
            'CAN_VIEW' => false
        ]);
    } else {
        $template->getEngine()->addVariables([
            'CAN_VIEW' => true
        ]);
    }
/data/core/classes/Core/User.php
SELECT * FROM nl2_users WHERE `username` = 'Partydragen';
    }

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

            return true;
        }

        if ($field !== 'hash') {
            $data = $this->_db->get('users', [$field, $value]);
        } else {
            $data = $this->_db->query(
                <<<'SQL'
                SELECT
                    nl2_users.*
                FROM nl2_users
                    LEFT JOIN nl2_users_session
                    ON nl2_users.id = nl2_users_session.user_id
                WHERE
                    nl2_users_session.hash = ?
                    AND nl2_users_session.active = 1
                    AND (
                        nl2_users_session.expires_at IS NULL
                        OR nl2_users_session.expires_at > ?
                    )
                SQL,
                [
                    $value,
                    time(),
                ]
/data/core/templates/frontend_init.php
SELECT * FROM nl2_page_descriptions WHERE `page` = '/profile/Partydragen';
        $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]);
    if ($page_metadata->count()) {
        $page_metadata = $page_metadata->first();
        $template->getEngine()->addVariables([
            'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags($page_metadata->description))),
            'PAGE_KEYWORDS' => addslashes(strip_tags($page_metadata->tags)),
        ]);

        $og_image = $page_metadata->image;
        if ($og_image) {
            $template->getEngine()->addVariable('OG_IMAGE', rtrim(URL::getSelfURL(), '/') . $og_image);
        }
    } else {
        $template->getEngine()->addVariables([
            'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags(Settings::get('default_meta_description', '')))),
            'PAGE_KEYWORDS' => addslashes(strip_tags(Settings::get('default_meta_keywords', ''))),
        ]);
    }
} else {
    $template->getEngine()->addVariables([
        'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags(PAGE_DESCRIPTION))),
/data/modules/Core/pages/profile.php
SELECT * FROM nl2_page_descriptions WHERE `page` = '/profile';
 * @var Language $language
 * @var Navigation $cc_nav
 * @var Navigation $navigation
 * @var Navigation $staffcp_nav
 * @var Pages $pages
 * @var TemplateBase $template
 * @var User $user
 * @var Widgets $widgets
 */

// 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('
/data/core/init.php
INSERT INTO nl2_online_guests (`ip`,`last_seen`) VALUES (?,);
            }
        }

        $user_integrations = [];
        foreach ($user->getIntegrations() as $integrationUser) {
            $user_integrations[$integrationUser->getIntegration()->getName()] = [
                'username' => Output::getClean($integrationUser->data()->username),
                'identifier' => Output::getClean($integrationUser->data()->identifier),
            ];
        }
    } 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;
        }

        // Auto language enabled?
        if (Settings::get('auto_language_detection')) {
            define('AUTO_LANGUAGE', true);
        }
    }

    // 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');
        }
/data/core/init.php
SELECT * FROM nl2_online_guests WHERE `ip` = '172.69.130.234';
        if (isset($forced) && $forced) {
            // Do they have TFA configured?
            if (!$user->data()->tfa_enabled && rtrim($_GET['route'], '/') != '/logout') {
                if (!str_contains($_SERVER['REQUEST_URI'], 'do=enable_tfa') && !isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
                    Session::put('force_tfa_alert', $language->get('admin', 'force_tfa_alert'));
                    Redirect::to(URL::build('/user/settings', 'do=enable_tfa'));
                }
            }
        }

        $user_integrations = [];
        foreach ($user->getIntegrations() as $integrationUser) {
            $user_integrations[$integrationUser->getIntegration()->getName()] = [
                'username' => Output::getClean($integrationUser->data()->username),
                'identifier' => Output::getClean($integrationUser->data()->identifier),
            ];
        }
    } 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;
        }

        // Auto language enabled?
        if (Settings::get('auto_language_detection')) {
            define('AUTO_LANGUAGE', true);
        }
    }

    // Dark mode
    $cache->setCache('template_settings');
/data/core/init.php
SELECT * FROM nl2_groups WHERE `default_group` = '1';
                            : [DiscordHook::class, 'execute'],
                        'events' => json_decode($hook->events, true),
                    ];
                }
                $cache->store('hooks', $hook_array);
            }
        }
    }
    EventHandler::registerWebhooks($hook_array);

    // Get IP
    $ip = HttpUtils::getRemoteAddress();

    // Define default group pre validation
    $cache->setCache('pre_validation_default');
    $group_id = null;

    if ($cache->isCached('pre_validation_default')) {
        $group_id = $cache->retrieve('pre_validation_default');
    } else {
        $group_id = DB::getInstance()->get('groups', ['default_group', '1'])->results();
        $group_id = $group_id[0]->id;
    }

    define('PRE_VALIDATED_DEFAULT', $group_id);

    // Perform tasks if the user is logged in
    if ($user->isLoggedIn()) {
        Debugging::setCanViewDetailedError($user->hasPermission('admincp.errors'));
        Debugging::setCanGenerateDebugLink($user->hasPermission('admincp.core.debugging'));

        // Ensure a user is not banned
        if ($user->data()->isbanned == 1) {
            $user->logout();
            Session::flash('home_error', $language->get('user', 'you_have_been_banned'));
            Redirect::to(URL::build('/'));
        }

        // Is the IP address banned?
        $ip_bans = DB::getInstance()->get('ip_bans', ['ip', $ip])->results();
        if (count($ip_bans)) {
/data/modules/Lists/module.php
SELECT * FROM `nl2_lists_submissions` WHERE `vanity_url` IS NOT NULL;
        Lists::getInstance()->registerProviderConnection(new DiscordConnection());
        Lists::getInstance()->registerProviderConnection(new NamelessMCConnection());
        Lists::getInstance()->registerProviderConnection(new BF2142Connection());

        EventHandler::registerEvent(ListSubmissionCreatedEvent::class);

        // Store Listener
        EventHandler::registerListener(PaymentCompletedEvent::class, [StorePaymentListener::class, 'paymentCompleted']);

        // Register page for each lists
        $lists = DB::getInstance()->query('SELECT * FROM nl2_lists WHERE provider IS NOT NULL AND url IS NOT NULL');
        if ($lists->count()) {
            foreach ($lists->results() as $list) {
                // Register page
                $pages->add('Lists', $list->url, 'pages/submissions.php', 'lists-' . $list->id, true);
                $pages->add('Lists', $list->url . '/new', 'pages/new_submission.php', 'lists-' . $list->id);
            }
        }

        // Register page for each submission that has own vanity url
        $submissions = DB::getInstance()->query('SELECT * FROM `nl2_lists_submissions` WHERE `vanity_url` IS NOT NULL');
        foreach ($submissions->results() as $submission) {
            $pages->add('Lists', '/' . $submission->vanity_url, 'pages/submission.php');
        }
    }

    public function onInstall() {
        PhinxAdapter::migrate($this->getName(), __DIR__ . '/includes/migrations');

        mkdir(ROOT_PATH . '/uploads/lists_icons');
        mkdir(ROOT_PATH . '/uploads/lists_images');
        mkdir(ROOT_PATH . '/uploads/lists_banners');
    }

    public function onUninstall() {
        PhinxAdapter::rollback($this->getName(), __DIR__ . '/includes/migrations');
    }

    public function onEnable() {
        PhinxAdapter::migrate($this->getName(), __DIR__ . '/includes/migrations');

/data/modules/Lists/module.php
SELECT * FROM nl2_lists WHERE provider IS NOT NULL AND url IS NOT NULL;
        $pages->add('Lists', '/panel/lists/settings', 'pages/panel/settings.php');
        $pages->add('Lists', '/panel/lists', 'pages/panel/lists.php');
        $pages->add('Lists', '/panel/lists/tags', 'pages/panel/tags.php');
        $pages->add('Lists', '/queries/querysubmissions', 'queries/querysubmissions.php');

        // Register provider connections
        Lists::getInstance()->registerProviderConnection(new DefaultConnection());
        Lists::getInstance()->registerProviderConnection(new MinecraftConnection());
        Lists::getInstance()->registerProviderConnection(new VotifierConnection());
        Lists::getInstance()->registerProviderConnection(new MCStatisticsConnection());
        Lists::getInstance()->registerProviderConnection(new DiscordConnection());
        Lists::getInstance()->registerProviderConnection(new NamelessMCConnection());
        Lists::getInstance()->registerProviderConnection(new BF2142Connection());

        EventHandler::registerEvent(ListSubmissionCreatedEvent::class);

        // Store Listener
        EventHandler::registerListener(PaymentCompletedEvent::class, [StorePaymentListener::class, 'paymentCompleted']);

        // Register page for each lists
        $lists = DB::getInstance()->query('SELECT * FROM nl2_lists WHERE provider IS NOT NULL AND url IS NOT NULL');
        if ($lists->count()) {
            foreach ($lists->results() as $list) {
                // Register page
                $pages->add('Lists', $list->url, 'pages/submissions.php', 'lists-' . $list->id, true);
                $pages->add('Lists', $list->url . '/new', 'pages/new_submission.php', 'lists-' . $list->id);
            }
        }

        // Register page for each submission that has own vanity url
        $submissions = DB::getInstance()->query('SELECT * FROM `nl2_lists_submissions` WHERE `vanity_url` IS NOT NULL');
        foreach ($submissions->results() as $submission) {
            $pages->add('Lists', '/' . $submission->vanity_url, 'pages/submission.php');
        }
    }

    public function onInstall() {
        PhinxAdapter::migrate($this->getName(), __DIR__ . '/includes/migrations');

        mkdir(ROOT_PATH . '/uploads/lists_icons');
        mkdir(ROOT_PATH . '/uploads/lists_images');
/data/core/classes/Database/PhinxAdapter.php
SELECT version, migration_name FROM nl2_phinxlog_lists;

        if (!$migrationDir) {
            $migrationDir = __DIR__ . '/../../migrations';
        }

        $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($migrationDir), static function ($file_name) {
                // Pattern that matches Phinx migration file names (eg: 20230403000000_create_stroopwafel_table.php)
                return preg_match('/^\d{14}_\w+\.php$/', $file_name);
            }),
        );

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

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

        if ($returnResults) {
            return [
                'missing' => count($missing),
                'extra' => count($extra),
            ];
        }

        // 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>';
            }
        }

/data/core/classes/Core/Settings.php
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` = 'Store';
        $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 get(string $setting, ?string $fallback = null, string $module = 'core'): ?string
    {
        if (!self::hasSettingsCache($module)) {
            // 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);
        }

        $cache = &self::getSettingsCache($module);

        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
/data/modules/OAuth2/module.php
SELECT * FROM nl2_oauth2_applications WHERE nameless = 1 AND enabled = 1;

        // Check if module version changed
        $cache->setCache('oauth2_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 {
            // Register integrations for namelessmc applications
            $applications = $this->_db->query("SELECT * FROM nl2_oauth2_applications WHERE nameless = 1 AND enabled = 1")->results();
            foreach ($applications as $app) {
                $application = new Application(null, null, $app);
                Integrations::getInstance()->registerIntegration(new ApplicationIntegration($language, $application));

                NamelessOAuth::getInstance()->registerProvider(strtolower($application->getName()), 'OAuth2', [
                    'class' => NamelessProvider::class,
                    'user_id_name' => 'id',
                    'scope_id_name' => 'identify',
                    'icon' => 'fa-solid fa-globe',
                    'verify_email' => static fn () => true,
                ]);

                // Register group sync for namelessmc application if enabled
                if ($application->data()->group_sync) {
                    GroupSyncManager::getInstance()->registerInjector(new ApplicationGroupSyncInjector($application));
                }
            }
        } catch (Exception $e) {
            // Database tables don't exist yet
        }
/data/core/classes/Core/Module.php
SELECT * FROM nl2_modules WHERE `name` = 'Core';

    /**
     * Get this module's ID.
     *
     * @return int The ID for the module
     */
    public function getId(): int
    {
        return DB::getInstance()->query('SELECT `id` FROM nl2_modules WHERE `name` = ?', [$this->_name])->first()->id;
    }

    /**
     * Get a module ID from name.
     *
     * @param string $name Module name
     *
     * @return ?int Module ID
     */
    public static function getIdFromName(string $name): ?int
    {
        $query = DB::getInstance()->get('modules', ['name', $name]);

        if ($query->count()) {
            return $query->first()->id;
        }

        return null;
    }

    /**
     * Get a module name from ID.
     *
     * @param int $id Module ID
     *
     * @return ?string Module name
     */
    public static function getNameFromId(int $id): ?string
    {
        $query = DB::getInstance()->get('modules', ['id', $id]);

        if ($query->count()) {
/data/core/classes/Integrations/IntegrationBase.php
SELECT * FROM nl2_integrations WHERE name = 'Google';
 * @author Partydragen
 * @version 2.1.0
 * @license MIT
 */
abstract class IntegrationBase
{
    private DB $_db;
    private IntegrationData $_data;
    protected string $_icon;
    private array $_errors = [];
    protected Language $_language;
    protected ?string $_settings = null;

    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.
/data/core/classes/Integrations/IntegrationBase.php
SELECT * FROM nl2_integrations WHERE name = 'Minecraft';
 * @author Partydragen
 * @version 2.1.0
 * @license MIT
 */
abstract class IntegrationBase
{
    private DB $_db;
    private IntegrationData $_data;
    protected string $_icon;
    private array $_errors = [];
    protected Language $_language;
    protected ?string $_settings = null;

    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.
/data/modules/Core/module.php
SELECT * FROM nl2_custom_pages WHERE `id` <> '0';
        }

        // "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();
/data/core/classes/Core/Settings.php
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` IS NULL;
    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 get(string $setting, ?string $fallback = null, string $module = 'core'): ?string
    {
        if (!self::hasSettingsCache($module)) {
            // 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);
        }

        $cache = &self::getSettingsCache($module);

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

    /**
     * Modify a setting in the database table `nl2_settings`.
     *
     * @param string      $setting   Setting name.
/data/core/classes/Database/PhinxAdapter.php
SELECT version, migration_name FROM nl2_phinxlog;

        if (!$migrationDir) {
            $migrationDir = __DIR__ . '/../../migrations';
        }

        $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($migrationDir), static function ($file_name) {
                // Pattern that matches Phinx migration file names (eg: 20230403000000_create_stroopwafel_table.php)
                return preg_match('/^\d{14}_\w+\.php$/', $file_name);
            }),
        );

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

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

        if ($returnResults) {
            return [
                'missing' => count($missing),
                'extra' => count($extra),
            ];
        }

        // 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>';
            }
        }