topic_comment_tool.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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="opennamu_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="opennamu_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("select id from topic where code = ? and id = ? and top = 'O'"), [topic_num, num])
  28. top_topic_d = curs.fetchall()
  29. ban += '''
  30. <h2>''' + load_lang('admin_tool') + '''</h2>
  31. <ul class="opennamu_ul">
  32. <li>
  33. <a href="/auth/give/ban/''' + url_pas(data[0][1]) + '''">
  34. ''' + (load_lang('release') if ban_check(data[0][1]) == 1 else load_lang('ban')) + '''
  35. </a>
  36. </li>
  37. <li>
  38. <a href="/thread/''' + topic_num + '''/comment/''' + num + '''/blind">
  39. ''' + (load_lang('hide_release') if data[0][0] == 'O' else load_lang('hide')) + '''
  40. </a>
  41. </li>
  42. <li>
  43. <a href="/thread/''' + topic_num + '''/comment/''' + num + '''/notice">
  44. ''' + (load_lang('pinned_release') if top_topic_d else load_lang('pinned')) + '''
  45. </a>
  46. </li>
  47. <li>
  48. <a href="/thread/''' + topic_num + '''/comment/''' + num + '''/delete">
  49. ''' + load_lang('delete') + '''
  50. </a>
  51. </ul>
  52. '''
  53. return easy_minify(flask.render_template(skin_check(),
  54. imp = [load_lang('discussion_tool'), wiki_set(), wiki_custom(), wiki_css(['(#' + num + ')', 0])],
  55. data = ban,
  56. menu = [['thread/' + topic_num + '#' + num, load_lang('return')]]
  57. ))