Merge remote-tracking branch 'origin/master'

master
fireworks88 2021-09-10 20:55:05 +02:00
commit 3d9a3179ce
35 changed files with 342 additions and 360 deletions

BIN
chart.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -38,6 +38,7 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
created_utc = Column(Integer, default=0)
edited_utc = Column(Integer, default=0)
is_banned = Column(Boolean, default=False)
removed_by = Column(Integer)
bannedfor = Column(Boolean)
distinguish_level = Column(Integer, default=0)
deleted_utc = Column(Integer, default=0)

View File

@ -44,6 +44,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
created_utc = Column(BigInteger, default=0)
thumburl = Column(String)
is_banned = Column(Boolean, default=False)
removed_by = Column(Integer)
bannedfor = Column(Boolean)
processing = Column(Boolean, default=False)
views = Column(Integer, default=0)

View File

@ -11,10 +11,16 @@ CF_ZONE = environ.get("CLOUDFLARE_ZONE", "").strip()
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
IBB_KEY = environ.get("IBB_KEY", "").strip()
def upload_ibb(file, resize=False):
def upload_ibb(filepath=None, file=None, resize=False):
if file:
format = file.filename.split('.')[-1].lower().replace('jpg','png').replace('jpeg','png')
filepath = f"image.{format}"
file.save(filepath)
else: format = filepath.split('.')[-1].lower().replace('jpg','png').replace('jpeg','png')
if resize:
i = IImage.open(file)
i = IImage.open(filepath)
size = 100, 100
frames = ImageSequence.Iterator(i)
@ -28,28 +34,35 @@ def upload_ibb(file, resize=False):
om = next(frames)
om.info = i.info
try: om.save(f"image.{om.format}", save_all=True, append_images=list(frames), loop=0, optimize=True, quality=30)
except Exception as e:
print(e)
return
try: om.save(filepath, save_all=True, append_images=list(frames), loop=0, optimize=True, quality=30)
except: return
elif format != "gif":
i = IImage.open(filepath)
i.save(filepath, optimize=True, quality=30)
try:
with open(file, 'rb') as f:
with open(filepath, 'rb') as f:
data={'image': base64.b64encode(f.read())}
req = requests.post(f'https://api.imgbb.com/1/upload?key={IBB_KEY}', data=data)
resp = req.json()['data']
url = resp['url']
except Exception as e:
except:
if req: print(req.json())
else: print(e)
return
return(url)
return url
def upload_imgur(file, resize=False):
def upload_imgur(filepath=None, file=None, resize=False):
if file:
format = file.filename.split('.')[-1].lower().replace('jpg','png').replace('jpeg','png')
filepath = f"image.{format}"
file.save(filepath)
else: format = filepath.split('.')[-1].lower().replace('jpg','png').replace('jpeg','png')
if resize:
i = IImage.open(file)
i = IImage.open(filepath)
size = 100, 100
frames = ImageSequence.Iterator(i)
@ -63,15 +76,14 @@ def upload_imgur(file, resize=False):
om = next(frames)
om.info = i.info
try: om.save(f"image.{om.filename.split('.')[-1]}", save_all=True, append_images=list(frames), loop=0, optimize=True, quality=30)
except Exception as e:
#print(om.filename)
print(type(om))
print(om.format)
print(e)
return
try: om.save(filepath, save_all=True, append_images=list(frames), loop=0, optimize=True, quality=30)
except: return
elif format != "gif":
i = IImage.open(filepath)
i.save(filepath, optimize=True, quality=30)
try:
with open(file, 'rb') as f:
with open(filepath, 'rb') as f:
data={'image': base64.b64encode(f.read())}
req = requests.post('https://api.imgur.com/3/upload.json', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}, data=data)
resp = req.json()['data']
@ -79,14 +91,13 @@ def upload_imgur(file, resize=False):
if not "_d." in url:
url = url.replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg")
if "_d." in url: url += "?maxwidth=9999"
except Exception as e:
except:
if req: print(req.json())
else: print(e)
return
new_image = Image(text=url, deletehash=resp["deletehash"])
g.db.add(new_image)
return(url)
return url
class UploadException(Exception):
@ -118,4 +129,4 @@ def upload_video(file):
img = Image(text=link, deletehash=resp['deletehash'])
g.db.add(img)
return link
return link

View File

@ -23,36 +23,124 @@ from files.helpers.discord import add_role
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
@app.post("/@<username>/revert_actions")
@admin_level_required(6)
def revert_actions(v, username):
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
user = get_user(username)
if not user: abort(404)
items = g.db.query(Submission).options(lazyload('*')).filter_by(removed_by=user.id).all() + g.db.query(Comment).options(lazyload('*')).filter_by(removed_by=user.id).all()
for item in items:
item.is_banned = False
item.removed_by = None
g.db.add(item)
users = g.db.query(User).options(lazyload('*')).filter_by(is_banned=user.id).all()
for user in users:
user.unban()
return {"message": "Admin actions reverted!"}
@app.post("/@<username>/make_admin")
@admin_level_required(6)
def make_admin(v, username):
user = get_user(username)
if not user: abort(404)
user.admin_level = 6
g.db.add(user)
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
user = get_user(username)
if not user: abort(404)
user.admin_level = 6
g.db.add(user)
return {"message": "User has been made admin!"}
@app.post("/@<username>/make_fake_admin")
@admin_level_required(6)
def make_fake_admin(v, username):
user = get_user(username)
if not user: abort(404)
user.admin_level = 1
g.db.add(user)
return {"message": "User has been made fake admin!"}
@app.post("/@<username>/remove_admin")
@admin_level_required(6)
def remove_admin(v, username):
user = get_user(username)
if not user: abort(404)
user.admin_level = 0
g.db.add(user)
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
user = get_user(username)
if not user: abort(404)
user.admin_level = 0
g.db.add(user)
return {"message": "Admin removed!"}
@app.post("/@<username>/make_fake_admin")
@admin_level_required(6)
def make_fake_admin(v, username):
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
user = get_user(username)
if not user: abort(404)
user.admin_level = 1
g.db.add(user)
return {"message": "User has been made fake admin!"}
@app.post("/@<username>/remove_fake_admin")
@admin_level_required(6)
def remove_fake_admin(v, username):
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
user = get_user(username)
if not user: abort(404)
user.admin_level = 0
g.db.add(user)
return {"message": "Fake admin removed!"}
@app.post("/admin/monthly")
@limiter.limit("1/day")
@admin_level_required(6)
def monthly(v):
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [12,28,29,747,995]) or ('rdrama' not in request.host and 'pcm' not in request.host):
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
_awards = []
for u in g.db.query(User).filter(User.patron > 0).all():
grant_awards = {}
if u.patron == 1:
grant_awards["shit"] = 1
grant_awards["stars"] = 1
elif u.patron == 2:
grant_awards["shit"] = 3
grant_awards["stars"] = 3
elif u.patron == 3:
grant_awards["shit"] = 5
grant_awards["stars"] = 5
grant_awards["ban"] = 1
elif u.patron == 4:
grant_awards["shit"] = 10
grant_awards["stars"] = 10
grant_awards["ban"] = 3
elif u.patron == 5 or u.patron == 8:
grant_awards["shit"] = 20
grant_awards["stars"] = 20
grant_awards["ban"] = 6
for name in grant_awards:
for count in range(grant_awards[name]):
thing += 1
_awards.append(AwardRelationship(
id=thing,
user_id=u.id,
kind=name
))
text = "You were given the following awards:\n\n"
for key, value in grant_awards.items():
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
g.db.bulk_save_objects(_awards)
return {"message": "Monthly awards granted"}
@app.get('/admin/rules')
@admin_level_required(6)
def get_rules(v):
@ -110,7 +198,7 @@ def image_posts_listing(v):
firstrange = 25 * (page - 1)
secondrange = firstrange+26
posts = [x.id for x in posts if x.is_image][firstrange:secondrange]
next_exists = (len(posts) == 26)
next_exists = (len(posts) > 25)
posts = get_posts(posts[:25], v=v)
return render_template("admin/image_posts.html", v=v, listing=posts, next_exists=next_exists, page=page, sort="new")
@ -128,7 +216,7 @@ def flagged_posts(v):
).join(Submission.flags).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
listing = [p.id for p in posts]
next_exists = (len(listing) == 26)
next_exists = (len(listing) > 25)
listing = listing[:25]
listing = get_posts(listing, v=v)
@ -150,7 +238,7 @@ def flagged_comments(v):
).join(Comment.flags).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
listing = [p.id for p in posts]
next_exists = (len(listing) == 26)
next_exists = (len(listing) > 25)
listing = listing[:25]
listing = get_comments(listing, v=v)
@ -169,59 +257,6 @@ def admin_home(v):
x = f.read()
return render_template("admin/admin_home.html", v=v, x=x)
@app.post("/admin/monthly")
@limiter.limit("1/day")
@admin_level_required(6)
def monthly(v):
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
_awards = []
for u in g.db.query(User).filter(User.patron > 0).all():
grant_awards = {}
if u.patron == 1:
grant_awards["shit"] = 1
grant_awards["stars"] = 1
elif u.patron == 2:
grant_awards["shit"] = 3
grant_awards["stars"] = 3
elif u.patron == 3:
grant_awards["shit"] = 5
grant_awards["stars"] = 5
grant_awards["ban"] = 1
elif u.patron == 4:
grant_awards["shit"] = 10
grant_awards["stars"] = 10
grant_awards["ban"] = 3
elif u.patron == 5 or u.patron == 8:
grant_awards["shit"] = 20
grant_awards["stars"] = 20
grant_awards["ban"] = 6
for name in grant_awards:
for count in range(grant_awards[name]):
thing += 1
_awards.append(AwardRelationship(
id=thing,
user_id=u.id,
kind=name
))
text = "You were given the following awards:\n\n"
for key, value in grant_awards.items():
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
g.db.bulk_save_objects(_awards)
return {"message": "Monthly awards granted"}
@app.post("/admin/disablesignups")
@admin_level_required(6)
@validate_formkey
@ -366,7 +401,7 @@ def users_list(v):
users = [x for x in users]
next_exists = (len(users) == 26)
next_exists = (len(users) > 25)
users = users[:25]
return render_template("admin/new_users.html",
@ -515,7 +550,7 @@ def admin_removed(v):
ids=[x[0] for x in ids]
next_exists = len(ids) == 26
next_exists = len(ids) > 25
ids = ids[:25]
@ -852,6 +887,7 @@ def ban_post(post_id, v):
post.is_approved = 0
post.stickied = False
post.is_pinned = False
post.removed_by = v.id
ban_reason=request.form.get("reason", "")
ban_reason = ban_reason.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
@ -973,6 +1009,7 @@ def api_ban_comment(c_id, v):
comment.is_banned = True
comment.is_approved = 0
comment.removed_by = v.id
g.db.add(comment)
ma=ModAction(
@ -1125,9 +1162,9 @@ def admin_nunuke_user(v):
return redirect(user.url)
@app.get("/admin/user_stat_data")
@admin_level_required(2)
def user_stat_data(v):
@app.get("/chart")
@auth_required
def chart(v):
days = int(request.args.get("days", 25))
@ -1149,74 +1186,13 @@ def user_stat_data(v):
day_cutoffs = [today_cutoff - day * i for i in range(days)]
day_cutoffs.insert(0, calendar.timegm(now))
daily_signups = [{"date": time.strftime("%d", time.gmtime(day_cutoffs[i + 1])),
"day_start":day_cutoffs[i + 1],
"signups": g.db.query(User).filter(User.created_utc < day_cutoffs[i],
User.created_utc > day_cutoffs[i + 1] ).count()
} for i in range(len(day_cutoffs) - 1)
]
daily_times = [time.strftime("%d", time.gmtime(day_cutoffs[i + 1])) for i in range(len(day_cutoffs) - 1)][2:][::-1]
user_stats = {'current_users': g.db.query(User).filter_by(is_banned=0, reserved=None).count(),
'banned_users': g.db.query(User).filter(User.is_banned != 0).count(),
'reserved_users': g.db.query(User).filter(User.reserved != None).count(),
'email_verified_users': g.db.query(User).filter_by(is_banned=0, is_activated=True).count(),
}
daily_signups = [g.db.query(User).filter(User.created_utc < day_cutoffs[i], User.created_utc > day_cutoffs[i + 1]).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
post_stats = [{"date": time.strftime("%d", time.gmtime(day_cutoffs[i + 1])),
"day_start":day_cutoffs[i + 1],
"posts": g.db.query(Submission).filter(Submission.created_utc < day_cutoffs[i],
Submission.created_utc > day_cutoffs[i + 1],
Submission.is_banned == False
).count()
} for i in range(len(day_cutoffs) - 1)
]
post_stats = [g.db.query(Submission).filter(Submission.created_utc < day_cutoffs[i], Submission.created_utc > day_cutoffs[i + 1], Submission.is_banned == False).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
comment_stats = [{"date": time.strftime("%d", time.gmtime(day_cutoffs[i + 1])),
"day_start": day_cutoffs[i + 1],
"comments": g.db.query(Comment).filter(Comment.created_utc < day_cutoffs[i],
Comment.created_utc > day_cutoffs[i + 1],
Comment.is_banned == False,
Comment.author_id != 1
).count()
} for i in range(len(day_cutoffs) - 1)
]
x = create_plot(sign_ups={'daily_signups': daily_signups},
posts={'post_stats': post_stats},
comments={'comment_stats': comment_stats},
)
final = {
"multi_plot": x,
"user_stats": user_stats,
"signup_data": daily_signups,
"post_data": post_stats,
"comment_data": comment_stats,
}
return final
def create_plot(**kwargs):
if not kwargs:
return abort(400)
# create multiple charts
daily_signups = [d["signups"] for d in kwargs["sign_ups"]['daily_signups']][1:][::-1]
post_stats = [d["posts"] for d in kwargs["posts"]['post_stats']][1:][::-1]
comment_stats = [d["comments"] for d in kwargs["comments"]['comment_stats']][1:][::-1]
daily_times = [d["date"] for d in kwargs["sign_ups"]['daily_signups']][1:][::-1]
multi_plots = multiple_plots(sign_ups=daily_signups,
posts=post_stats,
comments=comment_stats,
daily_times=daily_times)
return multi_plots
def multiple_plots(**kwargs):
comment_stats = [g.db.query(Comment).filter(Comment.created_utc < day_cutoffs[i], Comment.created_utc > day_cutoffs[i + 1],Comment.is_banned == False, Comment.author_id != 1).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
# create multiple charts
signup_chart = plt.subplot2grid((20, 4), (0, 0), rowspan=5, colspan=4)
@ -1226,16 +1202,16 @@ def multiple_plots(**kwargs):
signup_chart.grid(), posts_chart.grid(), comments_chart.grid()
signup_chart.plot(
kwargs['daily_times'],
kwargs['sign_ups'],
daily_times,
daily_signups,
color='red')
posts_chart.plot(
kwargs['daily_times'],
kwargs['posts'],
daily_times,
post_stats,
color='green')
comments_chart.plot(
kwargs['daily_times'],
kwargs['comments'],
daily_times,
comment_stats,
color='gold')
signup_chart.set_ylabel("Signups")
@ -1247,8 +1223,6 @@ def multiple_plots(**kwargs):
posts_chart.legend(loc='upper left', frameon=True)
comments_chart.legend(loc='upper left', frameon=True)
plt.savefig("image.png")
plt.savefig("chart.png")
plt.clf()
if "pcmemes.net" in request.host: return upload_ibb("image.png")
else: return upload_imgur("image.png")
return send_file("../chart.png")

View File

@ -277,10 +277,12 @@ def api_comment(v):
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
file.save(f"image.{file.filename.split('.')[-1]}")
if 'pcmemes.net' in request.host: url = upload_ibb(f"image.{file.filename.split('.')[-1]}")
else: url = upload_imgur(f"image.{file.filename.split('.')[-1]}")
if request.content_length > 16 * 1024 * 1024:
g.db.rollback()
abort(413)
if 'pcmemes.net' in request.host: url = upload_ibb(file=file)
else: url = upload_imgur(file=file)
body = request.form.get("body") + f"\n![]({url})"
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
@ -693,10 +695,12 @@ def edit_comment(cid, v):
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
file.save(f"image.{file.format}", optimize=True, quality=30)
if 'pcmemes.net' in request.host: url = upload_ibb(f"image.{file.format}")
else: url = upload_imgur(f"image.{file.format}")
if request.content_length > 16 * 1024 * 1024:
g.db.rollback()
abort(413)
if 'pcmemes.net' in request.host: url = upload_ibb(file=file)
else: url = upload_imgur(file=file)
body += f"\n![]({url})"
with CustomRenderer(post_id=c.parent_submission) as renderer:

View File

@ -25,15 +25,15 @@ def notifications(v):
firstrange = 25 * (page - 1)
secondrange = firstrange + 26
comments = comments[firstrange:secondrange]
next_exists = (len(comments) == 26)
next_exists = (len(comments) > 25)
comments = comments[:25]
elif messages:
cids = v.notification_messages(page=page)
next_exists = (len(cids) == 26)
next_exists = (len(cids) > 25)
cids = cids[:25]
comments = get_comments(cids, v=v)
elif posts:
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26)
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101)
comments = []
for x in notifications:
@ -42,8 +42,8 @@ def notifications(v):
x.read = True
g.db.add(x)
comments.append(c)
next_exists = (len(comments) == 26)
comments = comments[:25]
next_exists = (len(comments) > 100)
listing = comments[:100]
else:
notifications = v.notifications.join(Notification.comment).filter(
Comment.is_banned == False,
@ -51,7 +51,7 @@ def notifications(v):
Comment.author_id != AUTOJANNY_ACCOUNT,
).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all()
next_exists = (len(notifications) == 26)
next_exists = (len(notifications) > 25)
notifications = notifications[:25]
cids = [x.comment_id for x in notifications]
comments = get_comments(cids, v=v, load_parent=True)
@ -65,32 +65,33 @@ def notifications(v):
g.db.add(x)
i += 1
listing = []
for c in comments:
c._is_blocked = False
c._is_blocking = False
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
c.replies = []
while c.parent_comment and c.parent_comment.author_id == v.id:
parent = c.parent_comment
if c not in parent.replies2:
parent.replies2 = parent.replies2 + [c]
parent.replies = parent.replies2
c = parent
if c not in listing:
listing.append(c)
c.replies = c.replies2
elif c.parent_submission:
c.replies = []
if c not in listing:
listing.append(c)
else:
if c.parent_comment:
while c.level > 1:
c = c.parent_comment
if not posts:
listing = []
for c in comments:
c._is_blocked = False
c._is_blocking = False
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
c.replies = []
while c.parent_comment and c.parent_comment.author_id == v.id:
parent = c.parent_comment
if c not in parent.replies2:
parent.replies2 = parent.replies2 + [c]
parent.replies = parent.replies2
c = parent
if c not in listing:
listing.append(c)
c.replies = c.replies2
elif c.parent_submission:
c.replies = []
if c not in listing:
listing.append(c)
else:
if c.parent_comment:
while c.level > 1:
c = c.parent_comment
if c not in listing:
listing.append(c)
if c not in listing:
listing.append(c)
return render_template("notifications.html",
v=v,
@ -157,9 +158,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
if lt:
posts = posts.filter(Submission.created_utc < lt)
if v:
posts = posts.join(Submission.author).filter(or_(User.shadowbanned==False, Submission.author_id==v.id))
else:
if not v or v.shadowbanned:
posts = posts.join(Submission.author).filter(User.shadowbanned == False)
if sort == "hot":
@ -182,10 +181,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
else:
abort(400)
#print('fartbinn' in [x.author.username for x in posts])
firstrange = 50 * (page - 1)
secondrange = firstrange+51
secondrange = firstrange+200
posts = posts[firstrange:secondrange]
if random.random() < 0.004:
@ -205,7 +202,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
post.views = post.views + random.randint(7,10)
g.db.add(post)
next_exists = (len(posts) == 51)
next_exists = (len(posts) > 50)
posts = posts[:50]
@ -350,7 +347,7 @@ def changelog(v):
)
# check existence of next page
next_exists = (len(ids) == 51)
next_exists = (len(ids) > 50)
ids = ids[:50]
# check if ids exist
@ -450,7 +447,7 @@ def all_comments(v):
comments = get_comments(idlist, v=v)
next_exists = len(idlist) == 26
next_exists = len(idlist) > 25
idlist = idlist[:25]

View File

@ -183,18 +183,17 @@ def post_id(pid, anything=None, v=None):
post.preloaded_comments = [x for x in comments if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)]
# if session.get("read_comments"): read = list(set(session.get("read_comments")))
# else: read = None
if not v or v.highlightcomments:
last_view_utc = session.get(str(post.id))
if last_view_utc: last_view_utc = int(last_view_utc)
session[str(post.id)] = int(time.time())
# unread comment highlight
last_view_utc = session.get(str(post.id))
if last_view_utc:
last_view_utc = int(last_view_utc)
session[str(post.id)] = int(time.time())
#read_comments = [x.id for x in post.preloaded_comments]
keys = []
for key, val in session.items():
if type(val) is int and key not in ['login_nonce','user_id']:
if time.time() - val > 86400: keys.append(key)
for key in keys: session.pop(key)
post.views += 1
g.db.add(post)
@ -205,7 +204,9 @@ def post_id(pid, anything=None, v=None):
post.tree_comments()
if request.headers.get("Authorization"): return post.json
else: return post.rendered_page(v=v, last_view_utc=last_view_utc, sort=sort)
else:
if not v or v.highlightcomments: return post.rendered_page(v=v, last_view_utc=last_view_utc, sort=sort)
else: return post.rendered_page(v=v, sort=sort)
@app.post("/edit_post/<pid>")
@ -497,7 +498,6 @@ def thumbs(new_post):
image = PILimage.open(BytesIO(x.content))
else:
print(f'Unknown content type {x.headers.get("Content-Type")}')
return False, f'Unknown content type {x.headers.get("Content-Type")} for submitted content'
@ -505,8 +505,8 @@ def thumbs(new_post):
for chunk in image_req.iter_content(1024):
file.write(chunk)
if 'pcmemes.net' in request.host: post.thumburl = upload_ibb(f"image.png", True)
else: post.thumburl = upload_imgur(f"image.png", True)
if 'pcmemes.net' in request.host: post.thumburl = upload_ibb(filepath="image.png", resize=True)
else: post.thumburl = upload_imgur(filepath="image.png", resize=True)
g.db.add(post)
@ -891,58 +891,30 @@ def submit_post(v):
body=request.form.get("body", "")
), 403
if 'pcmemes.net' in request.host:
if file.content_type.startswith('image/'):
file.save(f"image.{file.format}", optimize=True, quality=30)
new_post.url = upload_ibb(f"image.{file.format}")
else:
try:
post_url = upload_video(file)
if not post_url.endswith('.mp4'):
post_url += 'mp4'
new_post.url = post_url
new_post.processing = True
gevent.spawn(check_processing_thread, v.id, new_post, post_url, g.db)
except UploadException as e:
if request.headers.get("Authorization"):
return {
"error": str(e),
}, 400
else:
return render_template(
"submit.html",
v=v,
error=str(e),
title=title,
body=request.form.get("body", "")
), 400
if file.content_type.startswith('image/'):
if 'pcmemes.net' in request.host: new_post.url = upload_ibb(file=file)
else: new_post.url = upload_imgur(file=file)
else:
if file.content_type.startswith('image/'):
file.save(f"image.{file.filename.split('.')[-1]}")
new_post.url = upload_imgur(f"image.{file.filename.split('.')[-1]}")
else:
try:
post_url = upload_video(file)
# shit to make webm work
if not post_url.endswith('.mp4'):
post_url += 'mp4'
# print(post_url)
new_post.url = post_url
new_post.processing = True
gevent.spawn(check_processing_thread, v.id, new_post, post_url, g.db)
except UploadException as e:
if request.headers.get("Authorization"):
return {
"error": str(e),
}, 400
else:
return render_template(
"submit.html",
v=v,
error=str(e),
title=title,
body=request.form.get("body", "")
), 400
try:
post_url = upload_video(file)
if not post_url.endswith('.mp4'):
post_url += 'mp4'
new_post.url = post_url
new_post.processing = True
gevent.spawn(check_processing_thread, v.id, new_post, post_url, g.db)
except UploadException as e:
if request.headers.get("Authorization"):
return {
"error": str(e),
}, 400
else:
return render_template(
"submit.html",
v=v,
error=str(e),
title=title,
body=request.form.get("body", "")
), 400
g.db.add(new_post)
g.db.add(new_post.submission_aux)

View File

@ -213,7 +213,7 @@ def searchposts(v):
criteria=searchparse(query)
total, ids = searchlisting(criteria, v=v, page=page, t=t, sort=sort)
next_exists = (len(ids) == 26)
next_exists = (len(ids) > 25)
ids = ids[:25]
posts = get_posts(ids, v=v)
@ -255,7 +255,7 @@ def searchcomments(v):
criteria=searchparse(query)
total, ids = searchcommentlisting(criteria, v=v, page=page, t=t, sort=sort)
next_exists = (len(ids) == 26)
next_exists = (len(ids) > 25)
ids = ids[:25]
comments = get_comments(ids, v=v)

View File

@ -113,9 +113,8 @@ def settings_profile_post(v):
if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400
else: return render_template("settings_profile.html", v=v, error=f"Image files only."), 400
file.save(f"image.{file.format}", optimize=True, quality=30)
if 'pcmemes.net' in request.host: url = upload_ibb(f"image.{file.format}")
else: url = upload_imgur(f"image.{file.format}")
if 'pcmemes.net' in request.host: url = upload_ibb(file=file)
else: url = upload_imgur(file=file)
bio += f"\n\n![]({url})"
@ -498,17 +497,16 @@ def settings_images_profile(v):
if request.headers.get("cf-ipcountry") == "T1": return "Image uploads are not allowed through TOR.", 403
file = request.files["profile"]
print(file.filename)
print(file.filename.split('.')[-1])
file.save(f"image.{file.filename.split('.')[-1]}")
if 'pcmemes.net' in request.host: highres = upload_ibb(f"image.{file.filename.split('.')[-1]}")
else: highres = upload_imgur(f"image.{file.filename.split('.')[-1]}")
format = file.filename.split('.')[-1].lower().replace('jpg','png').replace('jpeg','png')
filepath = f"image.{format}"
file.save(filepath)
if 'pcmemes.net' in request.host: highres = upload_ibb(filepath=filepath)
else: highres = upload_imgur(filepath=filepath)
if not highres: abort(400)
if 'pcmemes.net' in request.host: imageurl = upload_ibb(f"image.{file.filename.split('.')[-1]}", True)
else: imageurl = upload_imgur(f"image.{file.filename.split('.')[-1]}", True)
if 'pcmemes.net' in request.host: imageurl = upload_ibb(filepath=filepath, resize=True)
else: imageurl = upload_imgur(filepath=filepath, resize=True)
if not imageurl: abort(400)
v.highres = highres
@ -529,10 +527,8 @@ def settings_images_banner(v):
if request.headers.get("cf-ipcountry") == "T1": return "Image uploads are not allowed through TOR.", 403
file = request.files["banner"]
file.save(f"image.{file.filename.split('.')[-1]}")
if 'pcmemes.net' in request.host: imageurl = upload_ibb(f"image.{file.filename.split('.')[-1]}")
else: imageurl = upload_imgur(f"image.{file.filename.split('.')[-1]}")
if 'pcmemes.net' in request.host: imageurl = upload_ibb(file=file)
else: imageurl = upload_imgur(file=file)
if imageurl:
v.bannerurl = imageurl
@ -846,4 +842,14 @@ def settings_title_change(v):
v.customtitle = filter_title(new_name)
g.db.add(v)
return redirect("/settings/profile")
return redirect("/settings/profile")
@app.post("/settings/badges")
@auth_required
@validate_formkey
def settings_badge_recheck(v):
v.refresh_selfset_badges()
return {"message":"Badges Refreshed"}

View File

@ -291,7 +291,7 @@ def mfa_qr(secret, v):
mem = io.BytesIO()
img.save(mem, format="PNG", optimize=True, quality=30)
img.save(mem, format="PNG")
mem.seek(0, 0)
return send_file(mem, mimetype="image/png", as_attachment=False)
@ -423,7 +423,7 @@ def u_username(username, v=None):
ids = u.userpagelisting(v=v, page=page, sort=sort, t=t)
# we got 26 items just to see if a next page exists
next_exists = (len(ids) == 26)
next_exists = (len(ids) > 25)
ids = ids[:25]
# If page 1, check for sticky
@ -526,7 +526,7 @@ def u_username_comments(username, v=None):
)
# we got 26 items just to see if a next page exists
next_exists = (len(ids) == 26)
next_exists = (len(ids) > 25)
ids = ids[:25]
listing = get_comments(ids, v=v)

View File

@ -36,7 +36,7 @@
#### Statistics
* [Content Stats](/stats)
* [Advanced Stats](/admin/user_stat_data)
* [Stat Chart](/chart)
#### Configuration
* [Site Rules](/admin/rules)

View File

@ -65,7 +65,7 @@
</form>
<pre></pre>
{% if v.id in [1,28,29,995] %}
{% if v.id in [1,12,28,29,747,995] %}
<div><a class="btn btn-success" href="javascript:void(0)" onclick="post_toast('/admin/monthly')">Grant Monthly Awards</a></div>
{% endif %}
{% endblock %}
{% endblock %}

View File

@ -431,9 +431,9 @@
<li class="list-group-item"><a href="/votes?link={{c.fullname}}"><i class="fas fa-arrows-v"></i>Votes</a></li>
{% if v %}
<li id="save2-{{c.id}}" class="{% if c not in v.saved_comment_idlist() %}d-none{% endif %} list-group-item"><a href="javascript:void(0)" data-dismiss="modal" onclick="post_toast2('/save_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}')"><i class="fas fa-save"></i>Save</a></li>
<li id="save2-{{c.id}}" class="{% if c in v.saved_comment_idlist() %}d-none{% endif %} list-group-item"><a href="javascript:void(0)" data-dismiss="modal" onclick="post_toast2('/save_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}')"><i class="fas fa-save"></i>Save</a></li>
<li id="unsave2-{{c.id}}" class="{% if c in v.saved_comment_idlist() %}d-none{% endif %} list-group-item"><a href="javascript:void(0)" onclick="post_toast2('/unsave_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}')" data-dismiss="modal"><i class="fas fa-save"></i>Unsave</a></li>
<li id="unsave2-{{c.id}}" class="{% if c not in v.saved_comment_idlist() %}d-none{% endif %} list-group-item"><a href="javascript:void(0)" onclick="post_toast2('/unsave_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}')" data-dismiss="modal"><i class="fas fa-save"></i>Unsave</a></li>
{% endif %}

View File

@ -1251,7 +1251,7 @@
{% include "expanded_image_modal.html" %}
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
<!-- ClipboardJS -->

View File

@ -144,6 +144,6 @@ We also have some custom hooks for mentioning users and subreddits. Note that th
{% include "expanded_image_modal.html" %}
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
{% endblock %}

View File

@ -130,7 +130,7 @@
</div>
<hr class="my-2">
<div class="px-2">
<a class="dropdown-item" href="javascript:void(0)", onclick="post('/logout', callback=function(){window.location.reload(true)})"><i class="fas fa-sign-out fa-fw text-left mr-3"></i>Log out</a>
<a class="dropdown-item" href="javascript:void(0)", onclick="post('/logout', '1'"><i class="fas fa-sign-out fa-fw text-left mr-3"></i>Log out</a>
</div>
</div>
</div>
@ -190,7 +190,7 @@
<li class="nav-item"><a class="nav-link" href="/contact"><i class="fas fa-file-signature fa-fw mr-3"></i>Contact us</a></li>
<li class="nav-item border-top border-bottom mt-2 pt-2">
<a class="nav-link" href="javascript:void(0)", onclick="post('/logout', callback=function(){window.location.reload(true)})"><i class="fas fa-sign-out fa-fw mr-3 text-danger"></i>Log out</a>
<a class="nav-link" href="javascript:void(0)", onclick="post('/logout', '1'"><i class="fas fa-sign-out fa-fw mr-3 text-danger"></i>Log out</a>
</li>
{% else %}
<li class="nav-item d-flex align-items-center justify-content-center pb-3">

View File

@ -130,7 +130,7 @@
{% include "bootstrap.html" %}
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
</body>

View File

@ -254,7 +254,7 @@
</div>
</div>
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
{% block onload %}{% endblock %}

View File

@ -226,7 +226,7 @@
});
</script>
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
{% block scripts %}
{% endblock %}

View File

@ -45,7 +45,7 @@
</div>
<div class="footer">
<div class="d-flex">
<a href="javascript:void(0)" class="btn btn-secondary ml-auto" onclick="post_toast('/oauth/reroll/{{app.id}}', callback=function(xhr){document.getElementById('edit-{{app.id}}-client-id').value=JSON.parse(xhr.response)['id'];document.getElementById('edit-{{app.id}}-client-secret').value=JSON.parse(xhr.response)['secret'];})">Reroll Client ID</a>
<a href="javascript:void(0)" class="btn btn-secondary ml-auto" onclick="post_toast('/oauth/reroll/{{app.id}}','1')">Reroll Client ID</a>
<input type="submit" class="btn btn-primary ml-2" value="Save Changes">
</div>
</div>
@ -111,7 +111,7 @@
</div>
<div class="footer">
<div class="d-flex">
<a href="javascript:void(0)" class="btn btn-primary ml-auto text-white" onclick="post_toast('/oauth/rescind/{{auth.id}}', callback=function(xhr){document.getElementById('auth-{{auth.id}}').classList.add('d-none')})">Revoke</a>
<a href="javascript:void(0)" class="btn btn-primary ml-auto text-white" onclick="post_toast('/oauth/rescind/{{auth.id}}')">Revoke</a>
</div>
</div>
</div>

View File

@ -592,8 +592,12 @@
&nbsp;
<pre style="padding-top:0.7rem;line-height:1;" class="btn btn-secondary format d-inline-block m-0 font-weight-bolder text-uppercase" onclick="commentForm('bio-text');getGif()" aria-hidden="true" data-toggle="modal" data-target="#gifModal" data-toggle="tooltip" data-placement="bottom" title="Add GIF">GIF</pre>
&nbsp;
<pre style="padding-top:0.7rem" class="btn btn-secondary format d-inline-block m-0 fas fa-smile-beam" onclick="loadEmojis('bio-text',{{session.get('favorite_emojis')}})" aria-hidden="true" data-toggle="modal" data-target="#emojiModal" data-toggle="tooltip" data-placement="bottom" title="Add Emoji"></pre>
<pre style="padding-top:0.7rem" class="btn btn-secondary format d-inline-block m-0 fas fa-smile-beam" onclick="loadEmojis('bio-text')" aria-hidden="true" data-toggle="modal" data-target="#emojiModal" data-toggle="tooltip" data-placement="bottom" title="Add Emoji"></pre>
&nbsp;
<label class="btn btn-secondary format d-inline-block m-0">
<div id="filename-show"><i class="far fa-image"></i></div>
<input id="file-upload" type="file" name="file" accept="image/*" onchange="document.getElementById('filename-show').innerHTML='image';" hidden>
</label>
</div>
<pre></pre>

View File

@ -80,7 +80,7 @@
<td style="font-weight: bold">{{a['description']}}</td>
<td style="font-weight: bold">{{a['price']}}</td>
{% set kind = a['kind'] %}
<td style="font-weight: bold"><a class="btn btn-success" href="javascript:void(0)" onclick="post_toast('/buy/{{kind}}', function(){window.location.reload(true);})">Buy</a></td>
<td style="font-weight: bold"><a class="btn btn-success" href="javascript:void(0)" onclick="post_toast('/buy/{{kind}}')">Buy</a></td>
</tr>
{% endfor %}
</table>

View File

@ -233,7 +233,7 @@
<!-- {{'SITE_NAME' | app_config}} JS -->
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
</body>

View File

@ -144,7 +144,7 @@
<!-- {{'SITE_NAME' | app_config}} JS -->
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
</body>

View File

@ -132,8 +132,8 @@
<button id="save2-{{p.id}}" class="{% if p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast2('/save_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Save</a></button>
<button id="unsave2-{{p.id}}" class="{% if not p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast2('/unsave_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Unsave</a></button>
{% if v.admin_level >=3 %}
<button id="pin2-{{p.id}}" class="{% if p.sticked %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Pin</button>
<button id="unpin2-{{p.id}}" class="{% if not p.sticked %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Unpin</button>
<button id="pin2-{{p.id}}" class="{% if p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Pin</button>
<button id="unpin2-{{p.id}}" class="{% if not p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Unpin</button>
{% if v==p.author %}
<button id="distinguish2-{{p.id}}" class="{% if p.distinguish_level %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/distinguish/{{p.id}}','distinguish2-{{p.id}}','undistinguish2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-crown text-center mr-3"></i>Distinguish</button>
<button id="undistinguish2-{{p.id}}" class="{% if not p.distinguish_level %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/distinguish/{{p.id}}','distinguish2-{{p.id}}','undistinguish2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-crown text-center mr-3"></i>Undistinguish</button>

View File

@ -324,8 +324,8 @@
{% if v %}
{% if v.admin_level >=3 %}
<button id="pin2-{{p.id}}" class="{% if p.sticked %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Pin</button>
<button id="unpin2-{{p.id}}" class="{% if not p.sticked %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Unpin</button>
<button id="pin2-{{p.id}}" class="{% if p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Pin</button>
<button id="unpin2-{{p.id}}" class="{% if not p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Unpin</button>
{% if v==p.author %}
<button id="distinguish2-{{p.id}}" class="{% if p.distinguish_level %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/distinguish/{{p.id}}','distinguish2-{{p.id}}','undistinguish2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-crown text-center mr-3"></i>Distinguish</button>
<button id="undistinguish2-{{p.id}}" class="{% if not p.distinguish_level %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/distinguish/{{p.id}}','distinguish2-{{p.id}}','undistinguish2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-crown text-center mr-3"></i>Undistinguish</button>

View File

@ -482,7 +482,7 @@
<!-- {{'SITE_NAME' | app_config}} JS -->
<script src="/assets/js/general15.js"></script>
<script src="/assets/js/general17.js"></script>
<!-- ClipboardJS -->

View File

@ -13,8 +13,9 @@
{% if v %}
{% if v.id!=u.id and not u.is_private and not u.is_nofollow %}
<div id="button-sub-{{u.id}}" style="z-index: 2" class="{% if u.has_follower(v) %}d-none{% endif %}"><a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="post_toast('/follow/{{u.username}}', callback=function(){document.getElementById('button-unsub-{{u.id}}').classList.toggle('d-none');document.getElementById('button-sub-{{u.id}}').classList.toggle('d-none');})">Follow</a></div>
<div id="button-unsub-{{u.id}}" style="z-index: 2" class="{% if not u.has_follower(v) %} d-none{% endif %}"><a class="btn btn-secondary btn-sm" href="javascript:void(0)" onclick="post_toast('/unfollow/{{u.username}}', callback=function(){document.getElementById('button-unsub-{{u.id}}').classList.toggle('d-none');document.getElementById('button-sub-{{u.id}}').classList.toggle('d-none');})">Unfollow</a></div>
<div id="button-sub-{{u.id}}" style="z-index: 2" class="{% if u.has_follower(v) %}d-none{% endif %}"><a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="post_toast('/follow/{{u.username}}','button-sub-{{u.id}}','button-unsub-{{u.id}}')">Follow</a></div>
<div id="button-unsub-{{u.id}}" style="z-index: 2" class="{% if not u.has_follower(v) %} d-none{% endif %}"><a class="btn btn-secondary btn-sm" href="javascript:void(0)" onclick="post_toast('/unfollow/{{u.username}}','button-sub-{{u.id}}','button-unsub-{{u.id}}')">Unfollow</a></div>
{% endif %}
{% else %}
<div id="button-sub-{{u.id}}" style="z-index: 2" "><a class="btn btn-primary btn-sm" href="/signup?redirect={{request.path}}">Follow</a></div>

View File

@ -44,16 +44,18 @@
{% block desktopUserBanner %}
<!-- Desktop -->
<script>
var userid = document.getElementById("userid").value;
if (userid != "nosong")
{
var audio = new Audio(`/songs/${userid}`);
audio.loop=true;
audio.play();
document.getElementById('userpage').addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
}
window.addEventListener( 'load', function() {
var userid = document.getElementById("userid").value;
if (userid != "nosong")
{
var audio = new Audio(`/songs/${userid}`);
audio.loop=true;
audio.play();
document.getElementById('userpage').addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
}
}, false );
function transferCoins(mobile=false) {
let t = event.target;
@ -182,8 +184,8 @@
<div class="d-flex justify-content-between align-items-center">
<div>
{% if v and v.id != u.id %}
<a id="button-unsub" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast('/unfollow/{{u.username}}', callback=function(){document.getElementById('button-unsub').classList.toggle('d-none');document.getElementById('button-sub').classList.toggle('d-none');})">Unfollow</a>
<a id="button-sub" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast('/follow/{{u.username}}', callback=function(){document.getElementById('button-sub').classList.toggle('d-none');document.getElementById('button-unsub').classList.toggle('d-none');})">Follow</a>
<a id="button-unsub" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast2('/unfollow/{{u.username}}','button-unsub','button-sub')">Unfollow</a>
<a id="button-sub" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast2('/follow/{{u.username}}','button-unsub','button-sub')">Follow</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="toggleElement('profile-toggleable', 'message')">Message</a>
@ -195,10 +197,11 @@
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
{% elif v.id == 10 %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/revert_actions')">Revert admin actions</a>
{% endif %}
{% endif %}
{% if 'rdrama' in request.host and v.id in [28,29,995] %}
{% if 'rdrama' in request.host and v.id in [12,28,29,747,995] %}
{% if u.admin_level == 0 %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_fake_admin')">Make fake admin</a>
@ -206,6 +209,7 @@
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_fake_admin')">Remove fake admin</a>
{% else %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/revert_actions')">Revert admin actions</a>
{% endif %}
{% endif %}
@ -214,6 +218,7 @@
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
{% else %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/revert_actions')">Revert admin actions</a>
{% endif %}
{% endif %}
@ -242,6 +247,7 @@
{% elif v and v.id == u.id %}
<a href="/settings/profile" class="btn btn-secondary">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</a>
<a href="javascript:void(0)" onclick="post_toast('/settings/badges','1')" class="btn btn-secondary">Refresh Badges</a>
{% endif %}
{% if v and v.id != u.id and v.admin_level > 1 %}
<br><br>
@ -443,11 +449,11 @@
</div>
{% if v and v.id == u.id %}
<a href="/settings/profile" class="btn btn-secondary btn-sm">Edit profile</a>
<a href="/views" class="btn btn-secondary btn-sm">Profile views</a>
{% endif %}
<a href="javascript:void(0)" onclick="post_toast('/settings/badges','1')" class="btn btn-secondary">Refresh Badges</a>
{% endif %}
{% if v and v.id != u.id %}
<a id="button-unsub2" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast('/unfollow/{{u.username}}', callback=function(){document.getElementById('button-unsub2').classList.toggle('d-none');document.getElementById('button-sub2').classList.toggle('d-none');})">Unfollow</a>
<a id="button-sub2" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast('/follow/{{u.username}}', callback=function(){document.getElementById('button-sub2').classList.toggle('d-none');document.getElementById('button-unsub2').classList.toggle('d-none');})">Follow</a>
<a id="button-unsub2" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast2('/unfollow/{{u.username}}','button-unsub2','button-sub2')">Unfollow</a>
<a id="button-sub2" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" href="javascript:void(0)" onclick="post_toast2('/follow/{{u.username}}','button-unsub2','button-sub2')">Follow</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="toggleElement('profile-toggleable-mobile', 'message-mobile')">Message</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/suicide')">Get them help</a>
@ -458,10 +464,11 @@
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
{% elif v.id == 10 %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/revert_actions')">Revert admin actions</a>
{% endif %}
{% endif %}
{% if 'rdrama' in request.host and v.id in [28,29,995] %}
{% if 'rdrama' in request.host and v.id in [12,28,29,747,995] %}
{% if u.admin_level == 0 %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_fake_admin')">Make fake admin</a>
@ -469,6 +476,7 @@
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_fake_admin')">Remove fake admin</a>
{% else %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/revert_actions')">Revert admin actions</a>
{% endif %}
{% endif %}
@ -477,6 +485,7 @@
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/make_admin')">Make admin</a>
{% else %}
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
<a class="btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/revert_actions')">Revert admin actions</a>
{% endif %}
{% endif %}

View File

@ -13,11 +13,11 @@
<p class="text-muted">This user has enabled private mode to cloak their posting history.</p>
{% if u.id == 253 and 'rdrama' in request.host %}
{% if v and v.coins > 500 and not v.is_suspended %}
<a class="btn btn-primary" href="javascript:void(0)", onclick="post('/pay_rent', callback=function(){window.location.reload(true)})">Pay rent to view profile (500 coins)</a>
<a class="btn btn-primary" href="javascript:void(0)", onclick="post('/pay_rent', '1'">Pay rent to view profile (500 coins)</a>
{% endif %}
<pre></pre>
{% if v and v.coins > 5000 and time - v.created_utc > 604800 and not v.is_suspended %}
<a class="btn btn-primary" href="javascript:void(0)", onclick="post('/steal', callback=function(){window.location.reload(true)})">Attempt to steal coins</a>
<a class="btn btn-primary" href="javascript:void(0)", onclick="post('/steal', '1'">Attempt to steal coins</a>
<div class="text-small-extra text-muted mt-1">Landlords, like all other men, love to reap where they never sowed.</div>
{% endif %}
<pre>

BIN
image.PNG 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
image.jpeg 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
image.jpg 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -393,7 +393,8 @@ CREATE TABLE public.comments (
is_pinned boolean DEFAULT false,
app_id integer,
sentto integer,
bannedfor boolean
bannedfor boolean,
removed_by integer
);
@ -807,7 +808,8 @@ CREATE TABLE public.submissions (
is_bot boolean,
bannedfor boolean,
comment_count integer DEFAULT 0,
processing boolean DEFAULT false
processing boolean DEFAULT false,
removed_by integer
);