diff --git a/docker-compose.yml b/docker-compose.yml
index 4cafb5afa..ad40d3762 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,6 +11,7 @@ services:
environment:
- DATABASE_URL=postgresql://postgres@postgres:5432
- REDIS_URL=redis://redis
+ - OPERA_URL=http://opera-proxy:18080
links:
- "redis"
- "postgres"
@@ -37,3 +38,9 @@ services:
- POSTGRES_HOST_AUTH_METHOD=trust
ports:
- "5432:5432"
+
+ opera-proxy:
+ container_name: "opera-proxy"
+ image: yarmak/opera-proxy
+ ports:
+ - "18080:18080"
diff --git a/files/assets/css/main.css b/files/assets/css/main.css
index d19be5089..7d6df541d 100644
--- a/files/assets/css/main.css
+++ b/files/assets/css/main.css
@@ -4806,7 +4806,7 @@ input[type=radio] ~ .custom-control-label::before {
border-radius: 50%;
}
.emoji-modal {
- max-width: 90% !important
+ max-width: 80% !important
}
.emj, .emoji, strong a img, img[alt^=":"]:not(img[b]):not(img[alt*="#"]) {
height: 40px !important;
@@ -5075,10 +5075,8 @@ img[glow]:not([data-src]) {
}
.awardmodal {
- max-width: 90% !important;
- min-height: 90% !important;
- max-height: 90% !important;
- height: 90% !important;
+ max-width: 80% !important;
+ height: 100% !important;
margin: auto !important
}
@@ -5130,7 +5128,7 @@ html {
@media (max-width: 991.98px) {
.popover {
- max-width: 90% !important;
+ max-width: 80% !important;
}
}
@@ -6303,4 +6301,7 @@ div.markdown {
width: 50px;
height: 50px;
}
-}
\ No newline at end of file
+ .emoji-modal, .awardmodal {
+ max-width: 90% !important
+ }
+}
diff --git a/files/assets/images/PCM/banner.webp b/files/assets/images/PCM/banners/1.webp
similarity index 100%
rename from files/assets/images/PCM/banner.webp
rename to files/assets/images/PCM/banners/1.webp
diff --git a/files/assets/images/PCM/banners/croag-pride.webp b/files/assets/images/PCM/banners/2.webp
similarity index 100%
rename from files/assets/images/PCM/banners/croag-pride.webp
rename to files/assets/images/PCM/banners/2.webp
diff --git a/files/assets/images/PCM/banners/great-value.webp b/files/assets/images/PCM/banners/3.webp
similarity index 100%
rename from files/assets/images/PCM/banners/great-value.webp
rename to files/assets/images/PCM/banners/3.webp
diff --git a/files/assets/images/PCM/banners/great-value-v2.webp b/files/assets/images/PCM/banners/4.webp
similarity index 100%
rename from files/assets/images/PCM/banners/great-value-v2.webp
rename to files/assets/images/PCM/banners/4.webp
diff --git a/files/assets/images/PCM/banners/summer-2022.webp b/files/assets/images/PCM/banners/5.webp
similarity index 100%
rename from files/assets/images/PCM/banners/summer-2022.webp
rename to files/assets/images/PCM/banners/5.webp
diff --git a/files/assets/images/PCM/banners/yun-network.webp b/files/assets/images/PCM/banners/6.webp
similarity index 100%
rename from files/assets/images/PCM/banners/yun-network.webp
rename to files/assets/images/PCM/banners/6.webp
diff --git a/files/assets/images/PCM/banners/banner.webp b/files/assets/images/PCM/banners/banner.webp
deleted file mode 100644
index c58f43216..000000000
Binary files a/files/assets/images/PCM/banners/banner.webp and /dev/null differ
diff --git a/files/assets/images/PCM/banners/halloween.webp b/files/assets/images/PCM/banners/halloween.webp
deleted file mode 100644
index 08bddc13a..000000000
Binary files a/files/assets/images/PCM/banners/halloween.webp and /dev/null differ
diff --git a/files/assets/images/emojis/marseydrowned.webp b/files/assets/images/emojis/marseydrowned.webp
new file mode 100644
index 000000000..f5a4d4807
Binary files /dev/null and b/files/assets/images/emojis/marseydrowned.webp differ
diff --git a/files/assets/images/emojis/marseyvore.webp b/files/assets/images/emojis/marseyvore.webp
new file mode 100644
index 000000000..d8f3fcf1e
Binary files /dev/null and b/files/assets/images/emojis/marseyvore.webp differ
diff --git a/files/assets/images/emojis/marseyvore2.webp b/files/assets/images/emojis/marseyvore2.webp
new file mode 100644
index 000000000..095739eba
Binary files /dev/null and b/files/assets/images/emojis/marseyvore2.webp differ
diff --git a/files/assets/images/emojis/marseyvorezombiewolf.webp b/files/assets/images/emojis/marseyvorezombiewolf.webp
new file mode 100644
index 000000000..be539062c
Binary files /dev/null and b/files/assets/images/emojis/marseyvorezombiewolf.webp differ
diff --git a/files/assets/sitemap.xml b/files/assets/sitemap.xml
index e1e7bae04..87d13bab9 100644
--- a/files/assets/sitemap.xml
+++ b/files/assets/sitemap.xml
@@ -1325,11 +1325,6 @@
.*)", flags=re.A|re.DOTALL) +# Specifically match Snappy's way of formatting, this might break some losers' comments. +showmore_regex = re.compile(r"^(.{3000,}?
(?:)?)(\s*.*)", flags=re.A|re.DOTALL) search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 89cf58a5a..5d2867b6d 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -386,7 +386,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys if '
' not in sanitized: sanitized = sanitized.replace('\n','') - if showmore and len(sanitized) > 5000: + if showmore and len(sanitized) > 3500: sanitized = showmore_regex.sub(r'\1\2 ', sanitized, count=1) return sanitized.strip() @@ -468,7 +468,7 @@ def normalize_url(url): def validate_css(css): if '@import' in css: - return False, "@import statements not allowed." + return False, "@import statements are not allowed!" for i in css_url_regex.finditer(css): url = i.group(1) diff --git a/files/routes/comments.py b/files/routes/comments.py index 21d68cfb6..fd5deda04 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -194,7 +194,7 @@ def comment(v): if file.content_type.startswith('image/'): oldname = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(oldname) - image = process_image(oldname) + image = process_image(oldname, patron=v.patron) if image == "": return {"error":"Image upload failed"}, 400 if v.admin_level >= PERMS['SITE_SETTINGS_SIDEBARS_BANNERS_BADGES'] and level == 1: if parent_post.id == SIDEBAR_THREAD: diff --git a/files/routes/errors.py b/files/routes/errors.py index 6012b7673..484b89871 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -59,6 +59,12 @@ def error_413(e): return {"error": "Max image/audio size is 8 MB (16 MB for paypigs)"}, 413 else: return render_template('errors/413.html', err=True), 413 +@app.errorhandler(414) +def error_414(e): + if request.headers.get("Authorization") or request.headers.get("xhr"): + return {"error": "Max video size is 32 MB (64 MB for paypigs)"}, 414 + else: return render_template('errors/414.html', err=True), 414 + @app.errorhandler(415) def error_415(e): if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "Please upload only Image, Video, or Audio files!"}, 415 diff --git a/files/routes/posts.py b/files/routes/posts.py index 73d4e67e4..74e4638fb 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -596,7 +596,7 @@ def thumbnail_thread(pid): for chunk in image_req.iter_content(1024): file.write(chunk) - post.thumburl = process_image(name, resize=100) + post.thumburl = process_image(name, resize=100, uploader=post.author_id, db=db) db.add(post) db.commit() db.close() @@ -948,7 +948,7 @@ def submit_post(v, sub=None): if file.content_type.startswith('image/'): name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) - post.url = process_image(name) + post.url = process_image(name, patron=v.patron) name2 = name.replace('.webp', 'r.webp') copyfile(name, name2) diff --git a/files/routes/settings.py b/files/routes/settings.py index 92bd7476f..c262b53a8 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -6,6 +6,7 @@ from files.helpers.const import * from files.helpers.regex import * from files.helpers.actions import * from files.helpers.get import * +from files.helpers.security import * from files.mail import * from files.__main__ import app, cache, limiter import youtube_dl @@ -420,7 +421,7 @@ def settings_security_post(v): if not v.verifyPass(request.values.get("old_password")): return render_template("settings_security.html", v=v, error="Incorrect password") - v.passhash = v.hash_password(request.values.get("new_password")) + v.passhash = hash_password(request.values.get("new_password")) g.db.add(v) @@ -518,7 +519,7 @@ def settings_images_profile(v): name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) - highres = process_image(name) + highres = process_image(name, patron=v.patron) if not highres: abort(400) @@ -556,7 +557,7 @@ def settings_images_banner(v): name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) - bannerurl = process_image(name) + bannerurl = process_image(name, patron=v.patron) if bannerurl: if v.bannerurl and '/images/' in v.bannerurl: diff --git a/files/routes/static.py b/files/routes/static.py index 14a55beb6..751a46eb0 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -72,11 +72,8 @@ def marsey_list(): return jsonify(emojis) -@app.get('/rules') @app.get('/sidebar') -@app.get('/logged_out/rules') -@app.get('/logged_out/sidebar') -@auth_desired_with_logingate +@auth_desired def sidebar(v): return render_template('sidebar.html', v=v) @@ -519,7 +516,7 @@ if SITE == 'pcmemes.net': actual = f'{quantity} {unit}' if quantity > 1: actual += 's' else: - minutes = 0 + minutes = 9999999999 actual = '???' views = 0 diff --git a/files/routes/subs.py b/files/routes/subs.py index 486214e7d..5c7187454 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -124,7 +124,7 @@ def block_sub(v, sub): @auth_required def unblock_sub(v, sub): sub = get_sub_by_name(sub).name - if sub.name == "chudrama" and not v.can_see_chudrama: abort(403) + if sub == "chudrama" and not v.can_see_chudrama: abort(403) block = g.db.query(SubBlock).filter_by(user_id=v.id, sub=sub).one_or_none() if block: @@ -486,7 +486,7 @@ def sub_banner(v, sub): name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) - bannerurl = process_image(name) + bannerurl = process_image(name, patron=v.patron) if bannerurl: if sub.bannerurl and '/images/' in sub.bannerurl: @@ -518,7 +518,7 @@ def sub_sidebar(v, sub): file = request.files["sidebar"] name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) - sidebarurl = process_image(name) + sidebarurl = process_image(name, patron=v.patron) if sidebarurl: if sub.sidebarurl and '/images/' in sub.sidebarurl: @@ -550,7 +550,7 @@ def sub_marsey(v, sub): file = request.files["marsey"] name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) - marseyurl = process_image(name) + marseyurl = process_image(name, patron=v.patron) if marseyurl: if sub.marseyurl and '/images/' in sub.marseyurl: diff --git a/files/routes/users.py b/files/routes/users.py index ed58e5235..1bdaf148c 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -13,7 +13,7 @@ from flask import * from files.__main__ import app, limiter, db_session import sqlalchemy from sqlalchemy.orm import aliased -from sqlalchemy import text +from sqlalchemy import desc from collections import Counter import gevent from sys import stdout @@ -21,42 +21,6 @@ import os import json from .login import check_for_alts -def leaderboard_thread(): - db = db_session() - - global users9, users9_1, users9_2 - votes1 = db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote).filter(Vote.vote_type==-1).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() - votes2 = db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote).filter(CommentVote.vote_type==-1).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() - votes3 = Counter(dict(votes1)) + Counter(dict(votes2)) - users8 = db.query(User.id).filter(User.id.in_(votes3.keys())).all() - users9 = [] - for user in users8: - users9.append((user.id, votes3[user.id])) - if not users9: users9 = [(None,None)] - users9 = sorted(users9, key=lambda x: x[1], reverse=True) - users9_1, users9_2 = zip(*users9[:25]) - - global users13, users13_1, users13_2 - votes1 = db.query(Vote.user_id, func.count(Vote.user_id)).filter(Vote.vote_type==1).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all() - votes2 = db.query(CommentVote.user_id, func.count(CommentVote.user_id)).filter(CommentVote.vote_type==1).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all() - votes3 = Counter(dict(votes1)) + Counter(dict(votes2)) - users14 = db.query(User).filter(User.id.in_(votes3.keys())).all() - users13 = [] - for user in users14: - users13.append((user.id, votes3[user.id]-user.post_count-user.comment_count)) - if not users13: users13 = [(None,None)] - users13 = sorted(users13, key=lambda x: x[1], reverse=True) - users13_1, users13_2 = zip(*users13[:25]) - - db.close() - stdout.flush() - - -gevent.spawn(leaderboard_thread) - - - - @app.get("/@/upvoters/ /posts") @auth_required @@ -591,13 +555,6 @@ def leaderboard(v): pos7 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1] - users9_accs = g.db.query(User).filter(User.id.in_(users9_1)).all() - users9_accs = sorted(users9_accs, key=lambda x: users9_1.index(x.id)) - users9_accs = zip(users9_accs, users9_2) - try: - pos9 = [x[0] for x in users9].index(v.id) - pos9 = (pos9+1, users9[pos9][1]) - except: pos9 = (len(users9)+1, 0) users10 = users.order_by(User.truecoins.desc()).limit(25).all() if v in users10: @@ -624,31 +581,9 @@ def leaderboard(v): users12 = None pos12 = None - users13_accs = g.db.query(User).filter(User.id.in_(users13_1)).all() - users13_accs = sorted(users13_accs, key=lambda x: users13_1.index(x.id)) - users13_accs = zip(users13_accs, users13_2) - try: - pos13 = [x[0] for x in users13].index(v.id) - pos13 = (pos13+1, users13[pos13][1]) - except: pos13 = (len(users13)+1, 0) - - # winnings_sq = g.db.query(Casino_Game.user_id, func.sum(Casino_Game.winnings)).group_by(Casino_Game.user_id).subquery() - # users14 = g.db.query(User).join(winnings_sq, winnings_sq.c.user_id == User.id).order_by(winnings_sq.c.sum.desc()).limit(25).all() - # if v in users14: - # pos14 = None - # else: - # sq = g.db.query(User.id, func.rank().over(order_by=winnings_sq.c.sum.desc()).label("rank")).join(winnings_sq, winnings_sq.c.user_id == User.id).subquery() - # pos14 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1] - - # users15 = g.db.query(User).join(winnings_sq, winnings_sq.c.user_id == User.id).order_by(winnings_sq.c.sum.asc()).limit(25).all() - # if v in users15: - # pos15 = None - # else: - # sq = g.db.query(User.id, func.rank().over(order_by=winnings_sq.c.sum.asc()).label("rank")).join(winnings_sq, winnings_sq.c.user_id == User.id).subquery() - # pos15 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1] - sq = g.db.query(UserBlock.target_id, func.count(UserBlock.target_id).label("count")).group_by(UserBlock.target_id).subquery() users16 = g.db.query(User, sq.c.count).join(User, User.id == sq.c.target_id).order_by(sq.c.count.desc()) + sq = g.db.query(UserBlock.target_id, func.count(UserBlock.target_id).label("count"), func.rank().over(order_by=func.count(UserBlock.target_id).desc()).label("rank")).group_by(UserBlock.target_id).subquery() pos16 = g.db.query(sq.c.rank, sq.c.count).join(User, User.id == sq.c.target_id).filter(sq.c.target_id == v.id).limit(1).one_or_none() if not pos16: pos16 = (users16.count()+1, 0) @@ -668,9 +603,7 @@ def leaderboard(v): return render_template("leaderboard.html", v=v, users1=users1, pos1=pos1, users2=users2, pos2=pos2, users3=users3, pos3=pos3, users4=users4, pos4=pos4, users5=users5, pos5=pos5, - users7=users7, pos7=pos7, users9=users9_accs, pos9=pos9, - users10=users10, pos10=pos10, users11=users11, pos11=pos11, users12=users12, pos12=pos12, - users13=users13_accs, pos13=pos13, users16=users16, pos16=pos16, users17=users17, pos17=pos17, users18=users18, pos18=pos18) + users7=users7, pos7=pos7, users10=users10, pos10=pos10, users11=users11, pos11=pos11, users12=users12, pos12=pos12, users16=users16, pos16=pos16, users17=users17, pos17=pos17, users18=users18, pos18=pos18) @app.get("/ /css") def get_css(id): diff --git a/files/templates/authforms.html b/files/templates/authforms.html index f8e49e068..84d326a8b 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -31,17 +31,6 @@ {{v.css | safe}} {% endif %} - - {% if v.earlylife %} - - {% endif %} {% else %} @@ -116,4 +105,4 @@