view_raw.py 2.2 KB

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