Uncaught SmartyException

Unable to load template 'file:server_status' in 'file:navbar.tpl'

/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php

https://dev3.partydragen.com/player/Just_better__/
/data/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);
            }
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php
            }
        }
        $tpl->_cache = array();
        if (isset($uid)) {
            if ($smarty->debugging) {
                if (!isset($smarty->_debug)) {
                    $smarty->_debug = new Smarty_Internal_Debug();
                }
                $smarty->_debug->start_template($tpl);
                $smarty->_debug->start_render($tpl);
            }
            $tpl->compiled->getRenderedTemplateCode($tpl, $content_func);
            if ($smarty->debugging) {
                $smarty->_debug->end_template($tpl);
                $smarty->_debug->end_render($tpl);
            }
        } else {
            if (isset($tpl->compiled)) {
                $tpl->compiled->render($tpl);
            } else {
                $tpl->render();
            }
        }
    }

    /**
     * Get called sub-templates and save call count
     */
    public function _subTemplateRegister()
    {
        foreach ($this->compiled->includes as $name => $count) {
            if (isset(self::$subTplInfo[ $name ])) {
                self::$subTplInfo[ $name ] += $count;
            } else {
                self::$subTplInfo[ $name ] = $count;
            }
        }
    }

    /**
     * Check if this is a sub template
/data/cache/templates_c/3f86bf88c4e06cac6a626b421cab098a55e52c62_0.file.navbar.tpl.php
        <?php }?>

        <?php if ($_smarty_tpl->tpl_vars['BANNER_TEXTURE']->value == "grid") {?>
                        <div class="absolute inset-0 opacity-[0.07]"
                 style="background-image:
                 linear-gradient(to right, white 1px, transparent 1px),
                 linear-gradient(to bottom, white 1px, transparent 1px);
                 background-size:40px 40px;">
            </div>
        <?php }?>


                <div class="absolute inset-x-0 bottom-0 h-72 bg-gradient-to-t from-white via-white/70 to-transparent dark:from-slate-950 dark:via-slate-950/70"></div>
    </div>

        <div class="relative mx-auto max-w-[1500px] px-4 pt-20 pb-28 md:pt-24 md:pb-48">
        <div class="grid gap-6 md:grid-cols-3 md:items-center">

                        <div class="hidden md:flex items-center justify-start">
                <?php if ($_smarty_tpl->tpl_vars['MASTHEAD_CONTENT_LEFT']->value != 'none') {
$_smarty_tpl->_subTemplateRender($_smarty_tpl->tpl_vars['MASTHEAD_CONTENT_LEFT']->value, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, true);
}?>
            </div>

                        <div class="flex justify-center">
                <?php if ($_smarty_tpl->tpl_vars['MASTHEAD_CONTENT_CENTER']->value != 'none') {
$_smarty_tpl->_subTemplateRender($_smarty_tpl->tpl_vars['MASTHEAD_CONTENT_CENTER']->value, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, true);
}?>
            </div>

                        <div class="hidden md:flex items-center justify-end">
                <?php if ($_smarty_tpl->tpl_vars['MASTHEAD_CONTENT_RIGHT']->value != 'none') {
$_smarty_tpl->_subTemplateRender($_smarty_tpl->tpl_vars['MASTHEAD_CONTENT_RIGHT']->value, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, true);
}?>
            </div>

        </div>

    </div>
</div>

/data/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php
     *
     * @throws \Exception
     */
    public function getRenderedTemplateCode(Smarty_Internal_Template $_template, $unifunc = null)
    {
        $smarty = &$_template->smarty;
        $_template->isRenderingCache = $this->isCache;
        $level = ob_get_level();
        try {
            if (!isset($unifunc)) {
                $unifunc = $this->unifunc;
            }
            if (empty($unifunc) || !function_exists($unifunc)) {
                throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
            }
            if ($_template->startRenderCallbacks) {
                foreach ($_template->startRenderCallbacks as $callback) {
                    call_user_func($callback, $_template);
                }
            }
            $unifunc($_template);
            foreach ($_template->endRenderCallbacks as $callback) {
                call_user_func($callback, $_template);
            }
            $_template->isRenderingCache = false;
        } catch (Exception $e) {
            $_template->isRenderingCache = false;
            while (ob_get_level() > $level) {
                ob_end_clean();
            }
            if (isset($smarty->security_policy)) {
                $smarty->security_policy->endTemplate();
            }
            throw $e;
        }
    }

    /**
     * Get compiled time stamp
     *
     * @return int
/data/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php
        if (!$_template->source->exists) {
            $type = $_template->source->isConfig ? 'config' : 'template';
            throw new SmartyException("Unable to load {$type} '{$_template->source->type}:{$_template->source->name}'");
        }
        if ($_template->smarty->debugging) {
            if (!isset($_template->smarty->_debug)) {
                $_template->smarty->_debug = new Smarty_Internal_Debug();
            }
            $_template->smarty->_debug->start_render($_template);
        }
        if (!$this->processed) {
            $this->process($_template);
        }
        if (isset($_template->cached)) {
            $_template->cached->file_dependency =
                array_merge($_template->cached->file_dependency, $this->file_dependency);
        }
        if ($_template->source->handler->uncompiled) {
            $_template->source->handler->renderUncompiled($_template->source, $_template);
        } else {
            $this->getRenderedTemplateCode($_template);
        }
        if ($_template->caching && $this->has_nocache_code) {
            $_template->cached->hashes[ $this->nocache_hash ] = true;
        }
        if ($_template->smarty->debugging) {
            $_template->smarty->_debug->end_render($_template);
        }
    }

    /**
     * load compiled template or compile from source
     *
     * @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
     *
     * @throws Exception
     */
    public function process(Smarty_Internal_Template $_smarty_tpl)
    {
        $source = &$_smarty_tpl->source;
        $smarty = &$_smarty_tpl->smarty;
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php
                "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);
            }
            $this->compiled->render($this);
        }
        // display or fetch
        if ($display) {
            if ($this->caching && $this->smarty->cache_modified_check) {
                $this->smarty->ext->_cacheModify->cacheModifiedCheck(
                    $this->cached,
                    $this,
                    isset($content) ? $content : ob_get_clean()
                );
            } else {
                if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
                    && !$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ])
                                              || isset($this->smarty->registered_filters[ 'output' ]))
                ) {
                    echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
                } else {
                    echo ob_get_clean();
                }
            }
            if ($this->smarty->debugging) {
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php
            }
        }
        $tpl->_cache = array();
        if (isset($uid)) {
            if ($smarty->debugging) {
                if (!isset($smarty->_debug)) {
                    $smarty->_debug = new Smarty_Internal_Debug();
                }
                $smarty->_debug->start_template($tpl);
                $smarty->_debug->start_render($tpl);
            }
            $tpl->compiled->getRenderedTemplateCode($tpl, $content_func);
            if ($smarty->debugging) {
                $smarty->_debug->end_template($tpl);
                $smarty->_debug->end_render($tpl);
            }
        } else {
            if (isset($tpl->compiled)) {
                $tpl->compiled->render($tpl);
            } else {
                $tpl->render();
            }
        }
    }

    /**
     * Get called sub-templates and save call count
     */
    public function _subTemplateRegister()
    {
        foreach ($this->compiled->includes as $name => $count) {
            if (isset(self::$subTplInfo[ $name ])) {
                self::$subTplInfo[ $name ] += $count;
            } else {
                self::$subTplInfo[ $name ] = $count;
            }
        }
    }

    /**
     * Check if this is a sub template
/data/cache/templates_c/4cb7a5b62aa11969ec46e3de0e10f475e4dcc607_0.file.player.tpl.php
  'unifunc' => 'content_6a149088b14057_35907276',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '4cb7a5b62aa11969ec46e3de0e10f475e4dcc607' => 
    array (
      0 => '/data/custom/templates/Tailwind/mcstatistics/player.tpl',
      1 => 1779732616,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:header.tpl' => 1,
    'file:navbar.tpl' => 1,
    'file:footer.tpl' => 1,
  ),
),false)) {
function content_6a149088b14057_35907276 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_subTemplateRender('file:header.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
$_smarty_tpl->_subTemplateRender('file:navbar.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
?>

<div class="mb-6 grid gap-6 lg:grid-cols-12 lg:items-end">
    <div class="lg:col-span-9">
        <nav aria-label="Breadcrumb">
            <div class="rounded-xl border border-slate-200 bg-white px-5 py-2 shadow-soft dark:border-slate-800 dark:bg-slate-900">
                <ol class="flex flex-wrap items-center gap-2 text-sm">
                    <li>
                        <a
                            class="font-semibold transition-colors
                               text-slate-700 hover:text-indigo-600 hover:underline dark:text-slate-300 dark:hover:text-indigo-400"
                            href="#">
                            <?php echo $_smarty_tpl->tpl_vars['PLAYERS']->value;?>

                        </a>
                    </li>
                    <li class="text-slate-400 dark:text-slate-500">/</li>
                    <li>
                        <a
                            class="font-semibold transition-colors
/data/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php
     *
     * @throws \Exception
     */
    public function getRenderedTemplateCode(Smarty_Internal_Template $_template, $unifunc = null)
    {
        $smarty = &$_template->smarty;
        $_template->isRenderingCache = $this->isCache;
        $level = ob_get_level();
        try {
            if (!isset($unifunc)) {
                $unifunc = $this->unifunc;
            }
            if (empty($unifunc) || !function_exists($unifunc)) {
                throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
            }
            if ($_template->startRenderCallbacks) {
                foreach ($_template->startRenderCallbacks as $callback) {
                    call_user_func($callback, $_template);
                }
            }
            $unifunc($_template);
            foreach ($_template->endRenderCallbacks as $callback) {
                call_user_func($callback, $_template);
            }
            $_template->isRenderingCache = false;
        } catch (Exception $e) {
            $_template->isRenderingCache = false;
            while (ob_get_level() > $level) {
                ob_end_clean();
            }
            if (isset($smarty->security_policy)) {
                $smarty->security_policy->endTemplate();
            }
            throw $e;
        }
    }

    /**
     * Get compiled time stamp
     *
     * @return int
/data/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php
        if (!$_template->source->exists) {
            $type = $_template->source->isConfig ? 'config' : 'template';
            throw new SmartyException("Unable to load {$type} '{$_template->source->type}:{$_template->source->name}'");
        }
        if ($_template->smarty->debugging) {
            if (!isset($_template->smarty->_debug)) {
                $_template->smarty->_debug = new Smarty_Internal_Debug();
            }
            $_template->smarty->_debug->start_render($_template);
        }
        if (!$this->processed) {
            $this->process($_template);
        }
        if (isset($_template->cached)) {
            $_template->cached->file_dependency =
                array_merge($_template->cached->file_dependency, $this->file_dependency);
        }
        if ($_template->source->handler->uncompiled) {
            $_template->source->handler->renderUncompiled($_template->source, $_template);
        } else {
            $this->getRenderedTemplateCode($_template);
        }
        if ($_template->caching && $this->has_nocache_code) {
            $_template->cached->hashes[ $this->nocache_hash ] = true;
        }
        if ($_template->smarty->debugging) {
            $_template->smarty->_debug->end_render($_template);
        }
    }

    /**
     * load compiled template or compile from source
     *
     * @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
     *
     * @throws Exception
     */
    public function process(Smarty_Internal_Template $_smarty_tpl)
    {
        $source = &$_smarty_tpl->source;
        $smarty = &$_smarty_tpl->smarty;
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php
                "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);
            }
            $this->compiled->render($this);
        }
        // display or fetch
        if ($display) {
            if ($this->caching && $this->smarty->cache_modified_check) {
                $this->smarty->ext->_cacheModify->cacheModifiedCheck(
                    $this->cached,
                    $this,
                    isset($content) ? $content : ob_get_clean()
                );
            } else {
                if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
                    && !$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ])
                                              || isset($this->smarty->registered_filters[ 'output' ]))
                ) {
                    echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
                } else {
                    echo ob_get_clean();
                }
            }
            if ($this->smarty->debugging) {
/data/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);
            }
/data/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php
     * universal cache
     *
     * @var array()
     */
    public $_cache = array();

    /**
     * fetches a rendered 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
     * @return string rendered template output
     */
    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);
    }

/data/core/classes/Templates/SmartyTemplateEngine.php
            DebugBarHelper::getInstance()->addSmartyCollector($smarty);
        }

        $this->_securityPolicy = $securityPolicy;
        $this->_smarty = $smarty;

        parent::__construct();
    }

    public function render(string $templateFile): void
    {
        echo $this->fetch($templateFile);
    }

    public function fetch(string $templateFile): string
    {
        $templateFile = str_replace('.tpl', '', $templateFile);

        $this->_smarty->assign($this->getVariables());

        return $this->_smarty->fetch("$templateFile.tpl");
    }

    public function clearCache(): void
    {
        $this->_smarty->clearAllCache();
    }

    /**
     * Add an extra directory to the Smarty security policy.
     *
     * @param  string $dir Directory to add to policy
     * @return void
     */
    public function addSecurityPolicyDirectory(string $dir): void
    {
        $this->_securityPolicy->secure_dir = [...$this->_securityPolicy->secure_dir, $dir];
        $this->_smarty->enableSecurity($this->_securityPolicy);
    }
}
/data/core/classes/Templates/SmartyTemplateEngine.php
            'array_key_exists',
        ];
        $securityPolicy->secure_dir = [ROOT_PATH . '/custom/templates', ROOT_PATH . '/custom/panel_templates'];
        $smarty->enableSecurity($securityPolicy);

        $smarty->setCompileDir(ROOT_PATH . '/cache/templates_c');
        $smarty->setTemplateDir($dir);

        if (defined('PHPDEBUGBAR')) {
            DebugBarHelper::getInstance()->addSmartyCollector($smarty);
        }

        $this->_securityPolicy = $securityPolicy;
        $this->_smarty = $smarty;

        parent::__construct();
    }

    public function render(string $templateFile): void
    {
        echo $this->fetch($templateFile);
    }

    public function fetch(string $templateFile): string
    {
        $templateFile = str_replace('.tpl', '', $templateFile);

        $this->_smarty->assign($this->getVariables());

        return $this->_smarty->fetch("$templateFile.tpl");
    }

    public function clearCache(): void
    {
        $this->_smarty->clearAllCache();
    }

    /**
     * Add an extra directory to the Smarty security policy.
     *
     * @param  string $dir Directory to add to policy
/data/core/classes/Templates/TemplateBase.php
    {
        [$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(),
            ]);
        }

        $this->_engine->render($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;
/data/modules/MCStatistics/pages/player.php
    'ONLINE_ON_SERVER' =>$mcstatistics_language->get('general', 'online_on_server', [
        'server' => Output::getClean($player->data()->last_server->name)
    ]),
    'SERVERS_FIELDS' => $servers,
    'ABOUT_FIELDS' => $about_fields,
    'USER_ID' => $player_user->exists() ? $player_user->data()->id : null,
    'USER_STYLE' => $player_user->exists() ? $player_user->getGroupStyle() : null,
    'USER_AVATAR' => $player_user->exists() ? $player_user->getAvatar() : null,
    'USER_PROFILE' => $player_user->exists() ? $player_user->getProfileURL() : null,
]);

// 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('mcstatistics/player');
/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/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/core/classes/Core/User.php
SELECT * FROM nl2_users WHERE `username` = 'Just_better__';
    }

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

            return true;
        }

        if ($field !== 'hash') {
            $data = $this->_db->get('users', [$field, $value]);
        } else {
            $data = $this->_db->query(
                <<<'SQL'
                SELECT
                    nl2_users.*
                FROM nl2_users
                    LEFT JOIN nl2_users_session
                    ON nl2_users.id = nl2_users_session.user_id
                WHERE
                    nl2_users_session.hash = ?
                    AND nl2_users_session.active = 1
                    AND (
                        nl2_users_session.expires_at IS NULL
                        OR nl2_users_session.expires_at > ?
                    )
                SQL,
                [
                    $value,
                    time(),
                ]
/data/core/templates/frontend_init.php
SELECT * FROM nl2_page_descriptions WHERE `page` = '/player/Just_better__';
        $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/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/core/init.php
SELECT * FROM nl2_hooks WHERE `id` <> '0';
                || str_contains($_GET['route'], 'store/listener')
            )) {
                // Can continue as normal
            } else {
                require(ROOT_PATH . '/core/includes/maintenance.php');
                die;
            }
        } else {
            // Display notice to admin stating maintenance mode is enabled
            define('BYPASS_MAINTENANCE', true);
        }
    }

    // Webhooks
    $hook_array = [];
    if (Util::isModuleEnabled('Discord Integration')) {
        $cache->setCache('hooks');
        if ($cache->isCached('hooks')) {
            $hook_array = $cache->retrieve('hooks');
        } else {
            $hooks = DB::getInstance()->get('hooks', ['id', '<>', 0])->results();
            if (count($hooks)) {
                foreach ($hooks as $hook) {
                    if ($hook->action != 1 && $hook->action != 2) {
                        continue;
                    }

                    // TODO: more extendable webhook system, #2676
                    if ($hook->action == 2 && !class_exists(DiscordHook::class)) {
                        continue;
                    }

                    $hook_array[] = [
                        'id' => $hook->id,
                        'url' => Output::getClean($hook->url),
                        'action' => $hook->action == 1
                            ? [WebHook::class, 'execute']
                            : [DiscordHook::class, 'execute'],
                        'events' => json_decode($hook->events, true),
                    ];
                }
/data/modules/Lists/module.php
SELECT * FROM `nl2_lists_submissions` WHERE `vanity_url` IS NOT NULL;
        Lists::getInstance()->registerProviderConnection(new DiscordConnection());
        Lists::getInstance()->registerProviderConnection(new NamelessMCConnection());
        Lists::getInstance()->registerProviderConnection(new BF2142Connection());

        EventHandler::registerEvent(ListSubmissionCreatedEvent::class);

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

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

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

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

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

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

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

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

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

        EventHandler::registerEvent(ListSubmissionCreatedEvent::class);

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

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

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

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

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

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

        $migration_files = array_map(
            static function ($file_name) {
                [$version, $migration_name] = explode('_', $file_name, 2);
                $migration_name = str_replace(['.php', '_'], '', ucwords($migration_name, '_'));

                return $version . '_' . $migration_name;
            },
            array_filter(scandir($migrationDir), static function ($file_name) {
                // Pattern that matches Phinx migration file names (eg: 20230403000000_create_stroopwafel_table.php)
                return preg_match('/^\d{14}_\w+\.php$/', $file_name);
            }),
        );

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

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

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

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

/data/core/classes/Core/Settings.php
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` = 'MCStatistics';
        $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/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.