2
0

view_raw.py 1.9 KB

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