diff --git a/161.webp b/161.webp deleted file mode 100644 index ea2ccb81c..000000000 Binary files a/161.webp and /dev/null differ diff --git a/162.webp b/162.webp deleted file mode 100644 index a07e50c28..000000000 Binary files a/162.webp and /dev/null differ diff --git a/163.webp b/163.webp deleted file mode 100644 index 3b8f2ffe9..000000000 Binary files a/163.webp and /dev/null differ diff --git a/files/__main__.py b/files/__main__.py index cdd5c15a6..68073555c 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -8,7 +8,6 @@ from flask_limiter import Limiter from flask_compress import Compress from flask_limiter.util import get_ipaddr from flask_mail import Mail - from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker, scoped_session from sqlalchemy import * @@ -16,13 +15,14 @@ import gevent from werkzeug.middleware.proxy_fix import ProxyFix import redis import time +from sys import stdout +import faulthandler app = Flask(__name__, template_folder='templates') app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3) app.url_map.strict_slashes = False app.jinja_env.cache = {} app.jinja_env.auto_reload = True -import faulthandler faulthandler.enable() app.config["SITE_NAME"]=environ.get("SITE_NAME").strip() @@ -110,6 +110,7 @@ def before_request(): def teardown_request(error): if hasattr(g, 'db') and g.db: g.db.close() + stdout.flush() @app.after_request def after_request(response): diff --git a/files/assets/images/Drama/banners/162.webp b/files/assets/images/Drama/banners/162.webp new file mode 100644 index 000000000..a6583467c Binary files /dev/null and b/files/assets/images/Drama/banners/162.webp differ diff --git a/files/assets/images/Drama/banners/163.webp b/files/assets/images/Drama/banners/163.webp new file mode 100644 index 000000000..90c899abc Binary files /dev/null and b/files/assets/images/Drama/banners/163.webp differ diff --git a/files/assets/images/Drama/banners/164.webp b/files/assets/images/Drama/banners/164.webp new file mode 100644 index 000000000..9f62b0bdd Binary files /dev/null and b/files/assets/images/Drama/banners/164.webp differ diff --git a/files/classes/submission.py b/files/classes/submission.py index 2285531af..4b5a1e8d3 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -429,7 +429,7 @@ class Submission(Base): @property @lazy def is_image(self): - if self.url: return self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999') + if self.url: return self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999') or self.url.lower().endswith('&fidelity=high') else: return False @property diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 18d577b5c..866233edc 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -124,7 +124,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False): for i in re.finditer('https://i\.imgur\.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized): - sanitized = sanitized.replace(i.group(1), i.group(2) + "_d." + i.group(3) + "?maxwidth=9999") + sanitized = sanitized.replace(i.group(1), i.group(2) + "_d.webp?maxwidth=9999&fidelity=high") if noimages: sanitized = bleach.Cleaner(tags=no_images, diff --git a/files/routes/admin.py b/files/routes/admin.py index 646d77df1..a45a3fe32 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -380,6 +380,15 @@ def disable_signups(v): return {"message": "Signups disabled!"} +@app.post("/admin/purge_cache") +@admin_level_required(3) +def purge_cache(v): + response = str(requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_everything', headers=CF_HEADERS, data={"purge_everything":"true"})) + print(response) + if response == "": return {"message": "Cache purged!"} + return {"error": "Failed to purge cache."} + + @app.post("/admin/under_attack") @admin_level_required(2) def under_attack(v): @@ -394,9 +403,8 @@ def under_attack(v): ) g.db.add(ma) g.db.commit() - data='{"value":"high"}' - response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data=data)) + response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data={"value":"high"})) if response == "": return {"message": "Under attack mode disabled!"} return {"error": "Failed to disable under attack mode."} else: @@ -407,9 +415,8 @@ def under_attack(v): ) g.db.add(ma) g.db.commit() - data='{"value":"under_attack"}' - response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data=data)) + 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 == "": return {"message": "Under attack mode enabled!"} return {"error": "Failed to enable under attack mode."} diff --git a/files/routes/posts.py b/files/routes/posts.py index 930c87a7e..e6949041f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1167,9 +1167,9 @@ def submit_post(v): g.db.commit() - if request.headers.get("Authorization"): return new_post.json else: + new_post = get_post(new_post.id) if 'megathread' in new_post.title.lower(): sort = 'new' else: sort = v.defaultsortingcomments new_post.replies = [c] diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index 9ae37a170..afcfb6049 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -64,11 +64,12 @@ {% endif %} -{% if v.id == 1 %} -
+{% if v.admin_level == 3 %} +
-{% endif %} + +{% endif %} {% endblock %} \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index 638b7b31b..9018f7db0 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -173,7 +173,7 @@
{% endif %} -{% if c.sentto and c.level > 1 and c.created_utc > 1641340623 %} +{% if c.sentto and c.level > 2 and c.created_utc > 1641340623 %} {% set isreply = True %} {% else %} {% set isreply = False %} diff --git a/files/templates/formatting.html b/files/templates/formatting.html index 9fc40c9c3..bcbd97705 100644 --- a/files/templates/formatting.html +++ b/files/templates/formatting.html @@ -420,12 +420,12 @@ line breaks Marquee - <marquee direction="up" behavior="scroll" scrollamount="10" height="100"> + <marquee direction="up" behavior="scroll" scrollamount="10" height="250"> This is a sample scrolling text that has scrolls in the upper direction. </marquee> - + This is a sample scrolling text that has scrolls in the upper direction.