view_raw.py 2.0 KB

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