view_raw.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from .tool.func import *
  2. def view_raw_2(name = None, topic_num = None, num = None, doc_acl = 0):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. if acl_check(name, 'render') == 1:
  6. return re_error('/ban')
  7. if topic_num:
  8. topic_num = str(topic_num)
  9. if num:
  10. num = str(num)
  11. v_name = name
  12. p_data = ''
  13. sub = ' (' + load_lang('raw') + ')'
  14. if not topic_num and num:
  15. curs.execute(db_change("select title from history where title = ? and id = ? and hide = 'O'"), [name, num])
  16. if curs.fetchall() and admin_check(6) != 1:
  17. return re_error('/error/3')
  18. curs.execute(db_change("select data from history where title = ? and id = ?"), [name, num])
  19. sub += ' (r' + num + ')'
  20. menu = [['history/' + url_pas(name), load_lang('history')]]
  21. elif topic_num:
  22. if admin_check(6) != 1:
  23. curs.execute(db_change("select data from topic where id = ? and code = ? and block = ''"), [num, topic_num])
  24. else:
  25. curs.execute(db_change("select data from topic where id = ? and code = ?"), [num, topic_num])
  26. v_name = load_lang('discussion_raw')
  27. sub = ' (#' + num + ')'
  28. menu = [
  29. ['thread/' + topic_num + '#' + num, load_lang('discussion')],
  30. ['thread/' + topic_num + '/comment/' + num + '/tool', load_lang('return')]
  31. ]
  32. else:
  33. curs.execute(db_change("select data from data where title = ?"), [name])
  34. menu = [['w/' + url_pas(name), load_lang('return')]]
  35. data = curs.fetchall()
  36. if data:
  37. p_data += '<textarea readonly rows="25">' + html.escape(data[0][0]) + '</textarea>'
  38. if doc_acl == 1:
  39. p_data = '' + \
  40. load_lang('authority_error') + \
  41. '<hr class="main_hr">' + \
  42. p_data
  43. ''
  44. sub = ' (' + load_lang('edit') + ')'
  45. return easy_minify(flask.render_template(skin_check(),
  46. imp = [v_name, wiki_set(), wiki_custom(), wiki_css([sub, 0])],
  47. data = p_data,
  48. menu = menu
  49. ))
  50. else:
  51. return re_error('/error/3')