view_raw.py 1.9 KB

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