From ded5274be7fa80be0826d59e2d0d01223121a0f7 Mon Sep 17 00:00:00 2001 From: whiteblXK Date: Sat, 16 Mar 2019 19:03:00 +0100 Subject: [PATCH] Modules in admin panel, thanks to Lee for the code --- system/pages/admin/dashboard.php | 30 ++++++++++--------- system/pages/admin/modules/coins.php | 11 +++++++ system/pages/admin/modules/lastlogin.php | 11 +++++++ system/pages/admin/modules/points.php | 10 +++++++ .../admin/modules/templates/coins.html.twig | 29 ++++++++++++++++++ .../modules/templates/lastlogin.html.twig | 29 ++++++++++++++++++ .../admin/modules/templates/points.html.twig | 29 ++++++++++++++++++ 7 files changed, 135 insertions(+), 14 deletions(-) create mode 100644 system/pages/admin/modules/coins.php create mode 100644 system/pages/admin/modules/lastlogin.php create mode 100644 system/pages/admin/modules/points.php create mode 100644 system/pages/admin/modules/templates/coins.html.twig create mode 100644 system/pages/admin/modules/templates/lastlogin.html.twig create mode 100644 system/pages/admin/modules/templates/points.html.twig diff --git a/system/pages/admin/dashboard.php b/system/pages/admin/dashboard.php index 10e8dbe8..ec86249e 100644 --- a/system/pages/admin/dashboard.php +++ b/system/pages/admin/dashboard.php @@ -62,18 +62,6 @@ $query = $db->query('SELECT count(*) as `how_much` FROM `houses`;'); $query = $query->fetch(); $total_houses = $query['how_much']; -if ($db->hasColumn('accounts', 'premium_points')) { - $points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;'); -} else { - $points = 0; -} - -if ($db->hasColumn('accounts', 'coins')) { - $coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;'); -} else { - $coins = 0; -} - $twig->display('admin.statistics.html.twig', array( 'total_accounts' => $total_accounts, 'total_players' => $total_players, @@ -86,9 +74,23 @@ $twig->display('admin.dashboard.html.twig', array( 'closed_message' => $closed_message, 'status' => $status, 'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'), - 'points' => $points, - 'coins' => $coins, + )); + +echo '
'; +$config['modules'] = "lastlogin,points,coins"; +if(isset($config['modules'])) + $config['modules'] = explode(",", $config['modules']); + +$twig_loader->prependPath(__DIR__ . '/modules/templates'); +foreach($config['modules'] as $box) { + $file = __DIR__ . '/modules/' . $box . '.php'; + if(file_exists($file)) { + include($file); + } +} +echo '
'; + function clearCache() { global $template_name; diff --git a/system/pages/admin/modules/coins.php b/system/pages/admin/modules/coins.php new file mode 100644 index 00000000..3dbc19c8 --- /dev/null +++ b/system/pages/admin/modules/coins.php @@ -0,0 +1,11 @@ +hasColumn('accounts', 'coins')) { + $coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;'); +} else { + $coins = 0; +} + +$twig->display('coins.html.twig', array( + 'coins' => $coins +)); \ No newline at end of file diff --git a/system/pages/admin/modules/lastlogin.php b/system/pages/admin/modules/lastlogin.php new file mode 100644 index 00000000..d8d5ed52 --- /dev/null +++ b/system/pages/admin/modules/lastlogin.php @@ -0,0 +1,11 @@ +hasColumn('players', 'lastlogin')) { + $players = $db->query('SELECT `id`, `name`,`level`,`lastlogin` FROM `players` ORDER BY `lastlogin` DESC LIMIT 10;'); +} else { + $players = 0; +} + +$twig->display('lastlogin.html.twig', array( + 'players' => $players, +)); \ No newline at end of file diff --git a/system/pages/admin/modules/points.php b/system/pages/admin/modules/points.php new file mode 100644 index 00000000..e5040f53 --- /dev/null +++ b/system/pages/admin/modules/points.php @@ -0,0 +1,10 @@ +hasColumn('accounts', 'premium_points')) { + $points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;'); +} else { + $points = 0; +} + +$twig->display('points.html.twig', array( + 'points' => $points, +)); \ No newline at end of file diff --git a/system/pages/admin/modules/templates/coins.html.twig b/system/pages/admin/modules/templates/coins.html.twig new file mode 100644 index 00000000..e5183443 --- /dev/null +++ b/system/pages/admin/modules/templates/coins.html.twig @@ -0,0 +1,29 @@ +{% if coins is iterable %} +
+
+
+

Top 10 - Most coins

+
+
+ + + + + + + + {% set i = 0 %} + {% for result in coins %} + {% set i = i + 1 %} + + + + + + {% endfor %} + +
#Account {{ account_type }}Tibia coins
{{ i }}{{ result.name }}{{ result.coins }}
+
+
+
+{% endif %} \ No newline at end of file diff --git a/system/pages/admin/modules/templates/lastlogin.html.twig b/system/pages/admin/modules/templates/lastlogin.html.twig new file mode 100644 index 00000000..62d6fbc5 --- /dev/null +++ b/system/pages/admin/modules/templates/lastlogin.html.twig @@ -0,0 +1,29 @@ +{% if players is iterable %} +
+
+
+

Last 10 Logins

+
+
+ + + + + + + + {% set i = 0 %} + {% for result in players %} + {% set i = i + 1 %} + + + + + + {% endfor %} + +
#PlayerLogin Date
{{ i }}{{ result.name }}{{ result.lastlogin|date("M d Y, H:i:s") }}
+
+
+
+{% endif %} \ No newline at end of file diff --git a/system/pages/admin/modules/templates/points.html.twig b/system/pages/admin/modules/templates/points.html.twig new file mode 100644 index 00000000..acdcd390 --- /dev/null +++ b/system/pages/admin/modules/templates/points.html.twig @@ -0,0 +1,29 @@ +{% if points is iterable %} +
+
+
+

Top 10 - Most premium points

+
+
+ + + + + + + + {% set i = 0 %} + {% for result in points %} + {% set i = i + 1 %} + + + + + + {% endfor %} + +
#Account {{ account_type }}Premium points
{{ i }}{{ result.name }}{{ result.premium_points }}
+
+
+
+{% endif %} \ No newline at end of file