2
0

user_custom_head_view.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from .tool.func import *
  2. def user_custom_head_view_2(conn):
  3. curs = conn.cursor()
  4. ip = ip_check()
  5. if flask.request.method == 'POST':
  6. get_data = flask.request.form.get('content', '')
  7. if ip_or_user(ip) == 0:
  8. curs.execute(db_change("select user from custom where user = ?"), [ip + ' (head)'])
  9. if curs.fetchall():
  10. curs.execute(db_change("update custom set css = ? where user = ?"), [get_data, ip + ' (head)'])
  11. else:
  12. curs.execute(db_change("insert into custom (user, css) values (?, ?)"), [ip + ' (head)', get_data])
  13. conn.commit()
  14. flask.session['head'] = get_data
  15. return redirect('/custom_head')
  16. else:
  17. if ip_or_user(ip) == 0:
  18. start = ''
  19. curs.execute(db_change("select css from custom where user = ?"), [ip + ' (head)'])
  20. head_data = curs.fetchall()
  21. if head_data:
  22. data = head_data[0][0]
  23. else:
  24. data = ''
  25. else:
  26. start = '<span>' + load_lang('user_head_warring') + '</span><hr class=\"main_hr\">'
  27. if 'head' in flask.session:
  28. data = flask.session['head']
  29. else:
  30. data = ''
  31. start += '<span>&lt;style&gt;CSS&lt;/style&gt;<br>&lt;script&gt;JS&lt;/script&gt;</span><hr class=\"main_hr\">'
  32. return easy_minify(flask.render_template(skin_check(),
  33. imp = [load_lang(data = 'user_head', safe = 1), wiki_set(), custom(), other2([0, 0])],
  34. data = start + '''
  35. <form method="post">
  36. <textarea rows="25" cols="100" name="content">''' + data + '''</textarea>
  37. <hr class=\"main_hr\">
  38. <button id="save" type="submit">''' + load_lang('save') + '''</button>
  39. </form>
  40. ''',
  41. menu = [['user', load_lang('return')]]
  42. ))