Uncaught SmartyException

Unable to load template 'file:profile.tpl'

(File: /home/padow/Websites/dev/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php)

https://dev.namelessmc.xyz/profile/DominikSLK/


File: /home/padow/Websites/dev/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php
    /**
     * render template
     *
     * @param bool      $no_output_filter if true do not run output filter
     * @param null|bool $display          true: display, false: fetch null: sub-template
     *
     * @return string
     * @throws \Exception
     * @throws \SmartyException
     */
    public function render($no_output_filter = true, $display = null)
    {
        if ($this->smarty->debugging) {
            if (!isset($this->smarty->_debug)) {
                $this->smarty->_debug = new Smarty_Internal_Debug();
            }
            $this->smarty->_debug->start_template($this, $display);
        }
        // checks if template exists
        if (!$this->source->exists) {
            throw new SmartyException(
                "Unable to load template '{$this->source->type}:{$this->source->name}'" .
                ($this->_isSubTpl() ? " in '{$this->parent->template_resource}'" : '')
            );
        }
        // disable caching for evaluated code
        if ($this->source->handler->recompiled) {
            $this->caching = Smarty::CACHING_OFF;
        }
        // read from cache or render
        if ($this->caching === Smarty::CACHING_LIFETIME_CURRENT || $this->caching === Smarty::CACHING_LIFETIME_SAVED) {
            if (!isset($this->cached) || $this->cached->cache_id !== $this->cache_id
                || $this->cached->compile_id !== $this->compile_id
            ) {
                $this->loadCached(true);
            }
            $this->cached->render($this, $no_output_filter);
        } else {
            if (!isset($this->compiled) || $this->compiled->compile_id !== $this->compile_id) {
                $this->loadCompiled(true);
            }
File: /home/padow/Websites/dev/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php
                if ($template->caching) {
                    // return cache status of template
                    if (!isset($template->cached)) {
                        $template->loadCached();
                    }
                    $result = $template->cached->isCached($template);
                    Smarty_Internal_Template::$isCacheTplObj[ $template->_getTemplateId() ] = $template;
                } else {
                    return false;
                }
            } else {
                if ($saveVars) {
                    $savedTplVars = $template->tpl_vars;
                    $savedConfigVars = $template->config_vars;
                }
                ob_start();
                $template->_mergeVars();
                if (!empty(Smarty::$global_tpl_vars)) {
                    $template->tpl_vars = array_merge(Smarty::$global_tpl_vars, $template->tpl_vars);
                }
                $result = $template->render(false, $function);
                $template->_cleanUp();
                if ($saveVars) {
                    $template->tpl_vars = $savedTplVars;
                    $template->config_vars = $savedConfigVars;
                } else {
                    if (!$function && !isset(Smarty_Internal_Template::$tplObjCache[ $template->templateId ])) {
                        $template->parent = null;
                        $template->tpl_vars = $template->config_vars = array();
                        Smarty_Internal_Template::$tplObjCache[ $template->templateId ] = $template;
                    }
                }
            }

            if (isset($errorHandler)) {
                $errorHandler->deactivate();
            }

            if (isset($_smarty_old_error_level)) {
                error_reporting($_smarty_old_error_level);
            }
File: /home/padow/Websites/dev/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php
    public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null)
    {
        $result = $this->_execute($template, $cache_id, $compile_id, $parent, 0);
        return $result === null ? ob_get_clean() : $result;
    }

    /**
     * displays a Smarty template
     *
     * @param string $template   the resource handle of the template file or template object
     * @param mixed  $cache_id   cache id to be used with this template
     * @param mixed  $compile_id compile id to be used with this template
     * @param object $parent     next higher level of Smarty variables
     *
     * @throws \Exception
     * @throws \SmartyException
     */
    public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
    {
        // display template
        $this->_execute($template, $cache_id, $compile_id, $parent, 1);
    }

    /**
     * test if cache is valid
     *
     * @api  Smarty::isCached()
     * @link https://www.smarty.net/docs/en/api.is.cached.tpl
     *
     * @param null|string|\Smarty_Internal_Template $template   the resource handle of the template file or template
     *                                                          object
     * @param mixed                                 $cache_id   cache id to be used with this template
     * @param mixed                                 $compile_id compile id to be used with this template
     * @param object                                $parent     next higher level of Smarty variables
     *
     * @return bool cache status
     * @throws \Exception
     * @throws \SmartyException
     */
    public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null)
    {
File: /home/padow/Websites/dev/core/classes/Templates/TemplateBase.php
    public function displayTemplate(string $template, Smarty $smarty): 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);

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

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

        $smarty->display($template);
    }

    /**
     * Get all internal CSS styles.
     *
     * @return array Array of strings of CSS.
     */
    public function getCSS(): array {
        return $this->_css;
    }

    /**
     * Get all internal JS code.
     *
     * @return array Array of strings of JS.
     */
    public function getJS(): array {
        return $this->_js;
    }

File: /home/padow/Websites/dev/modules/Core/pages/profile.php
            AssetTree::IMAGE_PICKER,
        ]);
    }

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

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

    $template->onPageLoad();

    $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left'));
    $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right'));

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

    // Display template
    $template->displayTemplate('profile.tpl', $smarty);
} else {
    if (isset($_GET['error'])) {
        // User not exist
        $smarty->assign([
            'BACK' => $language->get('general', 'back'),
            'HOME' => $language->get('general', 'home'),
            'NOT_FOUND' => $language->get('user', 'couldnt_find_that_user')
        ]);
        // Load modules + template
        Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);

        $template->onPageLoad();

        $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left'));
        $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right'));

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

        // Display template
File: /home/padow/Websites/dev/index.php
        die();
    }
} else {
    // Use recursion to check - might have URL parameters in path
    $path_array = explode('/', $route);

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

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

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

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

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

require(ROOT_PATH . '/404.php');
SQL query:
SELECT * FROM nl2_tailpad_settings WHERE `id` <> '0';
File: /home/padow/Websites/dev/custom/templates/TailPad/template_settings/classes/PadUtil.php
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
            curl_setopt($ch, CURLOPT_TIMEOUT, 5);
            curl_setopt($ch, CURLOPT_URL, 'https://discordapp.com/api/servers/' . $id . '/widget.json');
            $result = curl_exec($ch);
            $result = json_decode($result);
            curl_close($ch);
            $discord_server = [
                'name' => $result->name,
                'members' => $result->presence_count,
                'link' => $result->instant_invite
            ];
        }
        return $discord_server;
    }
    
    public static function getSettingsToSmarty(): array
    {
        $settings_data = DB::getInstance()->get('tailpad_settings', ['id', '<>', 0])->results();
        $result = [];
        if (count($settings_data)) {
            foreach ($settings_data as $value) {
                $settings_data_array[$value->name] = [
                    'id' => Output::getClean($value->id),
                    'value' => Output::getClean($value->value)
                ];
                $result[strtoupper($value->name)] = htmlspecialchars_decode($settings_data_array[$value->name]['value']);
            }
        }
        return $result;
    }

    public static function updateOrCreateParam($key, $value)
    {
        $array = DB::getInstance()->get('tailpad_settings', ['name', '=', $key])->results();
        $data = end($array);
        if (!empty($data)) {
            DB::getInstance()->update('tailpad_settings', $data->id, [
                'value' => $value
SQL query:
SELECT * FROM nl2_mc_trade_config WHERE `name` = 'link_conf';
File: /home/padow/Websites/dev/modules/McTrade/module.php
    require_once(ROOT_PATH . '/modules/McTrade/widgets/McTradeBalance.php');
    $widgets->add(new McTradeBalance($smarty, $user, $this->_McTradeLanguage));

    require_once(ROOT_PATH . '/modules/McTrade/widgets/McTradeLastBuy.php');
    $widgets->add(new McTradeLastBuy($smarty, $user, $this->_McTradeLanguage));


    if (defined('FRONT_END')) {

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


      // Link Location

      $trade_title = $this->_McTradeLanguage->get('general', 'mctrade_head_front_end');

      $settings_link = DB::getInstance()->get('mc_trade_config', array('name', '=', 'link_conf'))->results();
      $settings_link = $settings_link['0'];


      if (isset($settings_link) && !empty($settings_link)) {

        $link_order = (int) $settings_link->value_one;
        $icon = $settings_link->value_two;

        if ($settings_link->value == 'footer') {

          $navs[0]->add($this->module_name, $trade_title, URL::build('/shop'), 'footer', null, $link_order, $icon);
        } elseif ($settings_link->value == 'top') {

          $navs[0]->add($this->module_name, $trade_title, URL::build('/shop'), 'top', null, $link_order, $icon);
        } elseif ($settings_link->value == 'dropdown') {

          $navs[0]->addItemToDropdown('more_dropdown', $this->module_name, $trade_title, URL::build('/shop'), 'top', null, $icon);
        } elseif ($settings_link->value == 'no_location') {
        }
      } else {
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'McTradeLastBuy';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'McTradeBalance';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'Latest Posts';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT * FROM nl2_mc_servers WHERE `parent_server` = '1';
File: /home/padow/Websites/dev/modules/Core/module.php
        // Check page type (frontend or backend)
        if (defined('FRONT_END')) {
            // Minecraft integration?
            if (defined('MINECRAFT') && MINECRAFT === true) {
                // Query main server
                $cache->setCache('mc_default_server');

                // Already cached?
                if ($cache->isCached('default_query')) {
                    $result = $cache->retrieve('default_query');
                    $default = $cache->retrieve('default');
                } else {
                    if ($cache->isCached('default')) {
                        $default = $cache->retrieve('default');
                        $sub_servers = $cache->retrieve('default_sub');
                    } else {
                        // Get default server from database
                        $default = DB::getInstance()->get('mc_servers', ['is_default', true])->results();
                        if (count($default)) {
                            // Get sub-servers of default server
                            $sub_servers = DB::getInstance()->get('mc_servers', ['parent_server', $default[0]->id])->results();
                            if (count($sub_servers)) {
                                $cache->store('default_sub', $sub_servers);
                            } else {
                                $cache->store('default_sub', []);
                            }

                            $default = $default[0];

                            $cache->store('default', $default, 60);
                        } else {
                            $cache->store('default', null, 60);
                        }
                    }

                    if (!is_null($default) && isset($default->ip)) {
                        $full_ip = ['ip' => $default->ip . (is_null($default->port) ? '' : ':' . $default->port), 'pre' => $default->pre, 'name' => $default->name];

                        // Get query type
                        $query_type = Util::getSetting('external_query') === '1' ? 'external' : 'internal';

SQL query:
SELECT * FROM nl2_mc_servers WHERE `is_default` = '1';
File: /home/padow/Websites/dev/modules/Core/module.php
            $navs[0]->add('leaderboards', $language->get('general', 'leaderboards'), URL::build('/leaderboards'), 'top', null, $leaderboards_order, $leaderboards_icon);
        }

        // Check page type (frontend or backend)
        if (defined('FRONT_END')) {
            // Minecraft integration?
            if (defined('MINECRAFT') && MINECRAFT === true) {
                // Query main server
                $cache->setCache('mc_default_server');

                // Already cached?
                if ($cache->isCached('default_query')) {
                    $result = $cache->retrieve('default_query');
                    $default = $cache->retrieve('default');
                } else {
                    if ($cache->isCached('default')) {
                        $default = $cache->retrieve('default');
                        $sub_servers = $cache->retrieve('default_sub');
                    } else {
                        // Get default server from database
                        $default = DB::getInstance()->get('mc_servers', ['is_default', true])->results();
                        if (count($default)) {
                            // Get sub-servers of default server
                            $sub_servers = DB::getInstance()->get('mc_servers', ['parent_server', $default[0]->id])->results();
                            if (count($sub_servers)) {
                                $cache->store('default_sub', $sub_servers);
                            } else {
                                $cache->store('default_sub', []);
                            }

                            $default = $default[0];

                            $cache->store('default', $default, 60);
                        } else {
                            $cache->store('default', null, 60);
                        }
                    }

                    if (!is_null($default) && isset($default->ip)) {
                        $full_ip = ['ip' => $default->ip . (is_null($default->port) ? '' : ':' . $default->port), 'pre' => $default->pre, 'name' => $default->name];

SQL query:
SELECT * FROM nl2_groups WHERE `default_group` = '1';
File: /home/padow/Websites/dev/modules/Core/module.php
            $widgets->add(new StatsWidget($smarty, $language, $cache));
        }

        // Validate user hook
        $validate_action = Util::getSetting('validate_user_action');
        $validate_action = json_decode($validate_action, true);

        if ($validate_action['action'] == 'promote') {
            EventHandler::registerListener('validateUser', 'ValidateHook::execute');
            define('VALIDATED_DEFAULT', $validate_action['group']);
        }

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

        // Check for updates
        if ($user->isLoggedIn()) {
            if ((defined('PANEL_PAGE') && PANEL_PAGE !== 'update') && $user->hasPermission('admincp.update')) {
                $cache->setCache('update_check');
                if ($cache->isCached('update_check')) {
                    $update_check = $cache->retrieve('update_check');
                } else {
                    $update_check = Util::updateCheck();
                    $cache->store('update_check', $update_check, 3600);
                }

                if (!is_string($update_check) && $update_check->updateAvailable()) {
                    $smarty->assign([
                        'NEW_UPDATE' => $update_check->isUrgent()
                            ? $language->get('admin', 'new_urgent_update_available')
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'Statistics';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'Server Status';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'Online Users';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'Online Staff';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = 'Latest Profile Posts';
File: /home/padow/Websites/dev/core/classes/Widgets/WidgetBase.php
     * Get the display order of this widget.
     *
     * @return int Display order of widget.
     */
    public function getOrder(): ?int {
        return $this->_order;
    }

    /**
     * Generate this widget's `$_content`.
     */
    abstract public function initialise(): void;

    /**
     * Get the data (location, order, pages) for a widget.
     *
     * @param string $name The widget to get data for.
     * @return object|null Widgets data.
     */
    protected static function getData(string $name): ?object {
        return DB::getInstance()->query('SELECT `location`, `order`, `pages` FROM nl2_widgets WHERE `name` = ?', [$name])->first();
    }

    /**
     * Parse the widgets JSON pages string into an array.
     *
     * @param object|null $data The widget data to get pages from.
     * @return array The parsed pages array.
     */
    protected static function parsePages(?object $data): array {
        if (isset($data->pages)) {
            return json_decode($data->pages, true) ?? [];
        }
        return [];
    }
}
SQL query:
SELECT * FROM nl2_topics WHERE `id` = '2';
File: /home/padow/Websites/dev/modules/Forum/profile_tab.php
                        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);
        }

        $posts[] = [
            'link' => URL::build('/forum/topic/' . $latest_post->topic_id . '-' . $forum->titleToURL($topic_title), 'pid=' . $latest_post->id),
            'title' => $topic_title,
SQL query:
SELECT * FROM nl2_forums_permissions WHERE `forum_id` = '2';
File: /home/padow/Websites/dev/modules/Forum/profile_tab.php

    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;
SQL query:
SELECT * FROM nl2_posts WHERE post_creator = 2 AND deleted = 0 ORDER BY post_date DESC LIMIT 15;
File: /home/padow/Websites/dev/modules/Forum/profile_tab.php
<?php
/*
 *  Made by Samerton
 *  https://github.com/NamelessMC/Nameless/
 *  NamelessMC version 2.0.0-pr8
 *
 *  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;
SQL query:
SELECT * FROM nl2_users_placeholders up JOIN nl2_placeholders_settings ps ON up.name = ps.name AND up.server_id = ps.server_id WHERE up.uuid = ;
File: /home/padow/Websites/dev/core/classes/Misc/Placeholders.php
     * Create a new row in nl2_placeholders_settings if a row with the "server_id" of $server_id and "name" of $name does not exist (this lets the same placeholder name be used across multiple NamelessMC plugin servers).
     *
     * @param int $server_id ID of the server this placeholder resides on
     *
     * @param string $name Name of placeholder
     */
    public function registerPlaceholder(int $server_id, string $name): void {
        $this->_db->query('INSERT IGNORE INTO nl2_placeholders_settings (server_id, name) VALUES (?, ?)', [$server_id, $name]);
    }

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

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

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

        $user_placeholders = [];

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

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

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

    private DB $_db;

    private array $_all_placeholders;

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

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

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

            $sort = $placeholder->leaderboard_sort;

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

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

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

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

        $fields = [];

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

        return $fields;
    }

    /**
     * Is a user blocked?
     *
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /home/padow/Websites/dev/core/classes/Core/User.php
    }

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

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

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

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

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

                return $integrations_list;
            }

            return [];
        })();
    }

SQL query:
SELECT * FROM nl2_user_profile_wall_posts_replies WHERE post_id = 16 ORDER BY time ASC;
File: /home/padow/Websites/dev/modules/Core/pages/profile.php
                    $reaction_name = Output::getClean($reaction_name[0]->name);
                    */

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

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

                foreach ($replies_query as $reply) {
                    $target_user = new User($reply->author_id);
                    $replies['replies'][] = [
                        'user_id' => Output::getClean($reply->author_id),
                        'username' => $target_user->getDisplayname(true),
                        'nickname' => $target_user->getDisplayname(),
                        'style' => $target_user->getGroupStyle(),
                        'profile' => $target_user->getProfileURL(),
                        'avatar' => $target_user->getAvatar(500),
                        'time_friendly' => $timeago->inWords($reply->time, $language),
                        'time_full' => date(DATE_FORMAT, $reply->time),
                        'content' => Output::getPurified(Output::getDecoded($reply->content)),
                        'self' => (($user->isLoggedIn() && $user->data()->id == $reply->author_id) ? 1 : 0),
SQL query:
SELECT * FROM nl2_user_profile_wall_posts_reactions WHERE `post_id` = '16';
File: /home/padow/Websites/dev/modules/Core/pages/profile.php
            $template_pagination_left ?? null,
            $template_pagination_right ?? null
        );
        $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query));
        $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/'));

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

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

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

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

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

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

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

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '1';
File: /home/padow/Websites/dev/modules/Core/pages/profile.php
    ]);

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

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

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

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

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

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

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

                foreach ($reactions_query as $reaction) {
                    // Get reaction name and icon
                    // TODO
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '1';
File: /home/padow/Websites/dev/core/classes/Core/User.php
    }

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

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

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

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

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

                return $integrations_list;
            }

            return [];
        })();
    }

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

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

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

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

                if ($groups_query->count()) {

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

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

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

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

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

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

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

                if ($groups_query->count()) {

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

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

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

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

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

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

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

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

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

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

                return $integrations_list;
            }

            return [];
        })();
    }

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

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

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

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

                if ($groups_query->count()) {

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

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

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

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

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

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

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

                if ($groups_query->count()) {

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

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

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

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

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

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

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

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

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

                    $target_user = new User($reaction->user_id);
                    $reactions['reactions'][] = [
SQL query:
SELECT * FROM nl2_users WHERE `id` = '1';
File: /home/padow/Websites/dev/modules/Core/pages/profile.php
    ]);

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

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

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

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

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

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

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

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

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

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

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

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

            if (!count($post_user)) {
                continue;
            }
SQL query:
SELECT nl2_users_integrations.*, nl2_integrations.name as integration_name FROM nl2_users_integrations LEFT JOIN nl2_integrations ON integration_id=nl2_integrations.id WHERE user_id = '2';
File: /home/padow/Websites/dev/core/classes/Core/User.php
    }

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

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

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

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

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

                return $integrations_list;
            }

            return [];
        })();
    }

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

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

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

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

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

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

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

                if ($groups_query->count()) {

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

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

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

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

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

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

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

                if ($groups_query->count()) {

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

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

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

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

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

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

$cache->setCache('backgroundcache');

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

if (!empty($banner_image)) {
SQL query:
SHOW TABLES LIKE 'nl2_tailpad_settings';
File: /home/padow/Websites/dev/custom/templates/TailPad/template_settings/classes/PadUtil.php
    }

    public static function updateOrCreateParam($key, $value)
    {
        $array = DB::getInstance()->get('tailpad_settings', ['name', '=', $key])->results();
        $data = end($array);
        if (!empty($data)) {
            DB::getInstance()->update('tailpad_settings', $data->id, [
                'value' => $value
            ]);
        } else {
            DB::getInstance()->insert('tailpad_settings', [
                'name' => $key,
                'value' => $value
            ]);
        }
    }

    public static function initialise()
    {
        if (DB::getInstance()->showTables('tailpad_settings')) {
            return;
        }

        try {
            $group = DB::getInstance()->get('groups', ['id', '=', 2])->results();
            $group = $group[0];
            $group_permissions = json_decode($group->permissions, TRUE);
            $group_permissions['admincp.tailpad'] = 1;
            $group_permissions = json_encode($group_permissions);
            DB::getInstance()->update('groups', 2, ['permissions' => $group_permissions]);
        } catch (Exception $e) {
            // Error
        }
        try {
            $engine = Config::get('mysql/engine');
            $charset = Config::get('mysql/charset');
        } catch (Exception $e) {
            $engine = 'InnoDB';
            $charset = 'utf8mb4';
        }
SQL query:
SELECT * FROM nl2_page_descriptions WHERE `page` = '/profile';
File: /home/padow/Websites/dev/modules/Core/pages/profile.php
/*
 *	Made by Samerton
 *  https://github.com/NamelessMC/Nameless/
 *  NamelessMC version 2.0.0-pr13
 *
 *  License: MIT
 *
 *  User profile page
 */

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

$timeago = new TimeAgo(TIMEZONE);

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

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

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

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

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

$template->addCSSStyle(
SQL query:
UPDATE nl2_online_guests SET `last_seen` = '1097' WHERE `id` =;
File: /home/padow/Websites/dev/core/init.php
            'user_title' => Output::getClean($user->data()->user_title),
            'avatar' => $user->getAvatar(),
            'integrations' => $user_integrations
        ]);

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

            $date = date('U');

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

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

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

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

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

            $date = date('U');

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

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

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

abstract class IntegrationBase {

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

    protected string $_name;
    protected ?int $_order;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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