2du 5 лет назад
Родитель
Сommit
26ad2bccf5
8 измененных файлов с 97 добавлено и 54 удалено
  1. 1 1
      language/en-US.json
  2. 1 1
      language/ko-KR.json
  3. 0 5
      route/login.py
  4. 0 2
      route/login_2fa.py
  5. 44 37
      route/tool/func.py
  6. 1 0
      route/user_info.py
  7. 49 7
      route/user_setting.py
  8. 1 1
      version.json

+ 1 - 1
language/en-US.json

@@ -376,7 +376,7 @@
         "oauth_settings_not_found" : "The administrator has not provided any data about using this feature.",
         "oauth_settings_not_found" : "The administrator has not provided any data about using this feature.",
         "oauth_disabled" : "The administrator has disabled this feature.",
         "oauth_disabled" : "The administrator has disabled this feature.",
         "http_warring" : "Warning: If you are not on HTTPS connection, Your information can be leaked. We won't response to that.",
         "http_warring" : "Warning: If you are not on HTTPS connection, Your information can be leaked. We won't response to that.",
-        "user_head_warring" : "User <HEAD> will be deleted if you close the browser or when you sign in.",
+        "user_head_warring" : "User data will be deleted if you close the browser or when you sign in.",
         "no_login_warring" : "You are not logged in. The IP address will be logged when editing or discussing with non-login.",
         "no_login_warring" : "You are not logged in. The IP address will be logged when editing or discussing with non-login.",
         "user_reset_sign" : "Your account information has changed like this.",
         "user_reset_sign" : "Your account information has changed like this.",
         "update_warring" : "Manual updates are recommended if your version is 0.2 or lower than the latest version. For Windows, the contents of the route folder disappear.",
         "update_warring" : "Manual updates are recommended if your version is 0.2 or lower than the latest version. For Windows, the contents of the route folder disappear.",

+ 1 - 1
language/ko-KR.json

@@ -271,7 +271,7 @@
     "other": "기타",
     "other": "기타",
     "edit": "편집",
     "edit": "편집",
     "open_discussion_list": "열린 토론 목록",
     "open_discussion_list": "열린 토론 목록",
-    "user_head_warring": "비로그인시 브라우저를 닫거나 로그인시 사용자가 지정한 <HEAD>는 삭제됩니다.",
+    "user_head_warring": "비로그인시 브라우저를 닫거나 로그인시 사용자가 지정한 정보는 삭제됩니다.",
     "email_required": "이메일 필요",
     "email_required": "이메일 필요",
     "1_day": "1일",
     "1_day": "1일",
     "regex_error": "정규표현식에 오류가 있습니다.",
     "regex_error": "정규표현식에 오류가 있습니다.",

+ 0 - 5
route/login.py

@@ -33,18 +33,13 @@ def login_2(conn):
         if pw_check_d != 1:
         if pw_check_d != 1:
             return re_error('/error/10')
             return re_error('/error/10')
 
 
-        curs.execute(db_change("select data from user_set where id = ? and name = 'custom_css'"), [user_id])
-        css_data = curs.fetchall()
-
         curs.execute(db_change('select data from user_set where name = "2fa" and id = ?'), [user_id])
         curs.execute(db_change('select data from user_set where name = "2fa" and id = ?'), [user_id])
         fa_data = curs.fetchall()
         fa_data = curs.fetchall()
         if fa_data and fa_data[0][0] != '':
         if fa_data and fa_data[0][0] != '':
-            flask.session['b_head'] = css_data[0][0] if css_data else ''
             flask.session['b_id'] = user_id
             flask.session['b_id'] = user_id
 
 
             return redirect('/2fa_login')
             return redirect('/2fa_login')
         else:
         else:
-            flask.session['head'] = css_data[0][0] if css_data else ''
             flask.session['id'] = user_id
             flask.session['id'] = user_id
 
 
             ua_plus(user_id, ip, user_agent, get_time())
             ua_plus(user_id, ip, user_agent, get_time())

+ 0 - 2
route/login_2fa.py

@@ -38,14 +38,12 @@ def login_2fa_2(conn):
             if pw_check_d != 1:
             if pw_check_d != 1:
                 return re_error('/error/10')
                 return re_error('/error/10')
 
 
-        flask.session['head'] = flask.session['b_head']
         flask.session['id'] = user_id
         flask.session['id'] = user_id
 
 
         ua_plus(user_id, ip, user_agent, get_time())
         ua_plus(user_id, ip, user_agent, get_time())
         conn.commit()
         conn.commit()
 
 
         flask.session.pop('b_id', None)
         flask.session.pop('b_id', None)
-        flask.session.pop('b_head', None)
 
 
         return redirect('/user')
         return redirect('/user')
     else:
     else:

+ 44 - 37
route/tool/func.py

@@ -438,29 +438,22 @@ def ua_plus(id, ip, ua, time):
 def load_lang(data, num = 2, safe = 0):
 def load_lang(data, num = 2, safe = 0):
     global global_lang
     global global_lang
 
 
-    if num == 1:
-        curs.execute(db_change("select data from other where name = 'language'"))
-        rep_data = curs.fetchall()
-        if rep_data:
-            try:
-                if not rep_data[0][0] in global_lang:
-                    lang = json.loads(open(os.path.join('language', rep_data[0][0] + '.json'), encoding='utf8').read())
-                    global_lang[rep_data[0][0]] = lang
-                else:
-                    lang = global_lang[rep_data[0][0]]
-            except:
-                return html.escape(data + ' (' + rep_data[0][0] + ')')
-
-            if data in lang:
-                return lang[data] if safe == 1 else html.escape(lang[data])
+    for i in range(0, 2):
+        if i == 0:
+            ip = ip_check()
+            if ip_or_user(ip) == 0:
+                curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip])
+                rep_data = curs.fetchall()
             else:
             else:
-                return html.escape(data + ' (' + rep_data[0][0] + ')')
+                if 'lang' in flask.session:
+                    rep_data = [[flask.session['lang']]]
+                else:
+                    continue
         else:
         else:
-            return html.escape(data + ' (' + rep_data[0][0] + ')')
-    else:
-        curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip_check()])
-        rep_data = curs.fetchall()
-        if rep_data and rep_data != '' and rep_data != 'default':
+            curs.execute(db_change("select data from other where name = 'language'"))
+            rep_data = curs.fetchall()
+        
+        if rep_data and rep_data[0][0] != '' and rep_data[0][0] != 'default':
             try:
             try:
                 if not rep_data[0][0] in global_lang:
                 if not rep_data[0][0] in global_lang:
                     lang = json.loads(open(os.path.join('language', rep_data[0][0] + '.json'), encoding='utf8').read())
                     lang = json.loads(open(os.path.join('language', rep_data[0][0] + '.json'), encoding='utf8').read())
@@ -468,14 +461,16 @@ def load_lang(data, num = 2, safe = 0):
                 else:
                 else:
                     lang = global_lang[rep_data[0][0]]
                     lang = global_lang[rep_data[0][0]]
             except:
             except:
-                return load_lang(data, 1, safe)
+                continue
 
 
             if data in lang:
             if data in lang:
                 return lang[data] if safe == 1 else html.escape(lang[data])
                 return lang[data] if safe == 1 else html.escape(lang[data])
             else:
             else:
-                return load_lang(data, 1, safe)
+                continue
         else:
         else:
-            return load_lang(data, 1, safe)
+            continue
+    
+    return html.escape(data + ' (' + rep_data[0][0] + ')')
 
 
 def ip_or_user(data = ''):
 def ip_or_user(data = ''):
     if data == '':
     if data == '':
@@ -524,18 +519,27 @@ def ip_warring():
 
 
 def skin_check(set_n = 0):
 def skin_check(set_n = 0):
     skin_list = load_skin('marisa', 1)
     skin_list = load_skin('marisa', 1)
-
-    curs.execute(db_change('select data from user_set where name = "skin" and id = ?'), [ip_check()])
-    skin_exist = curs.fetchall()
-    if skin_exist and skin_exist[0][0] != '' and skin_exist[0][0] in skin_list:
-        skin = skin_exist[0][0]
-    else:
-        curs.execute(db_change('select data from other where name = "skin"'))
+    skin = skin_list[0]
+    check_list = []
+    ip = ip_check()
+    
+    if ip_or_user(ip) == 0:
+        curs.execute(db_change('select data from user_set where name = "skin" and id = ?'), [ip])
         skin_exist = curs.fetchall()
         skin_exist = curs.fetchall()
-        if skin_exist and skin_exist[0][0] != '' and skin_exist[0][0] in skin_list:
-            skin = skin_exist[0][0]
-        else:
-            skin = skin_list[0]
+        check_list += skin_exist
+    else:
+        if 'skin' in flask.session:
+            check_list += [[flask.session['skin']]]
+            
+    curs.execute(db_change('select data from other where name = "skin"'))
+    skin_exist = curs.fetchall()
+    check_list += skin_exist
+    
+    for i in check_list:
+        if i[0] != '' and i[0] in skin_list:
+            skin = i[0]
+            
+            break
 
 
     return './views/' + skin + '/index.html' if set_n == 0 else skin
     return './views/' + skin + '/index.html' if set_n == 0 else skin
 
 
@@ -744,13 +748,15 @@ def ip_pas(raw_ip, type_d = 0):
     return ip if return_ip == 1 else end_ip
     return ip if return_ip == 1 else end_ip
 
 
 def custom():
 def custom():
-    user_head = flask.session['head'] if 'head' in flask.session else ''
-
     ip = ip_check()
     ip = ip_check()
     if ip_or_user(ip) == 0:
     if ip_or_user(ip) == 0:
         user_icon = 1
         user_icon = 1
         user_name = ip
         user_name = ip
 
 
+        curs.execute(db_change("select data from user_set where id = ? and name = 'custom_css'"), [ip])
+        user_head = curs.fetchall()
+        user_head = user_head[0][0] if user_head else ''
+        
         curs.execute(db_change('select data from user_set where name = "email" and id = ?'), [ip])
         curs.execute(db_change('select data from user_set where name = "email" and id = ?'), [ip])
         email = curs.fetchall()
         email = curs.fetchall()
         email = email[0][0] if email else ''
         email = email[0][0] if email else ''
@@ -780,6 +786,7 @@ def custom():
         user_admin = '0'
         user_admin = '0'
         user_acl_list = '0'
         user_acl_list = '0'
         user_notice = '0'
         user_notice = '0'
+        user_head = flask.session['head'] if 'head' in flask.session else ''
 
 
     curs.execute(db_change("select title from rd where title = ? and stop = ''"), ['user:' + ip])
     curs.execute(db_change("select title from rd where title = ? and stop = ''"), ['user:' + ip])
     user_topic = '1' if curs.fetchall() else '0'
     user_topic = '1' if curs.fetchall() else '0'

+ 1 - 0
route/user_info.py

@@ -25,6 +25,7 @@ def user_info_2(conn):
         plus = '''
         plus = '''
             <li><a href="/login">''' + load_lang('login') + '''</a></li>
             <li><a href="/login">''' + load_lang('login') + '''</a></li>
             <li><a href="/register">''' + load_lang('register') + '''</a></li>
             <li><a href="/register">''' + load_lang('register') + '''</a></li>
+            <li><a href="/change">''' + load_lang('user_setting') + '''</a></li>
         '''
         '''
         plus3 = ''
         plus3 = ''
 
 

+ 49 - 7
route/user_setting.py

@@ -42,18 +42,14 @@ def user_setting_2(conn, server_init):
         else:
         else:
             curs.execute(db_change('select data from user_set where name = "email" and id = ?'), [ip])
             curs.execute(db_change('select data from user_set where name = "email" and id = ?'), [ip])
             data = curs.fetchall()
             data = curs.fetchall()
-            if data:
-                email = data[0][0]
-            else:
-                email = '-'
+            email = data[0][0] if data else '-'
 
 
             div2 = load_skin('', 0, 1)
             div2 = load_skin('', 0, 1)
             div3 = ''
             div3 = ''
 
 
             curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip_check()])
             curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip_check()])
             data = curs.fetchall()
             data = curs.fetchall()
-            if not data:
-                data = [['default']]
+            data = [['default']] if not data else data
 
 
             for lang_data in support_language:
             for lang_data in support_language:
                 see_data = lang_data if lang_data != 'default' else load_lang('default')
                 see_data = lang_data if lang_data != 'default' else load_lang('default')
@@ -105,4 +101,50 @@ def user_setting_2(conn, server_init):
                 menu = [['user', load_lang('return')]]
                 menu = [['user', load_lang('return')]]
             ))
             ))
     else:
     else:
-        return redirect('/login')
+        if flask.request.method == 'POST':
+            flask.session['skin'] = flask.request.form.get('skin', '')
+            flask.session['lang'] = flask.request.form.get('lang', '')
+            
+            return redirect('/change')
+        else:
+            div2 = load_skin(('' if not 'skin' in flask.session else flask.session['skin']), 0, 1)
+            div3 = ''
+
+            data = [['default']] if not 'lang' in flask.session else [[flask.session['lang']]]
+
+            for lang_data in support_language:
+                see_data = lang_data if lang_data != 'default' else load_lang('default')
+                
+                if data and data[0][0] == lang_data:
+                    div3 = '<option value="' + lang_data + '">' + see_data + '</option>' + div3
+                else:
+                    div3 += '<option value="' + lang_data + '">' + see_data + '</option>'
+                    
+            http_warring = '' + \
+                '<hr class="main_hr">' + \
+                '<span>' + load_lang('http_warring') + '</span>' + \
+                '<hr class="main_hr">' + \
+                '<span>' + load_lang('user_head_warring') + '</span>' + \
+            ''
+            
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [load_lang('user_setting'), wiki_set(), custom(), other2([0, 0])],
+                data = '''
+                    <form method="post">
+                        <span>''' + load_lang('id') + ''' : ''' + ip_pas(ip) + '''</span>
+                        <hr class="main_hr">
+                        <h2>''' + load_lang('main') + '''</h2>
+                        <span>''' + load_lang('skin') + '''</span>
+                        <hr class="main_hr">
+                        <select name="skin">''' + div2 + '''</select>
+                        <hr class="main_hr">
+                        <span>''' + load_lang('language') + '''</span>
+                        <hr class="main_hr">
+                        <select name="lang">''' + div3 + '''</select>
+                        <hr class="main_hr">
+                        <button type="submit">''' + load_lang('save') + '''</button>
+                        ''' + http_warring + '''
+                    </form>
+                ''',
+                menu = [['user', load_lang('return')]]
+            ))

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
 {
     "beta" : {
     "beta" : {
-        "r_ver" : "v3.2.0-stable-13 (beta-48) (dev-2021-02-05-02)",
+        "r_ver" : "v3.2.0-stable-13 (beta-49) (dev-2021-02-14-01)",
         "c_ver" : "3203400",
         "c_ver" : "3203400",
         "s_ver" : "11"
         "s_ver" : "11"
     }
     }