diff --git a/Havana-Server/src/main/java/org/alexdev/havana/dao/mysql/BanDao.java b/Havana-Server/src/main/java/org/alexdev/havana/dao/mysql/BanDao.java index 47c52f6..49dbf26 100644 --- a/Havana-Server/src/main/java/org/alexdev/havana/dao/mysql/BanDao.java +++ b/Havana-Server/src/main/java/org/alexdev/havana/dao/mysql/BanDao.java @@ -115,28 +115,36 @@ public class BanDao { } } - public static List getActiveBans() { + public static List getActiveBans(int page, String sortBy) { List banList = new ArrayList<>(); - Connection sqlConnection = null; - PreparedStatement preparedStatement = null; - ResultSet resultSet = null; + int rows = 25; + int nextOffset = page * rows; - try { - sqlConnection = Storage.getStorage().getConnection(); - preparedStatement = Storage.getStorage().prepare("SELECT * FROM users_bans WHERE is_active = 1 ORDER BY banned_at DESC", sqlConnection); - resultSet = preparedStatement.executeQuery(); + if (nextOffset >= 0) { + Connection sqlConnection = null; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; - while (resultSet.next()) { - banList.add(new Ban(BanType.valueOf(resultSet.getString("ban_type")), resultSet.getString("banned_value"), resultSet.getString("message"), resultSet.getTime("banned_until").getTime() / 1000L, - resultSet.getTime("banned_at").getTime() / 1000L, resultSet.getInt("banned_by"))); + try { + sqlConnection = Storage.getStorage().getConnection(); + preparedStatement = Storage.getStorage().prepare("SELECT * FROM users_bans WHERE is_active = 1 ORDER BY " + sortBy + " DESC LIMIT ? OFFSET ?", sqlConnection); + preparedStatement.setInt(1, rows); + preparedStatement.setInt(2, nextOffset); + + resultSet = preparedStatement.executeQuery(); + + while (resultSet.next()) { + banList.add(new Ban(BanType.valueOf(resultSet.getString("ban_type")), resultSet.getString("banned_value"), resultSet.getString("message"), resultSet.getTime("banned_until").getTime() / 1000L, + resultSet.getTime("banned_at").getTime() / 1000L, resultSet.getInt("banned_by"))); + } + } catch (Exception e) { + Storage.logError(e); + } finally { + Storage.closeSilently(sqlConnection); + Storage.closeSilently(preparedStatement); + Storage.closeSilently(resultSet); } - } catch (Exception e) { - Storage.logError(e); - } finally { - Storage.closeSilently(sqlConnection); - Storage.closeSilently(preparedStatement); - Storage.closeSilently(resultSet); } return banList; diff --git a/Havana-Server/src/main/java/org/alexdev/havana/game/club/ClubSubscription.java b/Havana-Server/src/main/java/org/alexdev/havana/game/club/ClubSubscription.java index ae5dc30..b8dd863 100644 --- a/Havana-Server/src/main/java/org/alexdev/havana/game/club/ClubSubscription.java +++ b/Havana-Server/src/main/java/org/alexdev/havana/game/club/ClubSubscription.java @@ -80,7 +80,7 @@ public class ClubSubscription { * @param playerDetails the details of the player that subscribed * @param choice the subscription choice */ - public static boolean subscribeClub(PlayerDetails playerDetails, int choice) { + public static boolean subscribeClub(PlayerDetails playerDetails, int choice) throws SQLException { var choiceData = getChoiceData(choice); int credits = choiceData.getKey(); @@ -124,6 +124,17 @@ public class ClubSubscription { PlayerDao.saveSubscription(playerDetails.getId(), playerDetails.getFirstClubSubscription(), playerDetails.getClubExpiration()); CurrencyDao.decreaseCredits(playerDetails, credits); + TransactionDao.createTransaction( + playerDetails.getId(), + "0", + "0", + days, + "Habbo Club purchase", + credits, + 0, + true + ); + return true; } diff --git a/Havana-Web/src/main/java/org/alexdev/http/controllers/habblet/HabboClubHabblet.java b/Havana-Web/src/main/java/org/alexdev/http/controllers/habblet/HabboClubHabblet.java index afca0c6..c1701b9 100644 --- a/Havana-Web/src/main/java/org/alexdev/http/controllers/habblet/HabboClubHabblet.java +++ b/Havana-Web/src/main/java/org/alexdev/http/controllers/habblet/HabboClubHabblet.java @@ -13,6 +13,7 @@ import org.alexdev.havana.util.DateUtil; import org.alexdev.havana.util.config.GameConfiguration; import org.alexdev.http.util.RconUtil; +import java.sql.SQLException; import java.util.HashMap; import java.util.concurrent.TimeUnit; @@ -39,7 +40,7 @@ public class HabboClubHabblet { template.render(); } - public static void subscribe(WebConnection webConnection) { + public static void subscribe(WebConnection webConnection) throws SQLException { if (!webConnection.session().getBoolean("authenticated")) { return; } diff --git a/Havana-Web/src/main/java/org/alexdev/http/controllers/housekeeping/HousekeepingBansController.java b/Havana-Web/src/main/java/org/alexdev/http/controllers/housekeeping/HousekeepingBansController.java index a72ab0d..7bd3e6c 100644 --- a/Havana-Web/src/main/java/org/alexdev/http/controllers/housekeeping/HousekeepingBansController.java +++ b/Havana-Web/src/main/java/org/alexdev/http/controllers/housekeeping/HousekeepingBansController.java @@ -15,6 +15,21 @@ public class HousekeepingBansController { return; } + int currentPage = 0; + + if (client.get().contains("page")) { + currentPage = Integer.parseInt(client.get().getString("page")); + } + + String sortBy = "banned_at"; + + if (client.get().contains("sort")) { + if (client.get().getString("sort").equals("banned_at") || + client.get().getString("sort").equals("banned_until")) { + sortBy = client.get().getString("sort"); + } + } + Template tpl = client.template("housekeeping/users_bans"); tpl.set("housekeepingManager", HousekeepingManager.getInstance()); @@ -25,7 +40,12 @@ public class HousekeepingBansController { return; } - tpl.set("bans", BanDao.getActiveBans()); + tpl.set("pageName", "Bans"); + tpl.set("bans", BanDao.getActiveBans(currentPage, sortBy)); + tpl.set("nextBans", BanDao.getActiveBans(currentPage + 1, sortBy)); + tpl.set("previousBans", BanDao.getActiveBans(currentPage - 1, sortBy)); + tpl.set("page", currentPage); + tpl.set("sortBy", sortBy); tpl.render(); // Delete alert after it's been rendered diff --git a/Havana-Web/src/main/java/org/alexdev/http/game/housekeeping/HousekeepingStats.java b/Havana-Web/src/main/java/org/alexdev/http/game/housekeeping/HousekeepingStats.java index 09357e7..c9e7877 100644 --- a/Havana-Web/src/main/java/org/alexdev/http/game/housekeeping/HousekeepingStats.java +++ b/Havana-Web/src/main/java/org/alexdev/http/game/housekeeping/HousekeepingStats.java @@ -16,4 +16,28 @@ public class HousekeepingStats { this.petCount = petCount; this.photoCount = photoCount; } + + public int getUserCount() { + return userCount; + } + + public int getInventoryItemsCount() { + return inventoryItemsCount; + } + + public int getRoomItemCount() { + return roomItemCount; + } + + public int getGroupCount() { + return groupCount; + } + + public int getPetCount() { + return petCount; + } + + public int getPhotoCount() { + return photoCount; + } } diff --git a/README.md b/README.md index e6b2105..2e5eb57 100644 --- a/README.md +++ b/README.md @@ -198,17 +198,9 @@ Download the [havana_www.zip](https://www.mediafire.com/file/x94neh4qbu3l2s2/hav *(This is the default directory for static content within the Havana-Web project, but the directory where it looks for static images can be configured in the Housekeeping settings).* -Open Havana-Web.jar via +Start Havana-Web via start_web.sh (Unix/Linux distros) or start_web.bat (Windows) -``` -java -jar Havana-Web.jar -``` - -Open Havana-Server.jar via - -``` -java -jar Havana-Server.jar -``` +Start Havana-Server via start_server.sh (Unix/Linux distros) or start_server.bat (Windows) Your server should be up and running and accessible via http://localhost/ diff --git a/tools/www-tpl/default-en/housekeeping/base/header.tpl b/tools/www-tpl/default-en/housekeeping/base/header.tpl index 34ac923..7cf5c36 100644 --- a/tools/www-tpl/default-en/housekeeping/base/header.tpl +++ b/tools/www-tpl/default-en/housekeeping/base/header.tpl @@ -6,8 +6,8 @@ {{ site.siteName }}: {{ pageName }} - - + + diff --git a/tools/www-tpl/default-en/housekeeping/dashboard.tpl b/tools/www-tpl/default-en/housekeeping/dashboard.tpl index 79296a9..3737589 100644 --- a/tools/www-tpl/default-en/housekeeping/dashboard.tpl +++ b/tools/www-tpl/default-en/housekeeping/dashboard.tpl @@ -90,7 +90,7 @@ {{ player.id }} {{ player.name }} - Transactons {{ player.email }} - + {{ player.motto }} {{ player.credits }} {{ player.pixels }} diff --git a/tools/www-tpl/default-en/housekeeping/login.tpl b/tools/www-tpl/default-en/housekeeping/login.tpl index 2cec47b..32c8f3f 100644 --- a/tools/www-tpl/default-en/housekeeping/login.tpl +++ b/tools/www-tpl/default-en/housekeeping/login.tpl @@ -7,9 +7,9 @@ {{ site.siteName }}: Housekeeping - - - + + + @@ -40,6 +40,6 @@ © Copyright 2018 - Alex Miller - + diff --git a/tools/www-tpl/default-en/housekeeping/users_bans.tpl b/tools/www-tpl/default-en/housekeeping/users_bans.tpl index 9e00c89..88326d3 100644 --- a/tools/www-tpl/default-en/housekeeping/users_bans.tpl +++ b/tools/www-tpl/default-en/housekeeping/users_bans.tpl @@ -5,6 +5,16 @@

View and manage bans

{% include "housekeeping/base/alert.tpl" %}

Manage all currently active bans on the hotel

+
+ {% if nextBans|length > 0 %} + {% set ourNextPage = page + 1 %} + + {% endif %} + {% if previousBans|length > 0 %} + {% set ourNextPage = page - 1 %} + + {% endif %} +
@@ -13,8 +23,8 @@ - - + + diff --git a/tools/www-tpl/default-en/housekeeping/users_search.tpl b/tools/www-tpl/default-en/housekeeping/users_search.tpl index 67412cb..708f6e3 100644 --- a/tools/www-tpl/default-en/housekeeping/users_search.tpl +++ b/tools/www-tpl/default-en/housekeeping/users_search.tpl @@ -56,7 +56,7 @@ - +
Type Value MessageBanned UtilBanned AtBanned UtilBanned At Banned By
{{ player.id }} {{ player.name }} {{ player.email }} {{ player.mission }} {{ player.credits }} {{ player.pixels }}