remotes/1693045480750635534/spooky-22
Aevann1 2022-01-14 04:33:27 +02:00
parent 9135180328
commit 9ae0a6ef24
11 changed files with 24 additions and 15 deletions

BIN
161.webp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

BIN
162.webp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

BIN
163.webp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

View File

@ -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):

View File

@ -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

View File

@ -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,

View File

@ -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 == "<Response [200]>": 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 == "<Response [200]>": 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 == "<Response [200]>": return {"message": "Under attack mode enabled!"}
return {"error": "Failed to enable under attack mode."}

View File

@ -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]

View File

@ -64,11 +64,12 @@
</div>
{% endif %}
{% if v.id == 1 %}
<div class="custom-control custom-switch">
{% if v.admin_level == 3 %}
<div class="custom-control custom-switch mt-3">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="under_attack" name="under_attack" {% if x2 == "yes" %}checked{% endif %} onchange="post_toast('/admin/under_attack');">
<label class="custom-control-label" for="under_attack">Under attack mode</label>
</div>
{% endif %}
<button class="btn btn-primary mt-3" onclick="post_toast('/admin/purge_cache');">PURGE CACHE</button>
{% endif %}
{% endblock %}

View File

@ -173,7 +173,7 @@
</div>
{% 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 %}

View File

@ -420,12 +420,12 @@ line breaks
<tr>
<td>Marquee</td>
<td>
&lt;marquee direction="up" behavior="scroll" scrollamount="10" height="100"&gt;
&lt;marquee direction="up" behavior="scroll" scrollamount="10" height="250"&gt;
This is a sample scrolling text that has scrolls in the upper direction.
&lt;/marquee&gt;
</td>
<td>
<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>
</td>