view_diff_data.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. from .tool.func import *
  2. def view_diff_data_2(conn, name):
  3. curs = conn.cursor()
  4. if acl_check(name, 'render') == 1:
  5. return re_error('/ban')
  6. first = number_check(flask.request.args.get('first', '1'))
  7. second = number_check(flask.request.args.get('second', '1'))
  8. curs.execute(db_change("select title from history where title = ? and (id = ? or id = ?) and hide = 'O'"), [name, first, second])
  9. if curs.fetchall() and admin_check(6) != 1:
  10. return re_error('/error/3')
  11. curs.execute(db_change("select data from history where id = ? and title = ?"), [first, name])
  12. first_raw_data = curs.fetchall()
  13. if first_raw_data:
  14. curs.execute(db_change("select data from history where id = ? and title = ?"), [second, name])
  15. second_raw_data = curs.fetchall()
  16. if second_raw_data:
  17. if first == second:
  18. result = ''
  19. else:
  20. diff_data = difflib.SequenceMatcher(None, first_raw_data[0][0], second_raw_data[0][0])
  21. result = '<pre>' + diff(diff_data) + '</pre>'
  22. return easy_minify(flask.render_template(skin_check(),
  23. imp = [name, wiki_set(), custom(), other2([' (' + load_lang('compare') + ')', 0])],
  24. data = result,
  25. menu = [['history/' + url_pas(name), load_lang('return')]]
  26. ))
  27. return redirect('/history/' + url_pas(name))