recent_history_add.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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(conn) != 1:
  8. return re_error(conn, '/ban')
  9. if flask.request.method == 'POST':
  10. admin_check(conn, None, 'history_add (' + name + ')')
  11. today = get_time()
  12. content = flask.request.form.get('content', '')
  13. leng = '+' + str(len(content))
  14. history_plus(conn,
  15. name,
  16. content,
  17. today,
  18. 'Add:' + flask.request.form.get('get_ip', ''),
  19. flask.request.form.get('send', ''),
  20. leng,
  21. mode = 'add'
  22. )
  23. conn.commit()
  24. return redirect(conn, '/history/' + url_pas(name))
  25. else:
  26. return easy_minify(conn, flask.render_template(skin_check(conn),
  27. imp = [get_lang(conn, 'history_add'), wiki_set(conn), wiki_custom(conn), wiki_css(['(' + name + ')', 0])],
  28. data = '''
  29. <form method="post">
  30. <input placeholder="''' + get_lang(conn, 'why') + '''" name="send">
  31. <hr class="main_hr">
  32. <input placeholder="''' + get_lang(conn, 'name') + '''" name="get_ip">
  33. <hr class="main_hr">
  34. ''' + edit_editor(conn, ip) + '''
  35. </form>
  36. ''',
  37. menu = [['history/' + url_pas(name), get_lang(conn, 'return')]]
  38. ))