remove unnecessary shit
parent
95239be400
commit
a22c14f21c
|
@ -1139,5 +1139,5 @@ csp = f"default-src 'none'; frame-ancestors 'none'; form-action 'self'; manifest
|
||||||
if not IS_LOCALHOST:
|
if not IS_LOCALHOST:
|
||||||
csp += ' upgrade-insecure-requests;'
|
csp += ' upgrade-insecure-requests;'
|
||||||
|
|
||||||
with open("includes/content-security-policy", "w", encoding="utf-8") as f:
|
with open("includes/content-security-policy", "w") as f:
|
||||||
f.write(f'add_header Content-Security-Policy "{csp}";')
|
f.write(f'add_header Content-Security-Policy "{csp}";')
|
||||||
|
|
|
@ -43,7 +43,7 @@ def const_initialize():
|
||||||
filename = f"snappy_{SITE_NAME}.txt"
|
filename = f"snappy_{SITE_NAME}.txt"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(filename, "r", encoding="utf-8") as f:
|
with open(filename, "r") as f:
|
||||||
SNAPPY_QUOTES = f.read().split("\n{[para]}\n")
|
SNAPPY_QUOTES = f.read().split("\n{[para]}\n")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -6,7 +6,7 @@ def log_file(log_str, log_filename="rdrama.log"):
|
||||||
'''
|
'''
|
||||||
log_target = f"{LOG_DIRECTORY}/{log_filename}"
|
log_target = f"{LOG_DIRECTORY}/{log_filename}"
|
||||||
try:
|
try:
|
||||||
with open(log_target, "a", encoding="utf-8") as f:
|
with open(log_target, "a") as f:
|
||||||
f.write(log_str + '\n')
|
f.write(log_str + '\n')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to log to file {log_target} due to {e.__class__.__name__}")
|
print(f"Failed to log to file {log_target} due to {e.__class__.__name__}")
|
||||||
|
|
|
@ -65,7 +65,7 @@ def process_files(files, v, body, is_dm=False, dm_user=None):
|
||||||
body = body.replace(f'[{file.filename}]', f' {url} ', 1)
|
body = body.replace(f'[{file.filename}]', f' {url} ', 1)
|
||||||
|
|
||||||
if is_dm:
|
if is_dm:
|
||||||
with open(f"{LOG_DIRECTORY}/dm_media.log", "a+", encoding="utf-8") as f:
|
with open(f"{LOG_DIRECTORY}/dm_media.log", "a+") as f:
|
||||||
if dm_user:
|
if dm_user:
|
||||||
f.write(f'{url}, {v.username}, {v.id}, {dm_user.username}, {dm_user.id}, {int(time.time())}\n')
|
f.write(f'{url}, {v.username}, {v.id}, {dm_user.username}, {dm_user.id}, {int(time.time())}\n')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -35,13 +35,13 @@ def reload_settings():
|
||||||
global _SETTINGS
|
global _SETTINGS
|
||||||
if not os.path.isfile(SETTINGS_FILENAME):
|
if not os.path.isfile(SETTINGS_FILENAME):
|
||||||
_save_settings()
|
_save_settings()
|
||||||
with open(SETTINGS_FILENAME, 'r', encoding='utf_8') as f:
|
with open(SETTINGS_FILENAME, 'r') as f:
|
||||||
x = f.read()
|
x = f.read()
|
||||||
if x:
|
if x:
|
||||||
_SETTINGS = json.loads(x)
|
_SETTINGS = json.loads(x)
|
||||||
|
|
||||||
def _save_settings():
|
def _save_settings():
|
||||||
with open(SETTINGS_FILENAME, "w", encoding='utf_8') as f:
|
with open(SETTINGS_FILENAME, "w") as f:
|
||||||
json.dump(_SETTINGS, f)
|
json.dump(_SETTINGS, f)
|
||||||
|
|
||||||
def start_watching_settings():
|
def start_watching_settings():
|
||||||
|
|
|
@ -46,7 +46,7 @@ def loggedout_list(v):
|
||||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||||
@admin_level_required(PERMS['ENABLE_DM_MEDIA'])
|
@admin_level_required(PERMS['ENABLE_DM_MEDIA'])
|
||||||
def dm_media(v):
|
def dm_media(v):
|
||||||
with open(f"{LOG_DIRECTORY}/dm_media.log", "r", encoding="utf-8") as f:
|
with open(f"{LOG_DIRECTORY}/dm_media.log", "r") as f:
|
||||||
items=f.read().split("\n")[:-1]
|
items=f.read().split("\n")[:-1]
|
||||||
|
|
||||||
total = len(items)
|
total = len(items)
|
||||||
|
@ -68,7 +68,7 @@ def dm_media(v):
|
||||||
@admin_level_required(PERMS['EDIT_RULES'])
|
@admin_level_required(PERMS['EDIT_RULES'])
|
||||||
def edit_rules_get(v):
|
def edit_rules_get(v):
|
||||||
try:
|
try:
|
||||||
with open(f'files/templates/rules_{SITE_NAME}.html', 'r', encoding="utf-8") as f:
|
with open(f'files/templates/rules_{SITE_NAME}.html', 'r') as f:
|
||||||
rules = f.read()
|
rules = f.read()
|
||||||
except:
|
except:
|
||||||
rules = None
|
rules = None
|
||||||
|
@ -85,7 +85,7 @@ def edit_rules_post(v):
|
||||||
rules = request.values.get('rules', '').strip()
|
rules = request.values.get('rules', '').strip()
|
||||||
rules = sanitize(rules, blackjack="rules")
|
rules = sanitize(rules, blackjack="rules")
|
||||||
|
|
||||||
with open(f'files/templates/rules_{SITE_NAME}.html', 'w+', encoding="utf-8") as f:
|
with open(f'files/templates/rules_{SITE_NAME}.html', 'w+') as f:
|
||||||
f.write(rules)
|
f.write(rules)
|
||||||
|
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
|
|
|
@ -247,7 +247,7 @@ def comment(v):
|
||||||
body = body[:COMMENT_BODY_LENGTH_LIMIT].strip()
|
body = body[:COMMENT_BODY_LENGTH_LIMIT].strip()
|
||||||
|
|
||||||
if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and posting_to_post and post_target.id == SNAPPY_THREAD and level == 1:
|
if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and posting_to_post and post_target.id == SNAPPY_THREAD and level == 1:
|
||||||
with open(f"snappy_{SITE_NAME}.txt", "r+", encoding="utf-8") as f:
|
with open(f"snappy_{SITE_NAME}.txt", "r+") as f:
|
||||||
body_for_checking = '\n{[para]}\n' + body + '\n{[para]}\n'
|
body_for_checking = '\n{[para]}\n' + body + '\n{[para]}\n'
|
||||||
if body_for_checking in f.read():
|
if body_for_checking in f.read():
|
||||||
abort(400, "Snappy quote already exists!")
|
abort(400, "Snappy quote already exists!")
|
||||||
|
@ -452,12 +452,12 @@ def delete_comment(cid, v):
|
||||||
|
|
||||||
if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and c.parent_post == SNAPPY_THREAD and c.level == 1:
|
if v.admin_level >= PERMS['USE_ADMIGGER_THREADS'] and c.parent_post == SNAPPY_THREAD and c.level == 1:
|
||||||
body = '\n{[para]}\n' + c.body + '\n'
|
body = '\n{[para]}\n' + c.body + '\n'
|
||||||
with open(f"snappy_{SITE_NAME}.txt", "r", encoding="utf-8") as f:
|
with open(f"snappy_{SITE_NAME}.txt", "r") as f:
|
||||||
old_text = f.read()
|
old_text = f.read()
|
||||||
|
|
||||||
if old_text.endswith(body):
|
if old_text.endswith(body):
|
||||||
new_text = old_text.split(body)[0] + '\n'
|
new_text = old_text.split(body)[0] + '\n'
|
||||||
with open(f"snappy_{SITE_NAME}.txt", "w", encoding="utf-8") as f:
|
with open(f"snappy_{SITE_NAME}.txt", "w") as f:
|
||||||
f.write(new_text)
|
f.write(new_text)
|
||||||
|
|
||||||
return {"message": "Comment deleted!"}
|
return {"message": "Comment deleted!"}
|
||||||
|
|
|
@ -88,11 +88,11 @@ def git_head():
|
||||||
# However, they forbid '..', so I don't see an obvious dir traversal attack.
|
# However, they forbid '..', so I don't see an obvious dir traversal attack.
|
||||||
# Also, a malicious branch name would mean someone already owned the server
|
# Also, a malicious branch name would mean someone already owned the server
|
||||||
# or repo, so I think this isn't a weak link.
|
# or repo, so I think this isn't a weak link.
|
||||||
with open('.git/HEAD', encoding='utf_8') as head_f:
|
with open('.git/HEAD') as head_f:
|
||||||
head_txt = head_f.read()
|
head_txt = head_f.read()
|
||||||
try:
|
try:
|
||||||
head_path = git_regex.match(head_txt).group(1)
|
head_path = git_regex.match(head_txt).group(1)
|
||||||
with open('.git/' + head_path, encoding='utf_8') as ref_f:
|
with open('.git/' + head_path) as ref_f:
|
||||||
gitref = ref_f.read()[:7]
|
gitref = ref_f.read()[:7]
|
||||||
except:
|
except:
|
||||||
gitref = 'Error'
|
gitref = 'Error'
|
||||||
|
|
Loading…
Reference in New Issue