bbb
This commit is contained in:
parent
a7db542d90
commit
45ef23caca
14 changed files with 24 additions and 15 deletions
BIN
161.webp
BIN
161.webp
Binary file not shown.
Before Width: | Height: | Size: 42 KiB |
BIN
162.webp
BIN
162.webp
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
BIN
163.webp
BIN
163.webp
Binary file not shown.
Before Width: | Height: | Size: 52 KiB |
|
@ -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):
|
||||
|
|
BIN
files/assets/images/Drama/banners/162.webp
Normal file
BIN
files/assets/images/Drama/banners/162.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
files/assets/images/Drama/banners/163.webp
Normal file
BIN
files/assets/images/Drama/banners/163.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
BIN
files/assets/images/Drama/banners/164.webp
Normal file
BIN
files/assets/images/Drama/banners/164.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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."}
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 %}
|
|
@ -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 %}
|
||||
|
|
|
@ -420,12 +420,12 @@ line breaks
|
|||
<tr>
|
||||
<td>Marquee</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>
|
||||
<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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue