aboutsummaryrefslogtreecommitdiff
path: root/cgi/formatting.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/formatting.py')
-rw-r--r--cgi/formatting.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/cgi/formatting.py b/cgi/formatting.py
index 96bb73b..3da64da 100644
--- a/cgi/formatting.py
+++ b/cgi/formatting.py
@@ -3,7 +3,6 @@ import string
import html
import os
import re
-import pickle
import time
from database import *
@@ -111,7 +110,7 @@ def iphash(ip, post, t, useid, mobile, agent, cap_id, hide_end, has_countrycode)
if cap_id:
id = cap_id
- elif post['email'] and useid:
+ elif post['email'] and useid == 1:
id = '???'
elif ip == "127.0.0.1":
id = '???'
@@ -262,9 +261,9 @@ def checkRefLinks(message, parentid, parent_timestamp):
"""
board = Settings._.BOARD
- if board["board_type"] == '1':
+ if board["board_type"] == 1:
# Textboard
- if parentid != '0':
+ if parentid:
message = re.compile(r'>>(\d+(,\d+|-(?=[ \d\n])|\d+)*n?)').sub(
'<a href="' + Settings.BOARDS_URL + board['dir'] + '/read/' + str(parent_timestamp) + r'/\1">&gt;&gt;\1</a>', message)
else:
@@ -272,14 +271,14 @@ def checkRefLinks(message, parentid, parent_timestamp):
quotes_id_array = re.findall(r"&gt;&gt;([0-9]+)", message)
for quotes in quotes_id_array:
try:
- post = FetchOne('SELECT * FROM `posts` WHERE `id` = ' +
- quotes + ' AND `boardid` = ' + board['id'] + ' LIMIT 1')
- if post['parentid'] != '0':
+ post = FetchOne('SELECT * FROM `posts` WHERE `id` = %s AND `boardid` = %s LIMIT 1',
+ (quotes, board['id']))
+ if post['parentid']:
message = re.compile("&gt;&gt;" + quotes).sub('<a href="' + Settings.BOARDS_URL +
- board['dir'] + '/res/' + post['parentid'] + '.html#' + quotes + '">&gt;&gt;' + quotes + '</a>', message)
+ board['dir'] + '/res/' + str(post['parentid']) + '.html#' + quotes + '">&gt;&gt;' + quotes + '</a>', message)
else:
message = re.compile("&gt;&gt;" + quotes).sub('<a href="' + Settings.BOARDS_URL +
- board['dir'] + '/res/' + post['id'] + '.html#' + quotes + '">&gt;&gt;' + quotes + '</a>', message)
+ board['dir'] + '/res/' + str(post['id']) + '.html#' + quotes + '">&gt;&gt;' + quotes + '</a>', message)
except:
message = re.compile(
"&gt;&gt;" + quotes).sub(r'<span class="q">&gt;&gt;'+quotes+'</span>', message)
@@ -371,9 +370,9 @@ def checkWordfilters(message, ip, board):
wordfilters = FetchAll(
"SELECT * FROM `filters` WHERE `type` = '0' ORDER BY `id` ASC")
for wordfilter in wordfilters:
- if wordfilter["boards"] != "":
- boards = pickle.loads(wordfilter["boards"].encode("utf-8"))
- if wordfilter["boards"] == "" or board in boards:
+ if wordfilter["boards"]:
+ boards = str2boards(wordfilter["boards"])
+ if not wordfilter["boards"] or board in boards:
if wordfilter['action'] == '0':
if not re.search(wordfilter['from'], message, re.DOTALL | re.IGNORECASE) is None:
raise UserError(wordfilter['reason'])
@@ -404,9 +403,9 @@ def checkNamefilters(name, tripcode, ip, board):
namefilters = FetchAll("SELECT * FROM `filters` WHERE `type` = '1'")
for namefilter in namefilters:
- if namefilter["boards"] != "":
- boards = pickle.loads(namefilter["boards"])
- if namefilter["boards"] == "" or board in boards:
+ if namefilter["boards"]:
+ boards = str2boards(namefilter["boards"])
+ if not namefilter["boards"] or board in boards:
# check if this filter applies
match = False