diff --git a/docker-compose.yml b/docker-compose.yml index ee809296b..51d5ca4be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,66 +2,66 @@ version: '2.3' services: files: - build: - context: . - volumes: - - "./:/service" - environment: - - DATABASE_URL=postgresql://postgres@postgres:5432 - - MASTER_KEY=${MASTER_KEY:-KTVciAUQFpFh2WdJ/oiHJlxl6FvzRZp8kYzAAv3l2OA=} - - REDIS_URL=redis://redis - - DOMAIN=localhost - - SITE_NAME=Drama - - GIPHY_KEY=3435tdfsdudebussylmaoxxt43 - - FORCE_HTTPS=0 - - DISCORD_SERVER_ID=3435tdfsdudebussylmaoxxt43 - - DISCORD_CLIENT_ID=3435tdfsdudebussylmaoxxt43 - - DISCORD_CLIENT_SECRET=3435tdfsdudebussylmaoxxt43 - - DISCORD_BOT_TOKEN=3435tdfsdudebussylmaoxxt43 - #- HCAPTCHA_SITEKEY=3435tdfsdudebussylmaoxxt43 - - HCAPTCHA_SECRET=3435tdfsdudebussylmaoxxt43 - - YOUTUBE_KEY=3435tdfsdudebussylmaoxxt43 - - PUSHER_KEY=3435tdfsdudebussylmaoxxt43 - - CATBOX_KEY=3435tdfsdudebussylmaoxxt43 - - SPAM_SIMILARITY_THRESHOLD=0.5 - - SPAM_SIMILAR_COUNT_THRESHOLD=5 - - SPAM_URL_SIMILARITY_THRESHOLD=0.1 - - COMMENT_SPAM_SIMILAR_THRESHOLD=0.5 - - COMMENT_SPAM_COUNT_THRESHOLD=5 - - READ_ONLY=0 - - BOT_DISABLE=0 - - COINS_NAME=Dramacoins - - DEFAULT_TIME_FILTER=all - - DEFAULT_THEME=midnight - - DEFAULT_COLOR=ff66ac #YOU HAVE TO PICK ONE OF THOSE COLORS OR SHIT WILL BREAK: ff66ac, 805ad5, 62ca56, 38a169, 80ffff, 2a96f3, eb4963, ff0000, f39731, 30409f, 3e98a7, e4432d, 7b9ae4, ec72de, 7f8fa6, f8db58 - - SLOGAN=Dude bussy lmao - - GUMROAD_TOKEN=3435tdfsdudebussylmaoxxt43 - - GUMROAD_LINK=https://marsey1.gumroad.com/l/tfcvri - - CARD_VIEW=1 - - DISABLE_DOWNVOTES=0 - - DUES=0 - - MAIL_USERNAME=blahblahblah@gmail.com - - MAIL_PASSWORD=3435tdfsdudebussylmaoxxt43 - links: - - "redis" - - "postgres" - ports: - - "80:80" - depends_on: - - redis - - postgres + build: + context: . + volumes: + - "./:/service" + environment: + - DATABASE_URL=postgresql://postgres@postgres:5432 + - MASTER_KEY=${MASTER_KEY:-KTVciAUQFpFh2WdJ/oiHJlxl6FvzRZp8kYzAAv3l2OA=} + - REDIS_URL=redis://redis + - DOMAIN=0.0.0.0 + - SITE_NAME=Drama + - GIPHY_KEY=3435tdfsdudebussylmaoxxt43 + - FORCE_HTTPS=0 + - DISCORD_SERVER_ID=3435tdfsdudebussylmaoxxt43 + - DISCORD_CLIENT_ID=3435tdfsdudebussylmaoxxt43 + - DISCORD_CLIENT_SECRET=3435tdfsdudebussylmaoxxt43 + - DISCORD_BOT_TOKEN=3435tdfsdudebussylmaoxxt43 + #- HCAPTCHA_SITEKEY=3435tdfsdudebussylmaoxxt43 + - HCAPTCHA_SECRET=3435tdfsdudebussylmaoxxt43 + - YOUTUBE_KEY=3435tdfsdudebussylmaoxxt43 + - PUSHER_KEY=3435tdfsdudebussylmaoxxt43 + - CATBOX_KEY=3435tdfsdudebussylmaoxxt43 + - SPAM_SIMILARITY_THRESHOLD=0.5 + - SPAM_SIMILAR_COUNT_THRESHOLD=5 + - SPAM_URL_SIMILARITY_THRESHOLD=0.1 + - COMMENT_SPAM_SIMILAR_THRESHOLD=0.5 + - COMMENT_SPAM_COUNT_THRESHOLD=5 + - READ_ONLY=0 + - BOT_DISABLE=0 + - COINS_NAME=Dramacoins + - DEFAULT_TIME_FILTER=all + - DEFAULT_THEME=midnight + - DEFAULT_COLOR=ff66ac #YOU HAVE TO PICK ONE OF THOSE COLORS OR SHIT WILL BREAK: ff66ac, 805ad5, 62ca56, 38a169, 80ffff, 2a96f3, eb4963, ff0000, f39731, 30409f, 3e98a7, e4432d, 7b9ae4, ec72de, 7f8fa6, f8db58 + - SLOGAN=Dude bussy lmao + - GUMROAD_TOKEN=3435tdfsdudebussylmaoxxt43 + - GUMROAD_LINK=https://marsey1.gumroad.com/l/tfcvri + - CARD_VIEW=1 + - DISABLE_DOWNVOTES=0 + - DUES=0 + - MAIL_USERNAME=blahblahblah@gmail.com + - MAIL_PASSWORD=3435tdfsdudebussylmaoxxt43 + links: + - "redis" + - "postgres" + ports: + - "80:80" + depends_on: + - redis + - postgres redis: - image: redis - ports: - - "6379:6379" + image: redis + ports: + - "6379:6379" postgres: - image: postgres:12.3 - volumes: - - "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql" - - "./seed-db.sql:/docker-entrypoint-initdb.d/01-schema.sql" - environment: - - POSTGRES_HOST_AUTH_METHOD=trust - ports: - - "5432:5432" \ No newline at end of file + image: postgres:12.3 + volumes: + - "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql" + - "./seed-db.sql:/docker-entrypoint-initdb.d/01-schema.sql" + environment: + - POSTGRES_HOST_AUTH_METHOD=trust + ports: + - "5432:5432" \ No newline at end of file diff --git a/files/classes/user.py b/files/classes/user.py index 729ef8d0e..33f172f10 100755 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -48,7 +48,7 @@ class User(Base): patron = Column(Integer, default=0) verified = Column(String) verifiedcolor = Column(String) - marseyawarded = Column(String) + marseyawarded = Column(Integer) email = Column(String) css = deferred(Column(String)) profilecss = deferred(Column(String)) diff --git a/files/routes/awards.py b/files/routes/awards.py index 6df622dd6..beb34353d 100755 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -530,7 +530,7 @@ def award_post(pid, v): author.ban(reason=f"1-Day ban award used by @{v.username} on /post/{post.id}", days=1) send_notification(author.id, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.") elif author.unban_utc > 0: - author.unban_utc += 24*60*60 + author.unban_utc += 86400 send_notification(author.id, f"Your account has been suspended for yet another day for {link}. Seriously man?") elif kind == "unban": if not author.is_suspended or not author.unban_utc or time.time() > author.unban_utc: abort(403) @@ -587,7 +587,7 @@ def award_post(pid, v): new_badge = Badge(badge_id=67, user_id=author.id) g.db.add(new_badge) elif kind == "marsey": - author.marseyawarded = True + author.marseyawarded = time.time() + 86400 post.author.received_award_count += 1 g.db.add(post.author) @@ -652,7 +652,7 @@ def award_comment(cid, v): author.ban(reason=f"1-Day ban award used by @{v.username} on /comment/{c.id}", days=1) send_notification(author.id, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.") elif author.unban_utc > 0: - author.unban_utc += 24*60*60 + author.unban_utc += 86400 send_notification(author.id, f"Your account has been suspended for yet another day for {link}. Seriously man?") elif kind == "unban": if not author.is_suspended or not author.unban_utc or time.time() > author.unban_utc: abort(403) @@ -706,7 +706,7 @@ def award_comment(cid, v): new_badge = Badge(badge_id=67, user_id=author.id) g.db.add(new_badge) elif kind == "marsey": - author.marseyawarded = True + author.marseyawarded = time.time() + 86400 c.author.received_award_count += 1 g.db.add(c.author) @@ -728,8 +728,7 @@ def admin_userawards_get(v): @validate_formkey def admin_userawards_post(v): - if v.admin_level < 6: - abort(403) + if v.admin_level < 6: abort(403) try: u = request.values.get("username").strip() except: abort(404) @@ -746,8 +745,7 @@ def admin_userawards_post(v): if value: - if int(value) > 0: - notify_awards[key] = int(value) + if int(value) > 0: notify_awards[key] = int(value) for x in range(int(value)): thing += 1 @@ -762,14 +760,13 @@ def admin_userawards_post(v): text = "You were given the following awards:\n\n" - for key, value in notify_awards.items(): - text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n" + for key, value in notify_awards.items(): text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n" send_notification(u.id, text) g.db.commit() - if v.username == "Aevann": return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v) + if request.host == 'rdrama.net' and v.id in [1,28,995]: return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v) return render_template("admin/awards.html", awards=list(AWARDS2.values()), v=v) diff --git a/files/routes/comments.py b/files/routes/comments.py index 84d614542..b06bba907 100755 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -156,8 +156,12 @@ def api_comment(v): body = body.strip() if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) - if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + if time.time() > v.marseyawarded: + v.marseyawarded = None + g.db.add(v) + else: + marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400 @@ -187,6 +191,8 @@ def api_comment(v): body_md = CustomRenderer().render(mistletoe.Document(body_md)) body_html = sanitize(body_md) + if v.marseyawarded and len(list(re.finditer('>[^<]|[^>]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403 + bans = filter_comment_html(body_html) if bans: @@ -590,14 +596,20 @@ def edit_comment(cid, v): body = request.values.get("body", "").strip()[:10000] if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) - if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + if time.time() > v.marseyawarded: + v.marseyawarded = None + g.db.add(v) + else: + marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) + if v.marseyawarded and len(list(re.finditer('>[^<]|[^>]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403 + bans = filter_comment_html(body_html) if bans: diff --git a/files/routes/posts.py b/files/routes/posts.py index 7861f7dfc..d801813eb 100755 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -215,15 +215,21 @@ def edit_post(pid, v): body = request.values.get("body", "").strip() if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", title)) - if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 - if body: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) - if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + if time.time() > v.marseyawarded: + v.marseyawarded = None + g.db.add(v) + else: + marregex = list(re.finditer("^(:!?m\w+:\s*)+$", title)) + if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 + if body: + marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if title != p.title: + title_html = filter_title(title) + if v.marseyawarded and len(list(re.finditer('>[^<]|[^>]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403 p.title = title - p.title_html = filter_title(title) + p.title_html = title_html if body != p.body: for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): @@ -241,6 +247,7 @@ def edit_post(pid, v): return {"error": reason}, 403 p.body = body + if v.marseyawarded and len(list(re.finditer('>[^<]|[^>]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 40 p.body_html = body_html if "rama" in request.host and "ivermectin" in body_html.lower(): @@ -405,7 +412,7 @@ def thumbnail_thread(pid): thumb_candidate_urls=[] meta_tags = [ - "ruqqus:thumbnail", + "drama:thumbnail", "twitter:image", "og:image", "thumbnail" @@ -495,6 +502,8 @@ def submit_post(v): title = request.values.get("title", "").strip() url = request.values.get("url", "").strip() + title_html = filter_title(title) + if v.marseyawarded and len(list(re.finditer('>[^<]|[^>]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40 if url: if "/i.imgur.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp") @@ -513,16 +522,16 @@ def submit_post(v): domain = parsed_url.netloc - # qd = parse_qs(parsed_url.query) - # filtered = dict((k, v) for k, v in qd.items() if not k.startswith('utm_')) + qd = parse_qs(parsed_url.query) + filtered = dict((k, v) for k, v in qd.items() if not k.startswith('utm_')) - # new_url = ParseResult(scheme="https", - # netloc=parsed_url.netloc, - # path=parsed_url.path, - # params=parsed_url.params, - # query=urlencode(filtered, doseq=True), - # fragment=parsed_url.fragment) - # url = urlunparse(new_url) + new_url = ParseResult(scheme="https", + netloc=parsed_url.netloc, + path=parsed_url.path, + params=parsed_url.params, + query=urlencode(filtered, doseq=True), + fragment=parsed_url.fragment) + url = urlunparse(new_url) repost = g.db.query(Submission).options(lazyload('*')).filter( Submission.url.ilike(url), @@ -570,11 +579,15 @@ def submit_post(v): body = request.values.get("body", "").strip() if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", title)) - if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 - if body: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) - if len(marregex) == 0: return {"error":"You need to only type marseys!"}, 403 + if time.time() > v.marseyawarded: + v.marseyawarded = None + g.db.add(v) + else: + marregex = list(re.finditer("^(:!?m\w+:\s*)+$", title)) + if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 + if body: + marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 dup = g.db.query(Submission).options(lazyload('*')).filter( Submission.author_id == v.id, @@ -606,14 +619,11 @@ def submit_post(v): Submission.url.op('<->')(url) < app.config["SPAM_URL_SIMILARITY_THRESHOLD"], Submission.created_utc > cutoff ).all() - else: - similar_urls = [] + else: similar_urls = [] threshold = app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] - if v.age >= (60 * 60 * 24 * 7): - threshold *= 3 - elif v.age >= (60 * 60 * 24): - threshold *= 2 + if v.age >= (60 * 60 * 24 * 7): threshold *= 3 + elif v.age >= (60 * 60 * 24): threshold *= 2 if max(len(similar_urls), len(similar_posts)) >= threshold: @@ -663,7 +673,7 @@ def submit_post(v): body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) - + if v.marseyawarded and len(list(re.finditer('>[^<]|[^>]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 40 if len(body_html) > 20000: abort(400) @@ -690,7 +700,7 @@ def submit_post(v): body_html=body_html, embed_url=embed, title=title, - title_html=filter_title(title) + title_html=title_html ) g.db.add(new_post) @@ -859,33 +869,28 @@ def submit_post(v): else: body = random.choice(snappyquotes) body += "\n\n---\n\n" else: body = "" + if new_post.url: body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={quote(new_post.url)}&run=1) (click to archive)\n\n" gevent.spawn(archiveorg, new_post.url) - # archive other urls in post - url_regex = '([^\"]+)' - _body = new_post.body_html - #print(_body) - for url_match in re.finditer(url_regex, _body, flags=re.M|re.I): - href = url_match.group(3) + url_regex = '([^\"]+)' + for url_match in re.finditer(url_regex, new_post.body_html, flags=re.M|re.I): + href = url_match.group(3) + if not href: continue - if not href: - #print(f'{url_match.group(0)} skip') - continue + title = url_match.group(5) + if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" - #print(href) - title = url_match.group(5) - body += f'**[{title}]({href})**:\n\n' - body += f'* [reveddit.com](https://reveddit.com/{href})\n' - body += f'* [archive.org](https://web.archive.org/{href})\n' - body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n' - gevent.spawn(archiveorg, href) + body += f'**[{title}]({href})**:\n\n' + body += f'* [reveddit.com](https://reveddit.com/{href})\n' + body += f'* [archive.org](https://web.archive.org/{href})\n' + body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n' + gevent.spawn(archiveorg, href) body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) - c = Comment(author_id=SNAPPY_ACCOUNT, distinguish_level=6, parent_submission=new_post.id, diff --git a/files/routes/settings.py b/files/routes/settings.py index 292b7f4f3..8326bcc30 100755 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -500,6 +500,8 @@ def settings_images_profile(v): if not imageurl: abort(400) + if v.highres and '/images/' in v.highres : os.remove('/images/' + v.highres.split('/images/')[1]) + if v.profileurl and '/images/' in v.profileurl : os.remove('/images/' + v.profileurl.split('/images/')[1]) v.highres = highres v.profileurl = imageurl g.db.add(v) @@ -522,10 +524,11 @@ def settings_images_banner(v): name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif' file.save(name) - imageurl = request.host_url[:-1] + process_image(name) + bannerurl = request.host_url[:-1] + process_image(name) - if imageurl: - v.bannerurl = imageurl + if bannerurl: + if v.bannerurl and '/images/' in v.bannerurl : os.remove('/images/' + v.bannerurl.split('/images/')[1]) + v.bannerurl = bannerurl g.db.add(v) g.db.commit() diff --git a/files/routes/users.py b/files/routes/users.py index 23e75c804..4da2a101b 100755 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -160,10 +160,11 @@ def leaderboard(v): users3 = users.order_by(User.post_count.desc()).limit(10).all() users4 = users.order_by(User.comment_count.desc()).limit(10).all() users5 = users.order_by(User.received_award_count.desc()).limit(10).all() + users7 = users.order_by(User.coins_spent.desc()).limit(10).all() if 'pcmemes.net' in request.host: users6 = users.order_by(User.basedcount.desc()).limit(10).all() - return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6) - return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5) + return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7) + return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users7=users7) @app.get("/@/css") diff --git a/files/templates/admin/awards.html b/files/templates/admin/awards.html index 994404f89..47a459182 100755 --- a/files/templates/admin/awards.html +++ b/files/templates/admin/awards.html @@ -36,31 +36,29 @@
User Award Grant
- + +
+ + + + + + + + + + + {% for a in awards %} + + + + + + {% endfor %} +
IconTitleAmount
{{a['title']}}
-
- - - - - - - - - - - - {% for a in awards %} - - - - - - {% endfor %} -
IconTitleAmount
{{a['title']}}
- - +
diff --git a/files/templates/expanded_image_modal.html b/files/templates/expanded_image_modal.html index c1e452264..5aea9d31f 100755 --- a/files/templates/expanded_image_modal.html +++ b/files/templates/expanded_image_modal.html @@ -10,7 +10,7 @@