/data/modules/Tebex/pages/store/category.php
SELECT packages.id AS id,
packages.category_id AS category_id,
packages.name AS name,
packages.order AS `order`,
packages.price AS price,
packages.sale_active AS sale_active,
packages.sale_discount AS sale_discount,
packages.type AS `type`,
descriptions.description AS description,
descriptions.image AS image
FROM nl2_buycraft_packages AS packages
LEFT JOIN nl2_buycraft_packages_descriptions AS descriptions
ON descriptions.package_id = packages.id
WHERE packages.category_id = '1599665'
ORDER BY `order` ASC;
die('Please configure and synchronise the Tebex module in the StaffCP first!');
} else {
$store_url = Output::getClean(rtrim($store_url->first()->value, '/'));
}
// Show home tab?
$home_tab = DB::getInstance()->get('buycraft_settings', ['name', '=', 'home_tab']);
if ($home_tab->count())
$home_tab = $home_tab->first()->value;
else
$home_tab = 1;
$currency_code = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_iso']);
$currency_code = Output::getClean($currency_code->first()->value);
$currency_symbol = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_symbol']);
$currency_symbol = Output::getClean($currency_symbol->first()->value);
// Get packages
$packages = DB::getInstance()->query(<<<SQL
SELECT packages.id AS id,
packages.category_id AS category_id,
packages.name AS name,
packages.order AS `order`,
packages.price AS price,
packages.sale_active AS sale_active,
packages.sale_discount AS sale_discount,
packages.type AS `type`,
descriptions.description AS description,
descriptions.image AS image
FROM nl2_buycraft_packages AS packages
LEFT JOIN nl2_buycraft_packages_descriptions AS descriptions
ON descriptions.package_id = packages.id
WHERE packages.category_id = ?
ORDER BY `order` ASC
SQL, [$category_id], true);
if (!$packages->count()) {
$smarty->assign('NO_PACKAGES', $buycraft_language->get('language', 'no_packages'));
} else {
/data/modules/Tebex/pages/store/category.php
SELECT * FROM nl2_buycraft_settings WHERE `name` = 'currency_symbol';
// Retrieve store info from database
$store_url = DB::getInstance()->get('buycraft_settings', ['name', '=', 'domain']);
if (!$store_url->count()) {
die('Please configure and synchronise the Tebex module in the StaffCP first!');
} else {
$store_url = Output::getClean(rtrim($store_url->first()->value, '/'));
}
// Show home tab?
$home_tab = DB::getInstance()->get('buycraft_settings', ['name', '=', 'home_tab']);
if ($home_tab->count())
$home_tab = $home_tab->first()->value;
else
$home_tab = 1;
$currency_code = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_iso']);
$currency_code = Output::getClean($currency_code->first()->value);
$currency_symbol = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_symbol']);
$currency_symbol = Output::getClean($currency_symbol->first()->value);
// Get packages
$packages = DB::getInstance()->query(<<<SQL
SELECT packages.id AS id,
packages.category_id AS category_id,
packages.name AS name,
packages.order AS `order`,
packages.price AS price,
packages.sale_active AS sale_active,
packages.sale_discount AS sale_discount,
packages.type AS `type`,
descriptions.description AS description,
descriptions.image AS image
FROM nl2_buycraft_packages AS packages
LEFT JOIN nl2_buycraft_packages_descriptions AS descriptions
ON descriptions.package_id = packages.id
WHERE packages.category_id = ?
ORDER BY `order` ASC
SQL, [$category_id], true);
/data/modules/Tebex/pages/store/category.php
SELECT * FROM nl2_buycraft_settings WHERE `name` = 'currency_iso';
// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);
// Retrieve store info from database
$store_url = DB::getInstance()->get('buycraft_settings', ['name', '=', 'domain']);
if (!$store_url->count()) {
die('Please configure and synchronise the Tebex module in the StaffCP first!');
} else {
$store_url = Output::getClean(rtrim($store_url->first()->value, '/'));
}
// Show home tab?
$home_tab = DB::getInstance()->get('buycraft_settings', ['name', '=', 'home_tab']);
if ($home_tab->count())
$home_tab = $home_tab->first()->value;
else
$home_tab = 1;
$currency_code = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_iso']);
$currency_code = Output::getClean($currency_code->first()->value);
$currency_symbol = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_symbol']);
$currency_symbol = Output::getClean($currency_symbol->first()->value);
// Get packages
$packages = DB::getInstance()->query(<<<SQL
SELECT packages.id AS id,
packages.category_id AS category_id,
packages.name AS name,
packages.order AS `order`,
packages.price AS price,
packages.sale_active AS sale_active,
packages.sale_discount AS sale_discount,
packages.type AS `type`,
descriptions.description AS description,
descriptions.image AS image
FROM nl2_buycraft_packages AS packages
LEFT JOIN nl2_buycraft_packages_descriptions AS descriptions
ON descriptions.package_id = packages.id
/data/modules/Tebex/pages/store/category.php
SELECT * FROM nl2_buycraft_settings WHERE `name` = 'home_tab';
define('PAGE_DESCRIPTION', str_replace(array('{site}', '{category_title}', '{description}'), array(SITE_NAME, Output::getClean($category->name), Output::getClean(strip_tags(Output::getDecoded($category->description)))), $page_metadata->first()->description));
define('PAGE_KEYWORDS', $page_metadata->first()->tags);
}
$page_title = Output::getClean($category->name);
require_once ROOT_PATH . '/core/templates/frontend_init.php';
require_once ROOT_PATH . '/modules/Tebex/classes/Buycraft.php';
// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);
// Retrieve store info from database
$store_url = DB::getInstance()->get('buycraft_settings', ['name', '=', 'domain']);
if (!$store_url->count()) {
die('Please configure and synchronise the Tebex module in the StaffCP first!');
} else {
$store_url = Output::getClean(rtrim($store_url->first()->value, '/'));
}
// Show home tab?
$home_tab = DB::getInstance()->get('buycraft_settings', ['name', '=', 'home_tab']);
if ($home_tab->count())
$home_tab = $home_tab->first()->value;
else
$home_tab = 1;
$currency_code = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_iso']);
$currency_code = Output::getClean($currency_code->first()->value);
$currency_symbol = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_symbol']);
$currency_symbol = Output::getClean($currency_symbol->first()->value);
// Get packages
$packages = DB::getInstance()->query(<<<SQL
SELECT packages.id AS id,
packages.category_id AS category_id,
packages.name AS name,
packages.order AS `order`,
packages.price AS price,
packages.sale_active AS sale_active,
/data/modules/Tebex/pages/store/category.php
SELECT * FROM nl2_buycraft_settings WHERE `name` = 'domain';
if ($cache->isCached('buycraft_url')) {
$buycraft_url = Output::getClean(rtrim($cache->retrieve('buycraft_url'), '/'));
} else {
$buycraft_url = '/store';
}
$page_metadata = DB::getInstance()->get('page_descriptions', ['page', '=', $buycraft_url . '/view']);
if ($page_metadata->count()) {
define('PAGE_DESCRIPTION', str_replace(array('{site}', '{category_title}', '{description}'), array(SITE_NAME, Output::getClean($category->name), Output::getClean(strip_tags(Output::getDecoded($category->description)))), $page_metadata->first()->description));
define('PAGE_KEYWORDS', $page_metadata->first()->tags);
}
$page_title = Output::getClean($category->name);
require_once ROOT_PATH . '/core/templates/frontend_init.php';
require_once ROOT_PATH . '/modules/Tebex/classes/Buycraft.php';
// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);
// Retrieve store info from database
$store_url = DB::getInstance()->get('buycraft_settings', ['name', '=', 'domain']);
if (!$store_url->count()) {
die('Please configure and synchronise the Tebex module in the StaffCP first!');
} else {
$store_url = Output::getClean(rtrim($store_url->first()->value, '/'));
}
// Show home tab?
$home_tab = DB::getInstance()->get('buycraft_settings', ['name', '=', 'home_tab']);
if ($home_tab->count())
$home_tab = $home_tab->first()->value;
else
$home_tab = 1;
$currency_code = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_iso']);
$currency_code = Output::getClean($currency_code->first()->value);
$currency_symbol = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_symbol']);
$currency_symbol = Output::getClean($currency_symbol->first()->value);
/data/modules/Badges/module.php
SELECT * FROM nl2_badges_data WHERE `id` <> '0';
public function onUninstall() {}
public function onEnable() {}
public function onDisable() {}
public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template)
{
PermissionHandler::registerPermissions($this->module_name, [
'admincp.badges.view' => $this->BadgesLanguage->get('general', 'permission_view'),
'admincp.badges.add_edit' => $this->BadgesLanguage->get('general', 'permission_add_edit'),
'admincp.badges.delete' => $this->BadgesLanguage->get('general', 'permission_delete')
]);
$icon = '<i class="nav-icon fas fa-ribbon"></i>';
$order = 15;
if (defined('FRONT_END')) {
$badges_data = DB::getInstance()->get('badges_data', ['id', '<>', 0])->results();
if (count($badges_data)) {
$badges_user_data = DB::getInstance()->get('badges_users_data', ['user_id', '=', $user->data()->id])->results();
$user_badges_list = [];
foreach ($badges_user_data as $value) {
$user_badges_list[$value->badges_id] = true;
}
$user_posts = count(DB::getInstance()->get('topics', ['topic_creator', '=', $user->data()->id])->results());
$badges_list = [];
foreach ($badges_data as $value) {
$badges_list[$value->id] = [
'name' => $value->name,
'bdg_color' => $value->bdg_color,
'bdg_icon' => $value->bdg_icon,
'bdg_ribbon' => $value->bdg_ribbon
];
if ($user_posts >= $value->require_posts && !isset($user_badges_list[$value->id])) {
DB::getInstance()->insert('badges_users_data', [
/data/modules/Resources/module.php
ALTER TABLE `nl2_resources` ADD `short_description` varchar(64) NULL DEFAULT NULL;
$navs[2]->add('resources_settings', $this->_resource_language->get('resources', 'settings'), URL::build('/panel/resources/settings'), 'top', null, ($order + 0.3), $icon);
}
}
}
// AdminCP
PermissionHandler::registerPermissions('Resources', [
'admincp.resources' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_resource_language->get('resources', 'resources'),
'admincp.resources.categories' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_resource_language->get('resources', 'categories'),
'admincp.resources.downloads' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_resource_language->get('resources', 'downloads'),
'admincp.resources.settings' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_resource_language->get('resources', 'settings'),
'admincp.resources.licenses' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_resource_language->get('resources', 'manage_licenses'),
]);
}
// Update to 1.6.0
private static function updateTo160($cache) {
try {
DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `short_description` varchar(64) NULL DEFAULT NULL');
DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `has_icon` tinyint(1) NOT NULL DEFAULT \'0\'');
DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `icon` varchar(512) NULL DEFAULT NULL');
DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `icon_updated` int(11) NOT NULL DEFAULT \'0\'');
$cache->store('160', true);
mkdir(ROOT_PATH . '/uploads/resources_icons');
} catch (Exception $e) {
// continue anyway
}
}
public function getDebugInfo(): array {
return [];
}
}
/data/modules/Tebex/module.php
SELECT * FROM nl2_buycraft_settings WHERE `name` = 'currency_format';
'admincp.buycraft.giftcards' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'gift_cards'),
'admincp.buycraft.giftcards.new' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'new_gift_card'),
'admincp.buycraft.giftcards.update' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'update_gift_card'),
'admincp.buycraft.coupons' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'coupons'),
'admincp.buycraft.coupons.new' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'new_coupon'),
'admincp.buycraft.coupons.delete' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'delete_coupon'),
'admincp.buycraft.bans' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'bans'),
'admincp.buycraft.bans.new' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_buycraft_language->get('language', 'new_ban')
));
// Hooks
// TODO
// HookHandler::registerEvent('userPurchaseBuycraftPackage', $this->_buycraft_language->get('language', 'purchase_hook_info'));
// HookHandler::registerEvent('newBuycraftCoupon', $this->_buycraft_language->get('language', 'new_coupon_hook_info'));
// HookHandler::registerEvent('newBuycraftGiftCard', $this->_buycraft_language->get('language', 'new_gift_card_hook_info'));
// Classes
require_once(ROOT_PATH . '/modules/Tebex/classes/Buycraft.php');
// Get currency format
$currency_format = DB::getInstance()->get('buycraft_settings', ['name', '=', 'currency_format']);
if ($currency_format->count()) {
define('TEBEX_CURRENCY_FORMAT', $currency_format->first()->value);
} else {
define('TEBEX_CURRENCY_FORMAT', '{currencySymbol}{price}');
}
// Widgets
if ($pages->getActivePage()['widgets'] || (defined('PANEL_PAGE') && str_contains(PANEL_PAGE, 'widget'))) {
// Latest purchases
require_once(ROOT_PATH . '/modules/Tebex/widgets/LatestPurchasesWidget.php');
$widgets->add(new LatestPurchasesWidget($cache, $template->getEngine(), $this->_language, $this->_buycraft_language));
// Featured package
require_once(ROOT_PATH . '/modules/Tebex/widgets/FeaturedPackageWidget.php');
$widgets->add(new FeaturedPackageWidget($cache, $template->getEngine(), $this->_language, $this->_buycraft_language));
}
// Add link to navbar
$cache->setCache('navbar_order');
if(!$cache->isCached('tebex_order')){
/data/core/templates/frontend_init.php
SELECT * FROM nl2_page_descriptions WHERE `page` = '/store/category/1599665';
$default_group = $cache->retrieve('default_group');
} else {
try {
$default_group = Group::find(1, 'default_group')->id;
} catch (Exception $e) {
$default_group = 1;
}
$cache->store('default_group', $default_group);
}
}
// Page metadata
if (isset($_GET['route']) && $_GET['route'] != '/') {
$route = rtrim($_GET['route'], '/');
} else {
$route = '/';
}
if (!defined('PAGE_DESCRIPTION')) {
$page_metadata = DB::getInstance()->get('page_descriptions', ['page', $route]);
if ($page_metadata->count()) {
$page_metadata = $page_metadata->first();
$template->getEngine()->addVariables([
'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags($page_metadata->description))),
'PAGE_KEYWORDS' => addslashes(strip_tags($page_metadata->tags)),
]);
$og_image = $page_metadata->image;
if ($og_image) {
$template->getEngine()->addVariable('OG_IMAGE', rtrim(URL::getSelfURL(), '/') . $og_image);
}
} else {
$template->getEngine()->addVariables([
'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags(Settings::get('default_meta_description', '')))),
'PAGE_KEYWORDS' => addslashes(strip_tags(Settings::get('default_meta_keywords', ''))),
]);
}
} else {
$template->getEngine()->addVariables([
'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags(PAGE_DESCRIPTION))),
/data/modules/Tebex/pages/store/category.php
SELECT * FROM nl2_page_descriptions WHERE `page` = '/store/view';
LEFT JOIN nl2_buycraft_categories_descriptions AS descriptions
ON descriptions.category_id = categories.id
WHERE categories.id = ?
SQL, [$category_id], true);
if (!$category->count()) {
require_once(ROOT_PATH . '/404.php');
die();
}
$category = $category->first();
// Get variables from cache
$cache->setCache('buycraft_settings');
if ($cache->isCached('buycraft_url')) {
$buycraft_url = Output::getClean(rtrim($cache->retrieve('buycraft_url'), '/'));
} else {
$buycraft_url = '/store';
}
$page_metadata = DB::getInstance()->get('page_descriptions', ['page', '=', $buycraft_url . '/view']);
if ($page_metadata->count()) {
define('PAGE_DESCRIPTION', str_replace(array('{site}', '{category_title}', '{description}'), array(SITE_NAME, Output::getClean($category->name), Output::getClean(strip_tags(Output::getDecoded($category->description)))), $page_metadata->first()->description));
define('PAGE_KEYWORDS', $page_metadata->first()->tags);
}
$page_title = Output::getClean($category->name);
require_once ROOT_PATH . '/core/templates/frontend_init.php';
require_once ROOT_PATH . '/modules/Tebex/classes/Buycraft.php';
// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template);
// Retrieve store info from database
$store_url = DB::getInstance()->get('buycraft_settings', ['name', '=', 'domain']);
if (!$store_url->count()) {
die('Please configure and synchronise the Tebex module in the StaffCP first!');
} else {
$store_url = Output::getClean(rtrim($store_url->first()->value, '/'));
}
/data/modules/Tebex/pages/store/category.php
SELECT categories.id AS id,
categories.name AS name,
categories.parent_category AS parent_category,
descriptions.description AS description,
descriptions.image AS image
FROM nl2_buycraft_categories AS categories
LEFT JOIN nl2_buycraft_categories_descriptions AS descriptions
ON descriptions.category_id = categories.id
WHERE categories.id = '1599665';
// Always define page name
define('PAGE', 'tebex');
// Get category ID
$category_id = explode('/', $route);
$category_id = $category_id[count($category_id) - 1];
if (!$category_id) {
require_once(ROOT_PATH . '/404.php');
die();
}
$category_id = explode('-', $category_id);
if (!is_numeric($category_id[0])) {
require_once(ROOT_PATH . '/404.php');
die();
}
$category_id = $category_id[0];
// Query category
$category = DB::getInstance()->query(<<<SQL
SELECT categories.id AS id,
categories.name AS name,
categories.parent_category AS parent_category,
descriptions.description AS description,
descriptions.image AS image
FROM nl2_buycraft_categories AS categories
LEFT JOIN nl2_buycraft_categories_descriptions AS descriptions
ON descriptions.category_id = categories.id
WHERE categories.id = ?
SQL, [$category_id], true);
if (!$category->count()) {
require_once(ROOT_PATH . '/404.php');
die();
}
$category = $category->first();
// Get variables from cache
$cache->setCache('buycraft_settings');
/data/core/init.php
UPDATE nl2_online_guests SET `last_seen` = '66186' WHERE `id` =;
Redirect::to(URL::build('/user/settings', 'do=enable_tfa'));
}
}
}
$user_integrations = [];
foreach ($user->getIntegrations() as $integrationUser) {
$user_integrations[$integrationUser->getIntegration()->getName()] = [
'username' => Output::getClean($integrationUser->data()->username),
'identifier' => Output::getClean($integrationUser->data()->identifier),
];
}
} else {
// Perform tasks for guests
if (!$_SESSION['checked'] || (isset($_SESSION['checked']) && $_SESSION['checked'] <= strtotime('-5 minutes'))) {
$already_online = DB::getInstance()->get('online_guests', ['ip', $ip])->results();
$date = date('U');
if (count($already_online)) {
DB::getInstance()->update('online_guests', $already_online[0]->id, ['last_seen' => $date]);
} else {
DB::getInstance()->insert('online_guests', ['ip' => $ip, 'last_seen' => $date]);
}
$_SESSION['checked'] = $date;
}
// Auto language enabled?
if (Settings::get('auto_language_detection')) {
define('AUTO_LANGUAGE', true);
}
}
// Dark mode
$cache->setCache('template_settings');
$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')) {
/data/core/init.php
SELECT * FROM nl2_online_guests WHERE `ip` = '172.18.0.2';
if (isset($forced) && $forced) {
// Do they have TFA configured?
if (!$user->data()->tfa_enabled && rtrim($_GET['route'], '/') != '/logout') {
if (!str_contains($_SERVER['REQUEST_URI'], 'do=enable_tfa') && !isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
Session::put('force_tfa_alert', $language->get('admin', 'force_tfa_alert'));
Redirect::to(URL::build('/user/settings', 'do=enable_tfa'));
}
}
}
$user_integrations = [];
foreach ($user->getIntegrations() as $integrationUser) {
$user_integrations[$integrationUser->getIntegration()->getName()] = [
'username' => Output::getClean($integrationUser->data()->username),
'identifier' => Output::getClean($integrationUser->data()->identifier),
];
}
} else {
// Perform tasks for guests
if (!$_SESSION['checked'] || (isset($_SESSION['checked']) && $_SESSION['checked'] <= strtotime('-5 minutes'))) {
$already_online = DB::getInstance()->get('online_guests', ['ip', $ip])->results();
$date = date('U');
if (count($already_online)) {
DB::getInstance()->update('online_guests', $already_online[0]->id, ['last_seen' => $date]);
} else {
DB::getInstance()->insert('online_guests', ['ip' => $ip, 'last_seen' => $date]);
}
$_SESSION['checked'] = $date;
}
// Auto language enabled?
if (Settings::get('auto_language_detection')) {
define('AUTO_LANGUAGE', true);
}
}
// Dark mode
$cache->setCache('template_settings');
/data/core/init.php
SELECT * FROM nl2_groups WHERE `default_group` = '1';
: [DiscordHook::class, 'execute'],
'events' => json_decode($hook->events, true),
];
}
$cache->store('hooks', $hook_array);
}
}
}
EventHandler::registerWebhooks($hook_array);
// Get IP
$ip = HttpUtils::getRemoteAddress();
// Define default group pre validation
$cache->setCache('pre_validation_default');
$group_id = null;
if ($cache->isCached('pre_validation_default')) {
$group_id = $cache->retrieve('pre_validation_default');
} else {
$group_id = DB::getInstance()->get('groups', ['default_group', '1'])->results();
$group_id = $group_id[0]->id;
}
define('PRE_VALIDATED_DEFAULT', $group_id);
// Perform tasks if the user is logged in
if ($user->isLoggedIn()) {
Debugging::setCanViewDetailedError($user->hasPermission('admincp.errors'));
Debugging::setCanGenerateDebugLink($user->hasPermission('admincp.core.debugging'));
// Ensure a user is not banned
if ($user->data()->isbanned == 1) {
$user->logout();
Session::flash('home_error', $language->get('user', 'you_have_been_banned'));
Redirect::to(URL::build('/'));
}
// Is the IP address banned?
$ip_bans = DB::getInstance()->get('ip_bans', ['ip', $ip])->results();
if (count($ip_bans)) {
/data/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/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/Module.php
SELECT * FROM nl2_modules WHERE `name` = 'Core';
/**
* Get this module's ID.
*
* @return int The ID for the module
*/
public function getId(): int
{
return DB::getInstance()->query('SELECT `id` FROM nl2_modules WHERE `name` = ?', [$this->_name])->first()->id;
}
/**
* Get a module ID from name.
*
* @param string $name Module name
*
* @return ?int Module ID
*/
public static function getIdFromName(string $name): ?int
{
$query = DB::getInstance()->get('modules', ['name', $name]);
if ($query->count()) {
return $query->first()->id;
}
return null;
}
/**
* Get a module name from ID.
*
* @param int $id Module ID
*
* @return ?string Module name
*/
public static function getNameFromId(int $id): ?string
{
$query = DB::getInstance()->get('modules', ['id', $id]);
if ($query->count()) {
/data/core/classes/Integrations/IntegrationBase.php
SELECT * FROM nl2_integrations WHERE name = 'Google';
* @author Partydragen
* @version 2.1.0
* @license MIT
*/
abstract class IntegrationBase
{
private DB $_db;
private IntegrationData $_data;
protected string $_icon;
private array $_errors = [];
protected Language $_language;
protected ?string $_settings = null;
protected string $_name;
protected ?int $_order;
public function __construct()
{
$this->_db = DB::getInstance();
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name]);
if ($integration->count()) {
$integration = $integration->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
} else {
// Register integration to database
$this->_db->query('INSERT INTO nl2_integrations (name) VALUES (?)', [
$this->_name,
]);
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name])->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
}
}
/**
* Get the name of this integration.
/data/core/classes/Integrations/IntegrationBase.php
SELECT * FROM nl2_integrations WHERE name = 'Minecraft';
* @author Partydragen
* @version 2.1.0
* @license MIT
*/
abstract class IntegrationBase
{
private DB $_db;
private IntegrationData $_data;
protected string $_icon;
private array $_errors = [];
protected Language $_language;
protected ?string $_settings = null;
protected string $_name;
protected ?int $_order;
public function __construct()
{
$this->_db = DB::getInstance();
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name]);
if ($integration->count()) {
$integration = $integration->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
} else {
// Register integration to database
$this->_db->query('INSERT INTO nl2_integrations (name) VALUES (?)', [
$this->_name,
]);
$integration = $this->_db->query('SELECT * FROM nl2_integrations WHERE name = ?', [$this->_name])->first();
$this->_data = new IntegrationData($integration);
$this->_order = $integration->order;
}
}
/**
* Get the name of this integration.
/data/modules/Core/module.php
SELECT * FROM nl2_custom_pages WHERE `id` <> '0';
}
// "More" dropdown
$cache->setCache('navbar_icons');
if ($cache->isCached('more_dropdown_icon')) {
$icon = $cache->retrieve('more_dropdown_icon');
} else {
$icon = '';
}
$cache->setCache('navbar_order');
if ($cache->isCached('more_dropdown_order')) {
$order = $cache->retrieve('more_dropdown_order');
} else {
$order = 2500;
}
$navigation->addDropdown('more_dropdown', $language->get('general', 'more'), 'top', $order, $icon);
// Custom pages
$custom_pages = DB::getInstance()->get('custom_pages', ['id', '<>', 0])->results();
if (count($custom_pages)) {
$more = [];
$cache->setCache('navbar_order');
if ($user->isLoggedIn()) {
// Check all groups
$user_groups = $user->getAllGroupIds();
foreach ($custom_pages as $custom_page) {
$redirect = null;
// Get redirect URL if enabled
if ($custom_page->redirect == 1) {
$redirect = $custom_page->link;
}
$pages->addCustom(Output::urlEncodeAllowSlashes($custom_page->url), Output::getClean($custom_page->title), !$custom_page->basic);
foreach ($user_groups as $user_group) {
$custom_page_permissions = DB::getInstance()->get('custom_pages_permissions', ['group_id', $user_group])->results();
/data/core/classes/Core/Settings.php
SELECT `name`, `value` FROM `nl2_settings` WHERE `module` IS NULL;
private static function setSettingsCache(?string $module, array $cache): void
{
$cache_name = $module !== null ? $module : 'core';
self::$_cached_settings[$cache_name] = $cache;
}
/**
* Get a setting from the database table `nl2_settings`.
*
* @param string $setting Setting to check.
* @param ?string $fallback Fallback to return if $setting is not set in DB. Defaults to null.
* @param string $module Module name to keep settings separate from other modules. Set module
* to 'Core' for global settings.
* @return ?string Setting from DB or $fallback.
*/
public static function get(string $setting, ?string $fallback = null, string $module = 'core'): ?string
{
if (!self::hasSettingsCache($module)) {
// Load all settings for this module and store it as a dictionary
if ($module === 'core') {
$result = DB::getInstance()->query('SELECT `name`, `value` FROM `nl2_settings` WHERE `module` IS NULL')->results();
} else {
$result = DB::getInstance()->query('SELECT `name`, `value` FROM `nl2_settings` WHERE `module` = ?', [$module])->results();
}
$cache = [];
foreach ($result as $row) {
$cache[$row->name] = $row->value;
}
self::setSettingsCache($module, $cache);
}
$cache = &self::getSettingsCache($module);
return $cache[$setting] ?? $fallback;
}
/**
* Modify a setting in the database table `nl2_settings`.
*
* @param string $setting Setting name.
/data/core/classes/Database/PhinxAdapter.php
SELECT version, migration_name FROM nl2_phinxlog;
if (!$migrationDir) {
$migrationDir = __DIR__ . '/../../migrations';
}
$migration_files = array_map(
static function ($file_name) {
[$version, $migration_name] = explode('_', $file_name, 2);
$migration_name = str_replace(['.php', '_'], '', ucwords($migration_name, '_'));
return $version . '_' . $migration_name;
},
array_filter(scandir($migrationDir), static function ($file_name) {
// Pattern that matches Phinx migration file names (eg: 20230403000000_create_stroopwafel_table.php)
return preg_match('/^\d{14}_\w+\.php$/', $file_name);
}),
);
$migration_database_entries = array_map(static function ($row) {
return $row->version . '_' . $row->migration_name;
}, DB::getInstance()->query("SELECT version, migration_name FROM $table")->results());
$missing = array_diff($migration_files, $migration_database_entries);
$extra = array_diff($migration_database_entries, $migration_files);
if ($returnResults) {
return [
'missing' => count($missing),
'extra' => count($extra),
];
}
// Likely a pull from the repo dev branch or migrations
// weren't run during an upgrade script.
if (($missing_count = count($missing)) > 0) {
echo "There are $missing_count migrations files which have not been executed:" . '<br>';
foreach ($missing as $missing_migration) {
echo " - $missing_migration" . '<br>';
}
}