forked from MarseyWorld/MarseyWorld
fds
parent
3fbc423336
commit
50b995d3a0
|
@ -487,7 +487,6 @@ class User(Base):
|
|||
User.id != self.id
|
||||
).order_by(User.username).all()
|
||||
|
||||
data = [x for x in data]
|
||||
output = []
|
||||
for x in data:
|
||||
user = x[0]
|
||||
|
|
|
@ -279,7 +279,7 @@ def get_domain(s):
|
|||
|
||||
domain_list.add(new_domain)
|
||||
|
||||
doms = [x for x in g.db.query(BannedDomain).filter(BannedDomain.domain.in_(domain_list)).all()]
|
||||
doms = g.db.query(BannedDomain).filter(BannedDomain.domain.in_(domain_list)).all()
|
||||
|
||||
if not doms:
|
||||
return None
|
||||
|
|
|
@ -37,28 +37,26 @@ def get_logged_in_user():
|
|||
abort(403)
|
||||
|
||||
|
||||
|
||||
|
||||
if not session.get("session_id"):
|
||||
session.permanent = True
|
||||
session["session_id"] = secrets.token_hex(49)
|
||||
|
||||
sessions = cache.get(f'{SITE}_sessions') or {}
|
||||
|
||||
timestamp = int(time.time())
|
||||
|
||||
sessions[session["session_id"]] = (bool(v), timestamp)
|
||||
|
||||
|
||||
loggedin = cache.get(f'{SITE}_loggedin') or {}
|
||||
loggedout = cache.get(f'{SITE}_loggedout') or {}
|
||||
g.loggedin_counter = 0
|
||||
g.loggedout_counter = 0
|
||||
|
||||
for val in sessions.values():
|
||||
if timestamp - val[1] < 15*60:
|
||||
if val[0]: g.loggedin_counter += 1
|
||||
else: g.loggedout_counter += 1
|
||||
|
||||
|
||||
cache.set(f'{SITE}_sessions', sessions)
|
||||
timestamp = int(time.time())
|
||||
if v:
|
||||
if session["session_id"] in loggedout: del loggedout[session["session_id"]]
|
||||
loggedin[v.id] = timestamp
|
||||
else:
|
||||
loggedout[session["session_id"]] = timestamp
|
||||
|
||||
g.loggedin_counter = len([x for x in loggedin.values() if timestamp-x<15*60])
|
||||
cache.set(f'{SITE}_loggedin', loggedin)
|
||||
g.loggedout_counter = len([x for x in loggedout.values() if timestamp-x<15*60])
|
||||
cache.set(f'{SITE}_loggedout', loggedout)
|
||||
|
||||
|
||||
return v
|
||||
|
|
|
@ -24,6 +24,13 @@ GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
|
|||
|
||||
month = datetime.now().strftime('%B')
|
||||
|
||||
@app.get('/admin/loggedin')
|
||||
@admin_level_required(2)
|
||||
def loggedin_list(v):
|
||||
ids = cache.get(f'{SITE}_loggedin').keys()
|
||||
users = g.db.query(User).filter(User.id.in_(ids)).all()
|
||||
return render_template("agendaposters.html", v=v, users=users)
|
||||
|
||||
|
||||
@app.get('/admin/merge/<id1>/<id2>')
|
||||
@admin_level_required(3)
|
||||
|
@ -444,7 +451,7 @@ def monthly(v):
|
|||
@auth_required
|
||||
def shadowbanned(v):
|
||||
if not (v and v.admin_level > 1): abort(404)
|
||||
users = [x for x in g.db.query(User).filter(User.shadowbanned != None).order_by(User.shadowbanned).all()]
|
||||
users = g.db.query(User).filter(User.shadowbanned != None).order_by(User.shadowbanned).all()
|
||||
return render_template("shadowbanned.html", v=v, users=users)
|
||||
|
||||
|
||||
|
|
|
@ -171,6 +171,10 @@ def me(v):
|
|||
@auth_required
|
||||
def logout(v):
|
||||
|
||||
loggedin = cache.get(f'{SITE}_loggedin') or {}
|
||||
if session.get("lo_user") in loggedin: del loggedin[session["lo_user"]]
|
||||
cache.set(f'{SITE}_loggedin', loggedin)
|
||||
|
||||
session.pop("lo_user", None)
|
||||
|
||||
return {"message": "Logout successful!"}
|
||||
|
|
|
@ -282,7 +282,7 @@ def searchusers(v):
|
|||
|
||||
total=users.count()
|
||||
|
||||
users=[x for x in users.offset(25 * (page-1)).limit(26)]
|
||||
users = users.offset(25 * (page-1)).limit(26).all()
|
||||
next_exists=(len(users)>25)
|
||||
users=users[:25]
|
||||
|
||||
|
|
|
@ -542,7 +542,7 @@ def blocks(v):
|
|||
@auth_required
|
||||
def banned(v):
|
||||
|
||||
users = [x for x in g.db.query(User).filter(User.is_banned > 0, User.unban_utc == 0).all()]
|
||||
users = g.db.query(User).filter(User.is_banned > 0, User.unban_utc == 0).all()
|
||||
return render_template("banned.html", v=v, users=users)
|
||||
|
||||
@app.get("/formatting")
|
||||
|
|
|
@ -268,7 +268,7 @@ def grassed(v):
|
|||
@app.get("/agendaposters")
|
||||
@auth_required
|
||||
def agendaposters(v):
|
||||
users = [x for x in g.db.query(User).filter(User.agendaposter > 0).order_by(User.username).all()]
|
||||
users = g.db.query(User).filter(User.agendaposter > 0).order_by(User.username).all()
|
||||
return render_template("agendaposters.html", v=v, users=users)
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
<li><a href="/banned">Permabanned Users</a></li>
|
||||
<li><a href="/agendaposters">Users with Chud Theme</a></li>
|
||||
<li><a href="/grassed">Currently Grassed Users</a></li>
|
||||
<li><a href="/admin/loggedin">Currently Logged-in Users</a></li>
|
||||
</ul>
|
||||
|
||||
<h4>Safety</h4>
|
||||
|
|
|
@ -14,7 +14,12 @@
|
|||
{% include "journoid_banner.html" %}
|
||||
{%- else -%}
|
||||
<img src="/e/marseylowpoly.webp" style="height: 1em">
|
||||
PEOPLE HERE NOW: {{g.loggedin_counter}} logged in, {{g.loggedout_counter}} logged out
|
||||
|
||||
{% if v and v.admin_level > 1 %}
|
||||
PEOPLE HERE NOW: <a href="/admin/loggedin">{{g.loggedin_counter}} logged in</a>, {{g.loggedout_counter}} logged out
|
||||
{% else %}
|
||||
PEOPLE HERE NOW: {{g.loggedin_counter}} logged in, {{g.loggedout_counter}} logged out
|
||||
{% endif %}
|
||||
{%- endif -%}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -41,7 +41,11 @@ set VISITORS_HERE_FLAVOR = [
|
|||
<span>PEOPLE HERE NOW</span>
|
||||
</div>
|
||||
|
||||
<p class="mt-1 ml-1 mb-4 text-center text-lg">{{g.loggedin_counter}} logged in, {{g.loggedout_counter}} logged out</p>
|
||||
{% if v and v.admin_level > 1 %}
|
||||
<p class="mt-1 ml-1 mb-4 text-center text-lg"><a href="/admin/loggedin">{{g.loggedin_counter}} logged in</a>, {{g.loggedout_counter}} logged out</p>
|
||||
{% else %}
|
||||
<p class="mt-1 ml-1 mb-4 text-center text-lg">{{g.loggedin_counter}} logged in, {{g.loggedout_counter}} logged out</p>
|
||||
{% endif %}
|
||||
|
||||
{% if sub %}
|
||||
{% if sub.sidebar_html %}
|
||||
|
|
Loading…
Reference in New Issue