|
|
@@ -4,31 +4,79 @@ def api_topic_sub_2(conn, name, sub, time):
|
|
|
curs = conn.cursor()
|
|
|
|
|
|
if flask.request.args.get('num', None):
|
|
|
- if flask.request.args.get('over', '0') == '0':
|
|
|
- curs.execute("select id, data, date, ip from topic where title = ? and sub = ? and id + 0 = ? + 0 order by id + 0 asc", [name, sub, flask.request.args.get('num', '')])
|
|
|
- elif flask.request.args.get('over', '0') == '1':
|
|
|
- curs.execute("select id, data, date, ip from topic where title = ? and sub = ? and id + 0 >= ? + 0 order by id + 0 asc", [name, sub, flask.request.args.get('num', '')])
|
|
|
- else:
|
|
|
- curs.execute("select id, data, date, ip from topic where title = ? and sub = ? and id + 0 <= ? + 0 order by id + 0 asc", [name, sub, flask.request.args.get('num', '')])
|
|
|
- elif flask.request.args.get('time', None):
|
|
|
- if flask.request.args.get('over', '0') == '0':
|
|
|
- curs.execute("select id, data, date, ip from topic where title = ? and sub = ? and date = ? order by id + 0 asc", [name, sub, flask.request.args.get('time', '')])
|
|
|
- if flask.request.args.get('over', '0') == '1':
|
|
|
- curs.execute("select id, data, date, ip from topic where title = ? and sub = ? and date >= ? order by id + 0 asc", [name, sub, flask.request.args.get('time', '')])
|
|
|
- else:
|
|
|
- curs.execute("select id, data, date, ip from topic where title = ? and sub = ? and date <= ? order by id + 0 asc", [name, sub, flask.request.args.get('time', '')])
|
|
|
+ curs.execute("select id, data, date, ip, block, top from topic where title = ? and sub = ? and id + 0 = ? + 0 order by id + 0 asc", [
|
|
|
+ name,
|
|
|
+ sub,
|
|
|
+ flask.request.args.get('num', '')
|
|
|
+ ])
|
|
|
+ elif flask.request.args.get('top', None):
|
|
|
+ curs.execute("select id, data, date, ip, block, top from topic where title = ? and sub = ? and top = 'O' order by id + 0 asc", [name, sub])
|
|
|
else:
|
|
|
- curs.execute("select id, data, date, ip from topic where title = ? and sub = ? order by id + 0 asc", [name, sub])
|
|
|
+ curs.execute("select id, data, date, ip, block, top from topic where title = ? and sub = ? order by id + 0 asc", [name, sub])
|
|
|
|
|
|
data = curs.fetchall()
|
|
|
if data:
|
|
|
json_data = {}
|
|
|
+ admin = admin_check(3)
|
|
|
+
|
|
|
for i in data:
|
|
|
- json_data[i[0]] = {
|
|
|
- "data" : i[1],
|
|
|
- "date" : i[2],
|
|
|
- "id" : i[3]
|
|
|
- }
|
|
|
+ if i[4] != 'O' or (i[4] == 'O' and admin == 1):
|
|
|
+ t_data_f = i[1]
|
|
|
+ b_color = ''
|
|
|
+ else:
|
|
|
+ curs.execute("select who from re_admin where what = ? order by time desc limit 1", ['blind (' + name + ' - ' + sub + '#' + str(i[0]) + ')'])
|
|
|
+ who_blind = curs.fetchall()
|
|
|
+ if who_blind:
|
|
|
+ t_data_f = '[[user:' + who_blind[0][0] + ']] block'
|
|
|
+ b_color = 'toron_color_grey'
|
|
|
+ else:
|
|
|
+ t_data_f = 'block'
|
|
|
+ b_color = 'toron_color_grey'
|
|
|
+
|
|
|
+ if flask.request.args.get('render', None):
|
|
|
+ if i[0] == '1':
|
|
|
+ s_user = i[3]
|
|
|
+
|
|
|
+ if flask.request.args.get('top', None):
|
|
|
+ t_color = 'toron_color_red'
|
|
|
+ elif i[3] == s_user:
|
|
|
+ t_color = 'toron_color_green'
|
|
|
+ elif i[5] == '1':
|
|
|
+ t_color = 'toron_color_blue'
|
|
|
+ else:
|
|
|
+ t_color = 'toron_color'
|
|
|
+
|
|
|
+ ip = ip_pas(i[3])
|
|
|
+
|
|
|
+ curs.execute('select acl from user where id = ?', [i[3]])
|
|
|
+ u_acl = curs.fetchall()
|
|
|
+ if u_acl and u_acl[0][0] != 'user':
|
|
|
+ ip += ' <a href="javascript:void(0);" title="' + load_lang('admin') + '">★</a>'
|
|
|
+
|
|
|
+ if admin == 1 or b_color != 'toron_color_grey':
|
|
|
+ ip += ' <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/admin/' + i[0] + '">(' + load_lang('discussion_tool') + ')</a>'
|
|
|
+
|
|
|
+ curs.execute("select end from ban where block = ?", [i[3]])
|
|
|
+ if curs.fetchall():
|
|
|
+ ip += ' <a href="javascript:void(0);" title="' + load_lang('blocked') + '">†</a>'
|
|
|
+
|
|
|
+ if t_data_f == '':
|
|
|
+ t_data_f = '[br]'
|
|
|
+
|
|
|
+ all_data = '<table id="toron"><tbody><tr><td id="' + t_color + '">'
|
|
|
+ all_data += '<a href="#' + i[0] + '">#' + i[0] + '</a> ' + ip + ' <span style="float: right;">' + i[2] + '</span>'
|
|
|
+ all_data += '</td></tr><tr><td id="' + b_color + '">' + render_set(data = t_data_f) + '</td></tr></tbody></table><hr class=\"main_hr\">'
|
|
|
+
|
|
|
+ json_data[i[0]] = {
|
|
|
+ "data" : all_data
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ json_data[i[0]] = {
|
|
|
+ "data" : t_data_f,
|
|
|
+ "date" : i[2],
|
|
|
+ "ip" : i[3],
|
|
|
+ "block" : i[4],
|
|
|
+ }
|
|
|
|
|
|
return flask.jsonify(json_data)
|
|
|
else:
|