give_history_add.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. )
  20. conn.commit()
  21. return redirect('/history/' + url_pas(name))
  22. else:
  23. curs.execute(db_change('select data from other where name = "edit_bottom_text"'))
  24. sql_d = curs.fetchall()
  25. if sql_d and sql_d[0][0] != '':
  26. b_text = '<hr class=\"main_hr\">' + sql_d[0][0]
  27. else:
  28. b_text = ''
  29. curs.execute(db_change('select data from other where name = "edit_help"'))
  30. sql_d = curs.fetchall()
  31. if sql_d and sql_d[0][0] != '':
  32. p_text = sql_d[0][0]
  33. else:
  34. p_text = load_lang('default_edit_help')
  35. return easy_minify(flask.render_template(skin_check(),
  36. imp = [load_lang('history_add'), wiki_set(), custom(), other2(['(' + name + ')', 0])],
  37. data = '''
  38. <form method="post">
  39. <script>do_stop_exit();</script>
  40. ''' + edit_button() + '''
  41. <textarea rows="25" id="content" placeholder="''' + p_text + '''" name="content"></textarea>
  42. <hr class=\"main_hr\">
  43. <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
  44. <hr class=\"main_hr\">
  45. <input placeholder="''' + load_lang('name') + '''" name="get_ip" type="text">
  46. <hr class=\"main_hr\">
  47. <button id="save" type="submit" onclick="go_save_zone = 1;">''' + load_lang('save') + '''</button>
  48. <button id="preview" type="button" onclick="load_preview(\'''' + url_pas(name) + '\')">' + load_lang('preview') + '''</button>
  49. </form>
  50. ''' + b_text + '''
  51. <hr class=\"main_hr\">
  52. <div id="see_preview"></div>
  53. ''',
  54. menu = [['history/' + url_pas(name), load_lang('return')]]
  55. ))