/home/cxstudio76/domains/rextstore.app/public_html/modules/Resources/module.php
<?php
/*
* Made by Samerton
* https://github.com/NamelessMC/Nameless/
* NamelessMC version 2.1.0
*
* License: MIT
*
* Resource module class
*/
class Resources_Module extends Module {
private $_resource_language, $_language;
public function __construct($pages, $language, $resource_language, $endpoints){
$this->_resource_language = $resource_language;
$this->_language = $language;
$name = 'Resources';
$author = 'System';
$module_version = '2.2.5';
$nameless_version = '2.2.5';
parent::__construct($this, $name, $author, $module_version, $nameless_version);
// Hooks
EventHandler::registerEvent('newResource', $resource_language->get('resources', 'new_resource'));
EventHandler::registerEvent('updateResource', $resource_language->get('resources', 'update'));
// Define URLs which belong to this module
$pages->add('Resources', '/panel/resources/categories', 'pages/panel/categories.php');
$pages->add('Resources', '/panel/resources/downloads', 'pages/panel/downloads.php');
$pages->add('Resources', '/panel/resources/settings', 'pages/panel/settings.php');
$pages->add('Resources', '/resources', 'pages/resources/index.php', 'resources', true);
$pages->add('Resources', '/resources/category', 'pages/resources/category.php', 'resources', true);
/home/cxstudio76/domains/rextstore.app/public_html/modules/Resources/init.php
<?php
/*
* Made by Samerton
* https://github.com/NamelessMC/Nameless/
* NamelessMC version 2.0.0-pr13
*
* License: MIT
*
* Resource initialisation file
*/
// Initialise module language
$resource_language = new Language(ROOT_PATH . '/modules/Resources/language', LANGUAGE);
require_once ROOT_PATH . '/modules/Resources/classes/Resources_Sitemap.php';
require_once ROOT_PATH . '/modules/Resources/hooks/CloneGroupResourcesHook.php';
require_once ROOT_PATH . '/modules/Resources/hooks/DeleteUserResourcesHook.php';
require_once ROOT_PATH . '/modules/Resources/module.php';
$module = new Resources_Module($pages, $language, $resource_language);
/home/cxstudio76/domains/rextstore.app/public_html/core/init.php
];
}
$pages = $container->get(Pages::class);
// Sort by priority
usort($enabled_modules, static function ($a, $b) {
return $a['priority'] - $b['priority'];
});
// Load module dependencies
foreach ($enabled_modules as $module) {
if (file_exists(ROOT_PATH . '/modules/' . $module['name'] . '/autoload.php')) {
require_once ROOT_PATH . '/modules/' . $module['name'] . '/autoload.php';
}
}
// Load modules
foreach ($enabled_modules as $module) {
if (file_exists(ROOT_PATH . '/modules/' . $module['name'] . '/init.php')) {
require_once ROOT_PATH . '/modules/' . $module['name'] . '/init.php';
}
}
// Maintenance mode?
if (Settings::get('maintenance') === '1') {
// Enabled
// Admins only beyond this point
if (!$user->isLoggedIn() || !$user->canViewStaffCP()) {
// Maintenance mode
if (isset($_GET['route']) && (
rtrim($_GET['route'], '/') === '/login'
|| rtrim($_GET['route'], '/') === '/forgot_password'
|| str_contains($_GET['route'], '/api/')
|| str_contains($_GET['route'], 'queries')
|| str_contains($_GET['route'], 'oauth/')
|| str_contains($_GET['route'], 'store/listener')
)) {
// Can continue as normal
} else {
require(ROOT_PATH . '/core/includes/maintenance.php');
/home/cxstudio76/domains/rextstore.app/public_html/index.php
if (!ini_get('upload_tmp_dir')) {
$tmp_dir = sys_get_temp_dir();
} else {
$tmp_dir = ini_get('upload_tmp_dir');
}
if (HttpUtils::getProtocol() === 'https') {
ini_set('session.cookie_secure', 'On');
}
ini_set('session.cookie_httponly', 1);
ini_set('open_basedir', ROOT_PATH . PATH_SEPARATOR . $tmp_dir . PATH_SEPARATOR . '/proc/stat');
// Get the directory the user is trying to access
$directory = $_SERVER['REQUEST_URI'];
$directories = explode('/', $directory);
$lim = count($directories);
// Start initialising the page
require(ROOT_PATH . '/core/init.php');
// Get page to load from URL
if (!isset($_GET['route']) || $_GET['route'] == '/') {
if ((!isset($_GET['route']) || ($_GET['route'] != '/')) && count($directories) > 1) {
require(ROOT_PATH . '/404.php');
} else {
// Homepage
$homepage = $pages->getPageByURL(Settings::get('home_type'));
if ($homepage != null) {
$pages->setActivePage($homepage);
require(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', $homepage['module'], $homepage['file']]));
} else {
$pages->setActivePage($pages->getPageByURL('/'));
require(ROOT_PATH . '/modules/Core/pages/index.php');
}
}
die;
}
$route = rtrim(strtok($_GET['route'], '?'), '/');
/home/cxstudio76/domains/rextstore.app/public_html/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()) {
/home/cxstudio76/domains/rextstore.app/public_html/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.
/home/cxstudio76/domains/rextstore.app/public_html/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.
/home/cxstudio76/domains/rextstore.app/public_html/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');
/home/cxstudio76/domains/rextstore.app/public_html/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();
/home/cxstudio76/domains/rextstore.app/public_html/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.
/home/cxstudio76/domains/rextstore.app/public_html/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>';
}
}