users here now
parent
ca18dc8bdd
commit
2b9dcb0c6a
|
@ -5,6 +5,21 @@ from files.__main__ import db_session
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
def get_logged_in_user():
|
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()
|
if not (hasattr(g, 'db') and g.db): g.db = db_session()
|
||||||
|
|
||||||
v = None
|
v = None
|
||||||
|
|
|
@ -169,9 +169,6 @@ def notifications(v):
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def front_all(v, sub=None, subdomain=None):
|
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 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',''))
|
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out',''))
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
<img class="mb-4" alt="sidebar image" role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{image}}')" loading="lazy" src="{{image}}" width=100%>
|
<img class="mb-4" alt="sidebar image" role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{image}}')" loading="lazy" src="{{image}}" width=100%>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{{g.counter}} USERS HERE NOW<br><br>
|
||||||
|
|
||||||
{% if sub %}
|
{% if sub %}
|
||||||
{% if sub.sidebar_html %}
|
{% if sub.sidebar_html %}
|
||||||
<div class="mb-4">{{sub.sidebar_html|safe}}</div>
|
<div class="mb-4">{{sub.sidebar_html|safe}}</div>
|
||||||
|
|
Loading…
Reference in New Issue