master
Aevann1 2021-12-03 21:20:52 +02:00
parent c94ffa3adf
commit 6e54b9dccf
3 changed files with 27 additions and 24 deletions

View File

@ -15,7 +15,7 @@ from .clients import *
from files.__main__ import Base, cache
from files.helpers.security import *
import random
from os import environ, remove
from os import environ, remove, path
site = environ.get("DOMAIN").strip()
site_name = environ.get("SITE_NAME").strip()
@ -466,18 +466,29 @@ class User(Base):
return data
def ban(self, admin=None, reason=None, days=0):
def deletepfp(self):
if self.highres and '/images/' in self.highres:
image = '/images/' + self.highres.split('/images/')[1]
if path.exists(image): remove(image)
if self.profileurl and '/images/' in self.profileurl:
image = '/images/' + self.profileurl.split('/images/')[1]
if path.exists(image): remove(image)
self.highres = None
self.profileurl = None
def deletebanner(self):
if self.bannerurl and '/images/' in self.bannerurl:
image = '/images/' + self.bannerurl.split('/images/')[1]
if path.exists(image): remove(image)
self.bannerurl = None
def ban(self, admin=None, reason=None, days=0):
if days > 0:
ban_time = int(time.time()) + (days * 86400)
self.unban_utc = ban_time
else:
if self.highres and '/images/' in self.highres: remove('/images/' + self.highres.split('/images/')[1])
if self.profileurl and '/images/' in self.profileurl: remove('/images/' + self.profileurl.split('/images/')[1])
if self.bannerurl and '/images/' in self.bannerurl: remove('/images/' + self.bannerurl.split('/images/')[1])
self.bannerurl = None
self.profileurl = None
self.deletepfp()
self.deletebanner()
if self.discord_id: remove_user(self)
self.is_banned = admin.id if admin else AUTOJANNY_ID

View File

@ -754,11 +754,6 @@ def ban_user(user_id, v):
if user.admin_level >= v.admin_level: abort(403)
if 'form' in request.values:
days = float(request.values.get("days")) if request.values.get('days') else 0
reason = sanitize(request.values.get("reason", ""))[:256]
message = request.values.get("reason", "").strip()[:256]
else:
days = float(request.values.get("days")) if request.values.get('days') else 0
reason = sanitize(request.values.get("reason", ""))[:256]
message = request.values.get("reason", "").strip()[:256]

View File

@ -762,13 +762,11 @@ def settings_images_banner(v):
@validate_formkey
def settings_delete_profile(v):
if v.highres and '/images/' in v.highres: os.remove('/images/' + v.highres.split('/images/')[1])
if v.profileurl and '/images/' in v.profileurl: os.remove('/images/' + v.profileurl.split('/images/')[1])
v.highres = None
v.profileurl = None
if v.profileurl or v.highres:
v.deletepfp()
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v,
msg="Profile picture successfully removed.")
@ -779,8 +777,7 @@ def settings_delete_profile(v):
def settings_delete_banner(v):
if v.bannerurl:
if '/images/' in v.bannerurl: os.remove('/images/' + v.bannerurl.split('/images/')[1])
v.bannerurl = None
v.deletebanner()
g.db.add(v)
g.db.commit()