recent_history_add.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from .tool.func import *
  2. from .edit import edit_editor
  3. def recent_history_add(name = 'Test', do_type = ''):
  4. with get_db_connect() as conn:
  5. curs = conn.cursor()
  6. ip = ip_check()
  7. if admin_check() != 1:
  8. return re_error('/ban')
  9. if flask.request.method == 'POST':
  10. admin_check(None, 'history_add (' + name + ')')
  11. today = get_time()
  12. content = flask.request.form.get('content', '')
  13. leng = '+' + str(len(content))
  14. history_plus(
  15. name,
  16. content,
  17. today,
  18. 'Add:' + flask.request.form.get('get_ip', ''),
  19. flask.request.form.get('send', ''),
  20. leng,
  21. t_check = 'add',
  22. mode = 'add'
  23. )
  24. conn.commit()
  25. return redirect('/history/' + url_pas(name))
  26. else:
  27. return easy_minify(flask.render_template(skin_check(),
  28. imp = [load_lang('history_add'), wiki_set(), wiki_custom(), wiki_css(['(' + name + ')', 0])],
  29. data = '''
  30. <form method="post">
  31. <input placeholder="''' + load_lang('why') + '''" name="send">
  32. <hr class="main_hr">
  33. <input placeholder="''' + load_lang('name') + '''" name="get_ip">
  34. <hr class="main_hr">
  35. ''' + edit_editor(curs, ip) + '''
  36. </form>
  37. ''',
  38. menu = [['history/' + url_pas(name), load_lang('return')]]
  39. ))