simple server info page for xenforo node page

This commit is contained in:
jenz 2026-02-13 19:19:20 +01:00
parent c2c177f876
commit 4c88546d35
7 changed files with 176 additions and 0 deletions

View File

@ -0,0 +1 @@
[{"name": "UNLOZE.com/stoat | Zombie Escape | Stage: [Purple] | Nosteam", "map": "ze_minimal_v4_1", "players": "65/65", "ip": "51.195.188.106:27015"}, {"name": "UNLOZE.com/stoat | [ZRiot: Day 8/12] BOSS - Nightmares | Ranking", "map": "zr_roblox_crossroads_scythx", "players": "1/65", "ip": "51.195.188.106:27016"}, {"name": "UNLOZE | Minigames | FastDL | Ranking", "map": "mg_GumObstacle", "players": "2/41", "ip": "51.195.188.106:27017"}, {"name": "UNLOZE.com/stoat | Zombie Escape 2 | UK", "map": "ze_random_v9", "players": "7/65", "ip": "51.195.188.106:27035"}, {"name": "UNLOZE Sven Server", "map": "sandstone", "players": "0/32", "ip": "51.195.188.106:27025"}]

View File

@ -0,0 +1,102 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UNLOZE Server Status</title>
<style>
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #121212; color: #e0e0e0; padding: 20px; }
.container { max-width: 900px; margin: auto; }
h1 { border-bottom: 2px solid #444; padding-bottom: 10px; color: #fff; }
.server-card {
background: #1e1e1e;
border-radius: 8px;
padding: 15px;
margin-bottom: 15px;
border-left: 5px solid #00ff41; /* Green accent */
display: flex;
justify-content: space-between;
align-items: center;
transition: transform 0.2s;
}
.server-card:hover { transform: translateX(5px); background: #252525; }
.info-main { flex-grow: 1; }
.server-name { font-weight: bold; font-size: 1.1em; color: #00ff41; margin-bottom: 5px; }
.server-sub { font-size: 0.9em; color: #aaa; }
.stats { text-align: right; min-width: 120px; }
.players { font-size: 1.2em; font-weight: bold; color: #fff; }
.btn-connect {
background: #00ff41;
color: #000;
text-decoration: none;
padding: 8px 15px;
border-radius: 4px;
font-weight: bold;
font-size: 0.8em;
margin-left: 20px;
}
.btn-connect:hover { background: #00cc33; }
</style>
</head>
<body>
<div class="container">
<h1>UNLOZE Server Info</h1>
<div id="server-list">Loading servers...</div>
</div>
<script>
async function loadServers() {
try {
const response = await fetch('servers.json');
const data = await response.json();
const listContainer = document.getElementById('server-list');
listContainer.innerHTML = '';
data.forEach(server => {
const card = document.createElement('div');
card.className = 'server-card';
card.innerHTML = `
<div class="info-main">
<div class="server-name">${server.name}</div>
<div class="server-sub">Map: <strong>${server.map}</strong></div>
</div>
<div class="stats">
<div class="players">${server.players}</div>
<div class="server-sub">${server.ip}</div>
</div>
<a href="steam://connect/${server.ip}" class="btn-connect">CONNECT</a>
`;
listContainer.appendChild(card);
});
// --- ADD THIS LINE HERE ---
// Tell the parent XenForo page to resize now that the content is actually here
sendHeight();
} catch (error) {
console.error('Error loading JSON:', error);
document.getElementById('server-list').innerText = 'Failed to load server data.';
}
}
function sendHeight() {
// Add a little buffer (e.g., + 20) to ensure nothing is clipped
const height = document.body.scrollHeight + 20;
window.parent.postMessage({ type: 'setHeight', height: height }, '*');
}
// Initial load
loadServers();
// Refresh every 30s
setInterval(loadServers, 30000);
</script>
</body>
</html>

View File

@ -0,0 +1,6 @@
flask
flask_cors
waitress
werkzeug
python app.py

46
server_info/python/app.py Normal file
View File

@ -0,0 +1,46 @@
#!/home/nonroot/update_xenforo_server_info/venv/bin/python3
from flask import Flask
from flask import request
from flask_cors import CORS
from werkzeug.middleware.proxy_fix import ProxyFix
import traceback
import json
from pprint import pprint
from settings import ips, file_path
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1)
CORS(app)
#nginx used for reserve proxy
@app.route('/', methods = ['POST'])
def get_server_info():
real_ip = request.headers.get('X-Real-IP', request.remote_addr)
#ipv4 and ipv6 checks
if real_ip != ips[0] and not real_ip.startswith(ips[1]):
return "invalid"
try:
content = request.get_json()
server_content = content["content"].split("###")
del server_content[0] #removing # UNLOZE Server Info
new_j = []
for server in server_content:
name = server.split("\n")[0].strip()
map_ = server.split("**")[1].split(" ")[0]
players = server.split("(")[1].split(")")[0]
ip = server.split("\n[")[1].split("]")[0]
j = {"name": name, "map": map_, "players": players, "ip": ip}
new_j.append(j)
#print(new_j)
with open(file_path, 'w') as file:
json.dump(new_j, file, ensure_ascii=False)
except:
err = traceback.format_exc()
print("err: ", err)
return ""
if __name__ == "__main__":
from waitress import serve
serve(app, host="127.0.0.1", port=5085, threads = 1)

View File

@ -0,0 +1,2 @@
ips = ["", ""]
file_path = ""

View File

@ -0,0 +1,11 @@
[Unit]
Description=flask app that receives server_info
[Service]
Type=simple
User=nonroot
Environment=PYTHONUNBUFFERED=1
Environment=PATH=/home/nonroot/update_xenforo_server_info/venv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
WorkingDirectory=/home/nonroot/update_xenforo_server_info
ExecStart=/home/nonroot/update_xenforo_server_info/app.py
Restart=always

View File

@ -0,0 +1,8 @@
[Unit]
Description=Flask app for server_info receiving
[Timer]
OnCalendar=*-*-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 00:00:00
[Install]
WantedBy=multi-user.target