|
|
@@ -1,30 +1,37 @@
|
|
|
from .tool.func import *
|
|
|
|
|
|
-def user_setting_head():
|
|
|
+def user_setting_head(skin_name = ''):
|
|
|
with get_db_connect() as conn:
|
|
|
curs = conn.cursor()
|
|
|
|
|
|
ip = ip_check()
|
|
|
+
|
|
|
+ skin_name_org = skin_name
|
|
|
+ if skin_name != '':
|
|
|
+ skin_name = '_' + skin_name
|
|
|
|
|
|
if flask.request.method == 'POST':
|
|
|
get_data = flask.request.form.get('content', '')
|
|
|
if ip_or_user(ip) == 0:
|
|
|
- curs.execute(db_change("select id from user_set where id = ? and name = 'custom_css'"), [ip])
|
|
|
+ curs.execute(db_change("select id from user_set where id = ? and name = ?"), [ip, 'custom_css' + skin_name])
|
|
|
if curs.fetchall():
|
|
|
- curs.execute(db_change("update user_set set data = ? where id = ? and name = 'custom_css'"), [get_data, ip])
|
|
|
+ curs.execute(db_change("update user_set set data = ? where id = ? and name = ?"), [get_data, ip, 'custom_css' + skin_name])
|
|
|
else:
|
|
|
- curs.execute(db_change("insert into user_set (id, name, data) values (?, 'custom_css', ?)"), [ip, get_data])
|
|
|
+ curs.execute(db_change("insert into user_set (id, name, data) values (?, ?, ?)"), [ip, 'custom_css' + skin_name, get_data])
|
|
|
|
|
|
conn.commit()
|
|
|
|
|
|
- flask.session['head'] = get_data
|
|
|
+ flask.session['head' + skin_name] = get_data
|
|
|
|
|
|
- return redirect('/change/head')
|
|
|
+ if skin_name_org != '':
|
|
|
+ return redirect('/change/head/' + skin_name_org)
|
|
|
+ else:
|
|
|
+ return redirect('/change/head')
|
|
|
else:
|
|
|
if ip_or_user(ip) == 0:
|
|
|
start = ''
|
|
|
|
|
|
- curs.execute(db_change("select data from user_set where id = ? and name = 'custom_css'"), [ip])
|
|
|
+ curs.execute(db_change("select data from user_set where id = ? and name = ?"), [ip, 'custom_css' + skin_name])
|
|
|
head_data = curs.fetchall()
|
|
|
data = head_data[0][0] if head_data else ''
|
|
|
else:
|
|
|
@@ -32,7 +39,7 @@ def user_setting_head():
|
|
|
'<span>' + load_lang('user_head_warning') + '</span>' + \
|
|
|
'<hr class="main_hr">' + \
|
|
|
''
|
|
|
- data = flask.session['head'] if 'head' in flask.session else ''
|
|
|
+ data = flask.session['head' + skin_name] if 'head' + skin_name in flask.session else ''
|
|
|
|
|
|
start += '' + \
|
|
|
'<span>' + \
|
|
|
@@ -43,11 +50,25 @@ def user_setting_head():
|
|
|
'<hr class="main_hr">' + \
|
|
|
''
|
|
|
|
|
|
+ if skin_name == '':
|
|
|
+ sub_name = ''
|
|
|
+ else:
|
|
|
+ sub_name = ' (' + skin_name_org + ')'
|
|
|
+
|
|
|
+ start = '' + \
|
|
|
+ '<a href="/change/head">(' + load_lang('all') + ')</a> ' + \
|
|
|
+ ' '.join(['<a href="/change/head/' + url_pas(i) + '">(' + html.escape(i) + ')</a>' for i in load_skin('', 1)]) + \
|
|
|
+ '<hr class="main_hr">' + \
|
|
|
+ start + \
|
|
|
+ ''
|
|
|
+
|
|
|
return easy_minify(flask.render_template(skin_check(),
|
|
|
- imp = [load_lang(data = 'user_head', safe = 1), wiki_set(), wiki_custom(), wiki_css([0, 0])],
|
|
|
+ imp = [load_lang(data = 'user_head', safe = 1), wiki_set(), wiki_custom(), wiki_css(['(HTML)' + sub_name, 0])],
|
|
|
data = start + '''
|
|
|
<form method="post">
|
|
|
- <textarea rows="25" cols="100" name="content">''' + data + '''</textarea>
|
|
|
+ <textarea rows="25" cols="100" name="content">''' + html.escape(data) + '''</textarea>
|
|
|
+ <hr class="main_hr">
|
|
|
+ ''' + load_lang('user_css_warning') + ''' : <a href="/change/head_reset">/change/head_reset</a>
|
|
|
<hr class="main_hr">
|
|
|
<button id="opennamu_js_save" type="submit">''' + load_lang('save') + '''</button>
|
|
|
</form>
|