forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-12-03 20:10:24 +02:00
parent b1e628ce96
commit b7522a5960
13 changed files with 265 additions and 17 deletions

View File

@ -15,7 +15,7 @@ from .clients import *
from files.__main__ import Base, cache
from files.helpers.security import *
import random
from os import environ
from os import environ, remove
site = environ.get("DOMAIN").strip()
site_name = environ.get("SITE_NAME").strip()
@ -472,6 +472,10 @@ class User(Base):
ban_time = int(time.time()) + (days * 86400)
self.unban_utc = ban_time
else:
if self.highres and '/images/' in self.highres: remove('/images/' + self.highres.split('/images/')[1])
if self.profileurl and '/images/' in self.profileurl: remove('/images/' + self.profileurl.split('/images/')[1])
if self.bannerurl and '/images/' in self.bannerurl: remove('/images/' + self.bannerurl.split('/images/')[1])
self.bannerurl = None
self.profileurl = None
if self.discord_id: remove_user(self)

View File

@ -156,9 +156,11 @@ def front_all(v):
if v.agendaposter_expires_utc and v.agendaposter_expires_utc < time.time():
v.agendaposter_expires_utc = 0
v.agendaposter = False
v.agendaposter = None
send_notification(v.id, "Your agendaposter theme has expired!")
g.db.add(v)
badge = v.has_badge(26)
if badge: g.db.delete(badge)
g.db.commit()
if v.flairchanged and v.flairchanged < time.time():

View File

@ -761,6 +761,10 @@ def settings_images_banner(v):
@auth_required
@validate_formkey
def settings_delete_profile(v):
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 = None
v.profileurl = None
g.db.add(v)
@ -774,12 +778,13 @@ def settings_delete_profile(v):
@validate_formkey
def settings_delete_banner(v):
v.bannerurl = None
g.db.add(v)
g.db.commit()
if v.bannerurl:
if '/images/' in v.bannerurl: os.remove('/images/' + v.bannerurl.split('/images/')[1])
v.bannerurl = None
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v,
msg="Banner successfully removed.")
return render_template("settings_profile.html", v=v, msg="Banner successfully removed.")
@app.get("/settings/blocks")

View File

@ -36,7 +36,7 @@
</div>
</div>
<script defer src="/assets/js/award_modal.js?v=57"></script>
<script defer src="/assets/js/award_modal.js?v=58"></script>
<style>
.awards-wrapper input[type="radio"] {

View File

@ -1,3 +1,83 @@
{% if v %}
<script>
function vote(type, id, dir) {
var upvote = document.getElementById(type + '-' + id + '-up');
var downvote = document.getElementById(type + '-' + id + '-down');
var scoretext = document.getElementById(type + '-score-' + id);
var score = Number(scoretext.textContent);
if (dir == "1") {
if (upvote.classList.contains('active')) {
upvote.classList.remove('active')
scoretext.textContent = score - 1
votedirection = "0"
} else if (downvote.classList.contains('active')) {
upvote.classList.add('active')
downvote.classList.remove('active')
scoretext.textContent = score + 2
votedirection = "1"
} else {
upvote.classList.add('active')
scoretext.textContent = score + 1
votedirection = "1"
}
if (upvote.classList.contains('active')) {
scoretext.classList.add('score-up')
scoretext.classList.remove('score-down')
scoretext.classList.remove('score')
} else if (downvote.classList.contains('active')) {
scoretext.classList.add('score-down')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score')
} else {
scoretext.classList.add('score')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score-down')
}
}
else {
if (downvote.classList.contains('active')) {
downvote.classList.remove('active')
scoretext.textContent = score + 1
votedirection = "0"
} else if (upvote.classList.contains('active')) {
downvote.classList.add('active')
upvote.classList.remove('active')
scoretext.textContent = score - 2
votedirection = "-1"
} else {
downvote.classList.add('active')
scoretext.textContent = score - 1
votedirection = "-1"
}
if (upvote.classList.contains('active')) {
scoretext.classList.add('score-up')
scoretext.classList.remove('score-down')
scoretext.classList.remove('score')
} else if (downvote.classList.contains('active')) {
scoretext.classList.add('score-down')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score')
} else {
scoretext.classList.add('score')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score-down')
}
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "/vote/" + type.replace('-mobile','') + "/" + id + "/" + votedirection, true);
var form = new FormData()
form.append("formkey", formkey());
xhr.withCredentials=true;
xhr.send(form);
}
</script>
{% endif %}
<style>
html {
scroll-padding-top: 75px;
@ -327,8 +407,8 @@
<input id="file-edit-reply-{{c.id}}" type="file" name="file" accept="image/*" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} onchange="document.getElementById('filename-edit-reply-{{c.id}}').innerHTML='image';" hidden>
</label>
</div>
<a href="javascript:void(0)" form="comment-edit-form-{{c.id}}" class="btn btn-primary ml-2 fl-r" onclick="comment_edit('{{c.id}}')">Save Edit</a>
<a id="cancel-edit-{{c.id}}" href="javascript:void(0)" onclick="toggleEdit('{{c.id}}')" class="btn btn-link text-muted ml-auto cancel-form fl-r">Cancel</a>
<a href="javascript:void(0)" form="comment-edit-form-{{c.id}}" class="btn btn-primary ml-2 fl-r commentmob" onclick="comment_edit('{{c.id}}')">Save Edit</a>
<a id="cancel-edit-{{c.id}}" href="javascript:void(0)" onclick="toggleEdit('{{c.id}}')" class="btn btn-link text-muted ml-auto cancel-form fl-r commentmob">Cancel</a>
</form>
<div id="preview-edit-{{c.id}}" class="mb-3 mt-5"></div>
<div class="form-text text-small p-0 m-0"><a href="/formatting" target="_blank">Formatting help</a></div>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

View File

@ -114,7 +114,7 @@
</div>
</div>
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@ -168,7 +168,7 @@
{% block scripts %}
{% endblock %}
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script>
function formkey() {return '{{v.formkey}}';}

View File

@ -146,7 +146,7 @@
</div>
</div>
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script defer src="/assets/js/signup.js?v=63"></script>

View File

@ -96,7 +96,7 @@
</div>
</div>
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@ -895,6 +895,83 @@
</script>
{% if v %}
<script>
function vote(type, id, dir) {
var upvote = document.getElementById(type + '-' + id + '-up');
var downvote = document.getElementById(type + '-' + id + '-down');
var scoretext = document.getElementById(type + '-score-' + id);
var score = Number(scoretext.textContent);
if (dir == "1") {
if (upvote.classList.contains('active')) {
upvote.classList.remove('active')
scoretext.textContent = score - 1
votedirection = "0"
} else if (downvote.classList.contains('active')) {
upvote.classList.add('active')
downvote.classList.remove('active')
scoretext.textContent = score + 2
votedirection = "1"
} else {
upvote.classList.add('active')
scoretext.textContent = score + 1
votedirection = "1"
}
if (upvote.classList.contains('active')) {
scoretext.classList.add('score-up')
scoretext.classList.remove('score-down')
scoretext.classList.remove('score')
} else if (downvote.classList.contains('active')) {
scoretext.classList.add('score-down')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score')
} else {
scoretext.classList.add('score')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score-down')
}
}
else {
if (downvote.classList.contains('active')) {
downvote.classList.remove('active')
scoretext.textContent = score + 1
votedirection = "0"
} else if (upvote.classList.contains('active')) {
downvote.classList.add('active')
upvote.classList.remove('active')
scoretext.textContent = score - 2
votedirection = "-1"
} else {
downvote.classList.add('active')
scoretext.textContent = score - 1
votedirection = "-1"
}
if (upvote.classList.contains('active')) {
scoretext.classList.add('score-up')
scoretext.classList.remove('score-down')
scoretext.classList.remove('score')
} else if (downvote.classList.contains('active')) {
scoretext.classList.add('score-down')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score')
} else {
scoretext.classList.add('score')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score-down')
}
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "/vote/" + type.replace('-mobile','') + "/" + id + "/" + votedirection, true);
var form = new FormData()
form.append("formkey", formkey());
xhr.withCredentials=true;
xhr.send(form);
}
</script>
<script defer src="/assets/js/comments_v.js?v=73"></script>
{% include "award_modal.html" %}
{% include "emoji_modal.html" %}

View File

@ -1,3 +1,83 @@
{% if v %}
<script>
function vote(type, id, dir) {
var upvote = document.getElementById(type + '-' + id + '-up');
var downvote = document.getElementById(type + '-' + id + '-down');
var scoretext = document.getElementById(type + '-score-' + id);
var score = Number(scoretext.textContent);
if (dir == "1") {
if (upvote.classList.contains('active')) {
upvote.classList.remove('active')
scoretext.textContent = score - 1
votedirection = "0"
} else if (downvote.classList.contains('active')) {
upvote.classList.add('active')
downvote.classList.remove('active')
scoretext.textContent = score + 2
votedirection = "1"
} else {
upvote.classList.add('active')
scoretext.textContent = score + 1
votedirection = "1"
}
if (upvote.classList.contains('active')) {
scoretext.classList.add('score-up')
scoretext.classList.remove('score-down')
scoretext.classList.remove('score')
} else if (downvote.classList.contains('active')) {
scoretext.classList.add('score-down')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score')
} else {
scoretext.classList.add('score')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score-down')
}
}
else {
if (downvote.classList.contains('active')) {
downvote.classList.remove('active')
scoretext.textContent = score + 1
votedirection = "0"
} else if (upvote.classList.contains('active')) {
downvote.classList.add('active')
upvote.classList.remove('active')
scoretext.textContent = score - 2
votedirection = "-1"
} else {
downvote.classList.add('active')
scoretext.textContent = score - 1
votedirection = "-1"
}
if (upvote.classList.contains('active')) {
scoretext.classList.add('score-up')
scoretext.classList.remove('score-down')
scoretext.classList.remove('score')
} else if (downvote.classList.contains('active')) {
scoretext.classList.add('score-down')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score')
} else {
scoretext.classList.add('score')
scoretext.classList.remove('score-up')
scoretext.classList.remove('score-down')
}
}
var xhr = new XMLHttpRequest();
xhr.open("POST", "/vote/" + type.replace('-mobile','') + "/" + id + "/" + votedirection, true);
var form = new FormData()
form.append("formkey", formkey());
xhr.withCredentials=true;
xhr.send(form);
}
</script>
{% endif %}
{% if request.host == 'pcmemes.net' %}
{% set cc='SPLASH MOUNTAIN' %}
{% else %}

View File

@ -81,7 +81,7 @@
<input id="file-upload" type="file" name="file" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} accept="image/*, video/*" hidden>
</label>
<small class="form-text text-muted">Optional if you have text.</small>
<small class="form-text text-muted">You can upload videos up to 1 minute long.</small>
<small class="form-text text-muted">You can upload images or videos up to 1 minute long.</small>
</div>
</div>
@ -173,7 +173,7 @@
</div>
{% endblock %}
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/marked@3.0.8/lib/marked.min.js"></script>
<script defer src="/assets/js/submit.js?v=72"></script>