This commit is contained in:
cay 2026-04-10 17:13:23 +01:00
parent 5c7f26db49
commit efb8589a61
3 changed files with 12 additions and 29 deletions

22
app.js
View File

@ -59,8 +59,8 @@ app.use(
defaultSrc: ["'self'"],
scriptSrc: ["'self'", "'unsafe-inline'"],
scriptSrcAttr: ["'unsafe-inline'"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com", "https://cdnjs.cloudflare.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com", "https://cdnjs.cloudflare.com"],
imgSrc: ["'self'", "data:", "blob:"],
connectSrc: ["'self'", "ws:", "wss:"],
frameAncestors: ["'self'"], // Erlaubt iframe von eigener Domain
@ -108,25 +108,9 @@ app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "public")));
/* ========================
Server Stats (öffentlich kein Login nötig)
Zählt online Spieler pro Server
via Socket.io Verbindungen
Login Middleware
======================== */
app.get("/api/server-stats", (req, res) => {
const stats = {};
// Alle verbundenen Sockets durchgehen
const sockets = io.sockets.sockets;
sockets.forEach((socket) => {
if (socket.user && socket.serverId) {
stats[socket.serverId] = (stats[socket.serverId] || 0) + 1;
}
});
res.json(stats);
});
function requireLogin(req, res, next) {
if (!req.session.user) {
return res.status(401).json({ error: "Nicht eingeloggt" });

View File

@ -206,16 +206,14 @@
}
.hud-res-icon {
font-size: 0; /* Emoji unsichtbar */
color: transparent;
display: inline-block;
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
flex-shrink: 0;
background: url("/images/items/blauer-cristal.png") center / contain
no-repeat;
font-size: 15px;
filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
vertical-align: middle;
}
/* Ressource Icons (gem, silver, wood, stone, gold, iron) einheitliche Größe */

View File

@ -94,6 +94,7 @@
<link rel="stylesheet" href="/css/quickmenu.css" />
<link rel="stylesheet" href="/css/events.css" />
<link rel="stylesheet" href="/css/hud.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" />
<link rel="stylesheet" href="/css/mine.css" />
<script src="/js/heartbeat.js"></script>
<script src="/js/map-scale.js"></script>
@ -654,12 +655,12 @@
<div id="hud-currency">
<div class="hud-res-row">
<div class="hud-res">
<span class="hud-res-icon">💠</span>
<span class="hud-res-icon"><i class="fa-solid fa-gem" style="color:#4fc3f7;"></i></span>
<span class="hud-res-value" id="hud-gems">0</span>
</div>
<div class="hud-sep"></div>
<div class="hud-res">
<span class="hud-res-icon">🪙</span>
<span class="hud-res-icon"><i class="fa-solid fa-coins" style="color:#f0c040;"></i></span>
<span class="hud-res-value" id="hud-gold">0</span>
</div>
<button id="hud-gold-btn">Shop</button>
@ -667,12 +668,12 @@
<div class="hud-res-row">
<div class="hud-res">
<span class="hud-res-icon">🪵</span>
<span class="hud-res-icon"><i class="fa-solid fa-tree" style="color:#66bb6a;"></i></span>
<span class="hud-res-value" id="hud-wood">0</span>
</div>
<div class="hud-sep"></div>
<div class="hud-res">
<span class="hud-res-icon">🪨</span>
<span class="hud-res-icon"><i class="fa-solid fa-mountain" style="color:#a0a0a0;"></i></span>
<span class="hud-res-value" id="hud-stone">0</span>
</div>
</div>