topic_comment_tool.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from .tool.func import *
  2. def topic_comment_tool(topic_num = 1, num = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. num = str(num)
  6. topic_num = str(topic_num)
  7. if acl_check('', 'topic_view', topic_num) == 1:
  8. return re_error('/ban')
  9. curs.execute(db_change("select block, ip, date from topic where code = ? and id = ?"), [topic_num, num])
  10. data = curs.fetchall()
  11. if not data:
  12. return redirect('/thread/' + topic_num)
  13. ban = '''
  14. <h2>''' + load_lang('state') + '''</h2>
  15. <ul class="inside_ul">
  16. <li>''' + load_lang('writer') + ' : ''' + ip_pas(data[0][1]) + '''</li>
  17. <li>''' + load_lang('time') + ' : ' + data[0][2] + '''</li>
  18. </ul>
  19. <h2>''' + load_lang('other_tool') + '''</h2>
  20. <ul class="inside_ul">
  21. <li>
  22. <a href="/thread/''' + topic_num + '/comment/' + num + '''/raw">''' + load_lang('raw') + '''</a>
  23. </li>
  24. </ul>
  25. '''
  26. if admin_check(3) == 1:
  27. curs.execute(db_change(
  28. "select id from topic where code = ? and id = ? and top = 'O'"
  29. ), [topic_num, num])
  30. top_topic_d = curs.fetchall()
  31. curs.execute(db_change(
  32. "select end from rb where block = ? and ongoing = '1'"
  33. ), [data[0][1]])
  34. user_ban_d = curs.fetchall()
  35. ban += '''
  36. <h2>''' + load_lang('admin_tool') + '''</h2>
  37. <ul class="inside_ul">
  38. <li>
  39. <a href="/auth/give/ban/''' + url_pas(data[0][1]) + '''">
  40. ''' + (load_lang('release') if user_ban_d else load_lang('ban')) + '''
  41. </a>
  42. </li>
  43. <li>
  44. <a href="/thread/''' + topic_num + '''/comment/''' + num + '''/blind">
  45. ''' + (load_lang('hide_release') if data[0][0] == 'O' else load_lang('hide')) + '''
  46. </a>
  47. </li>
  48. <li>
  49. <a href="/thread/''' + topic_num + '''/comment/''' + num + '''/notice">
  50. ''' + (load_lang('pinned_release') if top_topic_d else load_lang('pinned')) + '''
  51. </a>
  52. </li>
  53. <li>
  54. <a href="/thread/''' + topic_num + '''/comment/''' + num + '''/delete">
  55. ''' + load_lang('delete') + '''
  56. </a>
  57. </ul>
  58. '''
  59. return easy_minify(flask.render_template(skin_check(),
  60. imp = [load_lang('discussion_tool'), wiki_set(), wiki_custom(), wiki_css(['(#' + num + ')', 0])],
  61. data = ban,
  62. menu = [['thread/' + topic_num + '#' + num, load_lang('return')]]
  63. ))