Uncaught PDOException

SQLSTATE[42S02]: Base table or view not found: 1146 Table 's2_namelessbackground.nl2_oauth' doesn't exist

(File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Database/DB.php)

https://minermanic.com/login/


File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Database/DB.php
     * @return static This DB instance.
     */
    public function query(string $sql, array $params = [], int $fetch_method = PDO::FETCH_OBJ) {
        $this->_error = false;
        if ($this->_statement = $this->_pdo->prepare($sql)) {
            $x = 1;
            foreach ($params as $param) {
                // Convert "true" and "false" to 1 and 0 so that query params can be more fluent
                if (is_bool($param)) {
                    $param = $param ? 1 : 0;
                }
                $this->_statement->bindValue($x, $param, is_int($param)
                    ? PDO::PARAM_INT
                    : PDO::PARAM_STR
                );
                $x++;
            }

            $this->_query_recorder->pushQuery($sql, $params);

            if ($this->_statement->execute()) {
                // Only fetch the results if this is a SELECT query.
                if (str_starts_with(strtoupper($sql), 'SELECT')) {
                    $this->_results = $this->_statement->fetchAll($fetch_method);
                }
                $this->_count = $this->_statement->rowCount();
            } else {
                print_r($this->_pdo->errorInfo());
                $this->_error = true;
            }
        }

        return $this;
    }

    /**
     * @deprecated Use query() instead
     * @return static
     */
    public function selectQuery(string $sql, array $params = [], int $fetch_method = PDO::FETCH_OBJ) {
        return $this->query($sql, $params, $fetch_method);
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Database/DB.php
     * @return static
     */
    public function createQuery(string $sql, array $params = []) {
        return $this->query($sql, $params);
    }

    /**
     * Execute some SQL action (which uses a where clause) on the database.
     *
     * @param string $action The action to perform (SELECT, DELETE).
     * @param string $table The table to perform the action on.
     * @param array $where The where clause.
     * @return static|false This instance if successful, false otherwise.
     */
    private function action(string $action, string $table, array $where = []) {
        [$where, $where_params] = $this->makeWhere($where);

        $table = $this->_prefix . $table;
        $sql = "{$action} FROM {$table} {$where}";

        if (!$this->query($sql, $where_params)->error()) {
            return $this;
        }

        return false;
    }

    /**
     * Insert a new row into a table within the database.
     *
     * @param string $table The table to insert into.
     * @param array $fields Array of data in "column => value" format to insert.
     * @return bool Whether an error occurred or not.
     */
    public function insert(string $table, array $fields = []): bool {
        $keys = array_keys($fields);
        $fieldCount = count($fields);
        $values = '';
        $x = 1;

        for ($i = 0; $i < $fieldCount; $i++) {
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Database/DB.php
        return $this->_pdo->lastInsertId();
    }

    /**
     * Whether there was an error during the last query.
     *
     * @return bool Whether there was an error.
     */
    public function error(): bool {
        return $this->_error;
    }

    /**
     * Perform a SELECT query on the database.
     *
     * @param string $table The table to select from.
     * @param array $where The where clause.
     * @return static|false This instance if successful, false otherwise.
     */
    public function get(string $table, array $where = []) {
        return $this->action('SELECT *', $table, $where);
    }

    /**
     * Perform a DELTE query on the database.
     *
     * @param string $table The table to delete from.
     * @param array $where The where clause.
     * @return static|false This instance if successful, false otherwise.
     */
    public function delete(string $table, array $where) {
        return $this->action('DELETE', $table, $where);
    }

    /**
     * Perform a raw SQL query on the database.
     *
     * @param string $sql The SQL query string to execute.
     * @param array $params The parameters to bind to the query.
     * @param int $fetch_method The PDO fetch method to use.
     * @return static This DB instance.
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Misc/OAuth.php
        $options = [
            'clientId' => $clientId,
            'clientSecret' => $clientSecret,
            'redirectUri' => $url,
        ];

        if (array_key_exists($provider, $this->_providers)) {
            return $this->_provider_instances[$provider] ??= new $this->_providers[$provider]['class']($options);
        }

        throw new RuntimeException("Unknown provider: $provider");
    }

    /**
     * Determine if a provider is enabled (different from setup!).
     *
     * @param string $provider The provider name
     * @return bool If the provider is enabled
     */
    public function isEnabled(string $provider): bool {
        return $this->_db->get('oauth', ['provider', $provider])->first()->enabled == '1';
    }

    /**
     * Set a provider as enabled or disabled (`1` or `0` respectively).
     *
     * @param string $provider The provider name
     * @param int $enabled Whether to enable or disable the provider
     */
    public function setEnabled(string $provider, int $enabled): void {
        $this->_db->query("UPDATE nl2_oauth SET enabled = ? WHERE provider = ?", [$enabled, $provider]);
    }

    /**
     * Determine if a provider is setup.
     * A provider is considered setup if it has a client ID and a client secret set.
     *
     * @param string $provider The provider name
     * @return bool If the provider is setup
     */
    public function isSetup(string $provider): bool {
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Misc/OAuth.php
    }

    /**
     * Set a provider as enabled or disabled (`1` or `0` respectively).
     *
     * @param string $provider The provider name
     * @param int $enabled Whether to enable or disable the provider
     */
    public function setEnabled(string $provider, int $enabled): void {
        $this->_db->query("UPDATE nl2_oauth SET enabled = ? WHERE provider = ?", [$enabled, $provider]);
    }

    /**
     * Determine if a provider is setup.
     * A provider is considered setup if it has a client ID and a client secret set.
     *
     * @param string $provider The provider name
     * @return bool If the provider is setup
     */
    public function isSetup(string $provider): bool {
        if (!$this->isEnabled($provider)) {
            return false;
        }

        [$client_id, $client_secret] = $this->getCredentials($provider);

        return $client_id !== '' && $client_secret !== '';
    }

    /**
     * Get the array key for a specific providers client ID.
     * Discord uses `id` and Google uses `sub`, so we have to be able to differentiate.
     *
     * @param string $provider The provider name
     * @return string The array key for the provider's client ID
     */
    public function getUserIdName(string $provider): string {
        if (array_key_exists($provider, $this->_providers)) {
            return $this->_providers[$provider]['user_id_name'];
        }

File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Misc/OAuth.php
    public function registerProvider(string $name, array $data): void {
        $this->_providers[$name] = $data;
    }

    /**
     * Get an array of all registered provider names and their data.
     *
     * @return array An array of all registered OAuth providers.
     */
    public function getProviders(): array {
        return $this->_providers;
    }

    /**
     * Determine if OAuth is available if at least one provider is setup.
     *
     * @return bool If any provider is setup
     */
    public function isAvailable(): bool {
        foreach (array_keys($this->_providers) as $provider) {
            if ($this->isSetup($provider)) {
                return true;
            }
        }
        return false;
    }

    /**
     * Get an array of provider names and their URL & icon.
     *
     * @return array Array of provider names and their instances
     */
    public function getProvidersAvailable(): array {
        $providers = [];
        foreach ($this->_providers as $provider_name => $provider_data) {
            if (!$this->isSetup($provider_name)) {
                continue;
            }

            $provider = $this->getProviderInstance($provider_name);

File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/modules/Core/pages/login.php
    $smarty->assign('USERNAME', $language->get('user', 'email_or_username'));
} else if (MINECRAFT) {
    $smarty->assign('USERNAME', $language->get('user', 'minecraft_username'));
} else {
    $smarty->assign('USERNAME', $language->get('user', 'username'));
}

$smarty->assign([
    'USERNAME_INPUT' => ($login_method == 'email' ? Output::getClean(Input::get('email')) : Output::getClean(Input::get('username'))),
    'PASSWORD' => $language->get('user', 'password'),
    'REMEMBER_ME' => $language->get('user', 'remember_me'),
    'FORGOT_PASSWORD_URL' => URL::build('/forgot_password'),
    'FORGOT_PASSWORD' => $language->get('user', 'forgot_password'),
    'FORM_TOKEN' => Token::get(),
    'SIGN_IN' => $language->get('general', 'sign_in'),
    'REGISTER_URL' => URL::build('/register'),
    'REGISTER' => $language->get('general', 'register'),
    'ERROR_TITLE' => $language->get('general', 'error'),
    'ERROR' => ($return_error ?? []),
    'NOT_REGISTERED_YET' => $language->get('general', 'not_registered_yet'),
    'OAUTH_AVAILABLE' => OAuth::getInstance()->isAvailable(),
    'OAUTH_PROVIDERS' => OAuth::getInstance()->getProvidersAvailable(),
]);

if (Session::exists('oauth_error')) {
    $smarty->assign('ERROR', Session::flash('oauth_error'));
} else if (isset($return_error)) {
    $smarty->assign('SESSION_FLASH', $return_error);
} else {
    $smarty->assign('SESSION_FLASH', '');
}

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

if ($captcha) {
    $smarty->assign('CAPTCHA', CaptchaBase::getActiveProvider()->getHtml());
    $template->addJSFiles([CaptchaBase::getActiveProvider()->getJavascriptSource() => []]);

    $submitScript = CaptchaBase::getActiveProvider()->getJavascriptSubmit('form-login');
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/index.php
        $pages->setActivePage($pages->getPageByURL('/'));
        require(ROOT_PATH . '/modules/Core/pages/index.php');
    }
    die();
}

$route = rtrim(strtok($_GET['route'], '?'), '/');

$all_pages = $pages->returnPages();

if (array_key_exists($route, $all_pages)) {
    $pages->setActivePage($all_pages[$route]);
    if (isset($all_pages[$route]['custom'])) {
        require(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', 'Core', 'pages', 'custom.php']));
        die();
    }

    $path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', $all_pages[$route]['module'], $all_pages[$route]['file']]);

    if (file_exists($path)) {
        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]);
SQL query:
SELECT * FROM nl2_oauth WHERE `provider` = 'discord';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Misc/OAuth.php
        $options = [
            'clientId' => $clientId,
            'clientSecret' => $clientSecret,
            'redirectUri' => $url,
        ];

        if (array_key_exists($provider, $this->_providers)) {
            return $this->_provider_instances[$provider] ??= new $this->_providers[$provider]['class']($options);
        }

        throw new RuntimeException("Unknown provider: $provider");
    }

    /**
     * Determine if a provider is enabled (different from setup!).
     *
     * @param string $provider The provider name
     * @return bool If the provider is enabled
     */
    public function isEnabled(string $provider): bool {
        return $this->_db->get('oauth', ['provider', $provider])->first()->enabled == '1';
    }

    /**
     * Set a provider as enabled or disabled (`1` or `0` respectively).
     *
     * @param string $provider The provider name
     * @param int $enabled Whether to enable or disable the provider
     */
    public function setEnabled(string $provider, int $enabled): void {
        $this->_db->query("UPDATE nl2_oauth SET enabled = ? WHERE provider = ?", [$enabled, $provider]);
    }

    /**
     * Determine if a provider is setup.
     * A provider is considered setup if it has a client ID and a client secret set.
     *
     * @param string $provider The provider name
     * @return bool If the provider is setup
     */
    public function isSetup(string $provider): bool {
SQL query:
SELECT * FROM nl2_settings WHERE `name` = 'login_method';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/modules/Core/pages/login.php
 *  Made by Samerton
 *  https://github.com/NamelessMC/Nameless/
 *  NamelessMC version 2.0.0-pr12
 *
 *  License: MIT
 *
 *  Login page
 */

// Set page name variable
const PAGE = 'login';
$page_title = $language->get('general', 'sign_in');
require_once(ROOT_PATH . '/core/templates/frontend_init.php');

// Ensure user isn't already logged in
if ($user->isLoggedIn()) {
    Redirect::to(URL::build('/'));
}

// Get login method
$login_method = DB::getInstance()->get('settings', ['name', 'login_method'])->results();
$login_method = $login_method[0]->value;

$captcha = CaptchaBase::isCaptchaEnabled('recaptcha_login');

// Deal with input
if (Input::exists()) {
    // Check form token
    if (Token::check()) {
        // Valid token
        if (!isset($_SESSION['tfa']) && $captcha) {
            $captcha_passed = CaptchaBase::getActiveProvider()->validateToken($_POST);
        } else {
            $captcha_passed = true;
        }

        if ($captcha_passed) {
            if (isset($_SESSION['password'])) {
                if (isset($_SESSION['username'])) {
                    $_POST['username'] = $_SESSION['username'];
                    unset($_SESSION['username']);
SQL query:
SELECT * FROM nl2_page_descriptions WHERE `page` = '/login';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/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:
UPDATE nl2_online_guests SET `last_seen` = '7733' WHERE `id` =;
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/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` = '34.239.167.149';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/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_iframe_pages WHERE `id` <> '0';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/modules/Iframe/module.php

    public function __construct($language, $pages, $INFO_MODULE)
    {
        $this->_language = $language;

        $this->IframeLanguage = $GLOBALS['IframeLanguage'];

        $name = $INFO_MODULE['name'];
        $author = $INFO_MODULE['author'];
        $module_version = $INFO_MODULE['module_ver'];
        $nameless_version = $INFO_MODULE['nml_ver'];
        parent::__construct($this, $name, $author, $module_version, $nameless_version);

        $pages->add('Iframe', '/panel/iframe', 'pages/panel/iframe.php');
        $pages->add('Iframe', '/panel/iframe/setting', 'pages/panel/setting.php');

        $queries = new Queries();

        if (DB::getInstance()->showTables('iframe_pages') || DB::getInstance()->showTables('iframe_data')) {

            $iframes_pages = DB::getInstance()->get('iframe_pages', ['id', '<>', 0])->results();
            if (count($iframes_pages)) {
                foreach ($iframes_pages as $page) {
                    $url = trim($page->url);
                    $pages->add('Iframe', $url, 'pages/index.php', 'Iframe', true);
                }
            }
        }
    }

    public function onInstall()
    {
        // Queries

        try {

            $data = DB::getInstance()->createTable("iframe_pages", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, PRIMARY KEY (`id`)", "ENGINE=InnoDB DEFAULT CHARSET=utf8");

            $data = DB::getInstance()->createTable("iframe_data", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `src` varchar(5000) NOT NULL, `iframe_size` varchar(255) NOT NULL, `page_id` int(11) NOT NULL, `description` text NOT NULL, `footer_description` text NOT NULL, PRIMARY KEY (`id`)", "ENGINE=InnoDB DEFAULT CHARSET=utf8");
        } catch (Exception $e) {
            // Error
SQL query:
SHOW TABLES LIKE 'nl2_iframe_pages';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/modules/Iframe/module.php

    private $_language, $IframeLanguage;

    public function __construct($language, $pages, $INFO_MODULE)
    {
        $this->_language = $language;

        $this->IframeLanguage = $GLOBALS['IframeLanguage'];

        $name = $INFO_MODULE['name'];
        $author = $INFO_MODULE['author'];
        $module_version = $INFO_MODULE['module_ver'];
        $nameless_version = $INFO_MODULE['nml_ver'];
        parent::__construct($this, $name, $author, $module_version, $nameless_version);

        $pages->add('Iframe', '/panel/iframe', 'pages/panel/iframe.php');
        $pages->add('Iframe', '/panel/iframe/setting', 'pages/panel/setting.php');

        $queries = new Queries();

        if (DB::getInstance()->showTables('iframe_pages') || DB::getInstance()->showTables('iframe_data')) {

            $iframes_pages = DB::getInstance()->get('iframe_pages', ['id', '<>', 0])->results();
            if (count($iframes_pages)) {
                foreach ($iframes_pages as $page) {
                    $url = trim($page->url);
                    $pages->add('Iframe', $url, 'pages/index.php', 'Iframe', true);
                }
            }
        }
    }

    public function onInstall()
    {
        // Queries

        try {

            $data = DB::getInstance()->createTable("iframe_pages", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, PRIMARY KEY (`id`)", "ENGINE=InnoDB DEFAULT CHARSET=utf8");

            $data = DB::getInstance()->createTable("iframe_data", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `src` varchar(5000) NOT NULL, `iframe_size` varchar(255) NOT NULL, `page_id` int(11) NOT NULL, `description` text NOT NULL, `footer_description` text NOT NULL, PRIMARY KEY (`id`)", "ENGINE=InnoDB DEFAULT CHARSET=utf8");
SQL query:
SELECT form_id FROM nl2_forms_permissions WHERE form_id = '2' AND post = 1 AND group_id IN(0);
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/modules/Forms/module.php

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

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

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

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

                    // Add link location to navigation if user have permission
                    if ($perm) {
                        switch ($form->link_location) {
                            case 1:
                                // Navbar
                                // Check cache first
                                $cache->setCache('navbar_order');
                                if (!$cache->isCached('form-' . $form->id . '_order')) {
                                    // Create cache entry now
                                    $form_order = 5;
                                    $cache->store('form-' . $form->id . '_order', 5);
                                } else {
                                    $form_order = $cache->retrieve('form-' . $form->id . '_order');
                                }
                                $navigation->add('form-' . $form->id, Output::getClean($form->title), URL::build(Output::getClean($form->url)), 'top', null, $form_order, $form->icon);
SQL query:
SELECT form_id FROM nl2_forms_permissions WHERE form_id = '1' AND post = 1 AND group_id IN(0);
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/modules/Forms/module.php

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

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

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

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

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

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

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

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

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

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

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

                    if (!$perm) {
                        $hasperm = $this->_db->query('SELECT form_id FROM nl2_forms_permissions WHERE form_id = ? AND post = 1 AND group_id IN('.$group_ids.')', array($form->id));
                        if ($hasperm->count()) {
                            $perm = true;
SQL query:
SELECT * FROM nl2_integrations WHERE name = 'Discord';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/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_integrations WHERE name = 'Minecraft';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Integrations/IntegrationBase.php
 * @package NamelessMC\Integrations
 * @author Partydragen
 * @version 2.0.0-pr13
 * @license MIT
 */

abstract class IntegrationBase {

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

    protected string $_name;
    protected ?int $_order;

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

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

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

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

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

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

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

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

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

                        foreach ($custom_page_permissions as $permission) {
                            if ($permission->page_id == $custom_page->id) {
                                if ($permission->view == 1) {
                                    // Check cache for order
                                    if (!$cache->isCached($custom_page->id . '_order')) {
                                        // Create cache entry now
                                        $page_order = 200;
                                        $cache->store($custom_page->id . '_order', 200);
                                    } else {
                                        $page_order = $cache->retrieve($custom_page->id . '_order');
SQL query:
SELECT * FROM nl2_custom_pages WHERE `id` <> '0';
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/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`;
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Core/Util.php
            }

            return '<a href="' . $m[1] . '" target="_blank">' . $m[2] . '</a>';
        }, $data);
    }

    /**
     * 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.
     * @param ?string $module Alphanumeric (no spaces!) module name to use as a settings table prefix. For example,
     *                        specify 'store' to use the 'nl2_store_settings' table. Null to use the standard
     *                        nl2_settings table.
     * @return ?string Setting from DB or $fallback.
     */
    public static function getSetting(string $setting, ?string $fallback = null, ?string $module = null): ?string {
        $table_name = $module == null ? 'nl2_settings' : "nl2_${module}_settings";

        if (self::$_cached_settings == null) {
            $result = DB::getInstance()->query('SELECT `name`, `value` FROM `' . $table_name. '`')->results();
            // Store settings in dictionary format
            self::$_cached_settings = [];
            foreach ($result as $row) {
                self::$_cached_settings[$row->name] = $row->value;
            }
        }

        if (isset(self::$_cached_settings[$setting])) {
            return self::$_cached_settings[$setting];
        } else {
            return null;
        }
    }

    /**
     * Modify a setting in the database table `nl2_settings`.
     *
     * @param string $setting Setting name.
     * @param string $new_value New setting value, or null to delete
     * @param ?string $module Alphanumeric (no spaces!) module name to use as a settings table prefix. For example,
SQL query:
SELECT COUNT(*) AS count FROM nl2_phinxlog;
File: /var/www/vhosts/mcmineworld.com/minermanic.com/Namelessv2/core/classes/Database/PhinxAdapter.php
<?php

class PhinxAdapter {

    /**
     * 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 = count(scandir(__DIR__ . '/../../migrations')) - 3; // -3 because of . and .. and phinx.php
        $migration_database_entries = DB::getInstance()->query('SELECT COUNT(*) AS count FROM nl2_phinxlog')->first()->count;

        if ($migration_files == $migration_database_entries) {
            return;
        }

        // Likely a pull from the repo dev branch or migrations
        // weren't run during an upgrade script.
        if (($diff = abs($migration_files - $migration_database_entries)) > 0) {
            throw new RuntimeException("There are {$diff} database migrations pending.");
        }

        // Something went wonky, either they've deleted migration files,
        // or they've added stuff to the nl2_phinxlog table.
        throw new RuntimeException("Inconsistent number of migration database entries ({$migration_database_entries}) and migration files ({$migration_files}).");
    }

    /**
     * Runs any pending migrations. Used for installation and upgrades. Resource heavy, only call when needed.
     *
     * @return string Output of the migration command from Phinx as if it was executed in the console.