From 2ac830467b9517e53958503fc8a053b61e246c93 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 6 Mar 2023 22:49:01 +0200 Subject: [PATCH] use STARS const --- files/helpers/config/const.py | 2 ++ files/helpers/media.py | 8 +++++--- files/routes/users.py | 4 +++- gunicorn.conf.py | 6 ++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 1c39c5289..7008ebee1 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -1063,3 +1063,5 @@ if AEVANN_ID: GLOBAL = environ.get("GLOBAL", "").strip() else: GLOBAL = None + +STARS = '\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n' diff --git a/files/helpers/media.py b/files/helpers/media.py index 62061f545..583c3289c 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -37,7 +37,9 @@ def media_ratelimit(v): count = g.db.query(Media).filter(Media.user_id == v.id, Media.created_utc > t).count() if count > 50: abort(500) - print(f'\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n@{v.username} hit the 50 files daily limit!\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n', flush=True) + print(STARS, flush=True) + print(f'@{v.username} hit the 50 file daily limit!') + print(STARS, flush=True) def process_files(files, v, body): if g.is_tor or not files.get("file"): return body @@ -218,10 +220,10 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in i_hash = str(imagehash.phash(i)) if i_hash in hashes.keys(): - print(f'\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\nRemove one of these existing duplicates please:\n\n', flush=True) + print(STARS, flush=True) print(hashes[i_hash], flush=True) print(img_path, flush=True) - print(f'\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n', flush=True) + print(STARS, flush=True) else: hashes[i_hash] = img_path with Image.open(filename) as i: diff --git a/files/routes/users.py b/files/routes/users.py index de49e3b48..f625cb32f 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1407,7 +1407,9 @@ def gumroad(): data = request.values ip = request.headers.get('CF-Connecting-IP') if ip != '34.193.146.117': - print(f'\n\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n\n/gumroad fail: {ip}\n\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n\n', flush=True) + print(STARS, flush=True) + print(f'/gumroad fail: {ip}') + print(STARS, flush=True) abort(400) id = data['sale_id'] diff --git a/gunicorn.conf.py b/gunicorn.conf.py index be857fbad..047ea471c 100644 --- a/gunicorn.conf.py +++ b/gunicorn.conf.py @@ -1,3 +1,5 @@ +STARS = '\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n' + bind = '0.0.0.0:5000' worker_class = 'gevent' @@ -13,14 +15,14 @@ def worker_abort(worker): try: from flask import g, request if g and request: - worker.log.warning(f"\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★") + worker.log.warning(STARS) worker.log.warning(f"While serving {request.method} {request.url}") u = getattr(g, 'v', None) if u: worker.log.warning(f"User: {u.username!r} id:{u.id}") else: worker.log.warning(f"User: not logged in") - worker.log.warning(f"\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n") + worker.log.warning(STARS) else: worker.log.warning("No request info") except: