give_history_add.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from .tool.func import *
  2. def give_history_add_2(conn, name):
  3. curs = conn.cursor()
  4. ip = ip_check()
  5. if admin_check() != 1:
  6. return re_error('/ban')
  7. if flask.request.method == 'POST':
  8. admin_check(None, 'history_add (' + name + ')')
  9. today = get_time()
  10. content = flask.request.form.get('content', '')
  11. leng = '+' + str(len(content))
  12. history_plus(
  13. name,
  14. content,
  15. today,
  16. 'Add:' + flask.request.form.get('get_ip', ''),
  17. flask.request.form.get('send', ''),
  18. leng,
  19. t_check = 'add',
  20. mode = 'add'
  21. )
  22. conn.commit()
  23. return redirect('/history/' + url_pas(name))
  24. else:
  25. curs.execute(db_change('select data from other where name = "edit_bottom_text"'))
  26. sql_d = curs.fetchall()
  27. if sql_d and sql_d[0][0] != '':
  28. b_text = '<hr class=\"main_hr\">' + sql_d[0][0]
  29. else:
  30. b_text = ''
  31. curs.execute(db_change('select data from other where name = "edit_help"'))
  32. sql_d = curs.fetchall()
  33. if sql_d and sql_d[0][0] != '':
  34. p_text = sql_d[0][0]
  35. else:
  36. p_text = load_lang('default_edit_help')
  37. return easy_minify(flask.render_template(skin_check(),
  38. imp = [load_lang('history_add'), wiki_set(), custom(), other2(['(' + name + ')', 0])],
  39. data = '''
  40. <form method="post">
  41. <script>do_stop_exit();</script>
  42. ''' + edit_button() + '''
  43. <textarea rows="25" id="content" placeholder="''' + p_text + '''" name="content"></textarea>
  44. <hr class=\"main_hr\">
  45. <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
  46. <hr class=\"main_hr\">
  47. <input placeholder="''' + load_lang('name') + '''" name="get_ip" type="text">
  48. <hr class=\"main_hr\">
  49. <button id="save" type="submit" onclick="go_save_zone = 1;">''' + load_lang('save') + '''</button>
  50. <button id="preview" type="button" onclick="load_preview(\'''' + url_pas(name) + '\')">' + load_lang('preview') + '''</button>
  51. </form>
  52. ''' + b_text + '''
  53. <hr class=\"main_hr\">
  54. <div id="see_preview"></div>
  55. ''',
  56. menu = [['history/' + url_pas(name), load_lang('return')]]
  57. ))