topic_block.py 783 B

123456789101112131415161718192021222324
  1. from .tool.func import *
  2. def topic_block_2(conn, topic_num, num):
  3. curs = conn.cursor()
  4. topic_num = str(topic_num)
  5. num = str(num)
  6. if admin_check(3, 'blind (code ' + topic_num + '#' + num + ')') != 1:
  7. return re_error('/error/3')
  8. curs.execute(db_change("select block from topic where code = ? and id = ?"), [topic_num, num])
  9. block = curs.fetchall()
  10. if block:
  11. if block[0][0] == 'O':
  12. curs.execute(db_change("update topic set block = '' where code = ? and id = ?"), [topic_num, num])
  13. else:
  14. curs.execute(db_change("update topic set block = 'O' where code = ? and id = ?"), [topic_num, num])
  15. rd_plus(topic_num, get_time())
  16. conn.commit()
  17. return redirect('/thread/' + topic_num + '#' + num)