vcxvcx
This commit is contained in:
parent
7844b0821e
commit
65122c970b
5 changed files with 49 additions and 63 deletions
|
@ -342,36 +342,29 @@ def reported_comments(v):
|
|||
@app.get("/admin")
|
||||
@admin_level_required(2)
|
||||
def admin_home(v):
|
||||
|
||||
with open('disable_signups', 'r') as f: x = f.read()
|
||||
with open('under_attack', 'r') as f: x2 = f.read()
|
||||
|
||||
return render_template("admin/admin_home.html", v=v, x=x, x2=x2)
|
||||
return render_template("admin/admin_home.html", v=v)
|
||||
|
||||
@app.post("/admin/disable_signups")
|
||||
@admin_level_required(3)
|
||||
def disable_signups(v):
|
||||
with open('disable_signups', 'r') as f: content = f.read()
|
||||
|
||||
with open('disable_signups', 'w') as f:
|
||||
if content == "yes":
|
||||
f.write("no")
|
||||
ma = ModAction(
|
||||
kind="enable_signups",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
return {"message": "Signups enabled!"}
|
||||
else:
|
||||
f.write("yes")
|
||||
ma = ModAction(
|
||||
kind="disable_signups",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
return {"message": "Signups disabled!"}
|
||||
if environ.get('disable_signups'):
|
||||
environ["disable_signups"] = ""
|
||||
ma = ModAction(
|
||||
kind="enable_signups",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
return {"message": "Signups enabled!"}
|
||||
else:
|
||||
environ["disable_signups"] = "1"
|
||||
ma = ModAction(
|
||||
kind="disable_signups",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
return {"message": "Signups disabled!"}
|
||||
|
||||
|
||||
@app.post("/admin/purge_cache")
|
||||
|
@ -386,33 +379,30 @@ def purge_cache(v):
|
|||
@app.post("/admin/under_attack")
|
||||
@admin_level_required(2)
|
||||
def under_attack(v):
|
||||
with open('under_attack', 'r') as f: content = f.read()
|
||||
if environ.get('under_attack'):
|
||||
environ["under_attack"] = ""
|
||||
ma = ModAction(
|
||||
kind="disable_under_attack",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
|
||||
with open('under_attack', 'w') as f:
|
||||
if content == "yes":
|
||||
f.write("no")
|
||||
ma = ModAction(
|
||||
kind="disable_under_attack",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data='{"value":"medium"}'))
|
||||
if response == "<Response [200]>": return {"message": "Under attack mode disabled!"}
|
||||
return {"error": "Failed to disable under attack mode."}
|
||||
else:
|
||||
environ["under_attack"] = "1"
|
||||
ma = ModAction(
|
||||
kind="enable_under_attack",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
|
||||
response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data='{"value":"medium"}'))
|
||||
if response == "<Response [200]>": return {"message": "Under attack mode disabled!"}
|
||||
return {"error": "Failed to disable under attack mode."}
|
||||
else:
|
||||
f.write("yes")
|
||||
ma = ModAction(
|
||||
kind="enable_under_attack",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
g.db.commit()
|
||||
|
||||
response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data='{"value":"under_attack"}'))
|
||||
if response == "<Response [200]>": return {"message": "Under attack mode enabled!"}
|
||||
return {"error": "Failed to enable under attack mode."}
|
||||
response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data='{"value":"under_attack"}'))
|
||||
if response == "<Response [200]>": return {"message": "Under attack mode enabled!"}
|
||||
return {"error": "Failed to enable under attack mode."}
|
||||
|
||||
@app.get("/admin/badge_grant")
|
||||
@admin_level_required(2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue