topic_stop.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. # 이 쪽 잘못 짜여 있음 내일 수정 필요
  22. if tool == 'close':
  23. why = flask.request.form.get('why', '')
  24. set_list = [
  25. 'O',
  26. 'S',
  27. 'close' + (('[br][br]why : ' + why) if why else ''),
  28. 'open' + (('[br][br]why : ' + why) if why else '')
  29. ]
  30. elif tool == 'stop':
  31. set_list = [
  32. '',
  33. 'O',
  34. 'stop',
  35. 'restart'
  36. ]
  37. else:
  38. return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
  39. curs.execute("select title from rd where title = ? and sub = ? and stop = ?", [name, sub, set_list[1]])
  40. if curs.fetchall():
  41. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [
  42. str(int(topic_check[0][0]) + 1),
  43. name,
  44. sub,
  45. set_list[3],
  46. time,
  47. ip
  48. ])
  49. curs.execute("update rd set stop = '' where title = ? and sub = ?", [name, sub])
  50. else:
  51. curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [
  52. str(int(topic_check[0][0]) + 1),
  53. name,
  54. sub,
  55. set_list[2],
  56. time,
  57. ip
  58. ])
  59. curs.execute("update rd set stop = ? where title = ? and sub = ?", [set_list[0], name, sub])
  60. rd_plus(name, sub, time)
  61. conn.commit()
  62. return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
  63. else:
  64. return easy_minify(flask.render_template(skin_check(),
  65. imp = [name, wiki_set(), custom(), other2([' (' + tool + ')', 0])],
  66. data = '''
  67. <span>''' + load_lang('markup_enabled') + '''</span>
  68. <hr class=\"main_hr\">
  69. <form method="post">
  70. <input placeholder="''' + load_lang('why') + '''" name="why" type="text">
  71. <hr class=\"main_hr\">
  72. <button type="submit">''' + load_lang('save') + '''</button>
  73. </form>
  74. ''',
  75. menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub), load_lang('return')]]
  76. ))