diff --git a/403.php b/403.php index be16b3ae87..eca2787c28 100644 --- a/403.php +++ b/403.php @@ -13,15 +13,15 @@ const PAGE = 403; $page_title = '403'; -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // 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'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Assign Smarty variables $smarty->assign( diff --git a/404.php b/404.php index 95509df970..961d3bd8fe 100644 --- a/404.php +++ b/404.php @@ -13,15 +13,15 @@ const PAGE = 404; $page_title = '404'; -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // 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'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Assign Smarty variables $smarty->assign( diff --git a/core/classes/Avatars/AvatarSource.php b/core/classes/Avatars/AvatarSource.php index 1f7ce43501..6498f96058 100644 --- a/core/classes/Avatars/AvatarSource.php +++ b/core/classes/Avatars/AvatarSource.php @@ -52,7 +52,7 @@ public static function getAvatarFromUserData(object $data, bool $allow_gifs = fa } foreach ($exts as $ext) { - if (file_exists(ROOT_PATH . '/uploads/avatars/' . $data->id . '.' . $ext)) { + if (file_exists(Constants::ROOT_PATH . '/uploads/avatars/' . $data->id . '.' . $ext)) { // We don't check the validity here since we know the file exists for sure return ($full ? rtrim(URL::getSelfURL(), '/') : '') . ((defined('CONFIG_PATH')) ? CONFIG_PATH . '/' : '/') . 'uploads/avatars/' . $data->id . '.' . $ext . '?v=' . urlencode($data->avatar_updated); } @@ -62,7 +62,7 @@ public static function getAvatarFromUserData(object $data, bool $allow_gifs = fa // Fallback to default avatar image if it is set and the avatar type is custom if (defined('DEFAULT_AVATAR_TYPE') && DEFAULT_AVATAR_TYPE == 'custom' && DEFAULT_AVATAR_IMAGE !== '') { - if (file_exists(ROOT_PATH . '/uploads/avatars/defaults/' . DEFAULT_AVATAR_IMAGE)) { + if (file_exists(Constants::ROOT_PATH . '/uploads/avatars/defaults/' . DEFAULT_AVATAR_IMAGE)) { // We don't check the validity here since we know the file exists for sure return ($full ? rtrim(URL::getSelfURL(), '/') : '') . ((defined('CONFIG_PATH')) ? CONFIG_PATH . '/' : '/') . 'uploads/avatars/defaults/' . DEFAULT_AVATAR_IMAGE; } @@ -99,7 +99,7 @@ public static function getAvatarFromUserData(object $data, bool $allow_gifs = fa * @return bool Whether the URL is a valid image URL */ private static function validImageUrl(string $url): bool { - $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']); + $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']); $cache->setCache('avatar_validity'); if ($cache->isCached($url)) { @@ -189,7 +189,7 @@ public static function getAllSources(): iterable { public static function getUrlToFormat(): string { // Default to Cravatar if (!isset(self::$_active_source)) { - require_once(ROOT_PATH . '/modules/Core/classes/Avatars/CravatarAvatarSource.php'); + require_once(Constants::ROOT_PATH . '/modules/Core/classes/Avatars/CravatarAvatarSource.php'); return (new CravatarAvatarSource())->getUrlToFormat(self::getDefaultPerspective()); } diff --git a/core/classes/Core/Config.php b/core/classes/Core/Config.php index 1e82dede81..767fe35e56 100644 --- a/core/classes/Core/Config.php +++ b/core/classes/Core/Config.php @@ -18,17 +18,17 @@ class Config { public static function writeable(): bool { clearstatcache(); if (self::exists()) { - return is_writable(ROOT_PATH . '/core/config.php'); + return is_writable(Constants::ROOT_PATH . '/core/config.php'); } - return is_writable(ROOT_PATH . '/core'); + return is_writable(Constants::ROOT_PATH . '/core'); } /** * @return bool Whether config file exists */ public static function exists(): bool { - return file_exists(ROOT_PATH . '/core/config.php'); + return file_exists(Constants::ROOT_PATH . '/core/config.php'); } /** @@ -45,7 +45,7 @@ public static function all(): array { throw new RuntimeException('Config file does not exist. If this happened during installation, please restart the installation in a new private/incognito browser window.'); } - return self::$_config_cache = require(ROOT_PATH . '/core/config.php'); + return self::$_config_cache = require(Constants::ROOT_PATH . '/core/config.php'); } /** @@ -55,11 +55,11 @@ public static function all(): array { */ public static function write(array $config): void { $contents = ' 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']); + $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']); $cache->setCache('modulescache'); $enabled_modules = $cache->retrieve('enabled_modules'); diff --git a/core/classes/Misc/Constants.php b/core/classes/Misc/Constants.php new file mode 100644 index 0000000000..811d89146a --- /dev/null +++ b/core/classes/Misc/Constants.php @@ -0,0 +1,15 @@ +setCompileDir(ROOT_PATH . '/cache/templates_c'); + $smarty->setCompileDir(Constants::ROOT_PATH . '/cache/templates_c'); $smarty->assign([ 'LANG' => defined('HTML_LANG') ? HTML_LANG : 'en', @@ -175,7 +175,7 @@ public static function catchException(?Throwable $exception, ?string $error_stri 'DEBUG_COPIED' => $language->get('general', 'debug_link_copied'), ]); - $smarty->display(ROOT_PATH . '/core/includes/error.tpl'); + $smarty->display(Constants::ROOT_PATH . '/core/includes/error.tpl'); die(); } @@ -199,9 +199,9 @@ private static function logError(string $type, string $contents): void { $dir_exists = false; try { - if (!is_dir(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs']))) { - if (is_writable(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache')) { - mkdir(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'logs'); + if (!is_dir(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'cache', 'logs']))) { + if (is_writable(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache')) { + mkdir(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'logs'); $dir_exists = true; } } else { @@ -209,7 +209,7 @@ private static function logError(string $type, string $contents): void { } if ($dir_exists) { - file_put_contents(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $type . '-log.log']), '[' . date('Y-m-d, H:i:s') . '] ' . $contents . PHP_EOL, FILE_APPEND); + file_put_contents(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'cache', 'logs', $type . '-log.log']), '[' . date('Y-m-d, H:i:s') . '] ' . $contents . PHP_EOL, FILE_APPEND); } } catch (Exception $ignored) { } diff --git a/core/classes/Misc/UpgradeScript.php b/core/classes/Misc/UpgradeScript.php index 5253c23c6e..5ccd692431 100644 --- a/core/classes/Misc/UpgradeScript.php +++ b/core/classes/Misc/UpgradeScript.php @@ -13,7 +13,7 @@ abstract class UpgradeScript { public function __construct() { $this->_cache = new Cache( - ['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/'] + ['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/'] ); } @@ -24,7 +24,7 @@ public function __construct() { * @return UpgradeScript|null Instance of UpgradeScript from file */ public static function get(string $current_version): ?UpgradeScript { - $path = ROOT_PATH . '/core/includes/updates/' . str_replace('.', '', $current_version) . '.php'; + $path = Constants::ROOT_PATH . '/core/includes/updates/' . str_replace('.', '', $current_version) . '.php'; if (!file_exists($path)) { return null; @@ -122,7 +122,7 @@ protected function deleteFilesInPath(string $path, array $files, bool $recursive */ protected function deleteFiles($paths): void { foreach ((array) $paths as $path) { - $path = ROOT_PATH . '/' . $path; + $path = Constants::ROOT_PATH . '/' . $path; if (!file_exists($path)) { $this->log("'$path' does not exist, cannot delete."); continue; diff --git a/core/classes/Templates/AssetResolver.php b/core/classes/Templates/AssetResolver.php index 5cea8f67b5..03a9ba7da1 100644 --- a/core/classes/Templates/AssetResolver.php +++ b/core/classes/Templates/AssetResolver.php @@ -148,7 +148,7 @@ private function buildPath(string $file, string $type): string { : '') . '/core/assets/' . $file; - if (!file_exists(ROOT_PATH . '/core/assets/' . $file)) { + if (!file_exists(Constants::ROOT_PATH . '/core/assets/' . $file)) { throw new InvalidArgumentException('Asset file "' . $href . '" not found'); } diff --git a/core/includes/image_upload.php b/core/includes/image_upload.php index 5351d29295..6880d8374a 100644 --- a/core/includes/image_upload.php +++ b/core/includes/image_upload.php @@ -11,14 +11,13 @@ // Initialisation $page = 'image_uploads'; -const ROOT_PATH = '../..'; // Get the directory the user is trying to access $directory = $_SERVER['REQUEST_URI']; $directories = explode('/', $directory); -require(ROOT_PATH . '/vendor/autoload.php'); -require(ROOT_PATH . '/core/init.php'); +require(Constants::ROOT_PATH . '/vendor/autoload.php'); +require(Constants::ROOT_PATH . '/core/init.php'); if (!$user->isLoggedIn()) { die('Not logged in'); @@ -88,8 +87,8 @@ } if ( - !is_dir(join(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'profile_images', $user->data()->id])) - && !mkdir(join(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'profile_images', $user->data()->id])) + !is_dir(join(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'profile_images', $user->data()->id])) + && !mkdir(join(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'profile_images', $user->data()->id])) ) { Session::flash('profile_banner_error', $language->get('admin', 'x_directory_not_writable', ['directory' => 'uploads/profile_images'])); Redirect::to(URL::build('/profile/' . urlencode($user->data()->username))); @@ -109,7 +108,7 @@ break; } -$image->setLocation(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', $folder])); +$image->setLocation(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', $folder])); if ($image['file']) { try { @@ -130,7 +129,7 @@ $diff = array_diff(array_merge($image_extensions, ['gif', 'ico']), [strtolower($image->getMime())]); foreach ($diff as $extension) { - $to_remove = glob(ROOT_PATH . '/uploads/avatars/' . $user->data()->id . '.' . $extension); + $to_remove = glob(Constants::ROOT_PATH . '/uploads/avatars/' . $user->data()->id . '.' . $extension); foreach ($to_remove as $file) { unlink($file); } diff --git a/core/includes/maintenance.php b/core/includes/maintenance.php index c4027427b5..536a9959c8 100644 --- a/core/includes/maintenance.php +++ b/core/includes/maintenance.php @@ -13,7 +13,7 @@ const PAGE = 'maintenance'; $page_title = $language->get('errors', 'maintenance_title'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); if (!$user->isLoggedIn()) { $smarty->assign( diff --git a/core/includes/tfa_signin.php b/core/includes/tfa_signin.php index 80fc3a8b79..cd725b75a3 100644 --- a/core/includes/tfa_signin.php +++ b/core/includes/tfa_signin.php @@ -42,8 +42,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('tfa.tpl', $smarty); diff --git a/core/includes/updates/203.php b/core/includes/updates/203.php index 8ef34408f5..53d343ea31 100644 --- a/core/includes/updates/203.php +++ b/core/includes/updates/203.php @@ -4,7 +4,7 @@ public function run(): void { $this->runMigrations(); // Move query interval from cache to settings table - $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']); + $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']); $cache->setCache('server_query_cache'); if ($cache->isCached('query_interval')) { $query_interval = $cache->retrieve('query_interval'); diff --git a/core/init.php b/core/init.php index 686350d8fa..0ba7a68608 100644 --- a/core/init.php +++ b/core/init.php @@ -28,25 +28,25 @@ // All paths should be writable, but recursively checking everything would take too much time. // Only check the most important paths. $writable_check_paths = [ - ROOT_PATH, - ROOT_PATH . '/cache', - ROOT_PATH . '/cache/logs', - ROOT_PATH . '/cache/sitemaps', - ROOT_PATH . '/cache/templates_c', - ROOT_PATH . '/uploads', - ROOT_PATH . '/core/config.php' + Constants::ROOT_PATH, + Constants::ROOT_PATH . '/cache', + Constants::ROOT_PATH . '/cache/logs', + Constants::ROOT_PATH . '/cache/sitemaps', + Constants::ROOT_PATH . '/cache/templates_c', + Constants::ROOT_PATH . '/uploads', + Constants::ROOT_PATH . '/core/config.php' ]; foreach ($writable_check_paths as $path) { if (is_dir($path) && !is_writable($path)) { die('

Your website directory or a subdirectory is not writable. Please ensure all files and directories are owned by - the correct user.

Example command to change owner recursively: sudo chown -R www-data: ' . Output::getClean(ROOT_PATH) . '

'); + the correct user.

Example command to change owner recursively: sudo chown -R www-data: ' . Output::getClean(Constants::ROOT_PATH) . '

'); } } -if (!file_exists(ROOT_PATH . '/cache/templates_c')) { +if (!file_exists(Constants::ROOT_PATH . '/cache/templates_c')) { try { - mkdir(ROOT_PATH . '/cache/templates_c', 0777, true); + mkdir(Constants::ROOT_PATH . '/cache/templates_c', 0777, true); } catch (Exception $e) { die('Unable to create /cache directories, please check your file permissions.'); } @@ -329,7 +329,7 @@ 'file_exists', 'array_key_exists' ]; - $securityPolicy->secure_dir = [ROOT_PATH . '/custom/templates', ROOT_PATH . '/custom/panel_templates']; + $securityPolicy->secure_dir = [Constants::ROOT_PATH . '/custom/templates', Constants::ROOT_PATH . '/custom/panel_templates']; $smarty->enableSecurity($securityPolicy); // Basic Smarty variables @@ -455,8 +455,8 @@ }); foreach ($enabled_modules as $module) { - if (file_exists(ROOT_PATH . '/modules/' . $module['name'] . '/init.php')) { - require(ROOT_PATH . '/modules/' . $module['name'] . '/init.php'); + if (file_exists(Constants::ROOT_PATH . '/modules/' . $module['name'] . '/init.php')) { + require(Constants::ROOT_PATH . '/modules/' . $module['name'] . '/init.php'); } } @@ -475,7 +475,7 @@ )) { // Can continue as normal } else { - require(ROOT_PATH . '/core/includes/maintenance.php'); + require(Constants::ROOT_PATH . '/core/includes/maintenance.php'); die(); } } else { diff --git a/core/installation/includes/header.php b/core/installation/includes/header.php index 52e45a9597..d045fabdef 100644 --- a/core/installation/includes/header.php +++ b/core/installation/includes/header.php @@ -1,5 +1,5 @@ setCompileDir(ROOT_PATH . '/cache/templates_c'); +$template_path = Constants::ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE; +$smarty->setCompileDir(Constants::ROOT_PATH . '/cache/templates_c'); -if (file_exists(ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE . '/template.php')) { - $smarty->setTemplateDir(ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE); +if (file_exists(Constants::ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE . '/template.php')) { + $smarty->setTemplateDir(Constants::ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE); - require(ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE . '/template.php'); + require(Constants::ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE . '/template.php'); } else { - $smarty->setTemplateDir(ROOT_PATH . '/custom/panel_templates/Default'); + $smarty->setTemplateDir(Constants::ROOT_PATH . '/custom/panel_templates/Default'); - require(ROOT_PATH . '/custom/panel_templates/Default/template.php'); + require(Constants::ROOT_PATH . '/custom/panel_templates/Default/template.php'); } $cache->setCache('backgroundcache'); diff --git a/core/templates/frontend_init.php b/core/templates/frontend_init.php index 6229b8bd4d..be5e85c3e7 100644 --- a/core/templates/frontend_init.php +++ b/core/templates/frontend_init.php @@ -52,16 +52,16 @@ } } -$smarty->setCompileDir(ROOT_PATH . '/cache/templates_c'); +$smarty->setCompileDir(Constants::ROOT_PATH . '/cache/templates_c'); -if (file_exists(ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php')) { - $smarty->setTemplateDir(ROOT_PATH . '/custom/templates/' . TEMPLATE); +if (file_exists(Constants::ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php')) { + $smarty->setTemplateDir(Constants::ROOT_PATH . '/custom/templates/' . TEMPLATE); - require(ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php'); + require(Constants::ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php'); } else { - $smarty->setTemplateDir(ROOT_PATH . '/custom/templates/DefaultRevamp'); + $smarty->setTemplateDir(Constants::ROOT_PATH . '/custom/templates/DefaultRevamp'); - require(ROOT_PATH . '/custom/templates/DefaultRevamp/template.php'); + require(Constants::ROOT_PATH . '/custom/templates/DefaultRevamp/template.php'); } // User related actions diff --git a/custom/templates/DefaultRevamp/template.php b/custom/templates/DefaultRevamp/template.php index 2ac3ddf288..36aefc6a53 100755 --- a/custom/templates/DefaultRevamp/template.php +++ b/custom/templates/DefaultRevamp/template.php @@ -34,7 +34,7 @@ public function __construct($cache, $smarty, $language, $user, $pages) { parent::__construct($template['name'], $template['version'], $template['nl_version'], $template['author']); - $this->_settings = ROOT_PATH . '/custom/templates/DefaultRevamp/template_settings/settings.php'; + $this->_settings = Constants::ROOT_PATH . '/custom/templates/DefaultRevamp/template_settings/settings.php'; $this->assets()->include([ AssetTree::FONT_AWESOME, diff --git a/custom/templates/DefaultRevamp/template_settings/settings.php b/custom/templates/DefaultRevamp/template_settings/settings.php index 34b87b807d..e001aadd67 100644 --- a/custom/templates/DefaultRevamp/template_settings/settings.php +++ b/custom/templates/DefaultRevamp/template_settings/settings.php @@ -128,5 +128,5 @@ 'NAVBAR_COLOUR' => $language->get('admin', 'navbar_colour'), 'NAVBAR_COLOURS' => $nav_colours, 'HOME_CUSTOM_CONTENT' => $language->get('admin', 'home_custom_content'), - 'SETTINGS_TEMPLATE' => ROOT_PATH . '/custom/templates/DefaultRevamp/template_settings/settings.tpl' + 'SETTINGS_TEMPLATE' => Constants::ROOT_PATH . '/custom/templates/DefaultRevamp/template_settings/settings.tpl' ]); diff --git a/dev/scripts/cli_install.php b/dev/scripts/cli_install.php index 256e4c86cb..a44d4ef204 100644 --- a/dev/scripts/cli_install.php +++ b/dev/scripts/cli_install.php @@ -87,8 +87,6 @@ function getEnvVar(string $name, string $fallback = null, array $valid_values = } } -const ROOT_PATH = __DIR__ . '/../..'; - print('♻️ Registering autoloader...' . PHP_EOL); require './vendor/autoload.php'; diff --git a/dev/scripts/seeder/db_seeder.php b/dev/scripts/seeder/db_seeder.php index 37b7af264c..ba8d79782c 100644 --- a/dev/scripts/seeder/db_seeder.php +++ b/dev/scripts/seeder/db_seeder.php @@ -3,7 +3,6 @@ die('This script must be run from the command line.'); } -define('ROOT_PATH', __DIR__ . '/../../..'); require 'vendor/autoload.php'; $classes = [ diff --git a/index.php b/index.php index 06d7af5f23..ac5310bd25 100644 --- a/index.php +++ b/index.php @@ -43,7 +43,7 @@ } const PATH = '/'; -const ROOT_PATH = __DIR__; +const ROOT_PATH = __DIR__; // Deprecated - Use Constants::ROOT_PATH instead require_once __DIR__ . '/vendor/autoload.php'; @@ -53,7 +53,7 @@ } if (!Config::exists() || Config::get('core.installed') !== true) { - if (is_file(ROOT_PATH . '/install.php')) { + if (is_file(Constants::ROOT_PATH . '/install.php')) { Redirect::to('install.php'); } else { die('Config does not exist, but neither does the installer'); @@ -73,7 +73,7 @@ } ini_set('session.cookie_httponly', 1); -ini_set('open_basedir', ROOT_PATH . PATH_SEPARATOR . $tmp_dir . PATH_SEPARATOR . '/proc/stat'); +ini_set('open_basedir', Constants::ROOT_PATH . PATH_SEPARATOR . $tmp_dir . PATH_SEPARATOR . '/proc/stat'); // Get the directory the user is trying to access $directory = $_SERVER['REQUEST_URI']; @@ -81,16 +81,16 @@ $lim = count($directories); // Start initialising the page -require(ROOT_PATH . '/core/init.php'); +require(Constants::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'); + require(Constants::ROOT_PATH . '/404.php'); } else { // Homepage $pages->setActivePage($pages->getPageByURL('/')); - require(ROOT_PATH . '/modules/Core/pages/index.php'); + require(Constants::ROOT_PATH . '/modules/Core/pages/index.php'); } die(); } @@ -102,11 +102,11 @@ 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'])); + require(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'modules', 'Core', 'pages', 'custom.php'])); die(); } - $path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', $all_pages[$route]['module'], $all_pages[$route]['file']]); + $path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'modules', $all_pages[$route]['module'], $all_pages[$route]['file']]); if (file_exists($path)) { require($path); @@ -126,7 +126,7 @@ $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']]); + $path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'modules', $all_pages[$new_path]['module'], $all_pages[$new_path]['file']]); if (file_exists($path)) { $pages->setActivePage($all_pages[$new_path]); @@ -137,4 +137,4 @@ } } -require(ROOT_PATH . '/404.php'); +require(Constants::ROOT_PATH . '/404.php'); diff --git a/install.php b/install.php index 468001f2b9..d4b2431042 100644 --- a/install.php +++ b/install.php @@ -18,14 +18,14 @@ // Definitions if (!defined('PATH')) { define('PATH', '/'); - define('ROOT_PATH', __DIR__); + define('Constants::ROOT_PATH', __DIR__); } $page = 'install'; $install_path = str_replace('\\', '/', substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']))); // Start initialising the page -require(ROOT_PATH . '/core/init.php'); +require(Constants::ROOT_PATH . '/core/init.php'); // Disable error reporting error_reporting(0); @@ -51,7 +51,7 @@ $install_path = substr(str_replace('\\', '/', substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']))), 1); if (Config::exists() && Config::get('core.installed') === true) { - require(ROOT_PATH . '/core/installation/already_installed.php'); + require(Constants::ROOT_PATH . '/core/installation/already_installed.php'); return; } @@ -63,4 +63,4 @@ } die($_GET['language'] . ' is not a valid language'); } -require(ROOT_PATH . '/core/installation/installer.php'); +require(Constants::ROOT_PATH . '/core/installation/installer.php'); diff --git a/modules/Cookie Consent/classes/CookieConsent.php b/modules/Cookie Consent/classes/CookieConsent.php index 7c804a5f34..24e9e7c6a2 100644 --- a/modules/Cookie Consent/classes/CookieConsent.php +++ b/modules/Cookie Consent/classes/CookieConsent.php @@ -83,7 +83,7 @@ public static function generateScript(array $options): string { return str_replace( '//"{x}"', substr($json, 1, -1), - file_get_contents(ROOT_PATH . '/modules/Cookie Consent/assets/js/template.js') + file_get_contents(Constants::ROOT_PATH . '/modules/Cookie Consent/assets/js/template.js') ); } } diff --git a/modules/Cookie Consent/init.php b/modules/Cookie Consent/init.php index 342024e4e1..77ccba7311 100644 --- a/modules/Cookie Consent/init.php +++ b/modules/Cookie Consent/init.php @@ -9,8 +9,8 @@ * Cookie Consent initialisation file */ -require_once ROOT_PATH . '/modules/Cookie Consent/module.php'; +require_once Constants::ROOT_PATH . '/modules/Cookie Consent/module.php'; -$cookie_language = new Language(ROOT_PATH . '/modules/Cookie Consent/language'); +$cookie_language = new Language(Constants::ROOT_PATH . '/modules/Cookie Consent/language'); $module = new CookieConsent_Module($language, $cookie_language, $pages); diff --git a/modules/Cookie Consent/pages/cookies.php b/modules/Cookie Consent/pages/cookies.php index a32e180171..135d8fd223 100644 --- a/modules/Cookie Consent/pages/cookies.php +++ b/modules/Cookie Consent/pages/cookies.php @@ -12,7 +12,7 @@ // Always define page name const PAGE = 'cookies'; $page_title = $cookie_language->get('cookie', 'cookie_notice'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Retrieve cookie notice from database $cookie_notice = DB::getInstance()->query('SELECT value FROM nl2_privacy_terms WHERE `name` = ?', ['cookies'])->first()->value; @@ -26,12 +26,12 @@ 'UPDATE_SETTINGS' => $cookie_language->get('cookie', 'update_settings'), ]); -$template->addJSScript(file_get_contents(ROOT_PATH . '/modules/Cookie Consent/assets/js/configure.js')); +$template->addJSScript(file_get_contents(Constants::ROOT_PATH . '/modules/Cookie Consent/assets/js/configure.js')); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('cookies.tpl', $smarty); diff --git a/modules/Cookie Consent/pages/panel/cookies.php b/modules/Cookie Consent/pages/panel/cookies.php index c7274f4155..579a6a5711 100644 --- a/modules/Cookie Consent/pages/panel/cookies.php +++ b/modules/Cookie Consent/pages/panel/cookies.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.cookies')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'cookie_divider'; const PANEL_PAGE = 'cookie_settings'; $page_title = $cookie_language->get('cookie', 'cookies'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (Input::exists()) { $errors = []; @@ -94,7 +94,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('cookies/cookies.tpl', $smarty); diff --git a/modules/Core/classes/Integrations/MinecraftIntegration.php b/modules/Core/classes/Integrations/MinecraftIntegration.php index cc468ceca4..cf63a82764 100644 --- a/modules/Core/classes/Integrations/MinecraftIntegration.php +++ b/modules/Core/classes/Integrations/MinecraftIntegration.php @@ -16,7 +16,7 @@ public function __construct(Language $language) { $this->_name = 'Minecraft'; $this->_icon = 'fas fa-cubes'; $this->_language = $language; - $this->_settings = ROOT_PATH . '/modules/Core/includes/admin_integrations/minecraft.php'; + $this->_settings = Constants::ROOT_PATH . '/modules/Core/includes/admin_integrations/minecraft.php'; parent::__construct(); } diff --git a/modules/Core/includes/endpoints/CreateWebhooksEndpoint.php b/modules/Core/includes/endpoints/CreateWebhooksEndpoint.php index 43258e93e4..70998da7b1 100644 --- a/modules/Core/includes/endpoints/CreateWebhooksEndpoint.php +++ b/modules/Core/includes/endpoints/CreateWebhooksEndpoint.php @@ -72,7 +72,7 @@ public function execute(Nameless2API $api): void { // Clear cache so the webhooks are refreshed - $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']); + $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']); $cache->setCache('hooks'); if ($cache->isCached('hooks')) { $cache->erase('hooks'); diff --git a/modules/Core/includes/endpoints/GetAnnouncementsEndpoint.php b/modules/Core/includes/endpoints/GetAnnouncementsEndpoint.php index a1c79db05c..62642a4538 100644 --- a/modules/Core/includes/endpoints/GetAnnouncementsEndpoint.php +++ b/modules/Core/includes/endpoints/GetAnnouncementsEndpoint.php @@ -16,7 +16,7 @@ public function execute(Nameless2API $api): void { $guest_announcements = []; $announcements = new Announcements( - new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']) + new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']) ); foreach ($announcements->getAvailable('api') as $announcement) { diff --git a/modules/Core/includes/endpoints/GetUserAnnouncementsEndpoint.php b/modules/Core/includes/endpoints/GetUserAnnouncementsEndpoint.php index e62797b856..4fb4953a68 100644 --- a/modules/Core/includes/endpoints/GetUserAnnouncementsEndpoint.php +++ b/modules/Core/includes/endpoints/GetUserAnnouncementsEndpoint.php @@ -18,7 +18,7 @@ public function execute(Nameless2API $api, User $user): void { $user_announcements = []; $announcements = new Announcements( - new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']) + new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']) ); foreach ($announcements->getAvailable('api', null, $user->getAllGroupIds()) as $announcement) { diff --git a/modules/Core/includes/endpoints/RegisterEndpoint.php b/modules/Core/includes/endpoints/RegisterEndpoint.php index d4556693db..288e925038 100644 --- a/modules/Core/includes/endpoints/RegisterEndpoint.php +++ b/modules/Core/includes/endpoints/RegisterEndpoint.php @@ -92,7 +92,7 @@ public function execute(Nameless2API $api): void { private function createUser(Nameless2API $api, string $username, string $email, bool $return, string $code = null): array { try { // Get default group ID - if (!is_file(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('default_group') . '.cache')) { + if (!is_file(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('default_group') . '.cache')) { // Not cached, cache now // Retrieve from database $default_group = $api->getDb()->get('groups', ['default_group', true]); @@ -112,9 +112,9 @@ private function createUser(Nameless2API $api, string $username, string $email, ]; // Store in cache file - file_put_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('default_group') . '.cache', json_encode($to_cache)); + file_put_contents(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('default_group') . '.cache', json_encode($to_cache)); } else { - $default_group = file_get_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('default_group') . '.cache'); + $default_group = file_get_contents(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('default_group') . '.cache'); $default_group = json_decode($default_group); $default_group = unserialize($default_group->default_group->data); } diff --git a/modules/Core/includes/endpoints/ServerInfoEndpoint.php b/modules/Core/includes/endpoints/ServerInfoEndpoint.php index 214086de1a..fafe4d0233 100644 --- a/modules/Core/includes/endpoints/ServerInfoEndpoint.php +++ b/modules/Core/includes/endpoints/ServerInfoEndpoint.php @@ -35,8 +35,8 @@ public function execute(Nameless2API $api): void { 'groups' => isset($_POST['groups']) ? json_encode($_POST['groups']) : '[]' ]); - if (file_exists(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('server_query_cache') . '.cache')) { - $query_cache = file_get_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('server_query_cache') . '.cache'); + if (file_exists(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('server_query_cache') . '.cache')) { + $query_cache = file_get_contents(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('server_query_cache') . '.cache'); $query_cache = json_decode($query_cache); if (isset($query_cache->query_interval)) { $query_interval = unserialize($query_cache->query_interval->data); @@ -58,7 +58,7 @@ public function execute(Nameless2API $api): void { ]; // Store in cache file - file_put_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('server_query_cache') . '.cache', json_encode($to_cache)); + file_put_contents(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('server_query_cache') . '.cache', json_encode($to_cache)); } } catch (Exception $e) { $api->throwError(CoreApiErrors::ERROR_UNABLE_TO_UPDATE_SERVER_INFO, $e->getMessage(), 500); @@ -92,7 +92,7 @@ public function execute(Nameless2API $api): void { $players_list[] = ['id' => $uuid, 'name' => $player['name']]; } - $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']); + $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']); $cache->setCache('latest_query'); $cache->store($server_id, [ 'player_count' => count($_POST['players']), diff --git a/modules/Core/init.php b/modules/Core/init.php index c7aec021aa..af3fc3c952 100644 --- a/modules/Core/init.php +++ b/modules/Core/init.php @@ -17,6 +17,6 @@ die('Run the installer first!'); } -require_once ROOT_PATH . '/modules/Core/module.php'; +require_once Constants::ROOT_PATH . '/modules/Core/module.php'; $module = new Core_Module($language, $pages, $user, $navigation, $cache, $endpoints); diff --git a/modules/Core/module.php b/modules/Core/module.php index d49a78a287..6c683470dd 100644 --- a/modules/Core/module.php +++ b/modules/Core/module.php @@ -445,7 +445,7 @@ public function __construct(Language $language, Pages $pages, User $user, Naviga AvatarSource::setActiveSource(DEFAULT_AVATAR_SOURCE); // Autoload API Endpoints - $endpoints->loadEndpoints(ROOT_PATH . '/modules/Core/includes/endpoints'); + $endpoints->loadEndpoints(Constants::ROOT_PATH . '/modules/Core/includes/endpoints'); GroupSyncManager::getInstance()->registerInjector(new NamelessMCGroupSyncInjector); GroupSyncManager::getInstance()->registerInjector(new MinecraftGroupSyncInjector); @@ -1471,25 +1471,25 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart self::addDataToDashboardGraph($language->get('admin', 'overview'), $data); // Dashboard stats - require_once(ROOT_PATH . '/modules/Core/collections/panel/TotalUsers.php'); + require_once(Constants::ROOT_PATH . '/modules/Core/collections/panel/TotalUsers.php'); CollectionManager::addItemToCollection('dashboard_stats', new TotalUsersItem($smarty, $language, $cache)); - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentUsers.php'); + require_once(Constants::ROOT_PATH . '/modules/Core/collections/panel/RecentUsers.php'); CollectionManager::addItemToCollection('dashboard_stats', new RecentUsersItem($smarty, $language, $cache)); // Dashboard items if ($user->hasPermission('modcp.punishments')) { - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentPunishments.php'); + require_once(Constants::ROOT_PATH . '/modules/Core/collections/panel/RecentPunishments.php'); CollectionManager::addItemToCollection('dashboard_main_items', new RecentPunishmentsItem($smarty, $language, $cache)); } if ($user->hasPermission('modcp.reports')) { - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentReports.php'); + require_once(Constants::ROOT_PATH . '/modules/Core/collections/panel/RecentReports.php'); CollectionManager::addItemToCollection('dashboard_main_items', new RecentReportsItem($smarty, $language, $cache)); } if ($user->hasPermission('admincp.users')) { - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentRegistrations.php'); + require_once(Constants::ROOT_PATH . '/modules/Core/collections/panel/RecentRegistrations.php'); CollectionManager::addItemToCollection('dashboard_main_items', new RecentRegistrationsItem($smarty, $language, $cache)); } } diff --git a/modules/Core/pages/api/v2/index.php b/modules/Core/pages/api/v2/index.php index 1e60fa227c..9f63f405c6 100644 --- a/modules/Core/pages/api/v2/index.php +++ b/modules/Core/pages/api/v2/index.php @@ -14,7 +14,7 @@ header('Content-Type: application/json; charset=UTF-8'); $page_title = 'api'; -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); diff --git a/modules/Core/pages/authme_connector.php b/modules/Core/pages/authme_connector.php index acf757f8cc..853721ba7b 100644 --- a/modules/Core/pages/authme_connector.php +++ b/modules/Core/pages/authme_connector.php @@ -10,8 +10,8 @@ */ $page_title = $language->get('general', 'register'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); -require_once(ROOT_PATH . '/modules/Core/includes/emails/register.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/modules/Core/includes/emails/register.php'); // Use recaptcha? $captcha = CaptchaBase::isCaptchaEnabled(); @@ -395,7 +395,7 @@ } } - $template_file = ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme.tpl'; + $template_file = Constants::ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme.tpl'; } else { $fields = new Fields(); // Step 2 @@ -438,7 +438,7 @@ 'SUBMIT' => $language->get('general', 'submit'), ]); - $template_file = ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme_email.tpl'; + $template_file = Constants::ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme_email.tpl'; } // Load modules + template @@ -446,7 +446,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/complete_signup.php b/modules/Core/pages/complete_signup.php index 971a15bfa6..6697c36526 100644 --- a/modules/Core/pages/complete_signup.php +++ b/modules/Core/pages/complete_signup.php @@ -13,7 +13,7 @@ const PAGE = 'complete_signup'; $page_title = $language->get('general', 'register'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -113,7 +113,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); $template->displayTemplate('complete_signup.tpl', $smarty); diff --git a/modules/Core/pages/custom.php b/modules/Core/pages/custom.php index a527e3b33d..6cdc6970c8 100644 --- a/modules/Core/pages/custom.php +++ b/modules/Core/pages/custom.php @@ -12,7 +12,7 @@ // Get page info from URL $custom_page = DB::getInstance()->get('custom_pages', ['url', rtrim($route, '/')]); if (!$custom_page->count()) { - require(ROOT_PATH . '/404.php'); + require(Constants::ROOT_PATH . '/404.php'); die(); } @@ -47,7 +47,7 @@ } if (!isset($can_view)) { - require(ROOT_PATH . '/403.php'); + require(Constants::ROOT_PATH . '/403.php'); die(); } @@ -60,7 +60,7 @@ define('PAGE', $custom_page->id); define('CUSTOM_PAGE', $custom_page->title); $page_title = Output::getClean($custom_page->title); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $template->assets()->include([ DARK_MODE @@ -85,8 +85,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); if ($custom_page->basic) { $template->displayTemplate('custom_basic.tpl', $smarty); diff --git a/modules/Core/pages/forgot_password.php b/modules/Core/pages/forgot_password.php index f12f448519..88574c7e82 100644 --- a/modules/Core/pages/forgot_password.php +++ b/modules/Core/pages/forgot_password.php @@ -12,7 +12,7 @@ const PAGE = 'forgot_password'; $page_title = str_replace('?', '', $language->get('user', 'forgot_password')); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Ensure user is not logged in if ($user->isLoggedIn()) { @@ -105,8 +105,8 @@ 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'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forgot_password.tpl', $smarty); @@ -186,8 +186,8 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('change_password.tpl', $smarty); diff --git a/modules/Core/pages/home.php b/modules/Core/pages/home.php index 781157c773..8f19eda216 100644 --- a/modules/Core/pages/home.php +++ b/modules/Core/pages/home.php @@ -12,7 +12,7 @@ // Always define page name const PAGE = 'index'; $page_title = $language->get('general', 'home'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $template->assets()->include([ DARK_MODE @@ -37,7 +37,7 @@ if ($home_type === 'news') { foreach ($front_page_modules as $module) { - require(ROOT_PATH . '/' . $module); + require(Constants::ROOT_PATH . '/' . $module); } } else if ($home_type === 'custom') { $smarty->assign('CUSTOM_HOME_CONTENT', Util::getSetting('home_custom_content')); @@ -54,8 +54,8 @@ $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('index.tpl', $smarty); diff --git a/modules/Core/pages/leaderboards.php b/modules/Core/pages/leaderboards.php index d15d3ead5e..7888d9c6c3 100644 --- a/modules/Core/pages/leaderboards.php +++ b/modules/Core/pages/leaderboards.php @@ -11,20 +11,20 @@ // MC integration and Placeholders enabled? if (!Util::getSetting('mc_integration') || Util::getSetting('placeholders') !== '1') { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } $leaderboard_placeholders = Placeholders::getInstance()->getLeaderboardPlaceholders(); if (!count($leaderboard_placeholders)) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } const PAGE = 'leaderboards'; $page_title = $language->get('general', 'leaderboards'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $leaderboard_placeholders_data = []; $leaderboard_users = []; @@ -110,8 +110,8 @@ function hideTables() { $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('leaderboards.tpl', $smarty); diff --git a/modules/Core/pages/login.php b/modules/Core/pages/login.php index 1b44082c80..b679faa510 100644 --- a/modules/Core/pages/login.php +++ b/modules/Core/pages/login.php @@ -12,7 +12,7 @@ // Set page name variable const PAGE = 'login'; $page_title = $language->get('general', 'sign_in'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Ensure user isn't already logged in if ($user->isLoggedIn()) { @@ -123,7 +123,7 @@ } else { // App - require(ROOT_PATH . '/core/includes/tfa_signin.php'); + require(Constants::ROOT_PATH . '/core/includes/tfa_signin.php'); die(); } } else { @@ -134,7 +134,7 @@ if ($tfa->verifyCode($user_query->data()->tfa_secret, str_replace(' ', '', $_POST['tfa_code'])) !== true) { Session::flash('tfa_signin', $language->get('user', 'invalid_tfa')); - require(ROOT_PATH . '/core/includes/tfa_signin.php'); + require(Constants::ROOT_PATH . '/core/includes/tfa_signin.php'); die(); } } else { @@ -313,8 +313,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('login.tpl', $smarty); diff --git a/modules/Core/pages/minecraft/banner.php b/modules/Core/pages/minecraft/banner.php index 4ff55fd510..70e1ad5d65 100644 --- a/modules/Core/pages/minecraft/banner.php +++ b/modules/Core/pages/minecraft/banner.php @@ -57,14 +57,14 @@ imageAlphaBlending($favicon, true); imageSaveAlpha($favicon, true); } else { - $favicon = imagecreatefrompng(ROOT_PATH . '/core/assets/img/favicon.png'); + $favicon = imagecreatefrompng(Constants::ROOT_PATH . '/core/assets/img/favicon.png'); } // Cache the favicon for 1 hour - imagepng($favicon, ROOT_PATH . '/cache/server_fav_' . urlencode($server->name) . '.png'); + imagepng($favicon, Constants::ROOT_PATH . '/cache/server_fav_' . urlencode($server->name) . '.png'); $cache->store('favicon', 'true', 3600); } else { - $favicon = imagecreatefrompng(ROOT_PATH . '/cache/server_fav_' . urlencode($server->name) . '.png'); + $favicon = imagecreatefrompng(Constants::ROOT_PATH . '/cache/server_fav_' . urlencode($server->name) . '.png'); } // remove ".png" from ending (lib expects file name w/o extension) @@ -80,7 +80,7 @@ header('Content-type: image/png'); - imagepng($image, ROOT_PATH . '/cache/server_' . urlencode($server->name) . '.png'); + imagepng($image, Constants::ROOT_PATH . '/cache/server_' . urlencode($server->name) . '.png'); imagepng($image); imagedestroy($favicon); @@ -90,7 +90,7 @@ $cache->store('image', 'true', 120); } else { header('Content-Type: image/png'); - $im = imagecreatefrompng(ROOT_PATH . '/cache/server_' . urlencode($server->name) . '.png'); + $im = imagecreatefrompng(Constants::ROOT_PATH . '/cache/server_' . urlencode($server->name) . '.png'); imagepng($im); imagedestroy($im); } diff --git a/modules/Core/pages/oauth.php b/modules/Core/pages/oauth.php index a54cddd225..3a8c0fd851 100644 --- a/modules/Core/pages/oauth.php +++ b/modules/Core/pages/oauth.php @@ -1,7 +1,7 @@ verifyCode($user->data()->tfa_secret, str_replace(' ', '', $_POST['tfa_code'])) !== true) { Session::flash('tfa_signin', $language->get('user', 'invalid_tfa')); - require(ROOT_PATH . '/core/includes/tfa_signin.php'); + require(Constants::ROOT_PATH . '/core/includes/tfa_signin.php'); die(); } unset($_SESSION['user_id']); @@ -123,7 +123,7 @@ if ($user->data()->tfa_enabled == 1 && $user->data()->tfa_complete == 1) { $_SESSION['user_id'] = $user_id; if (!isset($_POST['tfa_code'])) { - require(ROOT_PATH . '/core/includes/tfa_signin.php'); + require(Constants::ROOT_PATH . '/core/includes/tfa_signin.php'); die(); } } diff --git a/modules/Core/pages/panel/announcements.php b/modules/Core/pages/panel/announcements.php index 46706f9413..d4931b4403 100644 --- a/modules/Core/pages/panel/announcements.php +++ b/modules/Core/pages/panel/announcements.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.announcements')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'announcements'; const PANEL_PAGE = 'announcements'; $page_title = $language->get('admin', 'announcements'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['action'])) { // View all announcements @@ -336,7 +336,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/api.php b/modules/Core/pages/panel/api.php index a4e5203ecd..52f17fb71b 100644 --- a/modules/Core/pages/panel/api.php +++ b/modules/Core/pages/panel/api.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.api')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'api'; $page_title = $language->get('admin', 'api'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['view'])) { if (Input::exists()) { @@ -34,7 +34,7 @@ Util::setSetting('mc_api_key', $new_api_key); // Cache - file_put_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('apicache') . '.cache', $new_api_key); + file_put_contents(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('apicache') . '.cache', $new_api_key); // Redirect Session::flash('api_success', $language->get('admin', 'api_key_regenerated')); @@ -303,7 +303,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/auth.php b/modules/Core/pages/panel/auth.php index 00656ef3a2..15a78edaf2 100644 --- a/modules/Core/pages/panel/auth.php +++ b/modules/Core/pages/panel/auth.php @@ -26,7 +26,7 @@ const PAGE = 'panel'; const PANEL_PAGE = 'auth'; $page_title = $language->get('admin', 're-authenticate'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Deal with any input if (Input::exists()) { @@ -85,7 +85,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('auth.tpl', $smarty); diff --git a/modules/Core/pages/panel/avatars.php b/modules/Core/pages/panel/avatars.php index 158c720d95..66bd023bd2 100644 --- a/modules/Core/pages/panel/avatars.php +++ b/modules/Core/pages/panel/avatars.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.avatars')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'avatars'; $page_title = $language->get('admin', 'avatars'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Input if (Input::exists()) { @@ -85,7 +85,7 @@ ]); } -$image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'avatars', 'defaults']); +$image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'avatars', 'defaults']); $images = scandir($image_path); $template_images = []; @@ -138,7 +138,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/avatars.tpl', $smarty); diff --git a/modules/Core/pages/panel/debugging_and_maintenance.php b/modules/Core/pages/panel/debugging_and_maintenance.php index 2d483b159e..e2138754c6 100644 --- a/modules/Core/pages/panel/debugging_and_maintenance.php +++ b/modules/Core/pages/panel/debugging_and_maintenance.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.debugging')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'debugging_and_maintenance'; $page_title = $language->get('admin', 'debugging_and_maintenance'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Input if (Input::exists()) { @@ -108,7 +108,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/debugging_and_maintenance.tpl', $smarty); diff --git a/modules/Core/pages/panel/emails.php b/modules/Core/pages/panel/emails.php index a325f36672..10cd40fc9d 100644 --- a/modules/Core/pages/panel/emails.php +++ b/modules/Core/pages/panel/emails.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.emails')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'emails'; $page_title = $language->get('admin', 'emails'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Since emails are sent in the user's language, they need to be able to pick which language's messages to edit if (Session::exists('editing_language')) { @@ -261,7 +261,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/emails_errors.php b/modules/Core/pages/panel/emails_errors.php index 21b3cf4883..cf8e96490d 100644 --- a/modules/Core/pages/panel/emails_errors.php +++ b/modules/Core/pages/panel/emails_errors.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.emails')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'emails'; $page_title = $language->get('admin', 'email_errors'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (isset($_GET['do'])) { if (in_array($_GET['do'], ['delete', 'purge'])) { @@ -248,7 +248,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/emails_mass_message.php b/modules/Core/pages/panel/emails_mass_message.php index 97ab5eee70..a9441e6eb9 100644 --- a/modules/Core/pages/panel/emails_mass_message.php +++ b/modules/Core/pages/panel/emails_mass_message.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.emails_mass_message')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'emails'; $page_title = $language->get('admin', 'emails_mass_message'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Handle input if (Input::exists()) { @@ -128,7 +128,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/errors.php b/modules/Core/pages/panel/errors.php index 500edddff0..90b2a110f0 100644 --- a/modules/Core/pages/panel/errors.php +++ b/modules/Core/pages/panel/errors.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.errors')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,11 +18,11 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'debugging_and_maintenance'; $page_title = $language->get('admin', 'error_logs'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (isset($_GET['log'], $_GET['do']) && $_GET['do'] == 'purge') { if (Token::check()) { - file_put_contents(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $_GET['log'] . '-log.log']), ''); + file_put_contents(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'cache', 'logs', $_GET['log'] . '-log.log']), ''); Session::flash('error_log_success', $language->get('admin', 'log_purged_successfully')); Redirect::to(URL::build('/panel/core/errors')); } else { @@ -67,8 +67,8 @@ break; } - if (file_exists(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $_GET['log'] . '-log.log']))) { - $smarty->assign('LOG', nl2br(Output::getClean(Util::readFileEnd(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $type . '-log.log']))))); + if (file_exists(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'cache', 'logs', $_GET['log'] . '-log.log']))) { + $smarty->assign('LOG', nl2br(Output::getClean(Util::readFileEnd(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'cache', 'logs', $type . '-log.log']))))); } else { $smarty->assign('NO_LOG_FOUND', $language->get('admin', 'log_file_not_found')); } @@ -118,7 +118,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template if (!isset($_GET['log'])) { diff --git a/modules/Core/pages/panel/general_settings.php b/modules/Core/pages/panel/general_settings.php index 8e9d2545a1..8a7bde6011 100644 --- a/modules/Core/pages/panel/general_settings.php +++ b/modules/Core/pages/panel/general_settings.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.general')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'general_settings'; $page_title = $language->get('admin', 'general_settings'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Handle input if (isset($_GET['do'])) { @@ -149,7 +149,7 @@ } // Update config - if (is_writable(ROOT_PATH . '/' . implode(DIRECTORY_SEPARATOR, ['core', 'config.php']))) { + if (is_writable(Constants::ROOT_PATH . '/' . implode(DIRECTORY_SEPARATOR, ['core', 'config.php']))) { Config::setMultiple([ 'core.friendly' => $friendly, 'core.force_https' => $https, @@ -214,7 +214,7 @@ $languages = DB::getInstance()->get('languages', ['id', '<>', 0])->results(); $count = count($languages); for ($i = 0; $i < $count; $i++) { - $language_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'languages', $languages[$i]->short_code . '.json']); + $language_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'languages', $languages[$i]->short_code . '.json']); if (!file_exists($language_path)) { unset($languages[$i]); } @@ -298,7 +298,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/general_settings.tpl', $smarty); diff --git a/modules/Core/pages/panel/groups.php b/modules/Core/pages/panel/groups.php index dc63dbab2f..5e7c19fab9 100644 --- a/modules/Core/pages/panel/groups.php +++ b/modules/Core/pages/panel/groups.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.groups')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'groups'; const PANEL_PAGE = 'groups'; $page_title = $language->get('admin', 'groups'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -561,7 +561,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/hooks.php b/modules/Core/pages/panel/hooks.php index 64b8939713..bd03cb76f6 100644 --- a/modules/Core/pages/panel/hooks.php +++ b/modules/Core/pages/panel/hooks.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.hooks')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'hooks'; $page_title = $language->get('admin', 'hooks'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['action'])) { // View all hooks @@ -281,7 +281,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/images.php b/modules/Core/pages/panel/images.php index c8b3a18125..1db7413b56 100644 --- a/modules/Core/pages/panel/images.php +++ b/modules/Core/pages/panel/images.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.styles.images')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'images'; $page_title = $language->get('admin', 'images'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Reset background if (isset($_GET['action'])) { @@ -157,7 +157,7 @@ // Only display jpeg, png, jpg, gif $allowed_exts = ['gif', 'png', 'jpg', 'jpeg', 'ico']; -$image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'template_banners']); +$image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'template_banners']); $images = scandir($image_path); $template_banner_images = []; @@ -177,7 +177,7 @@ $n++; } -$image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'logos']); +$image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'logos']); $images = scandir($image_path); $logo_images = []; @@ -197,7 +197,7 @@ $n++; } -$image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'favicons']); +$image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'favicons']); $images = scandir($image_path); $favicon_images = []; @@ -217,7 +217,7 @@ $n++; } -$image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'og_images']); +$image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'og_images']); $images = scandir($image_path); $og_images = []; @@ -243,25 +243,25 @@ ])); } -if (!is_writable(ROOT_PATH . '/uploads/template_banners')) { +if (!is_writable(Constants::ROOT_PATH . '/uploads/template_banners')) { $smarty->assign('TEMPLATE_BANNERS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/template_banners') ])); } -if (!is_writable(ROOT_PATH . '/uploads/logos')) { +if (!is_writable(Constants::ROOT_PATH . '/uploads/logos')) { $smarty->assign('LOGOS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/logos') ])); } -if (!is_writable(ROOT_PATH . '/uploads/favicons')) { +if (!is_writable(Constants::ROOT_PATH . '/uploads/favicons')) { $smarty->assign('FAVICONS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/favicons') ])); } -if (!is_writable(ROOT_PATH . '/uploads/og_images')) { +if (!is_writable(Constants::ROOT_PATH . '/uploads/og_images')) { $smarty->assign('OG_IMAGES_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/og_images') ])); @@ -310,7 +310,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/images.tpl', $smarty); diff --git a/modules/Core/pages/panel/index.php b/modules/Core/pages/panel/index.php index 33fc8c7d82..59bf2d4b5a 100644 --- a/modules/Core/pages/panel/index.php +++ b/modules/Core/pages/panel/index.php @@ -10,14 +10,14 @@ */ if (!$user->handlePanelPageLoad()) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } const PAGE = 'panel'; const PANEL_PAGE = 'dashboard'; $page_title = $language->get('admin', 'dashboard'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -217,12 +217,12 @@ ]); } -if (is_dir(ROOT_PATH . '/modules/Core/pages/admin')) { +if (is_dir(Constants::ROOT_PATH . '/modules/Core/pages/admin')) { $smarty->assign([ 'DIRECTORY_WARNING' => $language->get('admin', 'admin_dir_still_exists') ]); } else { - if (is_dir(ROOT_PATH . '/modules/Core/pages/mod')) { + if (is_dir(Constants::ROOT_PATH . '/modules/Core/pages/mod')) { $smarty->assign([ 'DIRECTORY_WARNING' => $language->get('admin', 'mod_dir_still_exists') ]); @@ -252,7 +252,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('index.tpl', $smarty); diff --git a/modules/Core/pages/panel/integrations.php b/modules/Core/pages/panel/integrations.php index 18a9bba97e..814da3f6ff 100644 --- a/modules/Core/pages/panel/integrations.php +++ b/modules/Core/pages/panel/integrations.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.integrations.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PANEL_PAGE = 'integrations'; const EDITING_USER = true; $page_title = $language->get('admin', 'integrations'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); $integrations = Integrations::getInstance(); @@ -134,7 +134,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/minecraft.php b/modules/Core/pages/panel/minecraft.php index 9d90d884fe..5ecf14ef8f 100644 --- a/modules/Core/pages/panel/minecraft.php +++ b/modules/Core/pages/panel/minecraft.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.minecraft')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'integrations'; const PANEL_PAGE = 'minecraft'; $page_title = $language->get('admin', 'minecraft'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (Input::exists()) { // Check token @@ -111,7 +111,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('integrations/minecraft/minecraft.tpl', $smarty); diff --git a/modules/Core/pages/panel/minecraft_authme.php b/modules/Core/pages/panel/minecraft_authme.php index 46e0a9f113..c17b71e1e7 100644 --- a/modules/Core/pages/panel/minecraft_authme.php +++ b/modules/Core/pages/panel/minecraft_authme.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.minecraft.authme')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'authme'; $page_title = $language->get('admin', 'authme_integration'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Handle input if (Input::exists()) { @@ -144,7 +144,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('integrations/minecraft/minecraft_authme.tpl', $smarty); diff --git a/modules/Core/pages/panel/minecraft_query_errors.php b/modules/Core/pages/panel/minecraft_query_errors.php index 5a67691198..55ca68ebec 100644 --- a/modules/Core/pages/panel/minecraft_query_errors.php +++ b/modules/Core/pages/panel/minecraft_query_errors.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.minecraft.query_errors')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'query_errors'; $page_title = $language->get('admin', 'query_errors'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['id'])) { if (isset($_GET['action']) && $_GET['action'] == 'purge') { @@ -166,7 +166,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/minecraft_server_banners.php b/modules/Core/pages/panel/minecraft_server_banners.php index 4464a439c6..a425b4a2ff 100644 --- a/modules/Core/pages/panel/minecraft_server_banners.php +++ b/modules/Core/pages/panel/minecraft_server_banners.php @@ -10,12 +10,12 @@ */ if (!$user->handlePanelPageLoad('admincp.minecraft.banners')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } if (!function_exists('exif_imagetype')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -24,7 +24,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'server_banners'; $page_title = $language->get('admin', 'server_banners'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['server']) && !isset($_GET['edit'])) { $servers = DB::getInstance()->get('mc_servers', ['id', '<>', 0])->results(); @@ -84,7 +84,7 @@ if (Token::check()) { // Valid token try { - if (file_exists(ROOT_PATH . '/uploads/banners/' . Input::get('banner'))) { + if (file_exists(Constants::ROOT_PATH . '/uploads/banners/' . Input::get('banner'))) { DB::getInstance()->update('mc_servers', $_GET['edit'], [ 'banner_background' => Output::getClean(Input::get('banner')) ]); @@ -107,7 +107,7 @@ $server = $server[0]; - $image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'banners']); + $image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'banners']); $images = scandir($image_path); $template_images = []; @@ -173,7 +173,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/minecraft_servers.php b/modules/Core/pages/panel/minecraft_servers.php index 8fee81154a..105bd3156e 100644 --- a/modules/Core/pages/panel/minecraft_servers.php +++ b/modules/Core/pages/panel/minecraft_servers.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.minecraft.servers')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'servers'; $page_title = $language->get('admin', 'minecraft_servers'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (isset($_GET['action'])) { switch ($_GET['action']) { @@ -671,7 +671,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/modules.php b/modules/Core/pages/panel/modules.php index 7a6c6678bb..6fdf1b4a90 100644 --- a/modules/Core/pages/panel/modules.php +++ b/modules/Core/pages/panel/modules.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.modules')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'modules'; const PANEL_PAGE = 'modules'; $page_title = $language->get('admin', 'modules'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -42,12 +42,12 @@ } if (!$exists) { - if (!file_exists(ROOT_PATH . '/modules/' . $item->name . '/init.php')) { + if (!file_exists(Constants::ROOT_PATH . '/modules/' . $item->name . '/init.php')) { continue; } try { - require_once ROOT_PATH . '/modules/' . $item->name . '/init.php'; + require_once Constants::ROOT_PATH . '/modules/' . $item->name . '/init.php'; } catch (Exception $e) { $term = 'unable_to_load_module'; @@ -171,13 +171,13 @@ $name = Output::getClean($name[0]->name); // Ensure module is valid - if (!file_exists(ROOT_PATH . '/modules/' . $name . '/init.php')) { + if (!file_exists(Constants::ROOT_PATH . '/modules/' . $name . '/init.php')) { Redirect::to(URL::build('/panel/modules')); } $module = null; - require_once(ROOT_PATH . '/modules/' . $name . '/init.php'); + require_once(Constants::ROOT_PATH . '/modules/' . $name . '/init.php'); /** @phpstan-ignore-next-line */ if ($module instanceof Module) { @@ -272,8 +272,8 @@ // Store $cache->store('enabled_modules', $modules); - if (file_exists(ROOT_PATH . '/modules/' . $name . '/init.php')) { - require_once(ROOT_PATH . '/modules/' . $name . '/init.php'); + if (file_exists(Constants::ROOT_PATH . '/modules/' . $name . '/init.php')) { + require_once(Constants::ROOT_PATH . '/modules/' . $name . '/init.php'); $module->onDisable(); } @@ -289,7 +289,7 @@ if ($_GET['action'] == 'install') { if (Token::check()) { // Install any new modules - $directories = glob(ROOT_PATH . '/modules/*', GLOB_ONLYDIR); + $directories = glob(Constants::ROOT_PATH . '/modules/*', GLOB_ONLYDIR); define('MODULE_INSTALL', true); $errors = []; @@ -297,14 +297,14 @@ foreach ($directories as $directory) { $folders = explode('/', $directory); - if (file_exists(ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php')) { + if (file_exists(Constants::ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php')) { $exists = DB::getInstance()->get('modules', ['name', $folders[count($folders) - 1]])->results(); if (!count($exists)) { $module = null; try { - require_once(ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php'); + require_once(Constants::ROOT_PATH . '/modules/' . $folders[count($folders) - 1] . '/init.php'); /** @phpstan-ignore-next-line */ if ($module instanceof Module) { @@ -380,7 +380,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/modules.tpl', $smarty); diff --git a/modules/Core/pages/panel/navigation.php b/modules/Core/pages/panel/navigation.php index 5bbe3b8a45..54ccd4cbfd 100644 --- a/modules/Core/pages/panel/navigation.php +++ b/modules/Core/pages/panel/navigation.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.navigation')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'navigation'; $page_title = $language->get('admin', 'navigation'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Deal with input if (Input::exists()) { @@ -105,7 +105,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/navigation.tpl', $smarty); diff --git a/modules/Core/pages/panel/pages.php b/modules/Core/pages/panel/pages.php index a52b39e50f..dc0f4fa06b 100644 --- a/modules/Core/pages/panel/pages.php +++ b/modules/Core/pages/panel/pages.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.pages')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'pages'; const PANEL_PAGE = 'custom_pages'; $page_title = $language->get('admin', 'custom_pages'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -601,7 +601,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/panel_templates.php b/modules/Core/pages/panel/panel_templates.php index 69c3ffa6fb..caeedc99b6 100644 --- a/modules/Core/pages/panel/panel_templates.php +++ b/modules/Core/pages/panel/panel_templates.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.styles.panel_templates')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'panel_templates'; $page_title = $language->get('admin', 'panel_templates'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['action'])) { // Get all templates @@ -32,7 +32,7 @@ $templates_template = []; foreach ($templates as $item) { - $template_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'panel_templates', Output::getClean($item->name), 'template.php']); + $template_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'panel_templates', Output::getClean($item->name), 'template.php']); if (file_exists($template_path)) { require($template_path); @@ -95,15 +95,15 @@ if (Token::check()) { // Install new template // Scan template directory for new templates - $directories = glob(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); + $directories = glob(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); foreach ($directories as $directory) { $folders = explode(DIRECTORY_SEPARATOR, $directory); // Is it already in the database? $exists = DB::getInstance()->get('panel_templates', ['name', $folders[count($folders) - 1]])->results(); - if (!count($exists) && file_exists(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php')) { + if (!count($exists) && file_exists(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php')) { $template = null; - require_once(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php'); + require_once(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php'); /** @phpstan-ignore-next-line */ if ($template instanceof TemplateBase) { @@ -133,11 +133,11 @@ } $name = str_replace(['../', '/', '..'], '', $template[0]->name); - if (file_exists(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php')) { + if (file_exists(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php')) { $id = $template[0]->id; $template = null; - require(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php'); + require(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'panel_templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php'); /** @phpstan-ignore-next-line */ if ($template instanceof TemplateBase) { @@ -207,7 +207,7 @@ Redirect::to(URL::build('/panel/core/panel_templates')); } - if (!Util::recursiveRemoveDirectory(ROOT_PATH . '/custom/panel_templates/' . $item)) { + if (!Util::recursiveRemoveDirectory(Constants::ROOT_PATH . '/custom/panel_templates/' . $item)) { Session::flash('admin_templates_error', $language->get('admin', 'unable_to_delete_template')); } else { Session::flash('admin_templates', $language->get('admin', 'template_deleted_successfully')); @@ -316,7 +316,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/placeholders.php b/modules/Core/pages/panel/placeholders.php index 549eb25bbf..c80e993f44 100644 --- a/modules/Core/pages/panel/placeholders.php +++ b/modules/Core/pages/panel/placeholders.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.placeholders')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'placeholders'; $page_title = $language->get('admin', 'placeholders'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); $all_placeholders = Placeholders::getInstance()->getAllPlaceholders(); @@ -190,7 +190,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/privacy_and_terms.php b/modules/Core/pages/panel/privacy_and_terms.php index 339815f643..15222e1207 100644 --- a/modules/Core/pages/panel/privacy_and_terms.php +++ b/modules/Core/pages/panel/privacy_and_terms.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.terms')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'privacy_and_terms'; $page_title = $language->get('admin', 'privacy_and_terms'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (Input::exists()) { $errors = []; @@ -128,7 +128,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/privacy_and_terms.tpl', $smarty); diff --git a/modules/Core/pages/panel/profile_fields.php b/modules/Core/pages/panel/profile_fields.php index 39df867ba6..7ff28fb333 100644 --- a/modules/Core/pages/panel/profile_fields.php +++ b/modules/Core/pages/panel/profile_fields.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.fields')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'custom_profile_fields'; $page_title = $language->get('admin', 'custom_fields'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -336,7 +336,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/reactions.php b/modules/Core/pages/panel/reactions.php index da4fed8c3d..b7e928640c 100644 --- a/modules/Core/pages/panel/reactions.php +++ b/modules/Core/pages/panel/reactions.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.reactions')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'reactions'; $page_title = $language->get('user', 'reactions'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -328,7 +328,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/registration.php b/modules/Core/pages/panel/registration.php index f96268e278..6aa34d3b1f 100644 --- a/modules/Core/pages/panel/registration.php +++ b/modules/Core/pages/panel/registration.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.registration')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'registration'; $page_title = $language->get('admin', 'registration'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Deal with input if (Input::exists()) { @@ -82,7 +82,7 @@ // Config value if (Input::get('enable_recaptcha') == 1 || Input::get('enable_recaptcha_login') == 1) { - if (is_writable(ROOT_PATH . '/' . implode(DIRECTORY_SEPARATOR, ['core', 'config.php']))) { + if (is_writable(Constants::ROOT_PATH . '/' . implode(DIRECTORY_SEPARATOR, ['core', 'config.php']))) { Config::set('core.captcha', true); } else { $errors = [$language->get('admin', 'config_not_writable')]; @@ -211,7 +211,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/registration.tpl', $smarty); diff --git a/modules/Core/pages/panel/security.php b/modules/Core/pages/panel/security.php index b04f0a5bb9..5f7f349990 100644 --- a/modules/Core/pages/panel/security.php +++ b/modules/Core/pages/panel/security.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.security')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -20,7 +20,7 @@ // Define the sort column #, as for group_sync we dont show IP (since its from MC server or Discord bot) define('SORT', (isset($_GET['view']) && $_GET['view'] == 'group_sync') ? 1 : 2); $page_title = $language->get('admin', 'security'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['view'])) { $links = []; @@ -332,7 +332,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/seo.php b/modules/Core/pages/panel/seo.php index c1ce85f59b..ebc2a3fae8 100644 --- a/modules/Core/pages/panel/seo.php +++ b/modules/Core/pages/panel/seo.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.seo')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'seo'; $page_title = $language->get('admin', 'seo'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); $timeago = new TimeAgo(TIMEZONE); @@ -26,12 +26,12 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); $errors = []; -if (!is_dir(ROOT_PATH . '/cache/sitemaps')) { - if (!is_writable(ROOT_PATH . '/cache')) { +if (!is_dir(Constants::ROOT_PATH . '/cache/sitemaps')) { + if (!is_writable(Constants::ROOT_PATH . '/cache')) { $errors[] = $language->get('admin', 'cache_not_writable'); } else { - mkdir(ROOT_PATH . '/cache/sitemaps'); - file_put_contents(ROOT_PATH . '/cache/sitemaps/.htaccess', 'Allow from all'); + mkdir(Constants::ROOT_PATH . '/cache/sitemaps'); + file_put_contents(Constants::ROOT_PATH . '/cache/sitemaps/.htaccess', 'Allow from all'); } } @@ -42,7 +42,7 @@ if (Input::get('type') == 'sitemap') { $sitemap = new \SitemapPHP\Sitemap(rtrim(URL::getSelfURL(), '/')); - $sitemap->setPath(ROOT_PATH . '/cache/sitemaps/'); + $sitemap->setPath(Constants::ROOT_PATH . '/cache/sitemaps/'); $methods = $pages->getSitemapMethods(); foreach ($methods as $method) { @@ -71,10 +71,10 @@ } } - if (!is_writable(ROOT_PATH . '/cache/sitemaps')) { + if (!is_writable(Constants::ROOT_PATH . '/cache/sitemaps')) { $errors[] = $language->get('admin', 'sitemap_not_writable'); } else { - if (file_exists(ROOT_PATH . '/cache/sitemaps/sitemap-index.xml')) { + if (file_exists(Constants::ROOT_PATH . '/cache/sitemaps/sitemap-index.xml')) { $cache->setCache('sitemap_cache'); if ($cache->isCached('updated')) { $updated = $cache->retrieve('updated'); @@ -239,7 +239,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/social_media.php b/modules/Core/pages/panel/social_media.php index c4d16111b3..880a13114b 100644 --- a/modules/Core/pages/panel/social_media.php +++ b/modules/Core/pages/panel/social_media.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.core.social_media')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'social_media'; $page_title = $language->get('admin', 'social_media'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Deal with input if (Input::exists()) { @@ -99,7 +99,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/social_media.tpl', $smarty); diff --git a/modules/Core/pages/panel/templates.php b/modules/Core/pages/panel/templates.php index 36c0265c0e..1d2c81bf90 100644 --- a/modules/Core/pages/panel/templates.php +++ b/modules/Core/pages/panel/templates.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.styles.templates')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'template'; $page_title = $language->get('admin', 'templates'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['action'])) { // Get all templates @@ -42,7 +42,7 @@ $loaded_templates[] = $item->name; - $template_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($item->name), 'template.php']); + $template_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($item->name), 'template.php']); if (file_exists($template_path)) { require($template_path); @@ -158,15 +158,15 @@ if (Token::check()) { // Install new template // Scan template directory for new templates - $directories = glob(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); + $directories = glob(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); foreach ($directories as $directory) { $folders = explode(DIRECTORY_SEPARATOR, $directory); // Is it already in the database? $exists = DB::getInstance()->get('templates', ['name', $folders[count($folders) - 1]])->results(); - if (!count($exists) && file_exists(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php')) { + if (!count($exists) && file_exists(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php')) { $template = null; - require_once(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php'); + require_once(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $folders[count($folders) - 1]) . DIRECTORY_SEPARATOR . 'template.php'); /** @phpstan-ignore-next-line */ if ($template instanceof TemplateBase) { @@ -196,10 +196,10 @@ } $name = str_replace(['../', '/', '..'], '', $template[0]->name); - if (file_exists(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php')) { + if (file_exists(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php')) { $id = $template[0]->id; $template = null; - require_once(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php'); + require_once(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'template.php'); /** @phpstan-ignore-next-line */ if ($template instanceof TemplateBase) { @@ -268,7 +268,7 @@ Redirect::to(URL::build('/panel/core/templates')); } - if (!Util::recursiveRemoveDirectory(ROOT_PATH . '/custom/templates/' . $item)) { + if (!Util::recursiveRemoveDirectory(Constants::ROOT_PATH . '/custom/templates/' . $item)) { Session::flash('admin_templates_error', $language->get('admin', 'unable_to_delete_template')); } else { Session::flash('admin_templates', $language->get('admin', 'template_deleted_successfully')); @@ -341,7 +341,7 @@ Redirect::to(URL::build('/panel/core/templates')); } - require_once(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $template_query->name) . DIRECTORY_SEPARATOR . 'template.php'); + require_once(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $template_query->name) . DIRECTORY_SEPARATOR . 'template.php'); if ($template instanceof TemplateBase) { if ($template->getSettings()) { @@ -511,7 +511,7 @@ if (!isset($_GET['file']) && !isset($_GET['dir'])) { // Get all files // Build path to template folder - $template_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name)]); + $template_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name)]); $files = scandir($template_path); $template_files = []; @@ -548,14 +548,14 @@ } else { if (isset($_GET['dir']) && !isset($_GET['file'])) { // List files in dir - $realdir = realpath(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), Output::getClean($_GET['dir'])])); + $realdir = realpath(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), Output::getClean($_GET['dir'])])); $dir = ltrim(explode('custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template_query->name, $realdir)[1], '/'); - if (!is_dir(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir]))) { + if (!is_dir(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir]))) { Redirect::to(URL::build('/panel/core/templates')); } - $template_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir]); + $template_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir]); $files = scandir($template_path); $template_files = []; @@ -601,19 +601,19 @@ $template_file = 'core/templates_list_files.tpl'; } else { if (isset($_GET['file'])) { - $file = basename(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), Output::getClean($_GET['file'])])); + $file = basename(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), Output::getClean($_GET['file'])])); if (isset($_GET['dir'])) { - $realdir = realpath(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), Output::getClean($_GET['dir'])])); + $realdir = realpath(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), Output::getClean($_GET['dir'])])); $dir = ltrim(explode('custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template_query->name, $realdir)[1], '/'); - if (!is_dir(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir]))) { + if (!is_dir(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir]))) { Redirect::to(URL::build('/panel/core/templates')); } - $file_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir, $file]); + $file_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $dir, $file]); } else { - $file_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $file]); + $file_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), $file]); } $file_type = null; @@ -748,7 +748,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/update.php b/modules/Core/pages/panel/update.php index c32bd5e2cd..cad654c593 100644 --- a/modules/Core/pages/panel/update.php +++ b/modules/Core/pages/panel/update.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.update')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -27,7 +27,7 @@ const PARENT_PAGE = 'update'; const PANEL_PAGE = 'update'; $page_title = $language->get('admin', 'update'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -97,7 +97,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/update.tpl', $smarty); diff --git a/modules/Core/pages/panel/upgrade.php b/modules/Core/pages/panel/upgrade.php index adff3fbaf8..7c1fbee14a 100644 --- a/modules/Core/pages/panel/upgrade.php +++ b/modules/Core/pages/panel/upgrade.php @@ -16,7 +16,7 @@ Redirect::to(URL::build('/panel/update')); } -$cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']); +$cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => Constants::ROOT_PATH . '/cache/']); $version = DB::getInstance()->query('SELECT `value` FROM nl2_settings WHERE `name` = \'nameless_version\'')->first(); diff --git a/modules/Core/pages/panel/user.php b/modules/Core/pages/panel/user.php index 567c2a510b..ccfb6cb7db 100644 --- a/modules/Core/pages/panel/user.php +++ b/modules/Core/pages/panel/user.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad()) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -39,7 +39,7 @@ const PANEL_PAGE = 'users'; const PARENT_PAGE = 'users'; $page_title = Output::getClean($user_query->username); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -119,7 +119,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/user.tpl', $smarty); diff --git a/modules/Core/pages/panel/users.php b/modules/Core/pages/panel/users.php index 50e79883c0..27acd533ec 100644 --- a/modules/Core/pages/panel/users.php +++ b/modules/Core/pages/panel/users.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.users')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'users'; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -65,7 +65,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/users.tpl', $smarty); diff --git a/modules/Core/pages/panel/users_edit.php b/modules/Core/pages/panel/users_edit.php index 73dffa77d0..0d607d3e73 100644 --- a/modules/Core/pages/panel/users_edit.php +++ b/modules/Core/pages/panel/users_edit.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.users.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -29,7 +29,7 @@ const PANEL_PAGE = 'users'; const EDITING_USER = true; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -52,7 +52,7 @@ } } } else if ($_GET['action'] == 'resend_email' && $user_query->active == 0) { - require_once(ROOT_PATH . '/modules/Core/includes/emails/register.php'); + require_once(Constants::ROOT_PATH . '/modules/Core/includes/emails/register.php'); if (sendRegisterEmail($language, $user_query->email, $user_query->username, $user_query->id, $user_query->reset_code)) { Session::flash('edit_user_success', $language->get('admin', 'email_resent_successfully')); } else { @@ -426,7 +426,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/users_edit.tpl', $smarty); diff --git a/modules/Core/pages/panel/users_integrations.php b/modules/Core/pages/panel/users_integrations.php index 506fba600d..70fad564e8 100644 --- a/modules/Core/pages/panel/users_integrations.php +++ b/modules/Core/pages/panel/users_integrations.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.users.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PANEL_PAGE = 'users'; const EDITING_USER = true; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { Redirect::to(URL::build('/panel/users')); @@ -270,7 +270,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/users_ip_lookup.php b/modules/Core/pages/panel/users_ip_lookup.php index be7d5963d4..423358ae86 100644 --- a/modules/Core/pages/panel/users_ip_lookup.php +++ b/modules/Core/pages/panel/users_ip_lookup.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('modcp.ip_lookup')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'ip_lookup'; $page_title = $language->get('moderator', 'ip_lookup'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -172,7 +172,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/users_oauth.php b/modules/Core/pages/panel/users_oauth.php index b50717083e..50b5d18af8 100644 --- a/modules/Core/pages/panel/users_oauth.php +++ b/modules/Core/pages/panel/users_oauth.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.users.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PANEL_PAGE = 'users'; const EDITING_USER = true; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (isset($_GET['action']) && $_GET['action'] === 'delete') { if (Input::exists()) { @@ -93,7 +93,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('core/users_oauth.tpl', $smarty); diff --git a/modules/Core/pages/panel/users_punishments.php b/modules/Core/pages/panel/users_punishments.php index 392f387688..e85806b093 100644 --- a/modules/Core/pages/panel/users_punishments.php +++ b/modules/Core/pages/panel/users_punishments.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('modcp.punishments')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -20,7 +20,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'punishments'; $page_title = $language->get('moderator', 'punishments'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -195,7 +195,7 @@ // Need to delete any other avatars $to_remove = []; foreach (['jpg', 'jpeg', 'png', 'gif'] as $extension) { - $to_remove += glob(ROOT_PATH . '/uploads/avatars/' . $query->id . '.' . $extension); + $to_remove += glob(Constants::ROOT_PATH . '/uploads/avatars/' . $query->id . '.' . $extension); } foreach ($to_remove as $item) { @@ -511,7 +511,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/users_reports.php b/modules/Core/pages/panel/users_reports.php index f52fe06513..dd08f2a3f3 100644 --- a/modules/Core/pages/panel/users_reports.php +++ b/modules/Core/pages/panel/users_reports.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('modcp.reports')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'reports'; $page_title = $language->get('moderator', 'reports'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); $timeago = new TimeAgo(TIMEZONE); @@ -415,7 +415,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/panel/widgets.php b/modules/Core/pages/panel/widgets.php index eab79f60d3..20f054b27f 100644 --- a/modules/Core/pages/panel/widgets.php +++ b/modules/Core/pages/panel/widgets.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.widgets')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'widgets'; $page_title = $language->get('admin', 'widgets'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -296,7 +296,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Core/pages/portal.php b/modules/Core/pages/portal.php index f44ba2821b..2c2417c071 100644 --- a/modules/Core/pages/portal.php +++ b/modules/Core/pages/portal.php @@ -12,15 +12,15 @@ // Always define page name const PAGE = 'portal'; $page_title = $language->get('general', 'home'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // 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'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); $smarty->assign([ 'GENERAL_SETTINGS_URL' => URL::build('/panel/core/general_settings'), diff --git a/modules/Core/pages/privacy.php b/modules/Core/pages/privacy.php index 2cb027762a..56bc8507dc 100644 --- a/modules/Core/pages/privacy.php +++ b/modules/Core/pages/privacy.php @@ -12,7 +12,7 @@ // Always define page name const PAGE = 'privacy'; $page_title = $language->get('general', 'privacy_policy'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Retrieve privacy policy from database $policy = DB::getInstance()->get('privacy_terms', ['name', 'privacy'])->results(); @@ -32,8 +32,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('privacy.tpl', $smarty); diff --git a/modules/Core/pages/profile.php b/modules/Core/pages/profile.php index c21ee73726..af48e92dad 100644 --- a/modules/Core/pages/profile.php +++ b/modules/Core/pages/profile.php @@ -30,7 +30,7 @@ $page_title = $language->get('user', 'profile'); } -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $template->assets()->include([ DARK_MODE @@ -65,10 +65,10 @@ // Update banner if (isset($_POST['banner'])) { // Check image specified actually exists - if (is_file(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'profile_images', $_POST['banner']]))) { + if (is_file(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'profile_images', $_POST['banner']]))) { // Exists // Is it an image file? - if (in_array(pathinfo(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'profile_images', $_POST['banner']]), PATHINFO_EXTENSION), ['gif', 'png', 'jpg', 'jpeg'])) { + if (in_array(pathinfo(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'profile_images', $_POST['banner']]), PATHINFO_EXTENSION), ['gif', 'png', 'jpg', 'jpeg'])) { // Yes, update settings $user->update( [ @@ -505,7 +505,7 @@ // Custom profile banners $banners = []; - $image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'profile_images']); + $image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'profile_images']); $images = scandir($image_path); // Only display jpeg, png, jpg, gif @@ -524,7 +524,7 @@ ]; } - $image_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'profile_images', $user->data()->id]); + $image_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'profile_images', $user->data()->id]); if (is_dir($image_path)) { $images = scandir($image_path); @@ -862,8 +862,8 @@ $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('profile.tpl', $smarty); @@ -883,8 +883,8 @@ $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user_not_exist.tpl', $smarty); diff --git a/modules/Core/pages/register.php b/modules/Core/pages/register.php index 547b39170c..685f9a5980 100644 --- a/modules/Core/pages/register.php +++ b/modules/Core/pages/register.php @@ -19,8 +19,8 @@ const PAGE = 'register'; $page_title = $language->get('general', 'register'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); -require_once(ROOT_PATH . '/modules/Core/includes/emails/register.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/modules/Core/includes/emails/register.php'); // Check if registration is enabled if (!Util::getSetting('registration_enabled')) { @@ -39,8 +39,8 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('registration_disabled.tpl', $smarty); @@ -54,7 +54,7 @@ if ($authme_enabled == 1) { // Authme connector - require(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', 'Core', 'pages', 'authme_connector.php'])); + require(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'modules', 'Core', 'pages', 'authme_connector.php'])); die(); } } @@ -451,8 +451,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('register.tpl', $smarty); diff --git a/modules/Core/pages/status.php b/modules/Core/pages/status.php index 2d6d6e98de..2cf0fb0a87 100644 --- a/modules/Core/pages/status.php +++ b/modules/Core/pages/status.php @@ -10,13 +10,13 @@ */ if (!Util::getSetting('mc_integration') || !Util::getSetting('status_page')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } const PAGE = 'status'; $page_title = $language->get('general', 'status'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $servers = DB::getInstance()->orderWhere('mc_servers', 'display = 1', '`order`', 'ASC')->results(); @@ -38,8 +38,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('status.tpl', $smarty); diff --git a/modules/Core/pages/terms.php b/modules/Core/pages/terms.php index 5d22814e03..ce29932c3c 100644 --- a/modules/Core/pages/terms.php +++ b/modules/Core/pages/terms.php @@ -12,7 +12,7 @@ // Always define page name const PAGE = 'terms'; $page_title = $language->get('user', 'terms_and_conditions'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Retrieve terms from database $site_terms = DB::getInstance()->get('privacy_terms', ['name', 'terms'])->results(); @@ -36,8 +36,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('terms.tpl', $smarty); diff --git a/modules/Core/pages/user/alerts.php b/modules/Core/pages/user/alerts.php index 617263cbc6..3c681d3b56 100644 --- a/modules/Core/pages/user/alerts.php +++ b/modules/Core/pages/user/alerts.php @@ -17,7 +17,7 @@ // Always define page name for navbar const PAGE = 'cc_alerts'; $page_title = $language->get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $timeago = new TimeAgo(TIMEZONE); @@ -66,12 +66,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/alerts.tpl', $smarty); diff --git a/modules/Core/pages/user/connections.php b/modules/Core/pages/user/connections.php index 6af0b5d4d8..82603eec18 100644 --- a/modules/Core/pages/user/connections.php +++ b/modules/Core/pages/user/connections.php @@ -17,7 +17,7 @@ // Always define page name for navbar const PAGE = 'cc_connections'; $page_title = $language->get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); if (Input::exists()) { if (Token::check()) { @@ -124,12 +124,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/connections.tpl', $smarty); diff --git a/modules/Core/pages/user/index.php b/modules/Core/pages/user/index.php index 398d20cab5..9edbd9b2c2 100644 --- a/modules/Core/pages/user/index.php +++ b/modules/Core/pages/user/index.php @@ -17,7 +17,7 @@ // Always define page name for navbar const PAGE = 'cc_overview'; $page_title = $language->get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $user_details = [ $language->get('user', 'username') => $user->getDisplayname(true), @@ -178,12 +178,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/index.tpl', $smarty); diff --git a/modules/Core/pages/user/messaging.php b/modules/Core/pages/user/messaging.php index d5555e6d2c..6fd42d108d 100644 --- a/modules/Core/pages/user/messaging.php +++ b/modules/Core/pages/user/messaging.php @@ -17,7 +17,7 @@ // Always define page name for navbar const PAGE = 'cc_messaging'; $page_title = $language->get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $timeago = new TimeAgo(TIMEZONE); @@ -116,12 +116,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/messaging.tpl', $smarty); @@ -325,12 +325,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/new_message.tpl', $smarty); @@ -496,12 +496,12 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/view_message.tpl', $smarty); diff --git a/modules/Core/pages/user/oauth.php b/modules/Core/pages/user/oauth.php index 918b852691..69aa047bac 100644 --- a/modules/Core/pages/user/oauth.php +++ b/modules/Core/pages/user/oauth.php @@ -18,7 +18,7 @@ // Always define page name for navbar const PAGE = 'cc_oauth'; $page_title = $language->get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); if (Input::exists()) { if (Token::check()) { @@ -84,12 +84,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/oauth.tpl', $smarty); diff --git a/modules/Core/pages/user/placeholders.php b/modules/Core/pages/user/placeholders.php index 9a5f099ffd..83ddc5f338 100644 --- a/modules/Core/pages/user/placeholders.php +++ b/modules/Core/pages/user/placeholders.php @@ -16,14 +16,14 @@ // Placeholders enabled? if (Util::getSetting('placeholders') !== '1') { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } // Always define page name for navbar const PAGE = 'cc_placeholders'; $page_title = $language->get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $timeago = new TimeAgo(TIMEZONE); @@ -56,12 +56,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/placeholders.tpl', $smarty); diff --git a/modules/Core/pages/user/settings.php b/modules/Core/pages/user/settings.php index 2492869afe..acfb397e12 100644 --- a/modules/Core/pages/user/settings.php +++ b/modules/Core/pages/user/settings.php @@ -17,7 +17,7 @@ // Always define page name for navbar const PAGE = 'cc_settings'; $page_title = $language->get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Forum enabled? $forum_enabled = Util::isModuleEnabled('Forum'); @@ -106,10 +106,10 @@ ]); } Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); $template->displayTemplate('user/tfa.tpl', $smarty); } else { @@ -666,12 +666,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('user/settings.tpl', $smarty); diff --git a/modules/Core/pages/validate.php b/modules/Core/pages/validate.php index daec351135..54c2c35a29 100644 --- a/modules/Core/pages/validate.php +++ b/modules/Core/pages/validate.php @@ -12,7 +12,7 @@ $page = 'validate'; const PAGE = 'validate'; $page_title = $language->get('general', 'register'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); diff --git a/modules/Core/queries/debug_link.php b/modules/Core/queries/debug_link.php index 4d590a8221..d665916cc6 100755 --- a/modules/Core/queries/debug_link.php +++ b/modules/Core/queries/debug_link.php @@ -2,7 +2,7 @@ // Can user generate the debug link? if (!defined('DEBUGGING') && !$user->hasPermission('admincp.core.debugging')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -25,11 +25,11 @@ } if (!$exists) { - if (!file_exists(ROOT_PATH . '/modules/' . $item->name . '/init.php')) { + if (!file_exists(Constants::ROOT_PATH . '/modules/' . $item->name . '/init.php')) { continue; } - require_once(ROOT_PATH . '/modules/' . $item->name . '/init.php'); + require_once(Constants::ROOT_PATH . '/modules/' . $item->name . '/init.php'); } $namelessmc_modules[$module->getName()] = [ @@ -44,7 +44,7 @@ $templates_query = DB::getInstance()->get('templates', ['id', '<>', 0])->results(); foreach ($templates_query as $fe_template) { - $template_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($fe_template->name), 'template.php']); + $template_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', Output::getClean($fe_template->name), 'template.php']); if (file_exists($template_path)) { require_once($template_path); @@ -63,7 +63,7 @@ $panel_templates_query = DB::getInstance()->get('panel_templates', ['id', '<>', 0])->results(); foreach ($panel_templates_query as $panel_template) { - $template_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'panel_templates', Output::getClean($panel_template->name), 'template.php']); + $template_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'panel_templates', Output::getClean($panel_template->name), 'template.php']); if (file_exists($template_path)) { require_once($template_path); @@ -175,7 +175,7 @@ $logs = []; foreach (['fatal', 'warning', 'notice', 'other', 'custom'] as $type) { - $file_path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $type . '-log.log']); + $file_path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'cache', 'logs', $type . '-log.log']); $logs[$type] = file_exists($file_path) ? Util::readFileEnd($file_path, $max_bytes = 10_000) : ''; } @@ -258,8 +258,8 @@ 'disk_free_space' => disk_free_space('./'), 'memory_total_space' => ini_get('memory_limit'), 'memory_used_space' => memory_get_usage(), - 'config_writable' => is_writable(ROOT_PATH . '/core/config.php'), - 'cache_writable' => is_writable(ROOT_PATH . '/cache'), + 'config_writable' => is_writable(Constants::ROOT_PATH . '/core/config.php'), + 'cache_writable' => is_writable(Constants::ROOT_PATH . '/cache'), ], ]; diff --git a/modules/Core/queries/tinymce_image_upload.php b/modules/Core/queries/tinymce_image_upload.php index ac68eb0053..d64bb0b13d 100644 --- a/modules/Core/queries/tinymce_image_upload.php +++ b/modules/Core/queries/tinymce_image_upload.php @@ -11,7 +11,7 @@ } $image = (new \Bulletproof\Image($_FILES)) - ->setLocation(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'uploads', 'post_images'])) + ->setLocation(implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'uploads', 'post_images'])) ->setSize(10, 10000000 /* 10MB */) ->setDimension(10000, 10000) ->setName($user->data()->id . '-' . time()); diff --git a/modules/Core/queries/user.php b/modules/Core/queries/user.php index 2297450296..09d3b9ffb8 100644 --- a/modules/Core/queries/user.php +++ b/modules/Core/queries/user.php @@ -6,7 +6,7 @@ const PAGE = 'user_query'; $page_title = 'user_query'; -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); if (!is_numeric($_GET['id'])) { // Username diff --git a/modules/Core/widgets/OnlineUsersWidget.php b/modules/Core/widgets/OnlineUsersWidget.php index 1b353f8f20..b51f77b134 100644 --- a/modules/Core/widgets/OnlineUsersWidget.php +++ b/modules/Core/widgets/OnlineUsersWidget.php @@ -30,7 +30,7 @@ public function __construct(Cache $cache, Smarty $smarty, Language $language) { $this->_name = 'Online Users'; $this->_location = $widget_query->location; $this->_description = 'Displays a list of online users on your website.'; - $this->_settings = ROOT_PATH . '/modules/Core/includes/admin_widgets/online_users.php'; + $this->_settings = Constants::ROOT_PATH . '/modules/Core/includes/admin_widgets/online_users.php'; $this->_order = $widget_query->order; } diff --git a/modules/Discord Integration/classes/Discord.php b/modules/Discord Integration/classes/Discord.php index e192e88bc3..2be6b46314 100644 --- a/modules/Discord Integration/classes/Discord.php +++ b/modules/Discord Integration/classes/Discord.php @@ -155,7 +155,7 @@ public static function botRequest(string $url, ?string $body = null) { */ public static function getLanguageTerm(string $term, array $variables = []): string { if (!isset(self::$_discord_integration_language)) { - self::$_discord_integration_language = new Language(ROOT_PATH . '/modules/Discord Integration/language'); + self::$_discord_integration_language = new Language(Constants::ROOT_PATH . '/modules/Discord Integration/language'); } return self::$_discord_integration_language->get('discord_integration', $term, $variables); @@ -168,7 +168,7 @@ public static function getLanguageTerm(string $term, array $variables = []): str */ public static function saveRoles($roles): void { $roles = [json_encode($roles)]; - file_put_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('discord_roles') . '.cache', $roles); + file_put_contents(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('discord_roles') . '.cache', $roles); } /** @@ -177,8 +177,8 @@ public static function saveRoles($roles): void { * @return array Cached Discord roles */ public static function getRoles(): array { - if (file_exists(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('discord_roles') . '.cache')) { - return json_decode(file_get_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('discord_roles') . '.cache'), true); + if (file_exists(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('discord_roles') . '.cache')) { + return json_decode(file_get_contents(Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . sha1('discord_roles') . '.cache'), true); } return []; diff --git a/modules/Discord Integration/classes/DiscordIntegration.php b/modules/Discord Integration/classes/DiscordIntegration.php index 4fd1d49c84..578cbe0e71 100644 --- a/modules/Discord Integration/classes/DiscordIntegration.php +++ b/modules/Discord Integration/classes/DiscordIntegration.php @@ -15,7 +15,7 @@ public function __construct(Language $language) { $this->_name = 'Discord'; $this->_icon = 'fab fa-discord'; $this->_language = $language; - $this->_settings = ROOT_PATH . '/modules/Discord Integration/includes/admin_integrations/discord.php'; + $this->_settings = Constants::ROOT_PATH . '/modules/Discord Integration/includes/admin_integrations/discord.php'; parent::__construct(); } diff --git a/modules/Discord Integration/init.php b/modules/Discord Integration/init.php index e84a0aceb9..733fd1c5e9 100644 --- a/modules/Discord Integration/init.php +++ b/modules/Discord Integration/init.php @@ -1,5 +1,5 @@ add($this->getName(), '/panel/discord', 'pages/panel/discord.php'); - $endpoints->loadEndpoints(ROOT_PATH . '/modules/Discord Integration/includes/endpoints'); + $endpoints->loadEndpoints(Constants::ROOT_PATH . '/modules/Discord Integration/includes/endpoints'); // -- Events EventHandler::registerEvent(DiscordWebhookFormatterEvent::class); diff --git a/modules/Discord Integration/pages/panel/discord.php b/modules/Discord Integration/pages/panel/discord.php index e552d314fd..dd5f6c5268 100644 --- a/modules/Discord Integration/pages/panel/discord.php +++ b/modules/Discord Integration/pages/panel/discord.php @@ -10,7 +10,7 @@ */ if (!$user->handlePanelPageLoad('admincp.discord')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -18,7 +18,7 @@ const PARENT_PAGE = 'integrations'; const PANEL_PAGE = 'discord'; $page_title = Discord::getLanguageTerm('discord'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (Input::exists()) { $errors = []; @@ -140,7 +140,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('integrations/discord/discord.tpl', $smarty); diff --git a/modules/Discord Integration/widgets/DiscordWidget.php b/modules/Discord Integration/widgets/DiscordWidget.php index bb6cfa2fea..d910131a4e 100644 --- a/modules/Discord Integration/widgets/DiscordWidget.php +++ b/modules/Discord Integration/widgets/DiscordWidget.php @@ -31,7 +31,7 @@ public function __construct(Cache $cache, Smarty $smarty) { $this->_name = 'Discord'; $this->_location = $widget_query->location ?? null; $this->_description = 'Display your Discord channel on your site. Make sure you have entered your Discord widget details in the StaffCP -> Integrations -> Discord tab first!'; - $this->_settings = ROOT_PATH . '/modules/Discord Integration/includes/admin_widgets/discord.php'; + $this->_settings = Constants::ROOT_PATH . '/modules/Discord Integration/includes/admin_widgets/discord.php'; $this->_order = $widget_query->order ?? null; } diff --git a/modules/Forum/init.php b/modules/Forum/init.php index fdd773eb39..fba072615a 100644 --- a/modules/Forum/init.php +++ b/modules/Forum/init.php @@ -27,7 +27,7 @@ const FORUM = true; // Initialise forum language -$forum_language = new Language(ROOT_PATH . '/modules/Forum/language'); +$forum_language = new Language(Constants::ROOT_PATH . '/modules/Forum/language'); /* * Temp methods for front page module, profile page tab + admin sidebar; likely to change in the future @@ -42,11 +42,11 @@ if (!isset($profile_tabs)) { $profile_tabs = []; } -$profile_tabs['forum'] = ['title' => $forum_language->get('forum', 'forum'), 'smarty_template' => 'forum/profile_tab.tpl', 'require' => ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Forum' . DIRECTORY_SEPARATOR . 'profile_tab.php']; +$profile_tabs['forum'] = ['title' => $forum_language->get('forum', 'forum'), 'smarty_template' => 'forum/profile_tab.tpl', 'require' => Constants::ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Forum' . DIRECTORY_SEPARATOR . 'profile_tab.php']; // Following topics UserCP sidebar $cc_nav->add('cc_following_topics', $forum_language->get('forum', 'following_topics'), URL::build('/user/following_topics')); // Initialise module -require_once(ROOT_PATH . '/modules/Forum/module.php'); +require_once(Constants::ROOT_PATH . '/modules/Forum/module.php'); $module = new Forum_Module($language, $forum_language, $pages); diff --git a/modules/Forum/module.php b/modules/Forum/module.php index 35735b38c3..9e0900fc02 100644 --- a/modules/Forum/module.php +++ b/modules/Forum/module.php @@ -375,10 +375,10 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem Core_Module::addDataToDashboardGraph($this->_language->get('admin', 'overview'), $data); // Dashboard stats - require_once(ROOT_PATH . '/modules/Forum/collections/panel/RecentTopics.php'); + require_once(Constants::ROOT_PATH . '/modules/Forum/collections/panel/RecentTopics.php'); CollectionManager::addItemToCollection('dashboard_stats', new RecentTopicsItem($smarty, $this->_forum_language, $cache, $latest_topics_count)); - require_once(ROOT_PATH . '/modules/Forum/collections/panel/RecentPosts.php'); + require_once(Constants::ROOT_PATH . '/modules/Forum/collections/panel/RecentPosts.php'); CollectionManager::addItemToCollection('dashboard_stats', new RecentPostsItem($smarty, $this->_forum_language, $cache, $latest_posts_count)); } diff --git a/modules/Forum/pages/forum/edit.php b/modules/Forum/pages/forum/edit.php index 617247423d..43d96f15ad 100644 --- a/modules/Forum/pages/forum/edit.php +++ b/modules/Forum/pages/forum/edit.php @@ -12,7 +12,7 @@ // Always define page name const PAGE = 'forum'; $page_title = $forum_language->get('forum', 'edit_post'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // User must be logged in to proceed if (!$user->isLoggedIn()) { @@ -265,8 +265,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/forum_edit_post.tpl', $smarty); diff --git a/modules/Forum/pages/forum/index.php b/modules/Forum/pages/forum/index.php index 5a20ad28c5..0d6cb15091 100644 --- a/modules/Forum/pages/forum/index.php +++ b/modules/Forum/pages/forum/index.php @@ -12,7 +12,7 @@ // Always define page name const PAGE = 'forum'; $page_title = $forum_language->get('forum', 'forum'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Initialise $forum = new Forum(); @@ -115,8 +115,8 @@ $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/forum_index.tpl', $smarty); diff --git a/modules/Forum/pages/forum/merge.php b/modules/Forum/pages/forum/merge.php index dac900b926..a2af1de7e7 100644 --- a/modules/Forum/pages/forum/merge.php +++ b/modules/Forum/pages/forum/merge.php @@ -11,7 +11,7 @@ const PAGE = 'forum'; $page_title = $forum_language->get('forum', 'merge_topics'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $forum = new Forum(); @@ -90,8 +90,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/merge.tpl', $smarty); diff --git a/modules/Forum/pages/forum/move.php b/modules/Forum/pages/forum/move.php index 30e901ff0e..79d6d6f37b 100644 --- a/modules/Forum/pages/forum/move.php +++ b/modules/Forum/pages/forum/move.php @@ -11,7 +11,7 @@ const PAGE = 'forum'; $page_title = $forum_language->get('forum', 'move_topic'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $forum = new Forum(); @@ -76,8 +76,8 @@ } // Generate navbar and footer -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Get a list of all forums $template_forums = []; @@ -141,8 +141,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/move.tpl', $smarty); diff --git a/modules/Forum/pages/forum/new_topic.php b/modules/Forum/pages/forum/new_topic.php index 85d6733bf3..abe4fc846c 100644 --- a/modules/Forum/pages/forum/new_topic.php +++ b/modules/Forum/pages/forum/new_topic.php @@ -12,7 +12,7 @@ // Always define page name const PAGE = 'forum'; $page_title = $forum_language->get('forum', 'new_topic'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // User must be logged in to proceed if (!$user->isLoggedIn()) { @@ -180,8 +180,8 @@ // Get last post ID $last_post_id = DB::getInstance()->lastId(); $content = EventHandler::executeEvent('preTopicCreate', [ - 'alert_full' => ['path' => ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag_info', 'replace' => '{{author}}', 'replace_with' => $user->getDisplayname()], - 'alert_short' => ['path' => ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag'], + 'alert_full' => ['path' => Constants::ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag_info', 'replace' => '{{author}}', 'replace_with' => $user->getDisplayname()], + 'alert_short' => ['path' => Constants::ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag'], 'alert_url' => URL::build('/forum/topic/' . urlencode($topic_id), 'pid=' . urlencode($last_post_id)), 'content' => $content, 'user' => $user, @@ -282,8 +282,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/new_topic.tpl', $smarty); diff --git a/modules/Forum/pages/forum/search.php b/modules/Forum/pages/forum/search.php index 59bf7b78fe..a05e944f6e 100644 --- a/modules/Forum/pages/forum/search.php +++ b/modules/Forum/pages/forum/search.php @@ -143,7 +143,7 @@ } else { $page_title = $forum_language->get('forum', 'forum_search') . ' - ' . Output::getClean(substr($search, 0, 20)) . ' - ' . $language->get('general', 'page_x', ['page' => $p]); } -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $template->assets()->include([ AssetTree::TINYMCE, @@ -208,8 +208,8 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/search_results.tpl', $smarty); @@ -237,8 +237,8 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/search.tpl', $smarty); diff --git a/modules/Forum/pages/forum/view_forum.php b/modules/Forum/pages/forum/view_forum.php index e8040fca3f..bf77c7d5c5 100644 --- a/modules/Forum/pages/forum/view_forum.php +++ b/modules/Forum/pages/forum/view_forum.php @@ -20,13 +20,13 @@ $fid = $fid[count($fid) - 1]; if (!strlen($fid)) { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } $fid = explode('-', $fid); if (!is_numeric($fid[0])) { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } $fid = Output::getClean($fid[0]); @@ -37,7 +37,7 @@ // Does the forum exist, and can the user view it? $list = $forum->canViewForum($fid, $user_groups); if (!$list) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -74,7 +74,7 @@ $page_title = $forum_language->get('forum', 'forum'); $page_title .= ' - ' . $language->get('general', 'page_x', ['page' => $p]); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Redirect forum? if ($forum_query->redirect_forum == 1) { @@ -98,8 +98,8 @@ $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/view_forum_confirm_redirect.tpl', $smarty); @@ -501,8 +501,8 @@ $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require(Constants::ROOT_PATH . '/core/templates/navbar.php'); + require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template if (isset($no_topics_exist)) { diff --git a/modules/Forum/pages/forum/view_topic.php b/modules/Forum/pages/forum/view_topic.php index 223cf7b962..2408182c6f 100644 --- a/modules/Forum/pages/forum/view_topic.php +++ b/modules/Forum/pages/forum/view_topic.php @@ -20,13 +20,13 @@ $tid = $tid[count($tid) - 1]; if (!strlen($tid)) { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } $tid = explode('-', $tid); if (!is_numeric($tid[0])) { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } $tid = $tid[0]; @@ -36,7 +36,7 @@ $list = $forum->topicExist($tid); if (!$list) { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } @@ -45,13 +45,13 @@ $topic = $topic[0]; if ($topic->deleted == 1) { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); die(); } $list = $forum->canViewForum($topic->forum_id, $user_groups); if (!$list) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -64,7 +64,7 @@ if ($topic->topic_creator != $user_id && !$forum->canViewOtherTopics($topic->forum_id, $user_groups)) { // Only allow viewing stickied topics if ($topic->sticky == 0) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } } @@ -102,7 +102,7 @@ Redirect::to(URL::build('/forum/topic/' . urlencode($tid) . '-' . $forum->titleToURL($topic->topic_title)) . '#post-' . $_GET['pid']); } } else { - require_once(ROOT_PATH . '/404.php'); + require_once(Constants::ROOT_PATH . '/404.php'); } die(); } @@ -161,7 +161,7 @@ } $page_title = ((strlen(Output::getClean($topic->topic_title)) > 20) ? Output::getClean(mb_substr($topic->topic_title, 0, 20)) . '...' : Output::getClean($topic->topic_title)) . ' - ' . $language->get('general', 'page_x', ['page' => $p]); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); // Assign author + title to Smarty variables // Get first post @@ -273,8 +273,8 @@ // Get last post ID $last_post_id = DB::getInstance()->lastId(); $content = EventHandler::executeEvent('prePostCreate', [ - 'alert_full' => ['path' => ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag_info', 'replace' => '{{author}}', 'replace_with' => $user->getDisplayname()], - 'alert_short' => ['path' => ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag'], + 'alert_full' => ['path' => Constants::ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag_info', 'replace' => '{{author}}', 'replace_with' => $user->getDisplayname()], + 'alert_short' => ['path' => Constants::ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'user_tag'], 'alert_url' => URL::build('/forum/topic/' . urlencode($tid), 'pid=' . urlencode($last_post_id)), 'content' => $content, 'user' => $user, @@ -316,8 +316,8 @@ Alert::create( $user_following->user_id, 'new_reply', - ['path' => ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'new_reply_in_topic', 'replace' => ['{{author}}', '{{topic}}'], 'replace_with' => [Output::getClean($user->data()->nickname), Output::getClean($topic->topic_title)]], - ['path' => ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'new_reply_in_topic', 'replace' => ['{{author}}', '{{topic}}'], 'replace_with' => [Output::getClean($user->data()->nickname), Output::getClean($topic->topic_title)]], + ['path' => Constants::ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'new_reply_in_topic', 'replace' => ['{{author}}', '{{topic}}'], 'replace_with' => [Output::getClean($user->data()->nickname), Output::getClean($topic->topic_title)]], + ['path' => Constants::ROOT_PATH . '/modules/Forum/language', 'file' => 'forum', 'term' => 'new_reply_in_topic', 'replace' => ['{{author}}', '{{topic}}'], 'replace_with' => [Output::getClean($user->data()->nickname), Output::getClean($topic->topic_title)]], URL::build('/forum/topic/' . urlencode($tid) . '-' . $forum->titleToURL($topic->topic_title), 'pid=' . $last_post_id) ); DB::getInstance()->update('topics_following', $user_following->id, [ @@ -330,7 +330,7 @@ } } } - $path = implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', TEMPLATE, 'email', 'forum_topic_reply.html']); + $path = implode(DIRECTORY_SEPARATOR, [Constants::ROOT_PATH, 'custom', 'templates', TEMPLATE, 'email', 'forum_topic_reply.html']); $html = file_get_contents($path); $message = str_replace( @@ -818,7 +818,7 @@ $template->addJSScript(Input::createTinyEditor($language, 'quickreply', $content, true)); $template->addJSScript(' - function quote(post) { + function quote(post) { $.ajax({ type: "GET", url: "' . URL::build('/forum/get_quotes') . '", @@ -862,8 +862,8 @@ class: \'info\', $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/view_topic.tpl', $smarty); diff --git a/modules/Forum/pages/panel/forums.php b/modules/Forum/pages/panel/forums.php index 8667c67857..72a664b43b 100644 --- a/modules/Forum/pages/panel/forums.php +++ b/modules/Forum/pages/panel/forums.php @@ -11,7 +11,7 @@ // Can the user view the panel? if (!$user->handlePanelPageLoad('admincp.forums')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PARENT_PAGE = 'forum'; const PANEL_PAGE = 'forums'; $page_title = $forum_language->get('forum', 'forums'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['action']) && !isset($_GET['forum'])) { $forums = DB::getInstance()->orderAll('forums', 'forum_order', 'ASC')->results(); @@ -832,7 +832,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Forum/pages/panel/labels.php b/modules/Forum/pages/panel/labels.php index f5ae60204e..2a1e33fdad 100644 --- a/modules/Forum/pages/panel/labels.php +++ b/modules/Forum/pages/panel/labels.php @@ -11,7 +11,7 @@ // Can the user view the panel? if (!$user->handlePanelPageLoad('admincp.forums')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PARENT_PAGE = 'forum'; const PANEL_PAGE = 'forum_labels'; $page_title = $forum_language->get('forum', 'labels'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (!isset($_GET['action'])) { $db = DB::getInstance(); @@ -616,7 +616,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate($template_file, $smarty); diff --git a/modules/Forum/pages/panel/settings.php b/modules/Forum/pages/panel/settings.php index a69a0a0286..a644c2784b 100644 --- a/modules/Forum/pages/panel/settings.php +++ b/modules/Forum/pages/panel/settings.php @@ -11,7 +11,7 @@ // Can the user view the panel? if (!$user->handlePanelPageLoad('admincp.forums')) { - require_once(ROOT_PATH . '/403.php'); + require_once(Constants::ROOT_PATH . '/403.php'); die(); } @@ -19,7 +19,7 @@ const PARENT_PAGE = 'forum'; const PANEL_PAGE = 'forum_settings'; $page_title = $forum_language->get('forum', 'forums'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/backend_init.php'); if (Input::exists()) { if (Token::check()) { @@ -121,7 +121,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/panel_navbar.php'); // Display template $template->displayTemplate('forum/forums_settings.tpl', $smarty); diff --git a/modules/Forum/pages/user/following_topics.php b/modules/Forum/pages/user/following_topics.php index 4602e9ace0..d36800c140 100644 --- a/modules/Forum/pages/user/following_topics.php +++ b/modules/Forum/pages/user/following_topics.php @@ -17,7 +17,7 @@ // Always define page name for navbar const PAGE = 'cc_following_topics'; $page_title = $forum_language->get('forum', 'following_topics'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once(Constants::ROOT_PATH . '/core/templates/frontend_init.php'); $forum = new Forum(); $timeago = new TimeAgo(TIMEZONE); @@ -116,12 +116,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/cc_navbar.php'); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require(Constants::ROOT_PATH . '/core/templates/navbar.php'); +require(Constants::ROOT_PATH . '/core/templates/footer.php'); // Display template $template->displayTemplate('forum/following_topics.tpl', $smarty); diff --git a/modules/Forum/widgets/LatestPostsWidget.php b/modules/Forum/widgets/LatestPostsWidget.php index dfd32f7497..9a01c01117 100644 --- a/modules/Forum/widgets/LatestPostsWidget.php +++ b/modules/Forum/widgets/LatestPostsWidget.php @@ -32,7 +32,7 @@ public function __construct(Language $forum_language, Smarty $smarty, Cache $cac $this->_name = 'Latest Posts'; $this->_location = $widget_query->location ?? null; $this->_description = 'Display latest posts from your forum.'; - $this->_settings = ROOT_PATH . '/modules/Forum/widgets/admin/latest_posts.php'; + $this->_settings = Constants::ROOT_PATH . '/modules/Forum/widgets/admin/latest_posts.php'; $this->_order = $widget_query->order ?? null; $this->_smarty->assign([