forked from MarseyWorld/MarseyWorld
fix 500 error
parent
1d726ebd77
commit
63fa768883
|
@ -11,6 +11,10 @@ from files.__main__ import app, limiter, get_CF, redis_instance
|
|||
def before_request():
|
||||
g.v = None
|
||||
|
||||
g.agent = request.headers.get("User-Agent")
|
||||
if not g.agent and request.path != '/kofi':
|
||||
abort(403, 'Please use a "User-Agent" header!')
|
||||
|
||||
if request.host != SITE:
|
||||
abort(403, "Unauthorized host provided!")
|
||||
|
||||
|
@ -20,10 +24,6 @@ def before_request():
|
|||
if request.headers.get("CF-Worker"):
|
||||
abort(403, "Cloudflare workers are not allowed to access this website!")
|
||||
|
||||
g.agent = request.headers.get("User-Agent", "")
|
||||
if not g.agent and request.path != '/kofi':
|
||||
abort(403, 'Please use a "User-Agent" header!')
|
||||
|
||||
if not get_setting('bots') and request.headers.get("Authorization"):
|
||||
abort(403)
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ def calc_users():
|
|||
if v:
|
||||
if session["session_id"] in loggedout: del loggedout[session["session_id"]]
|
||||
loggedin[v.id] = timestamp
|
||||
else:
|
||||
elif hasattr(g, 'agent') and g.agent:
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue