diff --git a/pom.xml b/pom.xml
index 547d619..aed25af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,10 +53,11 @@
3.0.2
- com.mysql
- mysql-connector-j
- 8.0.32
+ org.postgresql
+ postgresql
+ 42.6.0
+
org.springframework.boot
spring-boot-starter-actuator
diff --git a/src/main/java/app/services/db/BanService.java b/src/main/java/app/services/db/BanService.java
index eaa6d78..aacc812 100644
--- a/src/main/java/app/services/db/BanService.java
+++ b/src/main/java/app/services/db/BanService.java
@@ -33,7 +33,7 @@ public class BanService {
}
public Ban getBan(SteamID steamID) {
- return jdbcTemplate.query("SELECT * FROM light_bans WHERE account_id = ? AND active = 1",
+ return jdbcTemplate.query("SELECT * FROM light_bans WHERE account_id = ? AND active = true",
new Object[]{ steamID.account_id },
(rs, n) -> new Ban(rs))
.stream()
@@ -55,7 +55,7 @@ public class BanService {
}
public List getBans(SteamID steamID) {
- return jdbcTemplate.query("SELECT * FROM light_bans WHERE account_id = ? AND active = 0",
+ return jdbcTemplate.query("SELECT * FROM light_bans WHERE account_id = ? AND active = false",
new Object[]{steamID.account_id},
(rs, n) -> new Ban(rs))
.stream()
@@ -65,8 +65,8 @@ public class BanService {
}
public List getLastBans(Integer limit, Integer offset) {
- return jdbcTemplate.query("SELECT * FROM `light_bans` WHERE `active` = ? ORDER BY `light_bans`.`id` DESC LIMIT ? OFFSET ?",
- new Object[]{1, limit, offset},
+ return jdbcTemplate.query("SELECT * FROM light_bans WHERE active = ? ORDER BY light_bans.id DESC LIMIT ? OFFSET ?",
+ new Object[]{true, limit, offset},
(rs, n) -> new Ban(rs))
.stream()
.peek(ban -> ban.cryptIP(cryptedCookie))
@@ -75,7 +75,7 @@ public class BanService {
}
public Long getBansCount() {
- return jdbcTemplate.query("SELECT COUNT(*) as c FROM `light_bans` WHERE active = 1",
+ return jdbcTemplate.query("SELECT COUNT(*) as c FROM light_bans WHERE active = true",
(rs, n) -> rs.getLong("c")).stream().findFirst().orElse(0L);
}
@@ -83,7 +83,7 @@ public class BanService {
Ban ban = getBan(user.getSteamids());
if (ban == null) return false;
return jdbcTemplate.update("UPDATE light_bans SET active = ?, unbanned_by_id = ?, unbanned_timestamp = CURRENT_TIMESTAMP WHERE id = ?",
- 0, admin.getSteamids().steam2, ban.getId()) > 0;
+ false, admin.getSteamids().steam2, ban.getId()) > 0;
}
public int addBan(PlayerProfile user, PlayerProfile admin, int ban_length, String ban_reason) {
@@ -99,8 +99,8 @@ public class BanService {
}
public List getUsersDiscordWithBanOnServers() {
- return jdbcTemplate.query("SELECT `discord_id` FROM `light_bans` INNER JOIN `steam2discord` ON `light_bans`.`active` = ? AND `light_bans`.`steam_id` COLLATE utf8mb4_unicode_ci LIKE `steam2discord`.`steam_id`",
- new Object[]{1},
+ return jdbcTemplate.query("SELECT discord_id FROM light_bans INNER JOIN steam2discord ON light_bans.active = ? AND light_bans.steam_id LIKE steam2discord.steam_id",
+ new Object[]{true},
(rs, n) -> rs.getLong("discord_id"));
}
diff --git a/src/main/java/app/services/db/DBService.java b/src/main/java/app/services/db/DBService.java
index d5a26f0..7d8da2c 100644
--- a/src/main/java/app/services/db/DBService.java
+++ b/src/main/java/app/services/db/DBService.java
@@ -31,13 +31,13 @@ public class DBService {
}
public Long getMainServerTime() {
- return jdbcTemplate_rw.query("SELECT UNIX_TIMESTAMP() as u",
+ return jdbcTemplate_rw.query("select CAST(extract(epoch from now()) as BIGINT) as u",
(rs, n) -> rs.getLong("u"))
.stream().findFirst().orElse(0L);
}
public Long getReplicaServerTime() {
- return jdbcTemplate_rw.query("SELECT UNIX_TIMESTAMP() as u",
+ return jdbcTemplate_rw.query("select CAST(extract(epoch from now()) as BIGINT) as u",
(rs, n) -> rs.getLong("u"))
.stream().findFirst().orElse(0L);
}
diff --git a/src/main/java/app/services/db/DetectService.java b/src/main/java/app/services/db/DetectService.java
index d7934bc..28a3242 100644
--- a/src/main/java/app/services/db/DetectService.java
+++ b/src/main/java/app/services/db/DetectService.java
@@ -40,11 +40,11 @@ public class DetectService {
public List getAccountsPerSteamID(SteamID steamID) {
List founded_steamid = new ArrayList<>();
for (Map.Entry stringServerEntry : stats.getServers().entrySet()) {
- founded_steamid.addAll(jdbcTemplate_ro.query("SELECT `steam_id` FROM `" + stringServerEntry.getValue().getDb() + "`." + "`user_connections` WHERE `connect_ip` in (SELECT `connect_ip` FROM `" + stringServerEntry.getValue().getDb() + "`." + "`user_connections` WHERE `steam_id` LIKE ? AND `connect_ip` NOT LIKE '10.%' GROUP BY `connect_ip` ORDER BY `id` DESC) GROUP BY `steam_id`",
+ founded_steamid.addAll(jdbcTemplate_ro.query("SELECT steam_id FROM " + stringServerEntry.getValue().getDb() + "." + "user_connections WHERE connect_ip in (SELECT connect_ip FROM " + stringServerEntry.getValue().getDb() + "." + "user_connections WHERE steam_id LIKE ? AND connect_ip NOT LIKE '10.%' GROUP BY connect_ip ORDER BY id DESC) GROUP BY steam_id",
new Object[]{steamID.steam2},
(rs, n) -> rs.getString("steam_id")));
}
- //SELECT `steam_id` FROM `tf2.facti13.five`.`user_connections` WHERE `connect_ip` in (SELECT `connect_ip` FROM `tf2.facti13.five`.`user_connections` WHERE `steam_id` LIKE 'STEAM_0:0:63666481' AND `connect_ip` NOT LIKE '10.%' GROUP BY `connect_ip` ORDER BY `id` DESC) GROUP BY `steam_id`;
+ //SELECT steam_id FROM tf2.facti13.five.user_connections WHERE connect_ip in (SELECT connect_ip FROM tf2.facti13.five.user_connections WHERE steam_id LIKE 'STEAM_0:0:63666481' AND connect_ip NOT LIKE '10.%' GROUP BY connect_ip ORDER BY id DESC) GROUP BY steam_id;
return founded_steamid.stream().distinct().map(SteamIDConverter::getSteamID).filter(Objects::nonNull).toList();
}
@@ -61,7 +61,7 @@ public class DetectService {
em_selector.set(0);
}
- String sql = "SELECT `steam_id` FROM `"+stringServerEntry.getValue().getDb()+"`."+"`user_connections` WHERE `connect_ip` in (SELECT `connect_ip` FROM `" + stringServerEntry.getValue().getDb() + "`." +"`user_connections` WHERE `steam_id` LIKE ? AND `connect_ip` NOT LIKE '10.%' GROUP BY `connect_ip` ORDER BY `id` DESC) GROUP BY `steam_id`";
+ String sql = "SELECT steam_id FROM "+stringServerEntry.getValue().getDb()+"."+"user_connections WHERE connect_ip in (SELECT connect_ip FROM " + stringServerEntry.getValue().getDb() + "." +"user_connections WHERE steam_id LIKE ? AND connect_ip NOT LIKE '10.%' GROUP BY connect_ip ORDER BY id DESC) GROUP BY steam_id";
switch (em_selector.get()) {
case 0:return jdbcTemplate_ro.query(sql, new Object[]{steamID.steam2}, (rs, n) -> rs.getString("steam_id"));
@@ -81,9 +81,9 @@ public class DetectService {
}
public List