2
0

topic_stop.py 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from .tool.func import *
  2. def topic_stop_2(conn, name, sub, tool):
  3. curs = conn.cursor()
  4. if admin_check(3, 'topic ' + tool + ' (' + name + ' - ' + sub + ')') != 1:
  5. return re_error('/error/3')
  6. ip = ip_check()
  7. time = get_time()
  8. if flask.request.method == 'POST' or tool == 'agree' or tool == 'stop':
  9. curs.execute("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1", [name, sub])
  10. topic_check = curs.fetchall()
  11. if topic_check:
  12. if tool == 'agree':
  13. curs.execute("select title from rd where title = ? and sub = ? and agree = 'O'", [name, sub])
  14. if curs.fetchall():
  15. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, 'ok', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
  16. curs.execute("update rd set agree = '' where title = ? and sub = ?", [name, sub])
  17. else:
  18. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, 'break', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
  19. curs.execute("update rd set agree = 'O' where title = ? and sub = ?", [name, sub])
  20. else:
  21. if tool == 'close':
  22. why = flask.request.form.get('why', '')
  23. set_list = [
  24. 'O',
  25. 'S',
  26. 'close' + (('[br][br]why : ' + why) if why else ''),
  27. 'open' + (('[br][br]why : ' + why) if why else '')
  28. ]
  29. elif tool == 'stop':
  30. set_list = ['', 'O', 'stop', 'restart']
  31. else:
  32. return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
  33. curs.execute("select title from rd where title = ? and sub = ? and stop = ?", [name, sub, set_list[0]])
  34. if curs.fetchall():
  35. 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])
  36. curs.execute("update rd set stop = '' where title = ? and sub = ?", [name, sub])
  37. else:
  38. 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])
  39. curs.execute("update rd set stop = ? where title = ? and sub = ?", [set_list[0], name, sub])
  40. rd_plus(name, sub, time)
  41. conn.commit()
  42. return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
  43. else:
  44. return easy_minify(flask.render_template(skin_check(),
  45. imp = [name, wiki_set(), custom(), other2([' (' + tool + ')', 0])],
  46. data = '''
  47. <span>''' + load_lang('markup_enabled') + '''</span>
  48. <hr class=\"main_hr\">
  49. <form method="post">
  50. <input placeholder="''' + load_lang('why') + '''" name="why" type="text">
  51. <hr class=\"main_hr\">
  52. <button type="submit">''' + load_lang('save') + '''</button>
  53. </form>
  54. ''',
  55. menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub), load_lang('return')]]
  56. ))