From 30cdb1ba73e3f3b1fc0b4046fc64b56c42b6e3a9 Mon Sep 17 00:00:00 2001 From: Lee <42119604+Leesneaks@users.noreply.github.com> Date: Sat, 7 Nov 2020 14:36:12 +0000 Subject: [PATCH] Dashboard modules updated More flexibility and additions on the dashboard modules. -Statistics: Accounts, Players, Monsters, Guilds, Houses -Website Status: Maintenance -Server Status: name, client, map, monsters loaded, MOTD, default: 'admin_panel_modules' => 'statistics,web_status,server_status,lastlogin,created,points,coins,balance', --- config.php | 2 +- system/pages/admin/dashboard.php | 35 ++++-------- system/pages/admin/modules/server_status.php | 46 +++++++++++++++ system/pages/admin/modules/statistics.php | 56 +++++++++++++++++++ .../admin/modules/templates/web_status.twig | 27 +++++++++ system/pages/admin/modules/web_status.php | 10 ++++ system/templates/admin.dashboard.html.twig | 27 --------- 7 files changed, 151 insertions(+), 52 deletions(-) create mode 100644 system/pages/admin/modules/server_status.php create mode 100644 system/pages/admin/modules/statistics.php create mode 100644 system/pages/admin/modules/templates/web_status.twig create mode 100644 system/pages/admin/modules/web_status.php diff --git a/config.php b/config.php index 37ef08df..cc906a54 100644 --- a/config.php +++ b/config.php @@ -273,7 +273,7 @@ $config = array( 'status_interval' => 60, // admin panel - 'admin_panel_modules' => 'lastlogin,points,coins', + 'admin_panel_modules' => 'statistics,web_status,server_status,lastlogin,created,points,coins,balance', // default - statistics,web_status,server_status,lastlogin,created,points,coins,balance // other 'anonymous_usage_statistics' => true, diff --git a/system/pages/admin/dashboard.php b/system/pages/admin/dashboard.php index 85925ae7..ba0ba8a0 100644 --- a/system/pages/admin/dashboard.php +++ b/system/pages/admin/dashboard.php @@ -47,33 +47,20 @@ $tmp = ''; if (fetchDatabaseConfig('site_closed_message', $tmp)) $closed_message = $tmp; -$query_count = $db->query('SELECT - (SELECT COUNT(*) FROM accounts) as total_accounts, - (SELECT COUNT(*) FROM players) as total_players, - (SELECT COUNT(*) FROM guilds) as total_guilds, - (SELECT COUNT(*) FROM houses) as total_houses;')->fetch(); - -$twig->display('admin.statistics.html.twig', array( - 'count' => $query_count, -)); - echo '
'; -$twig->display('admin.dashboard.html.twig', array( - 'is_closed' => $is_closed, - 'closed_message' => $closed_message, - 'status' => $status, - 'account_type' => USE_ACCOUNT_NAME ? 'name' : 'number' -)); +$twig->display('admin.dashboard.html.twig', array()); +echo '
'; $configAdminPanelModules = config('admin_panel_modules'); -if (isset($configAdminPanelModules)) +if (isset($configAdminPanelModules)) { + echo '
'; $configAdminPanelModules = explode(',', $configAdminPanelModules); - -$twig_loader->prependPath(__DIR__ . '/modules/templates'); -foreach ($configAdminPanelModules as $box) { - $file = __DIR__ . '/modules/' . $box . '.php'; - if (file_exists($file)) { - include($file); + $twig_loader->prependPath(__DIR__ . '/modules/templates'); + foreach ($configAdminPanelModules as $box) { + $file = __DIR__ . '/modules/' . $box . '.php'; + if (file_exists($file)) { + include($file); + } } -} echo '
'; +} \ No newline at end of file diff --git a/system/pages/admin/modules/server_status.php b/system/pages/admin/modules/server_status.php new file mode 100644 index 00000000..c89b67b4 --- /dev/null +++ b/system/pages/admin/modules/server_status.php @@ -0,0 +1,46 @@ +'; ?> +
+
+
+ Server Status Last checked: +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Server
Client
Map + ' . $status['mapAuthor'] . '
' . $status['mapWidth'] . ' x ' . $status['mapHeight']; + } else { + echo $error_icon; + } ?> +
Monsters
MOTD:
+
+
+
+ diff --git a/system/pages/admin/modules/statistics.php b/system/pages/admin/modules/statistics.php new file mode 100644 index 00000000..7dc65822 --- /dev/null +++ b/system/pages/admin/modules/statistics.php @@ -0,0 +1,56 @@ +query('SELECT + (SELECT COUNT(*) FROM `accounts`) as total_accounts, + (SELECT COUNT(*) FROM `players`) as total_players, + (SELECT COUNT(*) FROM `guilds`) as total_guilds, + (SELECT COUNT(*) FROM `' . TABLE_PREFIX . 'monsters`) as total_monsters, + (SELECT COUNT(*) FROM `houses`) as total_houses;')->fetch(); + +$error_icon = ''; +?> +
+
+ +
+ Accounts: + +
+
+
+
+
+ +
+ Players: + +
+
+
+
+
+ +
+ Monsters: + +
+
+
+
+
+ +
+ Guilds: + +
+
+
+
+
+ +
+ Houses: + +
+
+
diff --git a/system/pages/admin/modules/templates/web_status.twig b/system/pages/admin/modules/templates/web_status.twig new file mode 100644 index 00000000..9d88bf53 --- /dev/null +++ b/system/pages/admin/modules/templates/web_status.twig @@ -0,0 +1,27 @@ +
+
+
+
+ Website Status +
+ + +
+
+
+
+
+ + + (only visible if closed) +
+
+ +
+
+
\ No newline at end of file diff --git a/system/pages/admin/modules/web_status.php b/system/pages/admin/modules/web_status.php new file mode 100644 index 00000000..72b9f509 --- /dev/null +++ b/system/pages/admin/modules/web_status.php @@ -0,0 +1,10 @@ +display('web_status.twig', array( + 'is_closed' => $is_closed, + 'closed_message' => $closed_message, + 'status' => $status, + 'account_type' => USE_ACCOUNT_NAME ? 'name' : 'number' +)); +?> diff --git a/system/templates/admin.dashboard.html.twig b/system/templates/admin.dashboard.html.twig index 81b4284c..e69de29b 100644 --- a/system/templates/admin.dashboard.html.twig +++ b/system/templates/admin.dashboard.html.twig @@ -1,27 +0,0 @@ -
-
-
-
-
Website Status -
- - -
-
-
-
-
- - - (only visible if closed) -
-
- -
-
-