topic_comment_tool.py 2.8 KB

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