topic_top.py 1020 B

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