only show "upload profile background" if user on desktop or uses transparent theme
parent
7f1de57ffe
commit
7b0de3e79d
|
@ -1,4 +1,5 @@
|
|||
import secrets
|
||||
import user_agents
|
||||
|
||||
from files.helpers.const import *
|
||||
from files.helpers.settings import get_setting
|
||||
|
@ -21,8 +22,6 @@ def before_request():
|
|||
if not g.agent and request.path != '/kofi':
|
||||
return 'Please use a "User-Agent" header!', 403
|
||||
|
||||
ua = g.agent.lower()
|
||||
|
||||
if request.host != SITE:
|
||||
return {"error": "Unauthorized host provided"}, 403
|
||||
|
||||
|
@ -30,11 +29,13 @@ def before_request():
|
|||
|
||||
if not get_setting('bots') and request.headers.get("Authorization"): abort(403)
|
||||
|
||||
if '; wv) ' in ua:
|
||||
g.agent_parsed = str(user_agents.parse(g.agent))
|
||||
|
||||
if '; wv) ' in g.agent.lower():
|
||||
g.browser = 'webview'
|
||||
elif ' firefox/' in ua:
|
||||
elif g.agent_parsed.startswith('Firefox / '):
|
||||
g.browser = 'firefox'
|
||||
elif 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua:
|
||||
elif any(g.agent_parsed.startswith(x) for x in ('iPhone', 'iPad', 'iPod', 'PC / Mac OS X')):
|
||||
g.browser = 'apple'
|
||||
else:
|
||||
g.browser = 'chromium'
|
||||
|
|
|
@ -2,8 +2,6 @@ import time
|
|||
|
||||
from os import environ, listdir, path
|
||||
|
||||
import user_agents
|
||||
|
||||
from flask import g, session, has_request_context
|
||||
from jinja2 import pass_context
|
||||
|
||||
|
@ -59,9 +57,8 @@ def calc_users():
|
|||
if session["session_id"] in loggedout: del loggedout[session["session_id"]]
|
||||
loggedin[v.id] = timestamp
|
||||
else:
|
||||
ua = str(user_agents.parse(g.agent))
|
||||
if 'spider' not in ua.lower() and 'bot' not in ua.lower():
|
||||
loggedout[session["session_id"]] = (timestamp, ua)
|
||||
if 'spider' not in g.agent_parsed.lower() and 'bot' not in g.agent_parsed.lower():
|
||||
loggedout[session["session_id"]] = (timestamp, g.agent_parsed)
|
||||
|
||||
loggedin = {k: v for k, v in loggedin.items() if (timestamp - v) < LOGGEDIN_ACTIVE_TIME}
|
||||
loggedout = {k: v for k, v in loggedout.items() if (timestamp - v[0]) < LOGGEDIN_ACTIVE_TIME}
|
||||
|
|
|
@ -422,7 +422,7 @@
|
|||
<i class="fas fa-image mr-1"></i>
|
||||
{% if v.profile_background %}
|
||||
{{v.profile_background}}
|
||||
{% else %}
|
||||
{% elif v.theme == 'transparent' or g.agent_parsed.startswith('PC / ') %}
|
||||
Upload Profile Background
|
||||
{% endif %}
|
||||
</label>
|
||||
|
|
Loading…
Reference in New Issue