view_raw.py 2.2 KB

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