Uncaught TypeError

TemplateBase::displayTemplate(): Argument #1 ($template) must be of type string, null given, called in /data/modules/Lists/pages/submission.php on line 610

/data/core/classes/Templates/TemplateBase.php

https://dev3.partydragen.com/server/1681-dsbm/partydragen
/data/core/classes/Templates/TemplateBase.php
    public function getAuthor(): string
    {
        return $this->_author;
    }

    /**
     * Get settings URL of this template.
     *
     * @return string Settings URL of template.
     */
    public function getSettings(): string
    {
        return $this->_settings;
    }

    /**
     * Render this template.
     *
     * @param string $template Template file to render, relative to template base directory
     */
    public function displayTemplate(string $template): void
    {
        [$css, $js] = $this->assets()->compile();

        // Put the assets at the start of the arrays, so they load first (SBAdmin requires JQuery first, etc.)
        array_unshift($this->_css, ...$css);
        array_unshift($this->_js, ...$js);

        $this->_engine->addVariables([
            'TEMPLATE_CSS' => $this->getCSS(),
            'TEMPLATE_JS' => $this->getJS(),
        ]);

        if (defined('PHPDEBUGBAR') && PHPDEBUGBAR) {
            $debugBar = DebugBarHelper::getInstance()->getDebugBar()->getJavascriptRenderer();
            $this->_engine->addVariables([
                'DEBUGBAR_JS' => $debugBar->renderHead(),
                'DEBUGBAR_HTML' => $debugBar->render(),
            ]);
        }

/data/modules/Lists/pages/submission.php
}

if (isset($success))
    $template->getEngine()->addVariables([
        'SUCCESS' => $success,
        'SUCCESS_TITLE' => $language->get('general', 'success')
    ]);

if (isset($error))
    $template->getEngine()->addVariable('ERROR', $error);

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);

$template->onPageLoad();

require(ROOT_PATH . '/core/templates/navbar.php');
require(ROOT_PATH . '/core/templates/footer.php');

// Display template
$template->displayTemplate($template_file);
/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/Lists/module.php
SELECT * FROM nl2_lists WHERE link_location IS NOT NULL;
        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');

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

    public function onDisable() {
        // No actions necessary
    }

    public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template) {
        $lists = DB::getInstance()->query('SELECT * FROM nl2_lists WHERE link_location IS NOT NULL');
        if ($lists->count()) {
            foreach ($lists->results() as $list) {
                // Check cache first
                $cache->setCache('navbar_order');
                if (!$cache->isCached('lists-' . $list->id . '_order')){
                    $order = 5;
                    $cache->store('lists-' . $list->id . '_order', 5);
                } else {
                    $order = $cache->retrieve('lists-' . $list->id . '_order');
                }

                $cache->setCache('navbar_icons');
                if (!$cache->isCached('lists-' . $list->id . '_icon'))
                    $icon = '';
                else
                    $icon = $cache->retrieve('lists-' . $list->id . '_icon');

                switch ($list->link_location) {
                    case 1:
                        // Navbar
/data/modules/Resources/module.php
ALTER TABLE `nl2_resources` ADD `short_description` varchar(64) NULL DEFAULT NULL;

                    $navs[2]->add('resources_settings', $this->_resource_language->get('resources', 'settings'), URL::build('/panel/resources/settings'), 'top', null, ($order + 0.3), $icon);
                }

            }
        }

        // AdminCP
        PermissionHandler::registerPermissions('Resources', [
            'admincp.resources' => $this->_language->get('moderator', 'staff_cp') . ' &raquo; ' . $this->_resource_language->get('resources', 'resources'),
            'admincp.resources.categories' => $this->_language->get('moderator', 'staff_cp') . ' &raquo; ' . $this->_resource_language->get('resources', 'categories'),
            'admincp.resources.downloads' => $this->_language->get('moderator', 'staff_cp') . ' &raquo; ' . $this->_resource_language->get('resources', 'downloads'),
            'admincp.resources.settings' => $this->_language->get('moderator', 'staff_cp') . ' &raquo; ' . $this->_resource_language->get('resources', 'settings'),
            'admincp.resources.licenses' => $this->_language->get('moderator', 'staff_cp') . ' &raquo; ' . $this->_resource_language->get('resources', 'manage_licenses'),
        ]);
    }

    // Update to 1.6.0
    private static function updateTo160($cache) {
        try {
            DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `short_description` varchar(64) NULL DEFAULT NULL');
            DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `has_icon` tinyint(1) NOT NULL DEFAULT \'0\'');
            DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `icon` varchar(512) NULL DEFAULT NULL');
            DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `icon_updated` int(11) NOT NULL DEFAULT \'0\'');

            $cache->store('160', true);

            mkdir(ROOT_PATH . '/uploads/resources_icons');
        } catch (Exception $e) {
            // continue anyway
        }
    }

    public function getDebugInfo(): array {
        return [];
    }
}
/data/modules/Gallery/module.php
SELECT * FROM nl2_gallery_settings WHERE `id` = '2';
    }

    public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template)
    {

        PermissionHandler::registerPermissions('Gallery', [
            'admincp.gallery' => $this->GalleryLanguage->get('general', 'img_permision'),
            'admincp.gallery_video' => $this->GalleryLanguage->get('general', 'video_permision'),
            'front.gallery.view' => $this->GalleryLanguage->get('general', 'image_view_permision'),
            'front.gallery_video.view' => $this->GalleryLanguage->get('general', 'video_view_permision'),
        ]);


        $settings_data = DB::getInstance()->get('gallery_settings', ['id', '=', 1])->results();
        $settings = $settings_data['0'];
        $icon = $settings->icon;
        $gallery_order = $settings->order_link;
        $gallery_title = $this->GalleryLanguage->get('general', 'gallery_title');


        $settings_data_video = DB::getInstance()->get('gallery_settings', ['id', '=', 2])->results();
        $settings_video = $settings_data_video['0'];
        $icon_video = $settings_video->icon;
        $video_order = $settings_video->order_link;
        $video_title = $this->GalleryLanguage->get('general', 'video_title');


        if (defined('FRONT_END')) {

            if ($user->isLoggedIn() == 1) {
                $template->getEngine()->addVariable('LOGIN_STATUS', 'Is logged');
            } else {
                $template->getEngine()->addVariable('LOGIN_STATUS', 'No is logged');
            }

            $cache->setCache('gallery_settings');
            if ($cache->isCached('gallery_img_guest_view')) {
                $guest_img_view = $cache->retrieve('gallery_img_guest_view');
            } else {
                $guest_img_view = true;
                $cache->store('gallery_img_guest_view', true);
/data/modules/Gallery/module.php
SELECT * FROM nl2_gallery_settings WHERE `id` = '1';
        }

        $this->initialise();
    }

    public function onDisable()
    {
    }

    public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template)
    {

        PermissionHandler::registerPermissions('Gallery', [
            'admincp.gallery' => $this->GalleryLanguage->get('general', 'img_permision'),
            'admincp.gallery_video' => $this->GalleryLanguage->get('general', 'video_permision'),
            'front.gallery.view' => $this->GalleryLanguage->get('general', 'image_view_permision'),
            'front.gallery_video.view' => $this->GalleryLanguage->get('general', 'video_view_permision'),
        ]);


        $settings_data = DB::getInstance()->get('gallery_settings', ['id', '=', 1])->results();
        $settings = $settings_data['0'];
        $icon = $settings->icon;
        $gallery_order = $settings->order_link;
        $gallery_title = $this->GalleryLanguage->get('general', 'gallery_title');


        $settings_data_video = DB::getInstance()->get('gallery_settings', ['id', '=', 2])->results();
        $settings_video = $settings_data_video['0'];
        $icon_video = $settings_video->icon;
        $video_order = $settings_video->order_link;
        $video_title = $this->GalleryLanguage->get('general', 'video_title');


        if (defined('FRONT_END')) {

            if ($user->isLoggedIn() == 1) {
                $template->getEngine()->addVariable('LOGIN_STATUS', 'Is logged');
            } else {
                $template->getEngine()->addVariable('LOGIN_STATUS', 'No is logged');
            }
/data/modules/Lists/pages/submission.php
SELECT count(*) AS c FROM nl2_lists_submissions_members WHERE submission_id = '1681';
    ]);
}

$template->getEngine()->addVariables([
    'SUBMISSION_ID' => Output::getClean($submission->data()->id),
    'SUBMISSION_NAME' => Output::getClean($submission->data()->name),
    'DESCRIPTION' => Output::getPurified($submission->data()->description),
    'SUBMISSION_ICON' =>  $submission->getIcon(),
    'SUBMISSION_BANNER' =>  $submission->getBanner(),
    'USERS' => Output::getClean($submission->data()->users),
    'VOTES' => $lists_language->get('general', 'votes'),
    'VOTES_COUNT' => Output::getClean($submission->data()->votes),
    'TOTAL_VOTES_COUNT' => Output::getClean($submission->data()->total_votes),
    'CREATED' => $lists_language->get('general', 'created'),
    'CREATED_DATE' => $timeago->inWords($submission->data()->created, $language),
    'CREATED_DATE_FULL' => date(DATE_FORMAT, $submission->data()->created),
    'LAST_UPDATED' => $lists_language->get('general', 'last_updated'),
    'LAST_UPDATED_DATE' => $timeago->inWords($submission->data()->last_bumped, $language),
    'LAST_UPDATED_DATE_FULL' => date(DATE_FORMAT, $submission->data()->last_bumped),
    'FOLLOWERS' => $lists_language->get('general', 'followers'),
    'FOLLOWERS_COUNT' => DB::getInstance()->query('SELECT count(*) AS c FROM nl2_lists_submissions_members WHERE submission_id = ?', [$submission->data()->id])->first()->c,
    'TABS' => $tabs_menu,
    'OVERVIEW' => $lists_language->get('general', 'overview'),
    'OVERVIEW_LINK' => $submission->getLink(),
    'VOTE' => $lists_language->get('general', 'vote'),
    'VOTE_LINK' => $submission->getLink('/vote'),
    'DETAILS' => $details,
    'SUBMISSION_WIDGETS' => $submission_widgets,
    'TOKEN' => Token::get(),
    'TEAM_MEMBERS' => $lists_language->get('general', 'team_members'),
    'TEAM_MEMBERS_LIST' => $team_members,
    'IS_SPONSORED' => $submission->isSponsored(),
]);

if (Session::exists('submission_success')) {
    $success = Session::flash('submission_success');
}

if (isset($success))
    $template->getEngine()->addVariables([
        'SUCCESS' => $success,
/data/modules/Lists/pages/submission.php
SELECT * FROM nl2_lists_submissions_members WHERE submission_id = '1681' AND can_edit = 1;
foreach ($submission->getConnections() as $connection) {
    $details = array_merge($details, $connection->getProvider()->getStatsDetails($connection));

    $widget = $connection->getProvider()->getAddressWidget($connection);
    if (count($widget)) {
        $submission_widgets[] = $widget;
    }
}

// Team Members
$team_members = [];
$team_members[] = [
    'username' => $owner->getDisplayname(),
    'user_id' => $owner->data()->id,
    'user_profile' => $owner->getProfileURL(),
    'user_style' => $owner->getGroupStyle(),
    'user_avatar' => $owner->getAvatar(),
    'user_title' => 'Owner'
];

$members = DB::getInstance()->query('SELECT * FROM nl2_lists_submissions_members WHERE submission_id = ? AND can_edit = 1', [$submission->data()->id]);
if ($members->count()) {
    foreach ($members->results() as $member) {
        $member_user = new User($member->user_id);
        if (!$member_user->exists()) {
            continue;
        }

        $team_members[] = [
            'username' => $member_user->getDisplayname(),
            'user_id' => $member_user->data()->id,
            'user_profile' => $member_user->getProfileURL(),
            'user_style' => $member_user->getGroupStyle(),
            'user_avatar' => $member_user->getAvatar(),
            'user_title' => Output::getClean($member->user_title)
        ];
    }
}

// Is the user followed?
if ($user->isLoggedIn()) {
/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 = '7855';

        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 = '7855' 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/Lists/classes/Submission.php
SELECT * FROM nl2_lists_submissions_connections WHERE submission_id = '1681';
        if ($images->count()) {
            foreach ($images->results() as $image) {
                $images_list[] = [
                    'src' => (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/uploads/lists_images/' . Output::getClean($image->image),
                ];
            }
        }

        return $images_list;
    }

    /**
     * Get the submission's provider connections.
     *
     * @return SubmissionConnection[] Their provider connections.
     */
    public function getConnections(): array {
        return $this->_connections ??= (function (): array {
            $connections_list = [];

            $providers_query = $this->_db->query('SELECT * FROM nl2_lists_submissions_connections WHERE submission_id = ?', [$this->data()->id]);
            foreach ($providers_query->results() as $item) {
                $provider = Lists::getInstance()->getProviderConnection($item->provider);
                if ($provider == null) {
                    continue;
                }

                $connection = new SubmissionConnection($provider, null, null, $item);
                if ($connection->exists()) {
                    $connections_list[$provider->name()] = $connection;
                }
            }

            return $this->_connections = $connections_list;
        })();
    }

    public function getConnection(string $connection): ?SubmissionConnection {
        return $this->getConnections()[$connection] ?? null;
    }

/data/modules/Lists/pages/submission.php
SELECT id FROM nl2_lists_submissions_images WHERE submission_id = '1681';
            'EDIT_SUBMISSION_LINK' => URL::build('/user/lists/submissions/edit/' . $submission->data()->id)
        ]);
    }
}

// Tabs
$tabs_menu = [
    'overview' => [
        'title' => $lists_language->get('general', 'overview'),
        'active' => $view == 'overview',
        'link' => $submission->getLink(),
    ],
    'vote' => [
        'title' => $lists_language->get('general', 'vote'),
        'active' => $view == 'vote',
        'link' => $submission->getLink('/vote'),
    ]
];

// Images tab
if ($view == 'images' || DB::getInstance()->query('SELECT id FROM nl2_lists_submissions_images WHERE submission_id = ?', [$submission->data()->id])->count()) {
    $tabs_menu['images'] = [
        'title' => $lists_language->get('general', 'gallery'),
        'active' => $view == 'images',
        'link' => $submission->getLink('/images'),
    ];
}

$submission_widgets = [];
$details = [];
foreach ($submission->getConnections() as $connection) {
    $details = array_merge($details, $connection->getProvider()->getStatsDetails($connection));

    $widget = $connection->getProvider()->getAddressWidget($connection);
    if (count($widget)) {
        $submission_widgets[] = $widget;
    }
}

// Team Members
$team_members = [];
/data/core/templates/frontend_init.php
SELECT * FROM nl2_page_descriptions WHERE `page` = '/server/1681-dsbm/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/core/classes/Core/Settings.php
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` = 'Tailwind';
        $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/core/classes/Core/User.php
SELECT * FROM nl2_users WHERE `id` = '7855';
    }

    /**
     * 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/Lists/classes/Submission.php
SELECT `nl2_lists_submissions`.*, `type`, `sponsored_product_id`, `provider` FROM `nl2_lists_submissions` INNER JOIN `nl2_lists` ON `list_id` = `nl2_lists`.`id` WHERE `nl2_lists_submissions`.`id` = '1681';
use URL;
use User;

class Submission {
    private DB $_db;
    private $_data;
    private User $_user;

    /**
     * @var SubmissionConnection[] The submission provider connections.
     */
    private array $_connections;

    public function __construct($value = null, $field = 'id', $data = null) {
        $this->_db = DB::getInstance();

        if ($data == null) {
            if ($value != null) {

                if ($field == 'id') {
                    $data = $this->_db->query('SELECT `nl2_lists_submissions`.*, `type`, `sponsored_product_id`, `provider` FROM `nl2_lists_submissions` INNER JOIN `nl2_lists` ON `list_id` = `nl2_lists`.`id` WHERE `nl2_lists_submissions`.`id` = ?', [$value]);
                } else {
                    [$where, $params] = DB::makeWhere([$field, '=', $value]);

                    $data = $this->_db->query('SELECT `nl2_lists_submissions`.*, `type`, `sponsored_product_id`, `provider` FROM `nl2_lists_submissions` INNER JOIN `nl2_lists` ON `list_id` = `nl2_lists`.`id` ' . $where, $params);
                }

                if ($data->count()) {
                    $this->_data = $data->first();
                }
            }
        } else {
            $this->_data = $data;
        }
    }

    /**
     * Update a submission data in the database.
     *
     * @param array $fields Column names and values to update.
     */
/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 vanity_url FROM `nl2_lists_submissions` WHERE `vanity_url` IS NOT NULL;
        EventHandler::registerEvent(SubmissionVotedEvent::class);
        EventHandler::registerEvent(SubmissionBumpedEvent::class);
        EventHandler::registerEvent(SubmissionFollowedEvent::class);
        EventHandler::registerEvent(SubmissionUnfollowedEvent::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 . '/tags', 'pages/submissions_tags.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 vanity_url 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;
        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(SubmissionCreatedEvent::class);
        EventHandler::registerEvent(SubmissionUpdatedEvent::class);
        EventHandler::registerEvent(SubmissionDeletedEvent::class);
        EventHandler::registerEvent(SubmissionVotedEvent::class);
        EventHandler::registerEvent(SubmissionBumpedEvent::class);
        EventHandler::registerEvent(SubmissionFollowedEvent::class);
        EventHandler::registerEvent(SubmissionUnfollowedEvent::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 . '/tags', 'pages/submissions_tags.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 vanity_url 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');
/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/Integrations/IntegrationBase.php
SELECT * FROM nl2_integrations WHERE name = 'Discord';
 * @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/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/core/classes/Core/Settings.php
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` = 'Referrals';
        $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/Referrals/module.php
SELECT id, custom_url FROM nl2_referrals WHERE disabled = 0 AND custom_url IS NOT NULL;

        // Check if module version changed
        $cache->setCache('referrals_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 {
            // Define URLs which belong to this module
            $referrals = $this->_db->query('SELECT id, custom_url FROM nl2_referrals WHERE disabled = 0 AND custom_url IS NOT NULL');
            if ($referrals->count()) {
                foreach ($referrals->results() as $referral) {
                    $pages->add('Referrals', '/' . $referral->custom_url, 'pages/referral.php');
                }
            }

        } catch (Exception $e) {
            // Database tables don't exist yet
        }

        // Events
        EventHandler::registerEvent(ReferralRegistrationEvent::class);

        // Listeners
        EventHandler::registerListener(UserRegisteredEvent::class, [RegistrationListener::class, 'registration']);
        EventHandler::registerListener(UserValidatedEvent::class, [RegistrationListener::class, 'userValidated']);
        EventHandler::registerListener(DiscordWebhookFormatterEvent::class, [RegistrationListener::class, 'discordEmbedFormatter']);

        // Store integration
        $percentage = Settings::get('store_sale_percentage', '0', 'Referrals');
/data/modules/Forms/module.php
SELECT form_id FROM nl2_forms_permissions WHERE form_id = '1' AND post = 1 AND group_id IN(0);

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

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

                    // Add link location to navigation if user have permission
                    if ($perm) {
                        switch ($form->link_location) {
                            case 1:
                                // Navbar
/data/modules/Forms/module.php
SELECT id, link_location, url, icon, title, guest FROM nl2_forms;
        $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;
/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_permissions WHERE `group_id` = '0';
                                                $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');
/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.