topic_top.py 935 B

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