view_raw.py 1.9 KB

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