diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index cb0257852..d419f3f24 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -5,6 +5,21 @@ from files.__main__ import db_session from random import randint def get_logged_in_user(): + + if not session.get("session_id"): + session["session_id"] = secrets.token_hex(49) + + sessions = cache.get(f'{SITE}_sessions') or {} + sessions[session["session_id"]] = g.timestamp + + counter = 0 + for val in sessions.values(): + if g.timestamp - val < 60: + counter += 1 + g.counter = counter + + cache.set(f'{SITE}_sessions', sessions) + if not (hasattr(g, 'db') and g.db): g.db = db_session() v = None diff --git a/files/routes/front.py b/files/routes/front.py index 43b82221b..e0ad1ea3b 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -169,9 +169,6 @@ def notifications(v): @auth_desired def front_all(v, sub=None, subdomain=None): - if g.webview and not session.get("session_id"): - session["session_id"] = secrets.token_hex(49) - if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}") if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','')) diff --git a/files/templates/sidebar_rDrama.html b/files/templates/sidebar_rDrama.html index 295d20776..8c059a711 100644 --- a/files/templates/sidebar_rDrama.html +++ b/files/templates/sidebar_rDrama.html @@ -13,6 +13,8 @@ sidebar image {% endif %} + {{g.counter}} USERS HERE NOW

+ {% if sub %} {% if sub.sidebar_html %}
{{sub.sidebar_html|safe}}