2018-05-30 00:36:52 +01:00
|
|
|
<?php
|
2025-02-24 18:44:29 +00:00
|
|
|
/**
|
|
|
|
|
* NamelessMC Core Module
|
2016-11-29 22:27:19 +00:00
|
|
|
*
|
2025-02-24 18:44:29 +00:00
|
|
|
* @author Samerton
|
|
|
|
|
* @version 2.2.0
|
|
|
|
|
* @license MIT
|
2016-11-29 22:27:19 +00:00
|
|
|
*/
|
|
|
|
|
|
2018-09-10 01:14:58 +01:00
|
|
|
class Core_Module extends Module {
|
2021-04-12 18:36:34 -07:00
|
|
|
|
2021-10-29 22:00:05 -07:00
|
|
|
private static array $_dashboard_graph = [];
|
|
|
|
|
private static array $_notices = [];
|
|
|
|
|
private static array $_user_actions = [];
|
2021-12-07 22:14:12 -08:00
|
|
|
private Language $_language;
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-05-28 14:33:35 +02:00
|
|
|
public function __construct(Language $language, Pages $pages, User $user, Navigation $navigation, Cache $cache, Endpoints $endpoints) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$this->_language = $language;
|
|
|
|
|
|
|
|
|
|
$name = 'Core';
|
|
|
|
|
$author = '<a href="https://samerton.me" target="_blank" rel="nofollow noopener">Samerton</a>';
|
2026-04-19 09:44:29 +01:00
|
|
|
$module_version = '2.2.5';
|
|
|
|
|
$nameless_version = '2.2.5';
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
parent::__construct($this, $name, $author, $module_version, $nameless_version);
|
|
|
|
|
|
|
|
|
|
// Define URLs which belong to this module
|
2023-03-23 20:01:23 -07:00
|
|
|
$pages->add('Core', '/', 'pages/index.php', '', true);
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/api/v2', 'pages/api/v2/index.php');
|
|
|
|
|
$pages->add('Core', '/home', 'pages/home.php', 'index', true);
|
|
|
|
|
|
|
|
|
|
$pages->add('Core', '/login', 'pages/login.php');
|
|
|
|
|
$pages->add('Core', '/logout', 'pages/logout.php');
|
|
|
|
|
$pages->add('Core', '/profile', 'pages/profile.php', 'profile', true);
|
|
|
|
|
$pages->add('Core', '/register', 'pages/register.php');
|
2022-02-01 14:24:14 -08:00
|
|
|
$pages->add('Core', '/register/oauth', 'pages/register.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/validate', 'pages/validate.php');
|
|
|
|
|
$pages->add('Core', '/queries/admin_users', 'queries/admin_users.php');
|
2023-01-22 11:43:01 -08:00
|
|
|
$pages->add('Core', '/queries/authme_test_connection', 'queries/authme_test_connection.php');
|
2022-03-31 08:44:30 -07:00
|
|
|
$pages->add('Core', '/queries/mention_users', 'queries/mention_users.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/queries/alerts', 'queries/alerts.php');
|
2021-10-09 16:01:20 +01:00
|
|
|
$pages->add('Core', '/queries/dark_light_mode', 'queries/dark_light_mode.php');
|
2023-03-30 18:42:40 +01:00
|
|
|
$pages->add('Core', '/queries/queue', 'queries/queue.php');
|
|
|
|
|
$pages->add('Core', '/queries/queue_status', 'queries/queue_status.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/queries/pms', 'queries/pms.php');
|
|
|
|
|
$pages->add('Core', '/queries/servers', 'queries/servers.php');
|
|
|
|
|
$pages->add('Core', '/queries/server', 'queries/server.php');
|
|
|
|
|
$pages->add('Core', '/queries/user', 'queries/user.php');
|
2021-05-15 11:45:00 +01:00
|
|
|
$pages->add('Core', '/queries/users', 'queries/users.php');
|
2021-10-13 21:46:34 -07:00
|
|
|
$pages->add('Core', '/queries/debug_link', 'queries/debug_link.php');
|
2022-03-30 10:55:27 -07:00
|
|
|
$pages->add('Core', '/queries/tinymce_image_upload', 'queries/tinymce_image_upload.php');
|
2023-06-21 10:19:46 -07:00
|
|
|
$pages->add('Core', '/queries/reactions', 'queries/reactions.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/banner', 'pages/minecraft/banner.php');
|
|
|
|
|
$pages->add('Core', '/terms', 'pages/terms.php');
|
|
|
|
|
$pages->add('Core', '/privacy', 'pages/privacy.php');
|
|
|
|
|
$pages->add('Core', '/forgot_password', 'pages/forgot_password.php');
|
|
|
|
|
$pages->add('Core', '/complete_signup', 'pages/complete_signup.php');
|
|
|
|
|
$pages->add('Core', '/status', 'pages/status.php', 'status');
|
2023-06-12 10:30:49 -06:00
|
|
|
if (Settings::get('mc_integration')) {
|
2023-03-07 08:26:53 -08:00
|
|
|
$pages->add('Core', '/leaderboards', 'pages/leaderboards.php', 'leaderboards');
|
|
|
|
|
}
|
2022-02-01 14:24:14 -08:00
|
|
|
$pages->add('Core', '/oauth', 'pages/oauth.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2024-07-15 19:42:56 +01:00
|
|
|
$pages->add('Core', '/user', 'pages/user/index.php', 'cc_overview');
|
|
|
|
|
$pages->add('Core', '/user/settings', 'pages/user/settings.php', 'cc_settings');
|
|
|
|
|
$pages->add('Core', '/user/messaging', 'pages/user/messaging.php', 'cc_messaging');
|
|
|
|
|
$pages->add('Core', '/user/alerts', 'pages/user/alerts.php', 'cc_alerts');
|
2024-10-17 23:21:27 -07:00
|
|
|
$pages->add('Core', '/user/sessions', 'pages/user/sessions.php', 'cc_sessions');
|
2024-07-15 19:42:56 +01:00
|
|
|
$pages->add('Core', '/user/notification_settings', 'pages/user/notification_settings.php', 'cc_notification_settings');
|
|
|
|
|
$pages->add('Core', '/user/placeholders', 'pages/user/placeholders.php', 'cc_placeholders');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/user/acknowledge', 'pages/user/acknowledge.php');
|
2024-07-15 19:42:56 +01:00
|
|
|
$pages->add('Core', '/user/connections', 'pages/user/connections.php', 'cc_connections');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// Panel
|
|
|
|
|
$pages->add('Core', '/panel', 'pages/panel/index.php');
|
|
|
|
|
$pages->add('Core', '/panel/auth', 'pages/panel/auth.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/general_settings', 'pages/panel/general_settings.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/api', 'pages/panel/api.php');
|
2020-12-27 23:24:56 +01:00
|
|
|
$pages->add('Core', '/panel/core/seo', 'pages/panel/seo.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/panel/core/avatars', 'pages/panel/avatars.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/profile_fields', 'pages/panel/profile_fields.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/debugging_and_maintenance', 'pages/panel/debugging_and_maintenance.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/errors', 'pages/panel/errors.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/emails', 'pages/panel/emails.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/emails/errors', 'pages/panel/emails_errors.php');
|
2024-03-31 20:19:43 +01:00
|
|
|
$pages->add('Core', '/panel/core/mass_message', 'pages/panel/mass_message.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/panel/core/navigation', 'pages/panel/navigation.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/privacy_and_terms', 'pages/panel/privacy_and_terms.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/reactions', 'pages/panel/reactions.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/registration', 'pages/panel/registration.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/social_media', 'pages/panel/social_media.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/groups', 'pages/panel/groups.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/images', 'pages/panel/images.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/panel_templates', 'pages/panel/panel_templates.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/templates', 'pages/panel/templates.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/announcements', 'pages/panel/announcements.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/widgets', 'pages/panel/widgets.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/modules', 'pages/panel/modules.php');
|
|
|
|
|
$pages->add('Core', '/panel/core/pages', 'pages/panel/pages.php');
|
2023-03-30 18:42:40 +01:00
|
|
|
$pages->add('Core', '/panel/core/queue', 'pages/panel/queue.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/panel/core/hooks', 'pages/panel/hooks.php');
|
2022-04-16 18:42:24 +02:00
|
|
|
$pages->add('Core', '/panel/core/integrations', 'pages/panel/integrations.php');
|
2021-05-15 14:17:57 -07:00
|
|
|
$pages->add('Core', '/panel/minecraft/placeholders', 'pages/panel/placeholders.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/panel/minecraft', 'pages/panel/minecraft.php');
|
|
|
|
|
$pages->add('Core', '/panel/minecraft/authme', 'pages/panel/minecraft_authme.php');
|
|
|
|
|
$pages->add('Core', '/panel/minecraft/servers', 'pages/panel/minecraft_servers.php');
|
|
|
|
|
$pages->add('Core', '/panel/minecraft/query_errors', 'pages/panel/minecraft_query_errors.php');
|
|
|
|
|
$pages->add('Core', '/panel/minecraft/banners', 'pages/panel/minecraft_server_banners.php');
|
|
|
|
|
$pages->add('Core', '/panel/security', 'pages/panel/security.php');
|
|
|
|
|
$pages->add('Core', '/panel/update', 'pages/panel/update.php');
|
|
|
|
|
$pages->add('Core', '/panel/upgrade', 'pages/panel/upgrade.php');
|
|
|
|
|
$pages->add('Core', '/panel/users', 'pages/panel/users.php');
|
|
|
|
|
$pages->add('Core', '/panel/users/edit', 'pages/panel/users_edit.php');
|
2022-04-16 18:42:24 +02:00
|
|
|
$pages->add('Core', '/panel/users/integrations', 'pages/panel/users_integrations.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/panel/users/ip_lookup', 'pages/panel/users_ip_lookup.php');
|
|
|
|
|
$pages->add('Core', '/panel/users/punishments', 'pages/panel/users_punishments.php');
|
|
|
|
|
$pages->add('Core', '/panel/users/reports', 'pages/panel/users_reports.php');
|
2024-10-17 23:21:27 -07:00
|
|
|
$pages->add('Core', '/panel/users/sessions', 'pages/panel/users_sessions.php');
|
2020-12-19 19:25:59 +01:00
|
|
|
$pages->add('Core', '/panel/user', 'pages/panel/user.php');
|
|
|
|
|
|
|
|
|
|
// Ajax GET requests
|
|
|
|
|
$pages->addAjaxScript(URL::build('/queries/servers'));
|
|
|
|
|
|
2023-06-12 10:30:49 -06:00
|
|
|
if (Settings::get('queue_runner', 'ajax') == 'ajax') {
|
2023-03-30 18:42:40 +01:00
|
|
|
$pages->addAjaxScript(URL::build('/queries/queue'));
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-19 19:25:59 +01:00
|
|
|
// "More" dropdown
|
|
|
|
|
$cache->setCache('navbar_icons');
|
2025-05-20 18:37:24 -07:00
|
|
|
$icon = $cache->fetch('more_dropdown_icon', '');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
$cache->setCache('navbar_order');
|
2025-05-20 18:37:24 -07:00
|
|
|
$order = $cache->fetch('more_dropdown_order', 2500);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
$navigation->addDropdown('more_dropdown', $language->get('general', 'more'), 'top', $order, $icon);
|
|
|
|
|
|
|
|
|
|
// Custom pages
|
2022-05-28 14:10:01 +02:00
|
|
|
$custom_pages = DB::getInstance()->get('custom_pages', ['id', '<>', 0])->results();
|
2021-12-07 20:51:29 -08:00
|
|
|
if (count($custom_pages)) {
|
2021-10-29 22:00:05 -07:00
|
|
|
$more = [];
|
2020-12-19 19:25:59 +01:00
|
|
|
$cache->setCache('navbar_order');
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->isLoggedIn()) {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Check all groups
|
|
|
|
|
$user_groups = $user->getAllGroupIds();
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
foreach ($custom_pages as $custom_page) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$redirect = null;
|
|
|
|
|
|
|
|
|
|
// Get redirect URL if enabled
|
2021-12-07 22:14:12 -08:00
|
|
|
if ($custom_page->redirect == 1) {
|
2022-06-04 12:07:34 +02:00
|
|
|
$redirect = $custom_page->link;
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-04-08 08:50:32 +02:00
|
|
|
$pages->addCustom(Output::urlEncodeAllowSlashes($custom_page->url), Output::getClean($custom_page->title), !$custom_page->basic);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
foreach ($user_groups as $user_group) {
|
2022-05-28 14:10:01 +02:00
|
|
|
$custom_page_permissions = DB::getInstance()->get('custom_pages_permissions', ['group_id', $user_group])->results();
|
2021-12-07 20:51:29 -08:00
|
|
|
if (count($custom_page_permissions)) {
|
|
|
|
|
foreach ($custom_page_permissions as $permission) {
|
|
|
|
|
if ($permission->page_id == $custom_page->id) {
|
|
|
|
|
if ($permission->view == 1) {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Check cache for order
|
2025-05-20 18:37:24 -07:00
|
|
|
$page_order = $cache->fetch($custom_page->id . '_order', 200);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
switch ($custom_page->link_location) {
|
2020-12-19 19:25:59 +01:00
|
|
|
case 1:
|
|
|
|
|
// Navbar
|
2022-04-02 17:43:21 +02:00
|
|
|
$navigation->add(
|
|
|
|
|
$custom_page->id,
|
|
|
|
|
Output::getClean($custom_page->title),
|
2022-04-08 08:50:32 +02:00
|
|
|
(is_null($redirect)) ? URL::build(Output::urlEncodeAllowSlashes($custom_page->url)) : $redirect,
|
2022-04-02 17:43:21 +02:00
|
|
|
'top',
|
|
|
|
|
$custom_page->target ? '_blank' : null,
|
|
|
|
|
$page_order,
|
|
|
|
|
$custom_page->icon
|
|
|
|
|
);
|
2020-12-19 19:25:59 +01:00
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
// "More" dropdown
|
2022-04-02 17:43:21 +02:00
|
|
|
$more[] = [
|
|
|
|
|
'id' => $custom_page->id,
|
|
|
|
|
'title' => Output::getClean($custom_page->title),
|
2022-04-08 08:50:32 +02:00
|
|
|
'url' => is_null($redirect) ? URL::build(Output::urlEncodeAllowSlashes($custom_page->url)) : $redirect,
|
2022-04-02 17:43:21 +02:00
|
|
|
'redirect' => $redirect,
|
|
|
|
|
'target' => $custom_page->target,
|
|
|
|
|
'icon' => $custom_page->icon,
|
|
|
|
|
'order' => $page_order
|
|
|
|
|
];
|
2020-12-19 19:25:59 +01:00
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
// Footer
|
2022-04-02 17:43:21 +02:00
|
|
|
$navigation->add(
|
|
|
|
|
$custom_page->id,
|
|
|
|
|
Output::getClean($custom_page->title),
|
2022-04-08 08:50:32 +02:00
|
|
|
(is_null($redirect)) ? URL::build(Output::urlEncodeAllowSlashes($custom_page->url)) : $redirect,
|
2023-01-15 04:54:52 -08:00
|
|
|
'footer', $custom_page->target ? '_blank' : null,
|
2022-04-02 17:43:21 +02:00
|
|
|
2000,
|
|
|
|
|
$custom_page->icon
|
|
|
|
|
);
|
2020-12-19 19:25:59 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break 2;
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2022-01-15 15:18:05 -08:00
|
|
|
|
|
|
|
|
break;
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-05-28 14:10:01 +02:00
|
|
|
$custom_page_permissions = DB::getInstance()->get('custom_pages_permissions', ['group_id', 0])->results();
|
2021-12-07 20:51:29 -08:00
|
|
|
if (count($custom_page_permissions)) {
|
|
|
|
|
foreach ($custom_pages as $custom_page) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$redirect = null;
|
|
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
if ($custom_page->redirect == 1) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$redirect = Output::getClean($custom_page->link);
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-04-08 08:50:32 +02:00
|
|
|
$pages->addCustom(Output::urlEncodeAllowSlashes($custom_page->url), Output::getClean($custom_page->title), !$custom_page->basic);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
foreach ($custom_page_permissions as $permission) {
|
|
|
|
|
if ($permission->page_id == $custom_page->id) {
|
|
|
|
|
if ($permission->view == 1) {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Check cache for order
|
2025-05-20 18:37:24 -07:00
|
|
|
$page_order = $cache->fetch($custom_page->id . '_order', 200);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
switch ($custom_page->link_location) {
|
2020-12-19 19:25:59 +01:00
|
|
|
case 1:
|
|
|
|
|
// Navbar
|
2022-04-02 17:43:21 +02:00
|
|
|
$navigation->add(
|
|
|
|
|
$custom_page->id,
|
|
|
|
|
Output::getClean($custom_page->title),
|
2022-04-08 08:50:32 +02:00
|
|
|
is_null($redirect) ? URL::build(Output::urlEncodeAllowSlashes($custom_page->url)) : $redirect,
|
2022-04-02 17:43:21 +02:00
|
|
|
'top',
|
|
|
|
|
$custom_page->target ? '_blank' : null,
|
|
|
|
|
$page_order,
|
|
|
|
|
$custom_page->icon
|
|
|
|
|
);
|
2020-12-19 19:25:59 +01:00
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
// "More" dropdown
|
2022-04-02 17:43:21 +02:00
|
|
|
$more[] = [
|
|
|
|
|
'id' => $custom_page->id,
|
|
|
|
|
'title' => Output::getClean($custom_page->title),
|
2022-04-08 08:50:32 +02:00
|
|
|
'url' => is_null($redirect) ? URL::build(Output::urlEncodeAllowSlashes($custom_page->url)) : $redirect,
|
2022-04-02 17:43:21 +02:00
|
|
|
'redirect' => $redirect,
|
|
|
|
|
'target' => $custom_page->target,
|
|
|
|
|
'icon' => $custom_page->icon,
|
|
|
|
|
'order' => $page_order
|
|
|
|
|
];
|
2020-12-19 19:25:59 +01:00
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
// Footer
|
2022-04-02 17:43:21 +02:00
|
|
|
$navigation->add(
|
|
|
|
|
$custom_page->id,
|
|
|
|
|
Output::getClean($custom_page->title),
|
2022-04-08 08:50:32 +02:00
|
|
|
is_null($redirect) ? URL::build(Output::urlEncodeAllowSlashes($custom_page->url)) : $redirect,
|
2022-04-02 17:43:21 +02:00
|
|
|
'footer',
|
|
|
|
|
$custom_page->target ? '_blank' : null,
|
|
|
|
|
2000,
|
2022-04-02 17:50:24 +02:00
|
|
|
$custom_page->icon
|
|
|
|
|
);
|
2020-12-19 19:25:59 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$custom_page_permissions = null;
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (count($more)) {
|
2021-12-07 22:14:12 -08:00
|
|
|
foreach ($more as $item) {
|
2021-12-07 23:48:33 -08:00
|
|
|
$navigation->addItemToDropdown('more_dropdown', $item['id'], $item['title'], $item['url'], 'top', ($item['target']) ? '_blank' : null, $item['icon'] ?? '', $item['order']);
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$custom_pages = null;
|
|
|
|
|
|
2023-03-01 11:35:10 -08:00
|
|
|
// -- Events
|
|
|
|
|
EventHandler::registerEvent(AnnouncementCreatedEvent::class);
|
2024-03-31 20:19:43 +01:00
|
|
|
EventHandler::registerEvent(GenerateNotificationContentEvent::class);
|
2023-03-01 11:35:10 -08:00
|
|
|
EventHandler::registerEvent(GroupClonedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(ReportCreatedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserBannedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserDeletedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserGroupAddedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserGroupRemovedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserIntegrationLinkedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserIntegrationUnlinkedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserIntegrationVerifiedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserProfilePostCreatedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserProfilePostReplyCreatedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserRegisteredEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserValidatedEvent::class);
|
|
|
|
|
EventHandler::registerEvent(UserWarnedEvent::class);
|
|
|
|
|
|
|
|
|
|
// -- Pipelines
|
2025-05-02 19:19:52 +02:00
|
|
|
EventHandler::registerEvent(PreCustomPageCreateEvent::class);
|
|
|
|
|
EventHandler::registerEvent(PreCustomPageEditEvent::class);
|
|
|
|
|
EventHandler::registerEvent(RenderContentEvent::class);
|
|
|
|
|
EventHandler::registerEvent(RenderContentEditEvent::class);
|
2023-04-01 21:17:20 +01:00
|
|
|
|
2022-06-10 23:15:05 -06:00
|
|
|
NamelessOAuth::getInstance()->registerProvider('discord', 'Core', [
|
2022-05-23 00:30:51 -06:00
|
|
|
'class' => \Wohali\OAuth2\Client\Provider\Discord::class,
|
|
|
|
|
'user_id_name' => 'id',
|
|
|
|
|
'scope_id_name' => 'identify',
|
|
|
|
|
'icon' => 'fab fa-discord',
|
2023-04-01 13:30:26 -07:00
|
|
|
'button_css' => [
|
|
|
|
|
'background-color' => '#5865F2',
|
|
|
|
|
'color' => '#FFFFFF',
|
|
|
|
|
],
|
2023-01-23 10:28:32 -08:00
|
|
|
'verify_email' => static fn () => true,
|
2022-05-23 00:30:51 -06:00
|
|
|
]);
|
|
|
|
|
|
2022-06-10 23:15:05 -06:00
|
|
|
NamelessOAuth::getInstance()->registerProvider('google', 'Core', [
|
2022-05-23 00:30:51 -06:00
|
|
|
'class' => \League\OAuth2\Client\Provider\Google::class,
|
|
|
|
|
'user_id_name' => 'sub',
|
|
|
|
|
'scope_id_name' => 'openid',
|
2023-04-01 13:30:26 -07:00
|
|
|
'logo_url' => rtrim(URL::getSelfURL(), '/') . '/core/assets/img/google_logo.png',
|
|
|
|
|
// Google has strict restrictions (https://developers.google.com/identity/branding-guidelines) on how
|
|
|
|
|
// their logo should be formatted for login buttons, and should not be altered by any template
|
|
|
|
|
'logo_css' => [
|
|
|
|
|
'width' => '18px',
|
|
|
|
|
'height' => '18px',
|
|
|
|
|
'vertical-align' => 'middle',
|
|
|
|
|
'margin-bottom' => '-2px',
|
|
|
|
|
'margin-top' => '-2px',
|
|
|
|
|
],
|
|
|
|
|
'button_css' => [
|
|
|
|
|
'background-color' => '#FFFFFF',
|
|
|
|
|
'color' => '#757575',
|
|
|
|
|
'line-height' => '.05em',
|
|
|
|
|
'box-shadow' => 'inset 0px 0px 0px 1px #DFDFDF;'
|
|
|
|
|
],
|
|
|
|
|
'text_css' => [
|
|
|
|
|
'vertical-align' => 'middle',
|
|
|
|
|
],
|
2023-01-23 10:28:32 -08:00
|
|
|
'verify_email' => static fn () => true,
|
2022-05-23 00:30:51 -06:00
|
|
|
]);
|
|
|
|
|
|
2021-03-12 23:11:40 +00:00
|
|
|
// Captcha
|
2023-06-12 10:30:49 -06:00
|
|
|
$captchaPublicKey = Settings::get('recaptcha_key', '');
|
|
|
|
|
$captchaPrivateKey = Settings::get('recaptcha_secret', '');
|
|
|
|
|
$activeCaptcha = Settings::get('recaptcha_type', 'Recaptcha3');
|
2021-03-12 23:11:40 +00:00
|
|
|
|
|
|
|
|
CaptchaBase::addProvider(new hCaptcha($captchaPrivateKey, $captchaPublicKey));
|
|
|
|
|
CaptchaBase::addProvider(new Recaptcha2($captchaPrivateKey, $captchaPublicKey));
|
|
|
|
|
CaptchaBase::addProvider(new Recaptcha3($captchaPrivateKey, $captchaPublicKey));
|
|
|
|
|
CaptchaBase::setActiveProvider($activeCaptcha);
|
|
|
|
|
|
2021-05-08 15:07:07 -07:00
|
|
|
// Avatar Sources
|
|
|
|
|
AvatarSource::registerSource(new CrafatarAvatarSource());
|
|
|
|
|
AvatarSource::registerSource(new CraftheadAvatarSource());
|
|
|
|
|
AvatarSource::registerSource(new CravatarAvatarSource());
|
|
|
|
|
AvatarSource::registerSource(new MCHeadsAvatarSource());
|
|
|
|
|
AvatarSource::registerSource(new MinotarAvatarSource());
|
|
|
|
|
AvatarSource::registerSource(new VisageAvatarSource());
|
|
|
|
|
|
2020-12-19 19:25:59 +01:00
|
|
|
// Autoload API Endpoints
|
2022-03-26 12:10:17 -07:00
|
|
|
$endpoints->loadEndpoints(ROOT_PATH . '/modules/Core/includes/endpoints');
|
2021-10-05 15:13:04 -07:00
|
|
|
|
2022-04-13 18:47:38 -07:00
|
|
|
GroupSyncManager::getInstance()->registerInjector(new NamelessMCGroupSyncInjector);
|
|
|
|
|
GroupSyncManager::getInstance()->registerInjector(new MinecraftGroupSyncInjector);
|
2022-01-15 11:45:26 -08:00
|
|
|
|
2022-03-20 11:33:38 -07:00
|
|
|
Endpoints::registerTransformer('user', 'Core', static function (Nameless2API $api, string $value) {
|
2022-03-26 10:57:47 -07:00
|
|
|
$lookup_data = explode(':', $value);
|
|
|
|
|
if (count($lookup_data) === 1) {
|
|
|
|
|
// assume it is a namelessmc user id
|
|
|
|
|
$user = new User($lookup_data[0]);
|
|
|
|
|
if ($user->exists()) {
|
|
|
|
|
return $user;
|
|
|
|
|
}
|
|
|
|
|
} else if (count($lookup_data) === 2) {
|
|
|
|
|
// probably handling native namelessmc user
|
|
|
|
|
[$lookup_type, $lookup_value] = $lookup_data;
|
|
|
|
|
if ($lookup_type === 'id') {
|
|
|
|
|
$column = 'id';
|
|
|
|
|
} else if ($lookup_type === 'username') {
|
|
|
|
|
$column = 'username';
|
|
|
|
|
} else {
|
2022-05-24 23:05:07 -06:00
|
|
|
$api->throwError(Nameless2API::ERROR_CANNOT_FIND_USER, "invalid native lookup type: $value");
|
2022-03-26 10:57:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user = new User($lookup_value, $column);
|
|
|
|
|
if ($user->exists()) {
|
|
|
|
|
return $user;
|
|
|
|
|
}
|
|
|
|
|
} else if (count($lookup_data) === 3) {
|
2022-04-16 18:42:24 +02:00
|
|
|
// Handling a user integration lookup
|
2022-03-26 10:57:47 -07:00
|
|
|
[$integration_lookup_type, $integration_name, $lookup_value] = $lookup_data;
|
2022-04-16 18:42:24 +02:00
|
|
|
|
|
|
|
|
$integration = Integrations::getInstance()->getIntegration($integration_name);
|
|
|
|
|
if ($integration != null) {
|
|
|
|
|
if ($integration_lookup_type === 'integration_id') {
|
|
|
|
|
$integrationUser = new IntegrationUser($integration, $lookup_value, 'identifier');
|
|
|
|
|
if ($integrationUser->exists()) {
|
|
|
|
|
return $integrationUser->getUser();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 23:05:07 -06:00
|
|
|
$api->throwError(Nameless2API::ERROR_CANNOT_FIND_USER, "invalid integration lookup name: $value");
|
2022-04-16 18:42:24 +02:00
|
|
|
} else if ($integration_lookup_type === 'integration_name') {
|
|
|
|
|
$integrationUser = new IntegrationUser($integration, $lookup_value, 'username');
|
|
|
|
|
if ($integrationUser->exists()) {
|
|
|
|
|
return $integrationUser->getUser();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 23:05:07 -06:00
|
|
|
$api->throwError(Nameless2API::ERROR_CANNOT_FIND_USER, "invalid integration lookup name: $value");
|
2022-03-26 10:57:47 -07:00
|
|
|
} else {
|
2022-05-24 23:05:07 -06:00
|
|
|
$api->throwError(Nameless2API::ERROR_CANNOT_FIND_USER, "invalid integration lookup name: $value");
|
2022-03-26 10:57:47 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
2022-05-24 23:05:07 -06:00
|
|
|
$api->throwError(Nameless2API::ERROR_CANNOT_FIND_USER, "invalid integration lookup type: $value");
|
2022-03-26 10:57:47 -07:00
|
|
|
}
|
2022-01-15 11:45:26 -08:00
|
|
|
}
|
2022-03-26 10:57:47 -07:00
|
|
|
|
2022-05-24 23:05:07 -06:00
|
|
|
$api->throwError(Nameless2API::ERROR_CANNOT_FIND_USER, $value);
|
2022-01-15 11:45:26 -08:00
|
|
|
});
|
2022-04-02 17:44:13 +01:00
|
|
|
|
2022-04-16 18:42:24 +02:00
|
|
|
// Minecraft Integration
|
2023-06-12 10:30:49 -06:00
|
|
|
if (Settings::get('mc_integration')) {
|
2022-04-16 19:46:37 +02:00
|
|
|
Integrations::getInstance()->registerIntegration(new MinecraftIntegration($language));
|
|
|
|
|
}
|
2022-04-16 18:42:24 +02:00
|
|
|
|
2024-03-09 21:40:13 +01:00
|
|
|
Integrations::getInstance()->registerIntegration(new GoogleIntegration($language));
|
|
|
|
|
|
2023-03-01 11:35:10 -08:00
|
|
|
EventHandler::registerListener(GroupClonedEvent::class, CloneGroupHook::class);
|
|
|
|
|
|
2024-03-31 20:19:43 +01:00
|
|
|
EventHandler::registerListener(GenerateNotificationContentEvent::class, 'ContentHook::purify');
|
|
|
|
|
EventHandler::registerListener(GenerateNotificationContentEvent::class, 'ContentHook::renderEmojis', 10);
|
|
|
|
|
EventHandler::registerListener(GenerateNotificationContentEvent::class, 'MentionsHook::parsePost', 5);
|
|
|
|
|
|
2025-05-02 19:19:52 +02:00
|
|
|
EventHandler::registerListener(RenderContentEvent::class, [ContentHook::class, 'purify']);
|
|
|
|
|
EventHandler::registerListener(RenderContentEvent::class, [ContentHook::class, 'renderEmojis'], 10);
|
|
|
|
|
EventHandler::registerListener(RenderContentEvent::class, [ContentHook::class, 'replaceAnchors'], 5);
|
|
|
|
|
EventHandler::registerListener(RenderContentEvent::class, [MentionsHook::class, 'parsePost'], 5);
|
2022-04-23 22:05:59 +02:00
|
|
|
|
2025-05-02 19:19:52 +02:00
|
|
|
EventHandler::registerListener(RenderContentEditEvent::class, [ContentHook::class, 'purify']);
|
|
|
|
|
EventHandler::registerListener(RenderContentEditEvent::class, [ContentHook::class, 'replaceAnchors'], 15);
|
|
|
|
|
EventHandler::registerListener(RenderContentEditEvent::class, [MentionsHook::class, 'stripPost'], 15);
|
2022-07-20 19:18:29 +01:00
|
|
|
|
2025-05-02 19:19:52 +02:00
|
|
|
EventHandler::registerListener(ContentCreateEvent::class, [MentionsHook::class, 'preCreate']);
|
|
|
|
|
EventHandler::registerListener(ContentEditEvent::class, [MentionsHook::class, 'preEdit']);
|
2022-07-20 19:18:29 +01:00
|
|
|
|
2025-05-02 19:19:52 +02:00
|
|
|
EventHandler::registerListener(PreCustomPageCreateEvent::class, [MentionsHook::class, 'preCreate']);
|
|
|
|
|
EventHandler::registerListener(PreCustomPageEditEvent::class, [MentionsHook::class, 'preEdit']);
|
2023-04-01 21:17:20 +01:00
|
|
|
|
2025-03-29 14:22:14 +00:00
|
|
|
EventHandler::registerListener(UserRegisteredEvent::class, DefaultUserNotificationPreferencesHook::class);
|
|
|
|
|
|
2022-06-22 22:47:39 -06:00
|
|
|
Email::addPlaceholder('[Sitename]', Output::getClean(SITE_NAME));
|
|
|
|
|
Email::addPlaceholder('[Greeting]', static fn(Language $viewing_language) => $viewing_language->get('emails', 'greeting'));
|
|
|
|
|
Email::addPlaceholder('[Message]', static fn(Language $viewing_language, string $email) => $viewing_language->get('emails', $email . '_message'));
|
|
|
|
|
Email::addPlaceholder('[Thanks]', static fn(Language $viewing_language) => $viewing_language->get('emails', 'thanks'));
|
2023-03-07 08:26:53 -08:00
|
|
|
|
2024-07-14 11:38:20 +02:00
|
|
|
if (Util::isModuleEnabled('Members')) {
|
|
|
|
|
MemberListManager::getInstance()->registerListProvider(new RegisteredMembersListProvider($language));
|
|
|
|
|
MemberListManager::getInstance()->registerListProvider(new StaffMembersListProvider($language));
|
|
|
|
|
|
|
|
|
|
MemberListManager::getInstance()->registerMemberMetadataProvider(function (User $member) use ($language) {
|
|
|
|
|
return [
|
|
|
|
|
$language->get('general', 'joined') => date(DATE_FORMAT, $member->data()->joined),
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-06-21 10:19:46 -07:00
|
|
|
|
|
|
|
|
ReactionContextsManager::getInstance()->provideContext(new ProfilePostReactionContext());
|
2024-03-31 20:19:43 +01:00
|
|
|
|
|
|
|
|
// Notifications
|
2025-03-29 14:22:14 +00:00
|
|
|
Notification::addType(
|
|
|
|
|
'mass_message',
|
2025-04-27 13:15:52 -07:00
|
|
|
$language->get('notification', 'mass_messages'),
|
|
|
|
|
['alert' => true, 'email' => true],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Notification::addType(
|
|
|
|
|
'report',
|
|
|
|
|
$language->get('notification', 'reports'),
|
2025-06-07 11:48:08 -07:00
|
|
|
['alert' => true, 'email' => true],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Notification::addType(
|
|
|
|
|
'punishment',
|
|
|
|
|
$language->get('notification', 'punishments'),
|
2025-03-29 14:22:14 +00:00
|
|
|
['alert' => true, 'email' => true],
|
|
|
|
|
);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
public static function getDashboardGraphs(): array {
|
|
|
|
|
return self::$_dashboard_graph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getNotices(): array {
|
|
|
|
|
return self::$_notices;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getUserActions(): array {
|
|
|
|
|
$return = self::$_user_actions;
|
|
|
|
|
|
2022-01-15 15:18:05 -08:00
|
|
|
uasort($return, static function ($a, $b) {
|
2021-12-07 22:14:12 -08:00
|
|
|
return $a['title'] > $b['title'];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
public function onInstall() {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Not necessary for Core
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
public function onUninstall() {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Not necessary for Core
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
public function onEnable() {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Not necessary for Core
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
public function onDisable() {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Not necessary for Core
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 18:44:29 +00:00
|
|
|
public function onPageLoad(
|
|
|
|
|
User $user,
|
|
|
|
|
Pages $pages,
|
|
|
|
|
Cache $cache,
|
|
|
|
|
$smarty,
|
|
|
|
|
iterable $navs,
|
|
|
|
|
Widgets $widgets,
|
|
|
|
|
TemplateBase $template
|
|
|
|
|
) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$language = $this->_language;
|
|
|
|
|
|
|
|
|
|
// Permissions
|
2021-10-29 22:00:05 -07:00
|
|
|
PermissionHandler::registerPermissions($language->get('admin', 'administrator'), [
|
2021-08-25 20:55:30 +02:00
|
|
|
'administrator' => $language->get('admin', 'administrator') . ' » ' . $language->get('admin', 'administrator_permission_info'),
|
2021-10-29 22:00:05 -07:00
|
|
|
]);
|
2021-10-08 21:13:33 +02:00
|
|
|
|
2020-12-19 19:25:59 +01:00
|
|
|
// AdminCP
|
2021-10-29 22:00:05 -07:00
|
|
|
PermissionHandler::registerPermissions($language->get('moderator', 'staff_cp'), [
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.core' => $language->get('admin', 'core'),
|
|
|
|
|
'admincp.core.api' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'api'),
|
2020-12-27 23:24:56 +01:00
|
|
|
'admincp.core.seo' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'seo'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.core.general' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'general_settings'),
|
|
|
|
|
'admincp.core.avatars' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'avatars'),
|
|
|
|
|
'admincp.core.fields' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'custom_fields'),
|
|
|
|
|
'admincp.core.debugging' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'debugging_and_maintenance'),
|
|
|
|
|
'admincp.errors' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'debugging_and_maintenance') . ' » ' . $language->get('admin', 'error_logs'),
|
|
|
|
|
'admincp.core.emails' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'emails'),
|
2024-03-31 20:19:43 +01:00
|
|
|
'admincp.core.emails_mass_message' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'mass_message'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.core.navigation' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'navigation'),
|
2023-03-30 18:42:40 +01:00
|
|
|
'admincp.core.queue' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'queue'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.core.reactions' => $language->get('admin', 'core') . ' » ' . $language->get('user', 'reactions'),
|
|
|
|
|
'admincp.core.registration' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'registration'),
|
|
|
|
|
'admincp.core.social_media' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'social_media'),
|
|
|
|
|
'admincp.core.terms' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'privacy_and_terms'),
|
|
|
|
|
'admincp.core.hooks' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'hooks'),
|
|
|
|
|
'admincp.core.announcements' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'announcements'),
|
2021-05-14 10:35:30 -07:00
|
|
|
'admincp.core.placeholders' => $language->get('admin', 'core') . ' » ' . $language->get('admin', 'placeholders'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.integrations' => $language->get('admin', 'integrations'),
|
2022-04-16 18:42:24 +02:00
|
|
|
'admincp.integrations.edit' => $language->get('admin', 'integrations') . ' » ' . $language->get('admin', 'general_settings'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.minecraft' => $language->get('admin', 'integrations') . ' » ' . $language->get('admin', 'minecraft'),
|
|
|
|
|
'admincp.minecraft.authme' => $language->get('admin', 'integrations') . ' » ' . $language->get('admin', 'minecraft') . ' » ' . $language->get('admin', 'authme_integration'),
|
|
|
|
|
'admincp.minecraft.servers' => $language->get('admin', 'integrations') . ' » ' . $language->get('admin', 'minecraft') . ' » ' . $language->get('admin', 'minecraft_servers'),
|
|
|
|
|
'admincp.minecraft.query_errors' => $language->get('admin', 'integrations') . ' » ' . $language->get('admin', 'minecraft') . ' » ' . $language->get('admin', 'query_errors'),
|
|
|
|
|
'admincp.minecraft.banners' => $language->get('admin', 'integrations') . ' » ' . $language->get('admin', 'minecraft') . ' » ' . $language->get('admin', 'server_banners'),
|
|
|
|
|
'admincp.modules' => $language->get('admin', 'modules'),
|
|
|
|
|
'admincp.pages' => $language->get('admin', 'pages'),
|
|
|
|
|
'admincp.security' => $language->get('admin', 'security'),
|
|
|
|
|
'admincp.security.acp_logins' => $language->get('admin', 'security') . ' » ' . $language->get('admin', 'acp_logins'),
|
|
|
|
|
'admincp.security.template' => $language->get('admin', 'security') . ' » ' . $language->get('admin', 'template_changes'),
|
|
|
|
|
'admincp.security.emails' => $language->get('admin', 'security') . ' » ' . $language->get('admin', 'email_logs'),
|
2021-02-24 10:37:51 -08:00
|
|
|
'admincp.security.group_sync' => $language->get('admin', 'security') . ' » ' . $language->get('admin', 'group_sync_logs'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.security.all' => $language->get('admin', 'security') . ' » ' . $language->get('admin', 'all_logs'),
|
|
|
|
|
'admincp.styles' => $language->get('admin', 'styles'),
|
|
|
|
|
'admincp.styles.panel_templates' => $language->get('admin', 'styles') . ' » ' . $language->get('admin', 'panel_templates'),
|
|
|
|
|
'admincp.styles.templates' => $language->get('admin', 'styles') . ' » ' . $language->get('admin', 'templates'),
|
|
|
|
|
'admincp.styles.templates.edit' => $language->get('admin', 'styles') . ' » ' . $language->get('admin', 'templates') . ' » ' . $language->get('general', 'edit'),
|
|
|
|
|
'admincp.styles.images' => $language->get('admin', 'styles') . ' » ' . $language->get('admin', 'images'),
|
|
|
|
|
'admincp.update' => $language->get('admin', 'update'),
|
|
|
|
|
'admincp.users' => $language->get('admin', 'user_management'),
|
|
|
|
|
'modcp.ip_lookup' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'ip_lookup'),
|
|
|
|
|
'modcp.punishments' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'punishments'),
|
|
|
|
|
'modcp.punishments.reset_avatar' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'punishments') . ' » ' . $language->get('moderator', 'reset_avatar'),
|
|
|
|
|
'modcp.punishments.warn' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'punishments') . ' » ' . $language->get('moderator', 'warn_user'),
|
|
|
|
|
'modcp.punishments.ban' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'punishments') . ' » ' . $language->get('moderator', 'ban_user'),
|
|
|
|
|
'modcp.punishments.banip' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'punishments') . ' » ' . $language->get('moderator', 'ban_ip'),
|
|
|
|
|
'modcp.punishments.revoke' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'punishments') . ' » ' . $language->get('moderator', 'revoke'),
|
|
|
|
|
'modcp.reports' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'reports'),
|
|
|
|
|
'modcp.profile_banner_reset' => $language->get('admin', 'user_management') . ' » ' . $language->get('moderator', 'reset_profile_banner'),
|
|
|
|
|
'admincp.users.edit' => $language->get('admin', 'user_management') . ' » ' . $language->get('admin', 'users') . ' » ' . $language->get('general', 'edit'),
|
2024-10-17 23:21:27 -07:00
|
|
|
'admincp.users.sessions' => $language->get('admin', 'user_management') . ' » ' . $language->get('admin', 'users') . ' » ' . $language->get('general', 'sessions'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'admincp.groups' => $language->get('admin', 'groups'),
|
|
|
|
|
'admincp.groups.self' => $language->get('admin', 'groups') . ' » ' . $language->get('admin', 'can_edit_own_group'),
|
|
|
|
|
'admincp.widgets' => $language->get('admin', 'widgets'),
|
2021-10-29 22:00:05 -07:00
|
|
|
]);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// UserCP
|
2021-10-29 22:00:05 -07:00
|
|
|
PermissionHandler::registerPermissions('UserCP', [
|
2020-12-19 19:25:59 +01:00
|
|
|
'usercp.messaging' => $language->get('user', 'messaging'),
|
|
|
|
|
'usercp.signature' => $language->get('user', 'profile_settings') . ' » ' . $language->get('user', 'signature'),
|
|
|
|
|
'usercp.private_profile' => $language->get('user', 'profile_settings') . ' » ' . $language->get('user', 'private_profile'),
|
|
|
|
|
'usercp.nickname' => $language->get('user', 'profile_settings') . ' » ' . $language->get('user', 'nickname'),
|
2025-06-04 21:18:14 -07:00
|
|
|
'usercp.title' => $language->get('user', 'profile_settings') . ' » ' . $language->get('user', 'user_title'),
|
2020-12-19 19:25:59 +01:00
|
|
|
'usercp.profile_banner' => $language->get('user', 'profile_settings') . ' » ' . $language->get('user', 'upload_profile_banner'),
|
|
|
|
|
'usercp.gif_avatar' => $language->get('user', 'profile_settings') . ' » ' . $language->get('user', 'gif_avatar')
|
2021-10-29 22:00:05 -07:00
|
|
|
]);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// Profile Page
|
2021-10-29 22:00:05 -07:00
|
|
|
PermissionHandler::registerPermissions('Profile', [
|
2024-12-09 19:01:46 +00:00
|
|
|
'profile.private.bypass' => $language->get('general', 'bypass') . ' » ' . $language->get('user', 'private_profile'),
|
|
|
|
|
'profile.post' => $language->get('user', 'profile') . ' » ' . $language->get('user', 'profile_posts'),
|
2021-10-29 22:00:05 -07:00
|
|
|
]);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// Sitemap
|
2022-03-29 15:09:21 -07:00
|
|
|
$pages->registerSitemapMethod([Core_Sitemap::class, 'generateSitemap']);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-04-23 12:02:00 -07:00
|
|
|
// Widgets - only load if on a widget staffcp page or the frontend
|
2023-03-23 20:01:23 -07:00
|
|
|
if ($pages->getActivePage()['widgets'] || (defined('PANEL_PAGE') && str_contains(PANEL_PAGE, 'widget'))) {
|
2022-04-23 12:02:00 -07:00
|
|
|
// Facebook
|
2023-06-12 10:30:49 -06:00
|
|
|
$fb_url = Settings::get('fb_url');
|
2022-04-23 12:02:00 -07:00
|
|
|
if ($fb_url) {
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new FacebookWidget($template->getEngine(), $fb_url));
|
2022-04-23 12:02:00 -07:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-04-23 12:02:00 -07:00
|
|
|
// Twitter
|
2023-06-12 10:30:49 -06:00
|
|
|
$twitter = Settings::get('twitter_url');
|
2022-04-23 12:02:00 -07:00
|
|
|
if ($twitter) {
|
2023-06-12 10:30:49 -06:00
|
|
|
$theme = Settings::get('twitter_style');
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new TwitterWidget($template->getEngine(), $twitter, $theme));
|
2022-04-23 12:02:00 -07:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-04-23 12:02:00 -07:00
|
|
|
// Profile Posts
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new ProfilePostsWidget($template->getEngine(), $language, $cache, $user, new TimeAgo(TIMEZONE)));
|
2022-04-23 12:02:00 -07:00
|
|
|
|
|
|
|
|
// Online staff
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new OnlineStaffWidget($template->getEngine(), $language, $cache));
|
2022-04-23 12:02:00 -07:00
|
|
|
|
|
|
|
|
// Online users
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new OnlineUsersWidget($cache, $template->getEngine(), $language));
|
2022-04-23 12:02:00 -07:00
|
|
|
|
|
|
|
|
// Online users
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new ServerStatusWidget($template->getEngine(), $language, $cache));
|
2022-04-23 12:02:00 -07:00
|
|
|
|
|
|
|
|
// Statistics
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new StatsWidget($template->getEngine(), $language, $cache));
|
2023-06-21 10:19:46 -07:00
|
|
|
|
|
|
|
|
// Reactions profile widget
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new ReactionsProfileWidget($template->getEngine(), $language));
|
2023-06-21 10:19:46 -07:00
|
|
|
|
|
|
|
|
// Minecraft account profile widget
|
|
|
|
|
if (Settings::get('mc_integration')) {
|
2025-02-24 18:44:29 +00:00
|
|
|
$widgets->add(new MinecraftAccountProfileWidget($template->getEngine(), $cache, $language));
|
2023-06-21 10:19:46 -07:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate user hook
|
2023-06-12 10:30:49 -06:00
|
|
|
$validate_action = Settings::get('validate_user_action');
|
2022-06-01 11:02:20 +02:00
|
|
|
$validate_action = json_decode($validate_action, true);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($validate_action['action'] == 'promote') {
|
2023-03-01 11:35:10 -08:00
|
|
|
EventHandler::registerListener(UserValidatedEvent::class, ValidateHook::class);
|
2020-12-19 19:25:59 +01:00
|
|
|
define('VALIDATED_DEFAULT', $validate_action['group']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for updates
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->isLoggedIn()) {
|
2022-10-14 19:53:25 +02:00
|
|
|
if (!(defined('PANEL_PAGE') && PANEL_PAGE === 'update') && $user->hasPermission('admincp.update')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$cache->setCache('update_check');
|
2025-05-20 18:37:24 -07:00
|
|
|
$update_check = $cache->fetch('update_check', fn () => Util::updateCheck(), 3600);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-06-02 13:17:48 -06:00
|
|
|
if (!is_string($update_check) && $update_check->updateAvailable()) {
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariables([
|
2022-06-02 13:17:48 -06:00
|
|
|
'NEW_UPDATE' => $update_check->isUrgent()
|
|
|
|
|
? $language->get('admin', 'new_urgent_update_available')
|
|
|
|
|
: $language->get('admin', 'new_update_available'),
|
|
|
|
|
'NEW_UPDATE_URGENT' => $update_check->isUrgent(),
|
|
|
|
|
'CURRENT_VERSION' => $language->get('admin', 'current_version_x', [
|
|
|
|
|
'version' => Output::getClean(NAMELESS_VERSION)
|
|
|
|
|
]),
|
|
|
|
|
'NEW_VERSION' => $language->get('admin', 'new_version_x', [
|
2025-05-21 15:40:25 -07:00
|
|
|
'version' => Output::getClean($update_check->versionTag())
|
2022-06-02 13:17:48 -06:00
|
|
|
]),
|
2022-06-17 12:03:35 +02:00
|
|
|
'NAMELESS_UPDATE' => $language->get('admin', 'update'),
|
|
|
|
|
'NAMELESS_UPDATE_LINK' => URL::build('/panel/update')
|
2021-10-29 22:00:05 -07:00
|
|
|
]);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-12 10:30:49 -06:00
|
|
|
if (Settings::get('mc_integration') && Settings::get('status_page')) {
|
2023-02-16 12:57:24 +01:00
|
|
|
// Add status link to navbar
|
|
|
|
|
$cache->setCache('navbar_order');
|
2025-05-20 18:37:24 -07:00
|
|
|
$status_order = $cache->fetch('status_order', 3);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2023-02-16 12:57:24 +01:00
|
|
|
$cache->setCache('navbar_icons');
|
2025-05-20 18:37:24 -07:00
|
|
|
$icon = $cache->fetch('status_icon', '');
|
2023-02-16 12:57:24 +01:00
|
|
|
|
|
|
|
|
$navs[0]->add('status', $language->get('general', 'status'), URL::build('/status'), 'top', null, $status_order, $icon);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-23 20:01:23 -07:00
|
|
|
// Only add leaderboard link if there is at least one enabled placeholder and MC integration enabled
|
2023-06-12 10:30:49 -06:00
|
|
|
if (Settings::get('mc_integration') && Settings::get('placeholders') === '1') {
|
2023-03-23 20:01:23 -07:00
|
|
|
$leaderboard_placeholders = Placeholders::getInstance()->getLeaderboardPlaceholders();
|
2021-05-14 10:35:30 -07:00
|
|
|
|
2023-03-23 20:01:23 -07:00
|
|
|
if (count($leaderboard_placeholders)) {
|
|
|
|
|
$cache->setCache('navbar_order');
|
2025-05-20 18:37:24 -07:00
|
|
|
$leaderboards_order = $cache->fetch('leaderboards_order', 4);
|
2021-05-14 10:35:30 -07:00
|
|
|
|
2023-03-23 20:01:23 -07:00
|
|
|
$cache->setCache('navbar_icons');
|
2025-05-20 18:37:24 -07:00
|
|
|
$leaderboards_icon = $cache->fetch('leaderboards_icon', '');
|
2021-05-14 10:35:30 -07:00
|
|
|
|
2023-03-23 20:01:23 -07:00
|
|
|
$navs[0]->add('leaderboards', $language->get('general', 'leaderboards'), URL::build('/leaderboards'), 'top', null, $leaderboards_order, $leaderboards_icon);
|
|
|
|
|
}
|
2021-05-14 10:35:30 -07:00
|
|
|
}
|
|
|
|
|
|
2020-12-19 19:25:59 +01:00
|
|
|
// Check page type (frontend or backend)
|
2021-12-07 20:51:29 -08:00
|
|
|
if (defined('FRONT_END')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Minecraft integration?
|
2023-06-12 10:30:49 -06:00
|
|
|
if (Settings::get('mc_integration')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Query main server
|
|
|
|
|
$cache->setCache('mc_default_server');
|
|
|
|
|
|
|
|
|
|
// Already cached?
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($cache->isCached('default_query')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$result = $cache->retrieve('default_query');
|
|
|
|
|
$default = $cache->retrieve('default');
|
|
|
|
|
} else {
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($cache->isCached('default')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$default = $cache->retrieve('default');
|
|
|
|
|
$sub_servers = $cache->retrieve('default_sub');
|
|
|
|
|
} else {
|
|
|
|
|
// Get default server from database
|
2022-05-28 14:10:01 +02:00
|
|
|
$default = DB::getInstance()->get('mc_servers', ['is_default', true])->results();
|
2021-12-07 20:51:29 -08:00
|
|
|
if (count($default)) {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Get sub-servers of default server
|
2022-05-28 14:10:01 +02:00
|
|
|
$sub_servers = DB::getInstance()->get('mc_servers', ['parent_server', $default[0]->id])->results();
|
2021-12-07 22:14:12 -08:00
|
|
|
if (count($sub_servers)) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$cache->store('default_sub', $sub_servers);
|
2021-12-07 22:14:12 -08:00
|
|
|
} else {
|
2021-10-29 22:00:05 -07:00
|
|
|
$cache->store('default_sub', []);
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
$default = $default[0];
|
|
|
|
|
|
|
|
|
|
$cache->store('default', $default, 60);
|
2021-12-07 22:14:12 -08:00
|
|
|
} else {
|
2020-12-19 19:25:59 +01:00
|
|
|
$cache->store('default', null, 60);
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (!is_null($default) && isset($default->ip)) {
|
2023-06-01 22:08:25 +02:00
|
|
|
$full_ip = ['ip' => $default->ip . (is_null($default->port) ? '' : ':' . $default->port), 'pre' => $default->pre, 'name' => $default->name, 'id' => $default->id];
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// Get query type
|
2023-06-12 10:30:49 -06:00
|
|
|
$query_type = Settings::get('query_type', 'internal');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (isset($sub_servers) && count($sub_servers)) {
|
2021-10-29 22:00:05 -07:00
|
|
|
$servers = [$full_ip];
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
foreach ($sub_servers as $server) {
|
2022-02-12 13:10:39 -08:00
|
|
|
$servers[] = [
|
2023-02-09 21:31:20 +01:00
|
|
|
'id' => $server->id,
|
2022-02-12 13:10:39 -08:00
|
|
|
'ip' => $server->ip . (is_null($server->port) ? '' : ':' . $server->port),
|
|
|
|
|
'pre' => $server->pre,
|
|
|
|
|
'name' => $server->name,
|
|
|
|
|
'bedrock' => $server->bedrock
|
|
|
|
|
];
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2023-02-09 21:31:20 +01:00
|
|
|
$result = $query_type === 'plugin' ? PluginQuery::multiQuery($servers, $language, true) : MCQuery::multiQuery($servers, $query_type, $language, true);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (isset($result['status_value']) && $result['status_value'] == 1) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$result['status'] = $language->get('general', 'online');
|
|
|
|
|
|
2022-05-08 22:33:15 -06:00
|
|
|
if ($result['player_count'] == 1) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$result['status_full'] = $language->get('general', 'currently_1_player_online');
|
|
|
|
|
$result['x_players_online'] = $language->get('general', 'currently_1_player_online');
|
|
|
|
|
} else {
|
2022-05-08 22:33:15 -06:00
|
|
|
$result['status_full'] = $language->get('general', 'currently_x_players_online', ['count' => $result['player_count']]);
|
|
|
|
|
$result['x_players_online'] = $language->get('general', 'currently_x_players_online', ['count' => $result['player_count']]);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$result['status'] = $language->get('general', 'offline');
|
|
|
|
|
$result['status_full'] = $language->get('general', 'server_offline');
|
|
|
|
|
$result['server_offline'] = $language->get('general', 'server_offline');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
2023-02-09 21:31:20 +01:00
|
|
|
$result = $query_type === 'plugin' ? PluginQuery::singleQuery($default->id, $language) : MCQuery::singleQuery($full_ip, $query_type, $default->bedrock, $language);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (isset($result['status_value']) && $result['status_value'] == 1) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$result['status'] = $language->get('general', 'online');
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($result['player_count'] == 1) {
|
2020-12-19 19:25:59 +01:00
|
|
|
$result['status_full'] = $language->get('general', 'currently_1_player_online');
|
|
|
|
|
$result['x_players_online'] = $language->get('general', 'currently_1_player_online');
|
|
|
|
|
} else {
|
2022-04-23 06:27:10 -07:00
|
|
|
$result['status_full'] = $language->get('general', 'currently_x_players_online', ['count' => $result['player_count']]);
|
|
|
|
|
$result['x_players_online'] = $language->get('general', 'currently_x_players_online', ['count' => $result['player_count']]);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$result['status'] = $language->get('general', 'offline');
|
|
|
|
|
$result['status_full'] = $language->get('general', 'server_offline');
|
|
|
|
|
$result['server_offline'] = $language->get('general', 'server_offline');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cache for 1 minute
|
|
|
|
|
$cache->store('default_query', $result, 60);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariable('MINECRAFT', true);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
if (isset($result)) {
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariable('SERVER_QUERY', $result);
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (!is_null($default) && isset($default->ip)) {
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariables([
|
|
|
|
|
'CONNECT_WITH' => $language->get('general', 'connect_with_ip_x', [
|
|
|
|
|
'address' => '<span id="ip">' . Output::getClean($default->ip . ($default->port && $default->port != 25565 ? ':' . $default->port : '')) . '</span>',
|
|
|
|
|
]),
|
|
|
|
|
'DEFAULT_IP' => Output::getClean($default->ip . ($default->port != 25565 ? ':' . $default->port : '')),
|
|
|
|
|
'CLICK_TO_COPY_TOOLTIP' => $language->get('general', 'click_to_copy_tooltip'),
|
|
|
|
|
'COPIED' => $language->get('general', 'copied'),
|
|
|
|
|
]);
|
2020-12-19 19:25:59 +01:00
|
|
|
} else {
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariables([
|
|
|
|
|
'CONNECT_WITH' => '',
|
|
|
|
|
'DEFAULT_IP' => '',
|
|
|
|
|
]);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariable('SERVER_OFFLINE', $language->get('general', 'server_offline'));
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (defined('PAGE') && PAGE == 'user_query') {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Collection
|
2025-02-24 18:44:29 +00:00
|
|
|
$user_id = $template->getEngine()->getVariable('USER_ID');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2025-02-24 18:44:29 +00:00
|
|
|
$timeAgo = new TimeAgo(TIMEZONE);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user_id) {
|
2022-05-28 14:10:01 +02:00
|
|
|
$user_query = DB::getInstance()->get('users', ['id', $user_id])->results();
|
2021-12-07 20:51:29 -08:00
|
|
|
if (count($user_query)) {
|
2023-03-23 20:01:23 -07:00
|
|
|
$user_query = new UserData($user_query[0]);
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariables([
|
2023-03-23 20:01:23 -07:00
|
|
|
'REGISTERED' => $language->get('user', 'registered_x', [
|
2025-02-24 18:44:29 +00:00
|
|
|
'registeredAt' => $timeAgo->inWords($user_query->joined, $language),
|
2023-03-23 20:01:23 -07:00
|
|
|
]),
|
|
|
|
|
'REGISTERED_DATE' => date(DATE_FORMAT, $user_query->joined),
|
|
|
|
|
]);
|
|
|
|
|
|
2023-06-12 10:30:49 -06:00
|
|
|
if ($user->canBypassPrivateProfile() || (!Settings::get('private_profile') || !$user_query->private_profile)) {
|
2025-02-24 18:44:29 +00:00
|
|
|
$template->getEngine()->addVariables([
|
2023-03-23 20:01:23 -07:00
|
|
|
'LAST_SEEN' => $language->get('user', 'last_seen_x', [
|
2025-02-24 18:44:29 +00:00
|
|
|
'lastSeenAt' => $timeAgo->inWords($user_query->last_online, $language),
|
2023-03-23 20:01:23 -07:00
|
|
|
]),
|
|
|
|
|
'LAST_SEEN_DATE' => date(DATE_FORMAT, $user_query->last_online)
|
|
|
|
|
]);
|
|
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// Navigation
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->add('core_divider', mb_strtoupper($language->get('admin', 'core')), 'divider', 'top', null, 1, '');
|
|
|
|
|
$navs[2]->add('dashboard', $language->get('admin', 'dashboard'), URL::build('/panel'), 'top', null, 1, '<i class="nav-icon fas fa-home"></i>');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addDropdown('core_configuration', $language->get('admin', 'configuration'), 'top', 2, '<i class="nav-icon fas fa-wrench"></i>');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.general')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'general_settings', $language->get('admin', 'general_settings'), URL::build('/panel/core/general_settings'), 'top', null, '<i class="nav-icon fas fa-cogs"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.api')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'api', $language->get('admin', 'api'), URL::build('/panel/core/api'), 'top', null, '<i class="nav-icon fas fa-code"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
2020-12-28 12:46:52 +00:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.seo')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'seo', $language->get('admin', 'seo'), URL::build('/panel/core/seo'), 'top', null, '<i class="nav-icon fas fa-globe"></i>', 2);
|
2020-12-28 12:46:52 +00:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.avatars')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'avatars', $language->get('admin', 'avatars'), URL::build('/panel/core/avatars'), 'top', null, '<i class="nav-icon fas fa-image"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.fields')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'custom_profile_fields', $language->get('admin', 'custom_fields'), URL::build('/panel/core/profile_fields'), 'top', null, '<i class="nav-icon fas fa-id-card"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.debugging')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'debugging_and_maintenance', $language->get('admin', 'maintenance'), URL::build('/panel/core/debugging_and_maintenance'), 'top', null, '<i class="nav-icon fas fa-tachometer-alt"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.emails')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'emails', $language->get('admin', 'emails'), URL::build('/panel/core/emails'), 'top', null, '<i class="nav-icon fas fa-envelope"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.navigation')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'navigation', $language->get('admin', 'navigation'), URL::build('/panel/core/navigation'), 'top', null, '<i class="nav-icon fas fa-bars"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.terms')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'privacy_and_terms', $language->get('admin', 'privacy_and_terms'), URL::build('/panel/core/privacy_and_terms'), 'top', null, '<i class="nav-icon fas fa-file-alt"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-30 18:42:40 +01:00
|
|
|
if ($user->hasPermission('admincp.core.queue')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'queue', $language->get('admin', 'queue'), URL::build('/panel/core/queue'), 'top', null, '<i class="nav-icon fas fa-clock"></i>', 2);
|
2023-03-30 18:42:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.reactions')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'reactions', $language->get('user', 'reactions'), URL::build('/panel/core/reactions'), 'top', null, '<i class="nav-icon fas fa-smile"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.registration')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'registration', $language->get('admin', 'registration'), URL::build('/panel/core/registration'), 'top', null, '<i class="nav-icon fas fa-user-plus"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.social_media')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'social_media', $language->get('admin', 'social_media'), URL::build('/panel/core/social_media'), 'top', null, '<i class="nav-icon fas fa-users"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.hooks')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('core_configuration', 'hooks', $language->get('admin', 'hooks'), URL::build('/panel/core/hooks'), 'top', null, '<i class="nav-icon fas fa-link"></i>', 2);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-31 20:19:43 +01:00
|
|
|
if ($user->hasPermission('admincp.core.announcements') || $user->hasPermission('admincp.core.emails_mass_message')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addDropdown('announcements', $language->get('admin', 'communications'), 'top', 4, '<i class="nav-icon fas fa-bullhorn"></i>');
|
2024-03-31 20:19:43 +01:00
|
|
|
|
|
|
|
|
if ($user->hasPermission('admincp.core.announcements')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('announcements', 'announcements', $language->get('admin', 'announcements'), URL::build('/panel/core/announcements'), 'top', null, '<i class="nav-icon fas fa-bullhorn"></i>', 1);
|
2024-03-31 20:19:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($user->hasPermission('admincp.core.emails_mass_message')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('announcements', 'mass_message', $language->get('admin', 'mass_message'), URL::build('/panel/core/mass_message'), 'top', null, '<i class="nav-icon fas fa-envelopes-bulk"></i>', 1);
|
2024-03-31 20:19:43 +01:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.integrations')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addDropdown('integrations', $language->get('admin', 'integrations'), 'top', 5, '<i class="nav-icon fas fa-plug"></i>');
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-16 18:42:24 +02:00
|
|
|
if ($user->hasPermission('admincp.integrations.edit')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('integrations', 'integrations', $language->get('admin', 'general_settings'), URL::build('/panel/core/integrations'), 'top', null, '<i class="nav-icon fas fa-link"></i>', 1);
|
2022-04-16 18:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.minecraft')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('integrations', 'minecraft', $language->get('admin', 'minecraft'), URL::build('/panel/minecraft'), 'top', null, '<i class="nav-icon fas fa-cubes"></i>', 5);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.styles') || $user->hasPermission('admincp.sitemap') || $user->hasPermission('admincp.widgets')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addDropdown('layout', $language->get('admin', 'layout'), 'top', 6, '<i class="nav-icon fas fa-object-group"></i>');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.styles.images')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('layout', 'images', $language->get('admin', 'images'), URL::build('/panel/core/images'), 'top', null, '<i class="nav-icon fas fa-images"></i>', 6);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.styles.panel_templates')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('layout', 'panel_templates', $language->get('admin', 'panel_templates'), URL::build('/panel/core/panel_templates'), 'top', null, '<i class="nav-icon fas fa-tachometer-alt"></i>', 6);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.styles')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('layout', 'template', $language->get('admin', 'templates'), URL::build('/panel/core/templates'), 'top', null, '<i class="nav-icon fas fa-paint-brush"></i>', 6);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.widgets')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('layout', 'widgets', $language->get('admin', 'widgets'), URL::build('/panel/core/widgets'), 'top', null, '<i class="nav-icon fas fa-th"></i>', 6);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.modules')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->add('modules', $language->get('admin', 'modules'), URL::build('/panel/core/modules'), 'top', null, 7, '<i class="nav-icon fas fa-puzzle-piece"></i>');
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.pages')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->add('custom_pages', $language->get('admin', 'custom_pages'), URL::build('/panel/core/pages'), 'top', null, 8, '<i class="nav-icon fas fa-file"></i>');
|
2020-12-28 13:43:37 +01:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.groups')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->add('groups', $language->get('admin', 'groups'), URL::build('/panel/core/groups'), 'top', null, 3, '<i class="nav-icon fas fa-address-book"></i>');
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-08 21:13:33 +02:00
|
|
|
if ($user->hasPermission('admincp.users')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addDropdown('users', $language->get('admin', 'user_management'), 'top', 11, '<i class="nav-icon fas fa-user-circle"></i>');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('users', 'users', $language->get('admin', 'users'), URL::build('/panel/users'), 'top', null, '<i class="nav-icon fas fa-users"></i>', 11);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-10-08 21:13:33 +02:00
|
|
|
if ($user->hasPermission('modcp.ip_lookup')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('users', 'ip_lookup', $language->get('moderator', 'ip_lookup'), URL::build('/panel/users/ip_lookup'), 'top', null, '<i class="nav-icon fas fa-binoculars"></i>', 11);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-08 21:13:33 +02:00
|
|
|
if ($user->hasPermission('modcp.punishments')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('users', 'punishments', $language->get('moderator', 'punishments'), URL::build('/panel/users/punishments'), 'top', null, '<i class="nav-icon fas fa-gavel"></i>', 11);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-08 21:13:33 +02:00
|
|
|
if ($user->hasPermission('modcp.reports')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->addItemToDropdown('users', 'reports', $language->get('moderator', 'reports'), URL::build('/panel/users/reports'), 'top', null, '<i class="nav-icon fas fa-exclamation-triangle"></i>', 11);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-08 21:13:33 +02:00
|
|
|
if ($user->hasPermission('admincp.security')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->add('security', $language->get('admin', 'security'), URL::build('/panel/security'), 'top', null, 9, '<i class="nav-icon fas fa-lock"></i>');
|
2021-10-08 21:13:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($user->hasPermission('admincp.update')) {
|
2025-06-14 09:51:11 -07:00
|
|
|
$navs[2]->add('update', $language->get('admin', 'update'), URL::build('/panel/update'), 'top', null, 10, '<i class="nav-icon fas fa-download"></i>');
|
2021-10-08 21:13:33 +02:00
|
|
|
}
|
|
|
|
|
|
2020-12-19 19:25:59 +01:00
|
|
|
// Notices
|
|
|
|
|
$cache->setCache('notices_cache');
|
|
|
|
|
|
|
|
|
|
// Email errors?
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.core.emails')) {
|
2025-05-20 18:37:24 -07:00
|
|
|
$email_errors = $cache->fetch('email_orders', fn () => DB::getInstance()->query('SELECT COUNT(*) AS c FROM nl2_email_errors')->first()->c, 120);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2022-12-12 20:49:53 +00:00
|
|
|
if (intval($email_errors)) {
|
2020-12-19 19:25:59 +01:00
|
|
|
self::addNotice(URL::build('/panel/core/emails/errors'), $language->get('admin', 'email_errors_logged'));
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if (defined('PANEL_PAGE') && PANEL_PAGE == 'dashboard') {
|
2020-12-19 19:25:59 +01:00
|
|
|
// Dashboard graph
|
2025-05-20 18:37:24 -07:00
|
|
|
$data = $cache->fetch('core_data', function () {
|
2022-12-12 20:49:53 +00:00
|
|
|
$users = DB::getInstance()->query(
|
|
|
|
|
<<<SQL
|
|
|
|
|
SELECT DATE_FORMAT(FROM_UNIXTIME(`joined`), '%Y-%m-%d') d, COUNT(*) c
|
|
|
|
|
FROM nl2_users
|
2023-01-18 10:45:30 -08:00
|
|
|
WHERE `joined` > ? AND `joined` < UNIX_TIMESTAMP()
|
2022-12-12 20:49:53 +00:00
|
|
|
GROUP BY DATE_FORMAT(FROM_UNIXTIME(`joined`), '%Y-%m-%d')
|
|
|
|
|
SQL,
|
|
|
|
|
[strtotime('7 days ago')],
|
|
|
|
|
);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// Output array
|
2021-10-29 22:00:05 -07:00
|
|
|
$data = [];
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
$data['datasets']['users']['label'] = 'language/admin/registrations'; // for $language->get('admin', 'registrations');
|
|
|
|
|
$data['datasets']['users']['colour'] = '#0004FF';
|
|
|
|
|
|
2022-12-12 20:49:53 +00:00
|
|
|
if ($users->count()) {
|
|
|
|
|
foreach ($users->results() as $day) {
|
|
|
|
|
$data['_' . $day->d] = ['users' => $day->c];
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$users = null;
|
|
|
|
|
|
2022-12-12 20:49:53 +00:00
|
|
|
$data = self::fillMissingGraphDays($data, 'users');
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// Sort by date
|
|
|
|
|
ksort($data);
|
|
|
|
|
|
2025-05-20 18:37:24 -07:00
|
|
|
return $data;
|
|
|
|
|
}, 120);
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
self::addDataToDashboardGraph($language->get('admin', 'overview'), $data);
|
|
|
|
|
|
|
|
|
|
// Dashboard stats
|
2025-02-24 18:44:29 +00:00
|
|
|
require_once ROOT_PATH . '/modules/Core/collections/panel/TotalUsers.php';
|
2025-05-20 18:37:24 -07:00
|
|
|
CollectionManager::addItemToCollection('dashboard_stats', new TotalUsersItem($template->getEngine(), $language));
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2025-02-24 18:44:29 +00:00
|
|
|
require_once ROOT_PATH . '/modules/Core/collections/panel/RecentUsers.php';
|
2025-05-20 18:37:24 -07:00
|
|
|
CollectionManager::addItemToCollection('dashboard_stats', new RecentUsersItem($template->getEngine(), $language));
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
// Dashboard items
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('modcp.punishments')) {
|
2025-02-24 18:44:29 +00:00
|
|
|
require_once ROOT_PATH . '/modules/Core/collections/panel/RecentPunishments.php';
|
|
|
|
|
CollectionManager::addItemToCollection('dashboard_main_items', new RecentPunishmentsItem($template->getEngine(), $language, $cache));
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('modcp.reports')) {
|
2025-02-24 18:44:29 +00:00
|
|
|
require_once ROOT_PATH . '/modules/Core/collections/panel/RecentReports.php';
|
|
|
|
|
CollectionManager::addItemToCollection('dashboard_main_items', new RecentReportsItem($template->getEngine(), $language, $cache));
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-07 20:51:29 -08:00
|
|
|
if ($user->hasPermission('admincp.users')) {
|
2025-02-24 18:44:29 +00:00
|
|
|
require_once ROOT_PATH . '/modules/Core/collections/panel/RecentRegistrations.php';
|
|
|
|
|
CollectionManager::addItemToCollection('dashboard_main_items', new RecentRegistrationsItem($template->getEngine(), $language, $cache));
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
if ($user->hasPermission('admincp.users.edit')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
self::addUserAction($language->get('general', 'edit'), URL::build('/panel/users/edit/', 'id={id}'));
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2022-04-23 06:27:10 -07:00
|
|
|
|
2022-04-16 18:42:24 +02:00
|
|
|
if ($user->hasPermission('admincp.users.edit')) {
|
|
|
|
|
self::addUserAction($language->get('admin', 'integrations'), URL::build('/panel/users/integrations/', 'id={id}'));
|
|
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2024-10-17 23:21:27 -07:00
|
|
|
if ($user->hasPermission('admincp.users.sessions')) {
|
|
|
|
|
self::addUserAction($language->get('general', 'sessions'), URL::build('/panel/users/sessions', 'id={id}'));
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
if ($user->hasPermission('modcp.ip_lookup')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
self::addUserAction($language->get('moderator', 'ip_lookup'), URL::build('/panel/users/ip_lookup/', 'uid={id}'));
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
if ($user->hasPermission('modcp.punishments')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
self::addUserAction($language->get('moderator', 'punish'), URL::build('/panel/users/punishments/', 'user={id}'));
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
|
|
|
|
|
self::addUserAction($language->get('user', 'profile'), URL::build('/profile/{username}'));
|
|
|
|
|
|
2021-12-07 22:14:12 -08:00
|
|
|
if ($user->hasPermission('modcp.reports')) {
|
2020-12-19 19:25:59 +01:00
|
|
|
self::addUserAction($language->get('moderator', 'reports'), URL::build('/panel/users/reports/', 'uid={id}'));
|
2021-12-07 22:14:12 -08:00
|
|
|
}
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-01 11:35:10 -08:00
|
|
|
EventHandler::registerListener(UserDeletedEvent::class, DeleteUserHook::class);
|
2020-12-19 19:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2022-05-23 00:30:51 -06:00
|
|
|
public static function addNotice($url, $text): void {
|
2021-12-07 22:14:12 -08:00
|
|
|
self::$_notices[$url] = $text;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 23:06:06 -06:00
|
|
|
public static function addDataToDashboardGraph($title, $data): void {
|
2021-12-07 22:14:12 -08:00
|
|
|
if (isset(self::$_dashboard_graph[$title])) {
|
|
|
|
|
self::$_dashboard_graph[$title] = array_merge_recursive(self::$_dashboard_graph[$title], $data);
|
|
|
|
|
} else {
|
|
|
|
|
self::$_dashboard_graph[$title] = $data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-12 20:49:53 +00:00
|
|
|
/**
|
|
|
|
|
* Fill missing days in an array containing graph data
|
|
|
|
|
*
|
|
|
|
|
* @param array $data Initial data to display on graph
|
|
|
|
|
* @param string $key Key to output data under
|
|
|
|
|
* @return array Formatted data under $key
|
|
|
|
|
*/
|
|
|
|
|
public static function fillMissingGraphDays(array $data, string $key): array {
|
|
|
|
|
$start = new DateTime('-7 days');
|
|
|
|
|
$end = new DateTime('+1 day');
|
|
|
|
|
$interval = new DateInterval('P1D');
|
|
|
|
|
|
|
|
|
|
$dates = new DatePeriod($start, $interval, $end);
|
|
|
|
|
|
|
|
|
|
foreach ($dates as $date) {
|
|
|
|
|
$format = $date->format('Y-m-d');
|
|
|
|
|
if (!isset($data['_' . $format][$key])) {
|
|
|
|
|
$data['_' . $format][$key] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 00:30:51 -06:00
|
|
|
public static function addUserAction($title, $link): void {
|
2021-12-07 22:14:12 -08:00
|
|
|
self::$_user_actions[] = ['title' => $title, 'link' => $link];
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 21:46:34 -07:00
|
|
|
public function getDebugInfo(): array {
|
|
|
|
|
$servers = [];
|
2023-06-12 10:30:49 -06:00
|
|
|
$group_sync_server_id = Settings::get('group_sync_mc_server');
|
2021-10-13 21:46:34 -07:00
|
|
|
foreach (DB::getInstance()->get('mc_servers', ['id', '<>', 0])->results() as $server) {
|
2021-12-07 22:14:12 -08:00
|
|
|
$servers[(int)$server->id] = [
|
|
|
|
|
'id' => (int)$server->id,
|
2021-10-13 21:46:34 -07:00
|
|
|
'name' => $server->name,
|
|
|
|
|
'ip' => $server->ip,
|
|
|
|
|
'query_ip' => $server->query_ip,
|
|
|
|
|
'port' => $server->port,
|
|
|
|
|
'query_port' => $server->query_port,
|
2022-02-22 23:15:40 -08:00
|
|
|
'bedrock' => (bool)$server->bedrock,
|
2022-08-12 07:02:34 -07:00
|
|
|
'group_sync_server' => $server->id == $group_sync_server_id,
|
2021-10-13 21:46:34 -07:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'minecraft' => [
|
2023-06-12 10:30:49 -06:00
|
|
|
'mc_integration' => (bool)Settings::get(Settings::MINECRAFT_INTEGRATION),
|
|
|
|
|
'uuid_linking' => (bool)Settings::get('uuid_linking'),
|
2024-06-08 00:12:09 +02:00
|
|
|
'username_sync' => Settings::get('username_sync'),
|
2023-06-12 10:30:49 -06:00
|
|
|
'query_type' => Settings::get('query_type', 'internal'),
|
2021-10-13 21:46:34 -07:00
|
|
|
'servers' => $servers,
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
2018-09-10 01:14:58 +01:00
|
|
|
}
|