give_history_add.py 2.4 KB

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