diff --git a/drama/classes/comment.py b/drama/classes/comment.py index 219717042..46d6f2111 100644 --- a/drama/classes/comment.py +++ b/drama/classes/comment.py @@ -2,7 +2,6 @@ from flask import * from sqlalchemy import * from sqlalchemy.orm import relationship, deferred from .mix_ins import * -from drama.helpers.base36 import * from drama.helpers.lazy import lazy from drama.__main__ import Base diff --git a/drama/classes/mix_ins.py b/drama/classes/mix_ins.py index 4471690b5..9f5728008 100644 --- a/drama/classes/mix_ins.py +++ b/drama/classes/mix_ins.py @@ -1,4 +1,3 @@ -from drama.helpers.base36 import * from drama.helpers.lazy import lazy import math import random diff --git a/drama/classes/submission.py b/drama/classes/submission.py index d22a73308..060049de6 100644 --- a/drama/classes/submission.py +++ b/drama/classes/submission.py @@ -4,7 +4,6 @@ from sqlalchemy.orm import relationship, deferred import re, random from urllib.parse import urlparse from .mix_ins import * -from drama.helpers.base36 import * from drama.helpers.lazy import lazy from drama.__main__ import Base diff --git a/drama/classes/votes.py b/drama/classes/votes.py index c118aa248..4873d50bb 100644 --- a/drama/classes/votes.py +++ b/drama/classes/votes.py @@ -1,8 +1,6 @@ from flask import * -from time import time from sqlalchemy import * from sqlalchemy.orm import relationship -from drama.helpers.base36 import * from drama.__main__ import Base class Vote(Base): diff --git a/drama/helpers/get.py b/drama/helpers/get.py index 804f7daa2..14d841da2 100644 --- a/drama/helpers/get.py +++ b/drama/helpers/get.py @@ -46,10 +46,7 @@ def get_user(username, v=None, graceful=False): def get_account(id, v=None, graceful=False): - user = g.db.query(User - ).filter( - User.id == id - ).first() + user = g.db.query(User).filter(User.id == id).first() if not user: if not graceful: diff --git a/drama/routes/admin.py b/drama/routes/admin.py index 169fab9b6..e55b8d4d4 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -7,7 +7,6 @@ from PIL import Image as IMAGE from drama.helpers.wrappers import * from drama.helpers.alerts import * -from drama.helpers.base36 import * from drama.helpers.sanitize import * from drama.helpers.markdown import * from drama.helpers.security import * @@ -489,7 +488,22 @@ def admin_image_ban(v): i.save(tempname) h=imagehash.phash(IMAGE.open(tempname)) - h=hex2bin(str(h)) + + value = int(str(h), 16) + bindigits = [] + + # Seed digit: 2**0 + digit = (value % 2) + value //= 2 + bindigits.append(digit) + + while value > 0: + # Next power of 2**n + digit = (value % 2) + value //= 2 + bindigits.append(digit) + + h = ''.join([str(d) for d in bindigits]) #check db for existing badpic = g.db.query(BadPic).filter_by( diff --git a/drama/routes/users.py b/drama/routes/users.py index f005e9b84..7d49034ed 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -530,6 +530,7 @@ def user_profile(username): @app.route("/uid//pic/profile") @limiter.exempt def user_profile_uid(uid): + if isinstance(uid, str): uid = int(uid, 36) x=get_account(uid) return redirect(x.profile_url)