2
0

topic_stop.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from .tool.func import *
  2. def topic_stop_2(conn, name, sub, tool):
  3. curs = conn.cursor()
  4. if tool == 'close':
  5. set_list = [
  6. 'O',
  7. 'S',
  8. load_lang('close', 1),
  9. load_lang('open', 1)
  10. ]
  11. elif tool == 'stop':
  12. set_list = [
  13. '',
  14. 'O',
  15. load_lang('stop', 1),
  16. load_lang('restart', 1)
  17. ]
  18. elif tool == 'agree':
  19. pass
  20. else:
  21. return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
  22. if admin_check(3, 'topic ' + tool + ' (' + name + ' - ' + sub + ')') != 1:
  23. return re_error('/error/3')
  24. ip = ip_check()
  25. time = get_time()
  26. curs.execute("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1", [name, sub])
  27. topic_check = curs.fetchall()
  28. if topic_check:
  29. if tool == 'agree':
  30. curs.execute("select title from rd where title = ? and sub = ? and agree = 'O'", [name, sub])
  31. if curs.fetchall():
  32. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, '" + load_lang('agreement', 1) + " X', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
  33. curs.execute("update rd set agree = '' where title = ? and sub = ?", [name, sub])
  34. else:
  35. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, '" + load_lang('agreement', 1) + " O', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
  36. curs.execute("update rd set agree = 'O' where title = ? and sub = ?", [name, sub])
  37. else:
  38. curs.execute("select title from rd where title = ? and sub = ? and stop = ?", [name, sub, set_list[0]])
  39. if curs.fetchall():
  40. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, set_list[3], time, ip])
  41. curs.execute("update rd set stop = '' where title = ? and sub = ?", [name, sub])
  42. else:
  43. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, set_list[2], time, ip])
  44. curs.execute("update rd set stop = ? where title = ? and sub = ?", [set_list[0], name, sub])
  45. rd_plus(name, sub, time)
  46. conn.commit()
  47. return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))